int main() { init(); //Test(); wdt_start(wdt_60ms); while(1) { wdt_feed(); DoMenu(); if (isPedal1Pressed() == TRUE && (getCurMenuId() == idPrograms)) // если нажата педаль и активное меню - "Программы" { StartTaskWelding(); while(isPedal1Pressed()) { u8 res = DoWelding(); if (res == WELD_HAS_BROKEN) break; wdt_feed(); } StopTaskWelding(); SetMenu(&mPrograms); } } return 0; }
static void DoMenu(const std::vector<MENU>& men, bool topmost = 0) { bool MenuLoop = TRUE; while(MenuLoop) { int x; CHEAT_puts(""); for(x = 0; x < (int)men.size(); x++) CHEAT_printf("%d) %s", x + 1, men[x].text.c_str()); CHEAT_puts("D) Display Menu"); if(!topmost) CHEAT_puts("X) Return to Previous"); bool CommandLoop = TRUE; while(CommandLoop) { char buf[32]; int c, c_numeral; CHEAT_printf("Command> "); CHEAT_gets(buf,32); c = tolower(buf[0]); if(c == 0) continue; else if(c == 'd') { CommandLoop = FALSE; } else if(c == 'x' && !topmost) { CommandLoop = FALSE; MenuLoop = FALSE; } else if(trio_sscanf(buf, "%d", &c_numeral) == 1 && c_numeral <= x && c_numeral >= 1) { assert(!(men[c_numeral - 1].func_action && men[c_numeral - 1].menu_action)); if(men[c_numeral - 1].func_action) men[c_numeral - 1].func_action(men[c_numeral - 1].data); else if(men[c_numeral - 1].menu_action) DoMenu(*men[c_numeral - 1].menu_action); /* Mmm...recursivey goodness. */ CommandLoop = FALSE; } else { CHEAT_puts("Invalid command."); } } // while(CommandLoop) } // while(MenuLoop) }
int CheatLoop(void *arg) { MENU NewCheatsMenuNES[] = { { "Add Cheat", AddCheat, NULL }, { "Reset Search", ResetSearch, NULL }, { "Do Search", DoSearch, NULL }, { "Set Original to Current", SetOC, NULL }, { "Unhide Excluded", UnhideEx, NULL }, { "Show Results", ShowRes, NULL }, { "Add Game Genie Cheat", AddCheatGG, NULL }, { "Add PAR Cheat", AddCheatPAR, NULL }, { NULL } }; MENU NewCheatsMenuGB[] = { { "Add Cheat", AddCheat, NULL }, { "Reset Search", ResetSearch, NULL }, { "Do Search", DoSearch, NULL }, { "Set Original to Current", SetOC, NULL }, { "Unhide Excluded", UnhideEx, NULL }, { "Show Results", ShowRes, NULL }, { "Add Game Genie Cheat", AddCheatGG, NULL }, { NULL } }; MENU NewCheatsMenu[] = { { "Add Cheat", AddCheat, NULL }, { "Reset Search", ResetSearch, NULL }, { "Do Search", DoSearch, NULL }, { "Set Original to Current", SetOC, NULL }, { "Unhide Excluded", UnhideEx, NULL }, { "Show Results", ShowRes, NULL }, { NULL } }; MENU *thenewcm = NewCheatsMenu; if(!strcmp(CurGame->shortname, "nes")) thenewcm = NewCheatsMenuNES; else if(!strcmp(CurGame->shortname, "gb")) thenewcm = NewCheatsMenuGB; MENU MainMenu[] = { { "List Cheats", ListCheats, NULL }, { "New Cheats...", NULL, thenewcm }, { NULL } }; DoMenu(MainMenu, 1); return(1); }
int CheatLoop(void *arg) { MENU NewCheatsMenuNES[] = { {"Add Cheat",(void *)AddCheat, 1}, {"Reset Search",(void *)ResetSearch, 1}, {"Do Search",(void *)DoSearch, 1}, {"Set Original to Current",(void *)SetOC, 1}, {"Unhide Excluded",(void *)UnhideEx, 1}, {"Show Results",(void *)ShowRes, 1}, {"Add Game Genie Cheat",(void *)AddCheatGG, 1}, {"Add PAR Cheat",(void *)AddCheatPAR, 1}, {0} }; MENU NewCheatsMenuGB[] = { {"Add Cheat",(void *)AddCheat, 1}, {"Reset Search",(void *)ResetSearch, 1}, {"Do Search",(void *)DoSearch, 1}, {"Set Original to Current",(void *)SetOC, 1}, {"Unhide Excluded",(void *)UnhideEx, 1}, {"Show Results",(void *)ShowRes, 1}, {"Add Game Genie Cheat",(void *)AddCheatGG, 1}, {0} }; MENU NewCheatsMenu[] = { {"Add Cheat",(void *)AddCheat, 1}, {"Reset Search",(void *)ResetSearch, 1}, {"Do Search",(void *)DoSearch, 1}, {"Set Original to Current",(void *)SetOC, 1}, {"Unhide Excluded",(void *)UnhideEx, 1}, {"Show Results",(void *)ShowRes, 1}, {0} }; MENU *thenewcm = NewCheatsMenu; if(!strcmp(CurGame->shortname, "nes")) thenewcm = NewCheatsMenuNES; else if(!strcmp(CurGame->shortname, "gb")) thenewcm = NewCheatsMenuGB; MENU MainMenu[] = { {"List Cheats",(void *)ListCheats,1}, {"New Cheats...",(void *)thenewcm,0}, {0} }; DoMenu(MainMenu, 1); return(1); }
static void DoMenu(MENU *men, bool topmost = 0) { int x=0; redisplay: x=0; CHEAT_puts(""); while(men[x].text) { CHEAT_printf("%d) %s",x+1,men[x].text); x++; } CHEAT_puts("D) Display Menu"); if(!topmost) CHEAT_puts("X) Return to Previous"); { char buf[32]; int c; recommand: CHEAT_printf("Command> "); CHEAT_gets(buf,32); c=tolower(buf[0]); if(c == 0) goto recommand; else if(c=='d') goto redisplay; else if(c=='x' && !topmost) { return; } else if(trio_sscanf(buf,"%d",&c)) { if(c>x) goto invalid; if(men[c-1].type) { void (*func)(void)=(void(*)())men[c-1].action; func(); } else DoMenu((MENU*)men[c-1].action); /* Mmm...recursivey goodness. */ goto redisplay; } else { invalid: CHEAT_puts("Invalid command."); goto recommand; } } }
static void DoMenu(MENU *men) { int x=0; redisplay: x=0; puts(""); while(men[x].text) { printf("%d) %s\n",x+1,men[x].text); x++; } puts("D) Display Menu\nX) Return to Previous\n"); { char buf[32]; int c; recommand: printf("Command> "); fgets(buf,ARRAY_SIZE(buf),stdin); c=tolower(buf[0]); if(c=='\n') goto recommand; else if(c=='d') goto redisplay; else if(c=='x') { return; } else if(sscanf(buf,"%d",&c)) { if(c>x) goto invalid; if(men[c-1].type) { void (*func)(void)=(void(*)())men[c-1].action; func(); } else DoMenu((MENU*)men[c-1].action); /* Mmm...recursivey goodness. */ goto redisplay; } else { invalid: puts("Invalid command.\n"); goto recommand; } } }
int main(void) { dispBufferOn = ST_WR_FORE; GraphicsString(&Table); cputsxy(0, 3, CBOLDON "Your Serial Number is:"); cputhex16(GetSerialNumber()); DoMenu(&Menu); MainLoop(); // will never reach this point... return 0; }
void CStatisticsTree::OnContextMenu(CWnd* /*pWnd*/, CPoint point) { if (point.x != -1 || point.y != -1) { CRect rcClient; GetClientRect(&rcClient); ClientToScreen(&rcClient); if (!rcClient.PtInRect(point)) { Default(); return; } } DoMenu(point, TPM_LEFTALIGN | TPM_RIGHTBUTTON); }
/**************************************************************************** * Emulator Options Menu * ****************************************************************************/ int Emu_options () { int quit = 0; int ret; int prevmenu = menu; int mcardcount = 6; char mcardmenu[6][20] = { {"Video Options"}, {"SRAM Manager"}, {"STATE Manager"}, {"Game Infos"}, {"View Credits"}, {"Return to previous"} }; menu = 0; while (quit == 0) { strcpy (menutitle, "Emulator Options"); ret = DoMenu(&mcardmenu[0], mcardcount); switch (ret) { case -1: case 5: quit = 1; break; case 0: // Video Options OptionMenu(); break; case 1: // File Manager case 2: if (loadsavemenu(ret-1)) return 1; break; case 3: // ROM Information RomInfo(); break; case 4: // view credits legal(); break; } } menu = prevmenu; return 0; }
/* Display the submenu pointed to by the passed show: menu item. */ void ShowSubMenu (Menu_Item_Type *i) { int c; Menu_Type *m; /* find matching menu, if any */ if ((m=LookupMenu(i->command)) != NULL) { /* got match -- show it and handle input for it. */ AddWindow(m); DrawAll(); do { c=DoMenu(m,Pdmenu_Action,Handle_Ctrl_C); if ((c==QUIT_EXIT) || (c==Q_KEY_EXIT)) ExitWindow(); } while (c==0); } }
CPlugin::EDoMenu CPlugin::OpenPluginBkg(int nOpenFrom, INT_PTR nItem) { LPWSTR szCmdLine=NULL; CallMode Mode; switch(nOpenFrom) { case OPEN_COMMANDLINE: { LPCWSTR sz=reinterpret_cast<OpenCommandLineInfo*>(nItem)->CommandLine; size_t nLen=512; do { delete[] szCmdLine; nLen*=2; szCmdLine=new wchar_t[nLen]; } while (ExpandEnvironmentStrings(sz, szCmdLine,(DWORD)nLen) >= nLen-1); } break; case OPEN_FILEPANEL: Mode = nItem? CALL_APPS : CALL_RIGHTCLICK; break; case OPEN_LEFTDISKMENU: case OPEN_RIGHTDISKMENU: { struct DiskMenuParam {const wchar_t* CmdLine; BOOL Apps;} *p = reinterpret_cast<DiskMenuParam*>(nItem); Mode = p->Apps? CALL_APPS : CALL_RIGHTCLICK; szCmdLine=new wchar_t[wcslen(p->CmdLine)+1]; wcscpy(szCmdLine, p->CmdLine); } break; default: Mode = CALL_NORMAL; break; } EDoMenu enDoMenu=DoMenu(szCmdLine, Mode); delete[] szCmdLine; return enDoMenu; }
int CheatLoop(void *arg) { std::vector<MENU> NewCheatsMenu; std::vector<MENU> MainMenu; NewCheatsMenu.push_back( MENU(_("Add Cheat"), AddCheat, NULL) ); NewCheatsMenu.push_back( MENU(_("Reset Search"), ResetSearch, NULL) ); NewCheatsMenu.push_back( MENU(_("Do Search"), DoSearch, NULL) ); NewCheatsMenu.push_back( MENU(_("Set Original to Current"), SetOC, NULL) ); NewCheatsMenu.push_back( MENU(_("Unhide Excluded"), UnhideEx, NULL) ); NewCheatsMenu.push_back( MENU(_("Show Results"), ShowRes, NULL) ); MainMenu.push_back( MENU(_("List Cheats"), ListCheats, NULL) ); MainMenu.push_back( MENU(_("Cheat Search..."), NULL, &NewCheatsMenu) ); if(CurGame->CheatFormatInfo != NULL) { for(unsigned i = 0; i < CurGame->CheatFormatInfo->NumFormats; i++) { char buf[256]; trio_snprintf(buf, 256, _("Add %s Code"), CurGame->CheatFormatInfo->Formats[i].FullName); MainMenu.push_back( MENU(buf, AddCodeCheat, NULL, (void*)&CurGame->CheatFormatInfo->Formats[i]) ); } } try { DoMenu(MainMenu, 1); } catch(...) { } return(1); }
void DoMenu() { MakeMenuBackground(); CMenu oMenu( "Main Menu" ); if ( SState::IN_DEMO == g_oState.m_enGameMode ) { oMenu.AddMenuItem( "~SINGLE PLAYER GAME", SDLK_s, MENU_SINGLE_PLAYER )->SetEnabled(false); oMenu.AddMenuItem( "~NETWORK GAME", SDLK_n, MENU_NETWORK_GAME ); oMenu.AddMenuItem( "~MULTI PLAYER GAME", SDLK_m, MENU_MULTI_PLAYER ); } else { oMenu.AddMenuItem( "~SURRENDER GAME", SDLK_s, MENU_SURRENDER ); } oMenu.AddEnumMenuItem( "~LANGUAGE: ", g_oState.m_iLanguageCode, g_ppcLanguage, g_piLanguage, MENU_LANGUAGE ); oMenu.AddMenuItem( "~OPTIONS", SDLK_o, MENU_OPTIONS ); oMenu.AddMenuItem( "~INFO", SDLK_i, MENU_INFO )->SetEnabled(false); oMenu.AddMenuItem( "QUIT", SDLK_UNKNOWN, MENU_QUIT ); DoMenu( oMenu ); }
int loadmenu () { int prevmenu = menu; int ret,count,size; int quit = 0; #ifdef HW_RVL count = 7; char item[7][20] = { {"Load Recent"}, {"Load from SD"}, {"Load from USB"}, {"Load from IDE-EXI"}, {"Load from DVD"}, {"Stop DVD Motor"}, {"Return to previous"} }; #else count = 7; char item[7][20] = { {"Load Recent"}, {"Load from SD"}, {"Load from IDE-EXI"}, {"Load from WKF"}, {"Load from DVD"}, {"Stop DVD Motor"}, {"Return to previous"} }; #endif menu = load_menu; while (quit == 0) { strcpy (menutitle, ""); ret = DoMenu (&item[0], count); switch (ret) { // Load from DVD case 4: load_menu = menu; size = DVD_Open(gbrom); if (size) { dvd_on = 1; gbromsize = size; memfile_autosave(); reload_rom(); memfile_autoload(); return 1; } break; // Stop DVD Disc case 5: dvd_motor_off(); dvd_on = 0; menu = load_menu; break; // Button B - Return to Previous case -1: case 6: quit = 1; break; // Load from SD, USB, IDE-EXI, or WKF device default: load_menu = menu; size = FAT_Open(ret,gbrom); if (size) { gbromsize = size; memfile_autosave(); reload_rom(); memfile_autoload(); return 1; } break; } } menu = prevmenu; return 0; }
int loadsavemenu (int which) { int prevmenu = menu; int quit = 0; int ret; int count = 5; char items[5][20]; if (which == 1) { strcpy (menutitle, "STATE Manager"); sprintf(items[1], "Save State"); sprintf(items[2], "Load State"); } else { strcpy (menutitle, "SRAM Manager"); sprintf(items[1], "Save SRAM"); sprintf(items[2], "Load SRAM"); } sprintf(items[4], "Return to previous"); menu = 3; while (quit == 0) { if (device == 0) sprintf(items[0], "Device: FAT"); else if (device == 1) sprintf(items[0], "Device: MCARD A"); else if (device == 2) sprintf(items[0], "Device: MCARD B"); if (which == 1) { if (config.freeze_auto == 0) sprintf (items[3], "Auto FREEZE: FAT"); else if (config.freeze_auto == 1) sprintf (items[3], "Auto FREEZE: MCARD A"); else if (config.freeze_auto == 2) sprintf (items[3], "Auto FREEZE: MCARD B"); else sprintf (items[3], "Auto FREEZE: OFF"); } else { if (config.sram_auto == 0) sprintf (items[3], "Auto SRAM: FAT"); else if (config.sram_auto == 1) sprintf (items[3], "Auto SRAM: MCARD A"); else if (config.sram_auto == 2) sprintf (items[3], "Auto SRAM: MCARD B"); else sprintf (items[3], "Auto SRAM: OFF"); } ret = DoMenu(&items[0], count); switch (ret) { case -1: case 4: quit = 1; break; case 0: // Device FAT / MEMORY CARD device = (device + 1)%3; break; case 1: // ManageState or ManageSRAM case 2: if (which == 1) quit = ManageState (ret-1,device); else quit = ManageSRAM (ret-1,device); if (quit) return 1; break; case 3: if (which == 1) // FreezeState autoload & autosave { config.freeze_auto ++; if (config.freeze_auto > 2) config.freeze_auto = -1; config_save(); break; } else // SRAM autoload & autosave { config.sram_auto ++; if (config.sram_auto > 2) config.sram_auto = -1; config_save(); break; } } } menu = prevmenu; return 0; }
void OptionMenu () { int ret; int quit = 0; int filtering = config.usefilter + (config.filterdmg << 1); char optionmenu[7][20]; int prevmenu = menu; u16 xscale, yscale; menu = 0; while (quit == 0) { strcpy (menutitle, ""); if (config.aspect == 0) sprintf (optionmenu[0], "Aspect: STRETCH"); else if (config.aspect == 1) sprintf (optionmenu[0], "Aspect: ORIGINAL"); else if (config.aspect == 2) sprintf (optionmenu[0], "Aspect: SCALED"); sprintf (optionmenu[1], "Force Mono: %s",config.forcedmg ? "YES" : "NO"); if (filtering == 1) sprintf (optionmenu[2], "Filtering: GBC"); else if (filtering == 3) sprintf (optionmenu[2], "Filtering: ALL"); else sprintf (optionmenu[2], "Filtering: OFF"); sprintf (optionmenu[3], "GBA Features: %s",config.gbamode ? "YES" : "NO"); sprintf (optionmenu[4], "Palette: %s", paltxt[config.paletteindex]); sprintf (optionmenu[5], "RTC Synchro: %s", config.syncrtc ? "YES" : "NO"); sprintf(optionmenu[6], "Return to previous"); ret = DoMenu (&optionmenu[0], 7); switch (ret) { case 0: /* Aspect ratio */ config.aspect = (config.aspect + 1) % 3; if (config.aspect == 0) { xscale = 320; yscale = 224; } else if (config.aspect == 1) { xscale = 160; yscale = 144; } else { xscale = 250; yscale = 224; } square[6] = square[3] = xscale; square[0] = square[9] = -xscale; square[4] = square[1] = yscale; square[7] = square[10] = -yscale; draw_init(); break; case 1: /* Force Monochrome Display */ config.forcedmg ^= 1; break; case 2: /* Graphics Filtering */ filtering ++; if (filtering == 2) filtering = 3; if (filtering > 3) filtering = 0; config.usefilter = filtering & 1; config.filterdmg = (filtering >> 1) & 1; break; case 3: /* GBA-only features (used in some GB/GBC games) */ config.gbamode ^= 1; break; case 4: /* Color Palettes */ case -6: if (ret<0) { if (config.paletteindex == 0) config.paletteindex = 27; else config.paletteindex --; } else { config.paletteindex++; if (config.paletteindex > 27) config.paletteindex = 0; } break; case 5: /* RTC synchro */ config.syncrtc ^= 1; break; case -1: case 6: quit = 1; break; } } /* save Config File */ config_save(); /* update gnuboy defaults */ usefilter = config.usefilter; filterdmg = config.filterdmg; syncrtc = config.syncrtc; paletteindex = config.paletteindex; forcedmg = config.forcedmg; gbamode = config.gbamode; u8 c = gbrom[0x0147]; hw.cgb = ((c == 0x80) || (c == 0xc0)) && !forcedmg; hw.gba = (hw.cgb && gbamode); menu = prevmenu; }
CPlugin::EDoMenu CPlugin::MenuForPanelOrCmdLine(LPWSTR szCmdLine/*=NULL*/ , EAutoItem enAutoItem/*=AI_NONE*/) { EDoMenu enRet=DOMNU_ERR_SHOW; LPCWSTR* pParams=NULL; LPCWSTR* pFiles=NULL; LPCWSTR szCommand=NULL; auto_sz strCommand; do { unsigned nFiles=0, nFolders=0; auto_sz strCurDir; bool bGetFromPanel=true; if (szCmdLine && GetFilesFromParams(szCmdLine, &pParams, &nFiles, &nFolders, &strCurDir, enAutoItem!=AI_NONE)) { assert(pParams); pFiles=pParams; if (enAutoItem==AI_NONE) { bGetFromPanel=false; } else { strCommand=pParams[0]; szCommand=strCommand; pFiles=pParams+1; if (nFiles+nFolders>0) { bGetFromPanel=false; } else { delete[] pParams; pParams=NULL; } } } if (bGetFromPanel) { if (!GetFilesFromPanel(&pParams, &nFiles, &nFolders, &strCurDir)) { break; } assert(pParams); assert(nFiles+nFolders); pFiles=pParams; } auto_sz strFilesDir; bool bMenuAssigned=false; bool bDifferentFolders=false; unsigned i; for (i=0; i<nFiles+nFolders; i++) { LPCWSTR szFName=m_fsf.PointToName(pFiles[i]); if (pFiles[i]==szFName) { if (!bMenuAssigned) { strFilesDir=strCurDir; bMenuAssigned=true; } else if (strFilesDir!=strCurDir) { bDifferentFolders=true; break; } } else { if (*szFName==L'\0') { // это бывает для дисков (c:, c:\) szFName=pFiles[i]; } auto_sz strDir(pFiles[i], szFName-pFiles[i]); if (!bMenuAssigned) { strFilesDir=strDir; bMenuAssigned=true; } else if (strFilesDir!=strDir) { bDifferentFolders=true; break; } pFiles[i]=szFName; } } if (bDifferentFolders) { enRet=DOMNU_ERR_DIFFERENT_FOLDERS; break; } CPidl oDirPidl(m_pMalloc); ULONG nCount; if (FAILED(m_pDesktop->ParseDisplayName(NULL_HWND, NULL, strFilesDir, &nCount, &oDirPidl, NULL))) { enRet=DOMNU_ERR_SHOW; break; } IShellFolderPtr pCurFolder; if (FAILED(m_pDesktop->BindToObject(oDirPidl, NULL, IID_IShellFolder, reinterpret_cast<void**>(&pCurFolder)))) { enRet=DOMNU_ERR_SHOW; break; } CPidl oPidl(m_pMalloc); for (i=0; i<nFiles+nFolders; i++) { LPITEMIDLIST pidl; auto_sz szFile(pFiles[i]); if (szFile.Len()==2 && L':'==szFile[1]) { // диск (c:) szFile+=L"\\"; } HRESULT hr=0; if (FAILED(hr=pCurFolder->ParseDisplayName(NULL_HWND, NULL, szFile, &nCount, &pidl, NULL))) { enRet=DOMNU_ERR_SHOW; break; } oPidl.Add(pidl); } if (oPidl.Count()==nFolders+nFiles) { enRet=DoMenu(pCurFolder, oPidl.GetArray(), pFiles, nFiles, nFolders, szCommand, enAutoItem); } } while (0); delete[] pParams; return enRet; }
// Displays the command menu. This function is overloaded // because it is used both to display the context menu and also // the menu that drops down from the button. void CStatisticsTree::DoMenu() { CPoint cursorPos; GetCursorPos(&cursorPos); DoMenu(cursorPos); }
static int main(int argc, char *argv[]) { if (!PHYSFSX_init(argc, argv)) return 1; con_init(); // Initialise the console setbuf(stdout, NULL); // unbuffered output via printf #ifdef _WIN32 freopen( "CON", "w", stdout ); freopen( "CON", "w", stderr ); #endif if (CGameArg.SysShowCmdHelp) { print_commandline_help(); return(0); } printf("\nType '%s -help' for a list of command-line options.\n\n", PROGNAME); PHYSFSX_listSearchPathContent(); if (!PHYSFSX_checkSupportedArchiveTypes()) return(0); #if defined(DXX_BUILD_DESCENT_I) if (! PHYSFSX_contfile_init("descent.hog", 1)) #define DXX_NAME_NUMBER "1" #define DXX_HOGFILE_NAMES "descent.hog" #elif defined(DXX_BUILD_DESCENT_II) if (! PHYSFSX_contfile_init("descent2.hog", 1) && ! PHYSFSX_contfile_init("d2demo.hog", 1)) #define DXX_NAME_NUMBER "2" #define DXX_HOGFILE_NAMES "descent2.hog or d2demo.hog" #endif { #if defined(__unix__) && !defined(__APPLE__) #define DXX_HOGFILE_PROGRAM_DATA_DIRECTORY \ "\t$HOME/.d" DXX_NAME_NUMBER "x-rebirth\n" \ "\t" SHAREPATH "\n" #else #define DXX_HOGFILE_PROGRAM_DATA_DIRECTORY \ "\tDirectory containing D" DXX_NAME_NUMBER "X\n" #endif #if (defined(__APPLE__) && defined(__MACH__)) || defined(macintosh) #define DXX_HOGFILE_APPLICATION_BUNDLE \ "\tIn 'Resources' inside the application bundle\n" #else #define DXX_HOGFILE_APPLICATION_BUNDLE "" #endif #define DXX_MISSING_HOGFILE_ERROR_TEXT \ "Could not find a valid hog file (" DXX_HOGFILE_NAMES ")\nPossible locations are:\n" \ DXX_HOGFILE_PROGRAM_DATA_DIRECTORY \ "\tIn a subdirectory called 'Data'\n" \ DXX_HOGFILE_APPLICATION_BUNDLE \ "Or use the -hogdir option to specify an alternate location." UserError(DXX_MISSING_HOGFILE_ERROR_TEXT); } #if defined(DXX_BUILD_DESCENT_I) switch (PHYSFSX_fsize("descent.hog")) { case D1_MAC_SHARE_MISSION_HOGSIZE: case D1_MAC_MISSION_HOGSIZE: MacHog = 1; // used for fonts and the Automap break; } #endif load_text(); //print out the banner title #if defined(DXX_BUILD_DESCENT_I) con_printf(CON_NORMAL, "%s %s", DESCENT_VERSION, g_descent_build_datetime); // D1X version con_printf(CON_NORMAL, "This is a MODIFIED version of Descent, based on %s.", BASED_VERSION); con_printf(CON_NORMAL, "%s\n%s",TXT_COPYRIGHT,TXT_TRADEMARK); con_printf(CON_NORMAL, "Copyright (C) 2005-2013 Christian Beckhaeuser"); #elif defined(DXX_BUILD_DESCENT_II) con_printf(CON_NORMAL, "%s%s %s", DESCENT_VERSION, PHYSFSX_exists(MISSION_DIR "d2x.hog",1) ? " Vertigo Enhanced" : "", g_descent_build_datetime); // D2X version con_printf(CON_NORMAL, "This is a MODIFIED version of Descent 2, based on %s.", BASED_VERSION); con_printf(CON_NORMAL, "%s\n%s",TXT_COPYRIGHT,TXT_TRADEMARK); con_printf(CON_NORMAL, "Copyright (C) 1999 Peter Hawkins, 2002 Bradley Bell, 2005-2013 Christian Beckhaeuser"); #endif if (CGameArg.DbgVerbose) con_puts(CON_VERBOSE, TXT_VERBOSE_1); ReadConfigFile(); PHYSFSX_addArchiveContent(); arch_init(); select_tmap(CGameArg.DbgTexMap); #if defined(DXX_BUILD_DESCENT_II) Lighting_on = 1; #endif con_printf(CON_VERBOSE, "Going into graphics mode..."); gr_set_mode(Game_screen_mode); // Load the palette stuff. Returns non-zero if error. con_printf(CON_DEBUG, "Initializing palette system..." ); #if defined(DXX_BUILD_DESCENT_I) gr_use_palette_table( "PALETTE.256" ); #elif defined(DXX_BUILD_DESCENT_II) gr_use_palette_table(D2_DEFAULT_PALETTE ); #endif con_printf(CON_DEBUG, "Initializing font system..." ); gamefont_init(); // must load after palette data loaded. #if defined(DXX_BUILD_DESCENT_II) con_printf( CON_DEBUG, "Initializing movie libraries..." ); init_movies(); //init movie libraries #endif show_titles(); set_screen_mode(SCREEN_MENU); #ifdef DEBUG_MEMORY_ALLOCATIONS /* Memdebug runs before global destructors, so it incorrectly * reports as leaked any allocations that would be freed by a global * destructor. This local will force the newmenu globals to be * reset before memdebug scans, which prevents memdebug falsely * reporting them as leaked. * * External tools, such as Valgrind, know to run global destructors * before checking for leaks, so this hack is only necessary when * memdebug is used. */ struct hack_free_global_backgrounds { ~hack_free_global_backgrounds() { newmenu_free_background(); } }; hack_free_global_backgrounds hack_free_global_background; #endif con_printf( CON_DEBUG, "\nDoing gamedata_init..." ); gamedata_init(); #if defined(DXX_BUILD_DESCENT_II) #if DXX_USE_EDITOR if (GameArg.EdiSaveHoardData) { save_hoard_data(); exit(1); } #endif #endif if (CGameArg.DbgNoRun) return(0); con_printf( CON_DEBUG, "\nInitializing texture caching system..." ); texmerge_init(); // 10 cache bitmaps #if defined(DXX_BUILD_DESCENT_II) piggy_init_pigfile("groupa.pig"); //get correct pigfile #endif con_printf( CON_DEBUG, "\nRunning game..." ); init_game(); get_local_player().callsign = {}; #if defined(DXX_BUILD_DESCENT_I) key_flush(); #elif defined(DXX_BUILD_DESCENT_II) // If built with editor, option to auto-load a level and quit game // to write certain data. #ifdef EDITOR if (!GameArg.EdiAutoLoad.empty()) { Players[0].callsign = "dummy"; } else #endif #endif { if (!CGameArg.SysPilot.empty()) { char filename[sizeof(PLAYER_DIRECTORY_TEXT) + CALLSIGN_LEN + 4]; /* Step over the literal PLAYER_DIRECTORY_TEXT when it is * present. Point at &filename[0] when * PLAYER_DIRECTORY_TEXT is absent. */ const auto b = &filename[-CGameArg.SysUsePlayersDir]; snprintf(filename, sizeof(filename), PLAYER_DIRECTORY_STRING("%.12s"), CGameArg.SysPilot.c_str()); /* The pilot name is never used after this. Clear it to * free the allocated memory, if any. */ CGameArg.SysPilot.clear(); auto p = b; for (const auto &facet = std::use_facet<std::ctype<char>>(std::locale::classic()); char &c = *p; ++p) { c = facet.tolower(static_cast<uint8_t>(c)); } auto j = p - filename; if (j < sizeof(filename) - 4 && (j <= 4 || strcmp(&filename[j - 4], ".plr"))) // if player hasn't specified .plr extension in argument, add it { strcpy(&filename[j], ".plr"); j += 4; } if(PHYSFSX_exists(filename,0)) { get_local_player().callsign.copy(b, std::distance(b, &filename[j - 4])); read_player_file(); WriteConfigFile(); } } } #if defined(DXX_BUILD_DESCENT_II) #if DXX_USE_EDITOR if (!GameArg.EdiAutoLoad.empty()) { /* Any number >= FILENAME_LEN works */ Level_names[0].copy_if(GameArg.EdiAutoLoad.c_str(), GameArg.EdiAutoLoad.size()); LoadLevel(1, 1); } else #endif #endif { Game_mode = GM_GAME_OVER; DoMenu(); } while (window_get_front()) // Send events to windows and the default handler event_process(); // Tidy up - avoids a crash on exit { window *wind; show_menus(); while ((wind = window_get_front())) window_close(wind); } WriteConfigFile(); show_order_form(); con_printf( CON_DEBUG, "\nCleanup..." ); close_game(); texmerge_close(); gamedata_close(); gamefont_close(); Current_mission.reset(); PHYSFSX_removeArchiveContent(); return(0); //presumably successful exit }
int main(int argc, char *argv[]) { mem_init(); #ifdef __LINUX__ error_init(NULL); #else error_init(msgbox_error); set_warn_func(msgbox_warning); #endif PHYSFSX_init(argc, argv); con_init(); // Initialise the console setbuf(stdout, NULL); // unbuffered output via printf #ifdef _WIN32 freopen( "CON", "w", stdout ); freopen( "CON", "w", stderr ); #endif if (GameArg.SysShowCmdHelp) { print_commandline_help(); return(0); } printf("\nType %s -help' for a list of command-line options.\n\n", PROGNAME); PHYSFSX_listSearchPathContent(); if (!PHYSFSX_checkSupportedArchiveTypes()) return(0); if (! PHYSFSX_contfile_init("descent2.hog", 1)) { if (! PHYSFSX_contfile_init("d2demo.hog", 1)) #define DXX_NAME_NUMBER "2" #define DXX_HOGFILE_NAMES "descent2.hog or d2demo.hog" #if defined(__unix__) && !defined(__APPLE__) #define DXX_HOGFILE_PROGRAM_DATA_DIRECTORY \ "\t$HOME/.d" DXX_NAME_NUMBER "x-rebirth\n" \ "\t" SHAREPATH "\n" #else #define DXX_HOGFILE_PROGRAM_DATA_DIRECTORY \ "\tDirectory containing D" DXX_NAME_NUMBER "X\n" #endif #if (defined(__APPLE__) && defined(__MACH__)) || defined(macintosh) #define DXX_HOGFILE_APPLICATION_BUNDLE \ "\tIn 'Resources' inside the application bundle\n" #else #define DXX_HOGFILE_APPLICATION_BUNDLE "" #endif #define DXX_MISSING_HOGFILE_ERROR_TEXT \ "Could not find a valid hog file (" DXX_HOGFILE_NAMES ")\nPossible locations are:\n" \ DXX_HOGFILE_PROGRAM_DATA_DIRECTORY \ "\tIn a subdirectory called 'Data'\n" \ DXX_HOGFILE_APPLICATION_BUNDLE \ "Or use the -hogdir option to specify an alternate location." Error(DXX_MISSING_HOGFILE_ERROR_TEXT); } load_text(); //print out the banner title con_printf(CON_NORMAL, "%s%s %s\n", DESCENT_VERSION, PHYSFSX_exists(MISSION_DIR "d2x.hog",1) ? " Vertigo Enhanced" : "", g_descent_build_datetime); // D2X version con_printf(CON_NORMAL, "This is a MODIFIED version of Descent 2, based on %s.\n", BASED_VERSION); con_printf(CON_NORMAL, "%s\n%s\n",TXT_COPYRIGHT,TXT_TRADEMARK); con_printf(CON_NORMAL, "Copyright (C) 1999 Peter Hawkins, 2002 Bradley Bell, 2005-2011 Christian Beckhaeuser\n\n"); if (GameArg.DbgVerbose) con_printf(CON_VERBOSE,"%s%s", TXT_VERBOSE_1, "\n"); ReadConfigFile(); PHYSFSX_addArchiveContent(); arch_init(); select_tmap(GameArg.DbgTexMap); Lighting_on = 1; con_printf(CON_VERBOSE, "Going into graphics mode...\n"); gr_set_mode(Game_screen_mode); // Load the palette stuff. Returns non-zero if error. con_printf(CON_DEBUG, "Initializing palette system...\n" ); gr_use_palette_table(D2_DEFAULT_PALETTE ); con_printf(CON_DEBUG, "Initializing font system...\n" ); gamefont_init(); // must load after palette data loaded. set_default_handler(standard_handler); con_printf( CON_DEBUG, "Initializing movie libraries...\n" ); init_movies(); //init movie libraries show_titles(); set_screen_mode(SCREEN_MENU); con_printf( CON_DEBUG, "\nDoing gamedata_init..." ); gamedata_init(); #ifdef EDITOR if (GameArg.EdiSaveHoardData) { save_hoard_data(); exit(1); } #endif if (GameArg.DbgNoRun) return(0); con_printf( CON_DEBUG, "\nInitializing texture caching system..." ); texmerge_init( 10 ); // 10 cache bitmaps piggy_init_pigfile("groupa.pig"); //get correct pigfile con_printf( CON_DEBUG, "\nRunning game...\n" ); init_game(); Players[Player_num].callsign[0] = '\0'; // If built with editor, option to auto-load a level and quit game // to write certain data. #ifdef EDITOR if (GameArg.EdiAutoLoad) { strcpy(Auto_file, GameArg.EdiAutoLoad); strcpy(Players[0].callsign, "dummy"); } else #endif { if(GameArg.SysPilot) { char filename[32] = ""; int j; if (GameArg.SysUsePlayersDir) strcpy(filename, "Players/"); strncat(filename, GameArg.SysPilot, 12); filename[8 + 12] = '\0'; // unfortunately strncat doesn't put the terminating 0 on the end if it reaches 'n' for (j = GameArg.SysUsePlayersDir? 8 : 0; filename[j] != '\0'; j++) { switch (filename[j]) { case ' ': filename[j] = '\0'; } } if(!strstr(filename,".plr")) // if player hasn't specified .plr extension in argument, add it strcat(filename,".plr"); if(PHYSFSX_exists(filename,0)) { strcpy(strstr(filename,".plr"),"\0"); strcpy(Players[Player_num].callsign, GameArg.SysUsePlayersDir? &filename[8] : filename); read_player_file(); WriteConfigFile(); } } } #ifdef EDITOR if (GameArg.EdiAutoLoad) { strcpy((char *)&Level_names[0], Auto_file); LoadLevel(1, 1); } else #endif { Game_mode = GM_GAME_OVER; DoMenu(); } setjmp(LeaveEvents); while (window_get_front()) // Send events to windows and the default handler event_process(); // Tidy up - avoids a crash on exit { window *wind; show_menus(); while ((wind = window_get_front())) window_close(wind); } WriteConfigFile(); show_order_form(); con_printf( CON_DEBUG, "\nCleanup...\n" ); close_game(); texmerge_close(); gamedata_close(); gamefont_close(); free_text(); args_exit(); newmenu_free_background(); free_mission(); PHYSFSX_removeArchiveContent(); return(0); //presumably successful exit }
void DoConsoleCheatConfig(void) { MENU *curmenu=MainMenu; DoMenu(curmenu); }
void main (void) { DoMenu(&subMenu1); DoMenu(&subMenu2); }
/** * @brief 应用交易菜单选择 * @param 无 * @return * @li APP_SUCC * @li APP_QUIT * @li APP_TIMEOUT * @author * @date */ static int MenuFuncSel(void) { int nRet = 0; char szMenuResource[3072]; char szPrm[3072]; memset(szMenuResource, 0, sizeof(szMenuResource)); DoMenu(szMenuResource); sprintf(szPrm, "'%s'", szMenuResource); while(1) { AutoDoReversal(); /*自动冲正*/ nRet = PubLuaDisplay2("LuaMenuFunc", szPrm); switch(nRet) { case APP_FUNCQUIT: return KEY_FUNC_APP_SELECT; case -5://确认 case APP_TIMEOUT: case APP_QUIT: return nRet; case COUPON_VERIFY_MENU: MagIDVeriCoupon(); break; case TEL_VERIFY_MENU: MagTelnoVeriCoupon(); break; case CARD_VERIFY_MENU: MagCardVeriCoupon(); break; case PRECREATE_MENU: MagScanQrCodePay(); break; case CREATEANDPAY: MagBarcodePay(); break; case WX_VOIDPAY_MENU: break; case PRINT_MENU: Reprint(); break; case MANAGE_MENU: MenuManage(); return APP_SUCC; break; case BAIDU_PRECREATE_MENU: MagScanQrCodePayBaidu(); break; case BAIDU_CREATEANDPAY_MENU: MagBarcodeBaidu(); break; case JD_PRECREATE_MENU: MagJDScanQrCodePay(); break; case JD_CREATEANDPAY_MENU: MagJDBarcode(); break; case ALIPAY_PRECREATE_MENU: MagAlipayScanQrCodePay(); break; case ALI_CREATEANDPAY_MENU: MagAliBarcode(); break; case MEITUAN_COUPON_MENU: MagMeituanVeriCoupon(); break; case DZ_PRECREATE_MENU: MagDazhongScanQrCodePay(); break; case DZ_CREATEANDPAY_MENU: MagDazhongBarcode(); break; case DZ_COUPON_MENU: MagDazhongVeriCoupon(); break; case DZ_COUPONCONFIRM_MENU: MagDazhongConfirm(); break; case BESTPAY_CREATEANDPAY_MENU: MagBestpayBarcode(); break; case ALLPAY_CREATEANDPAY_MENU: MagAllpayBarcode(); break; case OTHERS: MenuOther(); break; case ALLPAY_REFUND_MENU: MagAllPayRefund(); break; case ALLPAY_BALANCE_MENU: MagBalance(TRANS_BALANCE_ALLPAY); break; default: break; } } return APP_SUCC; }
void CStatisticsTree::OnContextMenu(CWnd* /*pWnd*/, CPoint point) { DoMenu(point, TPM_LEFTALIGN | TPM_RIGHTBUTTON); }
void CStatisticsTree::DoMenu(CPoint doWhere) { DoMenu( doWhere, TPM_RIGHTALIGN | TPM_RIGHTBUTTON ); }
void MainMenu () { s8 ret; u8 quit = 0; menu = 0; #ifdef HW_RVL u8 count = 6; char items[6][20] = #else u8 count = 5; char items[5][20] = #endif { {"Play Game"}, {"Hard Reset"}, {"Load New Game"}, {"Emulator Options"}, #ifdef HW_RVL {"Return to Loader"}, #endif {"System Reboot"} }; /* 50 hz TV mode */ if (gc_pal) { VIDEO_Configure (vmode); VIDEO_ClearFrameBuffer(vmode, xfb[whichfb], COLOR_BLACK); VIDEO_Flush(); VIDEO_WaitVSync(); VIDEO_WaitVSync(); } /* autosave (SRAM only) */ int temp = config.freeze_auto; config.freeze_auto = -1; memfile_autosave(); config.freeze_auto = temp; while (quit == 0) { strcpy (menutitle, "Version 1.04.2"); ret = DoMenu (&items[0], count); switch (ret) { case -1: /*** Button B ***/ case 0: /*** Play Game ***/ quit = 1; break; case 1: emu_reset(); quit = 1; break; case 2: /*** Load ROM Menu ***/ quit = loadmenu(); break; case 3: /*** Emulator Options */ Emu_options(); break; case 4: /*** SD/PSO/TP Reload ***/ memfile_autosave(); VIDEO_ClearFrameBuffer(vmode, xfb[whichfb], COLOR_BLACK); VIDEO_Flush(); VIDEO_WaitVSync(); #ifdef HW_RVL DI_Close(); exit(0); break; case 5: /*** Return to Wii System Menu ***/ memfile_autosave(); VIDEO_ClearFrameBuffer(vmode, xfb[whichfb], COLOR_BLACK); VIDEO_Flush(); VIDEO_WaitVSync(); DI_Close(); SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); #else SYS_ResetSystem(SYS_HOTRESET,0,0); #endif break; } } /*** Remove any still held buttons ***/ while (PAD_ButtonsHeld(0)) PAD_ScanPads(); #ifdef HW_RVL while (WPAD_ButtonsHeld(0)) WPAD_ScanPads(); #endif /*** Restore fullscreen 50hz ***/ if (gc_pal) { extern GXRModeObj TV50hz_576i; GXRModeObj *rmode = &TV50hz_576i; Mtx p; rmode->xfbHeight = 574; rmode->viYOrigin = 0; rmode->viHeight = 574; VIDEO_Configure (rmode); VIDEO_ClearFrameBuffer(rmode, xfb[whichfb], COLOR_BLACK); VIDEO_Flush(); VIDEO_WaitVSync(); VIDEO_WaitVSync(); /* reset rendering mode */ GX_SetViewport (0.0F, 0.0F, rmode->fbWidth, rmode->efbHeight, 0.0F, 1.0F); GX_SetScissor (0, 0, rmode->fbWidth, rmode->efbHeight); f32 yScale = GX_GetYScaleFactor(rmode->efbHeight, rmode->xfbHeight); u16 xfbHeight = GX_SetDispCopyYScale (yScale); GX_SetDispCopySrc (0, 0, rmode->fbWidth, rmode->efbHeight); GX_SetDispCopyDst (rmode->fbWidth, xfbHeight); GX_SetCopyFilter (rmode->aa, rmode->sample_pattern, GX_TRUE, rmode->vfilter); GX_SetFieldMode (rmode->field_rendering, ((rmode->viHeight == 2 * rmode->xfbHeight) ? GX_ENABLE : GX_DISABLE)); GX_SetPixelFmt (GX_PF_RGB8_Z24, GX_ZC_LINEAR); guOrtho(p, rmode->efbHeight/2, -(rmode->efbHeight/2), -(rmode->fbWidth/2), rmode->fbWidth/2, 100, 1000); GX_LoadProjectionMtx (p, GX_ORTHOGRAPHIC); } #ifndef HW_RVL /*** Stop the DVD from causing clicks while playing ***/ uselessinquiry (); #endif }
/*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M Method: CMainWindow::WindowProc Summary: Main window procedure for this window object. See CVirWindow in the APPUTIL library (APPUTIL.CPP) for details on how this method gets called by the global WindowProc. Args: UINT uMsg, Windows message that is "sent" to this window. WPARAM wParam, First message parameter (word sized). LPARAM lParam) Second message parameter (long sized). Modifies: ... Returns: LRESULT Standard Windows WindowProc return value. M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/ LRESULT CMainWindow::WindowProc( UINT uMsg, WPARAM wParam, LPARAM lParam) { LRESULT lResult = FALSE; switch (uMsg) { case WM_CREATE: break; case WM_MEASUREITEM: // Get setup for painting text in this window. { LPMEASUREITEMSTRUCT lpmis = (LPMEASUREITEMSTRUCT) lParam; lpmis->itemHeight = m_tm.tmHeight + m_tm.tmExternalLeading; lpmis->itemWidth = m_wWidth; lResult = TRUE; } case WM_SIZE: // Handle a resize of this window. m_wWidth = LOWORD(lParam); m_wHeight = HIWORD(lParam); // Handle a resize of this window. // Restart the ball from upper left, clear window. m_pGuiBall->Restart(); break; case WM_TIMER: // This is our timed attempt to continuously paint the moving ball. // It doesn't move it. Other non-GUI threads move the virtual ball. m_pGuiBall->PaintBall(); break; case WM_COMMAND: // Dispatch and handle any Menu command messages received. lResult = DoMenu(wParam, lParam); break; case WM_CHAR: if (wParam == 0x1b) { // Exit this app if user hits ESC key. PostMessage(m_hWnd,WM_CLOSE,0,0); break; } case WM_LBUTTONUP: case WM_PAINT: // If something major happened or user clicks or hits key then // repaint the whole window. m_pGuiBall->PaintWin(); break; case WM_CLOSE: // The user selected Close on the main window's System menu // or Exit on the File menu. case WM_QUIT: // If the app is being quit then close any associated help windows. // ::WinHelp(m_hWnd, m_szHelpFile, HELP_QUIT, 0); default: // Defer all messages NOT handled here to the Default Window Proc. lResult = ::DefWindowProc(m_hWnd, uMsg, wParam, lParam); break; } return(lResult); }
CPlugin::EDoMenu CPlugin::SelectDrive() { CPidl oPidlMyComp(m_pMalloc); if (FAILED(SHGetSpecialFolderLocation(NULL_HWND, CSIDL_DRIVES, &oPidlMyComp))) { return DOMNU_ERR_SHOW; } auto_sz szMenuTitle; STRRET sr={STRRET_CSTR}; if (SUCCEEDED(m_pDesktop->GetDisplayNameOf(oPidlMyComp, SHGDN_NORMAL, &sr))) { szMenuTitle=auto_sz(sr, oPidlMyComp); } IShellFolderPtr pMyComputer; if (FAILED(m_pDesktop->BindToObject(oPidlMyComp, NULL, IID_IShellFolder, reinterpret_cast<void**>(&pMyComputer)))) { return DOMNU_ERR_SHOW; } IEnumIDListPtr pEnum; if (FAILED(pMyComputer->EnumObjects(NULL_HWND, SHCONTF_FOLDERS|SHCONTF_NONFOLDERS|SHCONTF_INCLUDEHIDDEN, &pEnum))) { return DOMNU_ERR_SHOW; } CFarMenu oDrivesMenu(g_szTopicMyComp); LPITEMIDLIST piid; ULONG nFetched; CPidl oPiids(m_pMalloc); unsigned nLastDrivePos=0; while (SUCCEEDED(pEnum->Next(1, &piid, &nFetched)) && nFetched) { sr.uType=STRRET_CSTR; if (FAILED(pMyComputer->GetDisplayNameOf(piid, SHGDN_NORMAL, &sr))) { assert(0); continue; } ULONG nAttr=SFGAO_FILESYSTEM; if (FAILED(pMyComputer->GetAttributesOf(1, (LPCITEMIDLIST*)&piid, &nAttr))) { assert(0); } auto_sz szMenuItem(sr, piid); if (SFGAO_FILESYSTEM==nAttr) { oDrivesMenu.InsertItem(nLastDrivePos, szMenuItem, false); oPiids.Insert(nLastDrivePos, piid); ++nLastDrivePos; } else { oDrivesMenu.AddItem(szMenuItem, false); oPiids.Add(piid); } } int nItem=OleThread::ShowMenu(oDrivesMenu,szMenuTitle, 0, m_GuiPos==0); switch (nItem) { case CFarMenu::SHOW_CANCEL: return DOMENU_CANCELLED; case CFarMenu::SHOW_BACK: return DOMENU_BACK; } LPCWSTR sz=oDrivesMenu[nItem]; return DoMenu(pMyComputer, oPiids.GetArray()+nItem, &sz, 0, 1); }
void menu() { FILE *pMenuFile; int Key, IsANSI; char temp[81], *Input, *sMenuPathFileName, buf[81]; Input = calloc(PATH_MAX, sizeof(char)); sMenuPathFileName = calloc(PATH_MAX, sizeof(char)); Syslog('+', "Starting menu loop"); /* * Loop forever, this is what a BBS should do until a user logs out. */ while (TRUE) { WhosDoingWhat(BROWSING, NULL); /* * Open menufile, first users language menu, if it fails * try to open the default menu. */ snprintf(sMenuPathFileName, PATH_MAX, "%s/share/int/menus/%s/%s", getenv("FTND_ROOT"), lang.lc, Menus[MenuLevel]); if ((pMenuFile = fopen(sMenuPathFileName, "r")) == NULL) { snprintf(sMenuPathFileName, PATH_MAX, "%s/share/int/menus/%s/%s", getenv("FTND_ROOT"), CFG.deflang, Menus[MenuLevel]); pMenuFile = fopen(sMenuPathFileName,"r"); if (pMenuFile != NULL) Syslog('b', "Menu %s (Default)", Menus[MenuLevel]); } else { Syslog('b', "Menu %s (%s)", Menus[MenuLevel], lang.Name); } if (pMenuFile == NULL) { clear(); WriteError("Can't open menu file: %s", sMenuPathFileName); MenuError++; /* * Is this the last attempt to open the default menu? */ if (MenuError == 10) { WriteError("FATAL ERROR: Too many menu errors"); snprintf(temp, 81, "Too many menu errors, notifying Sysop\r\n\r\n"); PUTSTR(temp); sleep(3); die(FTNERR_CONFIG_ERROR); } /* * Switch back to the default menu */ MenuLevel = 0; strcpy(Menus[0], CFG.default_menu); } else { /* * Display Menu Text Fields and Perform all autoexec menus in order of menu file. * First check if there are any ANSI menus, if not, send a clearscreen first. */ IsANSI = FALSE; while (fread(&menus, sizeof(menus), 1, pMenuFile) == 1) { if ( Le_Access(exitinfo.Security, menus.MenuSecurity) && (UserAge >= le_int(menus.Age))){ if ((le_int(menus.MenuType) == 5) || (le_int(menus.MenuType) == 19) || (le_int(menus.MenuType) == 20)) IsANSI = TRUE; } } fseek(pMenuFile, 0, SEEK_SET); if (! IsANSI) clear(); while (fread(&menus, sizeof(menus), 1, pMenuFile) == 1) { if ( Le_Access(exitinfo.Security, menus.MenuSecurity) && (UserAge >= le_int(menus.Age))){ if (menus.AutoExec) { DoMenu( le_int(menus.MenuType) ); } DisplayMenu( ); } } /* * Check if the BBS closed down for Zone Mail Hour or * system shutdown. If so, we run the Goodbye show. */ if (CheckStatus() == FALSE) { fclose(pMenuFile); Syslog('+', "Kicking user out, the BBS is closed."); sleep(3); Good_Bye(FTNERR_OK); } /* * Check the upsdown semafore */ if (IsSema((char *)"upsdown")) { fclose(pMenuFile); Syslog('+', "Kicking user out, upsdown semafore detected"); snprintf(temp, 81, "System power failure, closing the bbs"); PUTSTR(temp); Enter(2); sleep(3); Good_Bye(FTNERR_OK); } /* * Check if SysOp wants to chat to user everytime user gets prompt. */ if (CFG.iChatPromptChk) { snprintf(buf, 81, "CISC:1,%d", mypid); if (socket_send(buf) == 0) { strcpy(buf, socket_receive()); if (strcmp(buf, "100:1,1;") == 0) { Syslog('+', "Forced sysop/user chat"); Chat(exitinfo.Name, (char *)"#sysop"); continue; } } } /* * Check users timeleft */ TimeCheck(); alarm_on(); if (exitinfo.HotKeys) { Key = Readkey(); snprintf(Input, 81, "%c", Key); Enter(1); } else { colour(CFG.InputColourF, CFG.InputColourB); GetstrC(Input, 80); } if ((strcmp(Input, "")) != 0) { fseek(pMenuFile, 0, SEEK_SET); while (fread(&menus, sizeof(menus), 1, pMenuFile) == 1) { if ((strcmp(tu(Input), menus.MenuKey)) == 0) { if ((Le_Access(exitinfo.Security, menus.MenuSecurity)) && (UserAge >= le_int(menus.Age))) { Syslog('+', "Menu[%d] %d=(%s), Opt: '%s'", MenuLevel, le_int(menus.MenuType), menus.TypeDesc, menus.OptionalData); if (le_int(menus.MenuType) == 13) { /* * Terminate call, cleanup here */ free(Input); free(sMenuPathFileName); fclose(pMenuFile); } DoMenu(le_int(menus.MenuType)); break; } } } } fclose(pMenuFile); } /* If menu open */ } /* while true */ }
int main(int argc, char *argv[]) { mem_init(); #ifdef __LINUX__ error_init(NULL, NULL); #else error_init(msgbox_error, NULL); set_warn_func(msgbox_warning); #endif PHYSFSX_init(argc, argv); con_init(); // Initialise the console setbuf(stdout, NULL); // unbuffered output via printf #ifdef _WIN32 freopen( "CON", "w", stdout ); freopen( "CON", "w", stderr ); #endif if (GameArg.SysShowCmdHelp) { print_commandline_help(); set_exit_message(""); return(0); } printf("\nType %s -help' for a list of command-line options.\n\n", PROGNAME); PHYSFSX_listSearchPathContent(); if (!PHYSFSX_checkSupportedArchiveTypes()) return(0); if (! PHYSFSX_contfile_init("descent.hog", 1)) Error("Could not find a valid hog file (descent.hog)\nPossible locations are:\n" #if defined(__unix__) && !defined(__APPLE__) "\t$HOME/.d1x-rebirth\n" "\t" SHAREPATH "\n" #else "\tDirectory containing D1X\n" #endif "\tIn a subdirectory called 'Data'\n" #if (defined(__APPLE__) && defined(__MACH__)) || defined(macintosh) "\tIn 'Resources' inside the application bundle\n" #endif "Or use the -hogdir option to specify an alternate location."); switch (PHYSFSX_fsize("descent.hog")) { case D1_MAC_SHARE_MISSION_HOGSIZE: case D1_MAC_MISSION_HOGSIZE: MacHog = 1; // used for fonts and the Automap break; } load_text(); //print out the banner title con_printf(CON_NORMAL, "%s", DESCENT_VERSION); // D1X version con_printf(CON_NORMAL, " %s %s\n", __DATE__,__TIME__); con_printf(CON_NORMAL, "This is a MODIFIED version of Descent, based on %s.\n", BASED_VERSION); con_printf(CON_NORMAL, "%s\n%s\n",TXT_COPYRIGHT,TXT_TRADEMARK); con_printf(CON_NORMAL, "Copyright (C) 2005-2011 Christian Beckhaeuser\n\n"); if (GameArg.DbgVerbose) con_printf(CON_VERBOSE,"%s%s", TXT_VERBOSE_1, "\n"); ReadConfigFile(); PHYSFSX_addArchiveContent(); arch_init(); select_tmap(GameArg.DbgTexMap); con_printf(CON_VERBOSE, "Going into graphics mode...\n"); gr_set_mode(Game_screen_mode); // Load the palette stuff. Returns non-zero if error. con_printf(CON_DEBUG, "Initializing palette system...\n" ); gr_use_palette_table( "PALETTE.256" ); con_printf(CON_DEBUG, "Initializing font system...\n" ); gamefont_init(); // must load after palette data loaded. set_default_handler(standard_handler); show_titles(); set_screen_mode(SCREEN_MENU); con_printf( CON_DEBUG, "\nDoing gamedata_init..." ); gamedata_init(); if (GameArg.DbgNoRun) return(0); con_printf( CON_DEBUG, "\nInitializing texture caching system..." ); texmerge_init( 10 ); // 10 cache bitmaps con_printf( CON_DEBUG, "\nRunning game...\n" ); init_game(); Players[Player_num].callsign[0] = '\0'; key_flush(); if(GameArg.SysPilot) { char filename[32] = ""; int j; if (GameArg.SysUsePlayersDir) strcpy(filename, "Players/"); strncat(filename, GameArg.SysPilot, 12); filename[8 + 12] = '\0'; // unfortunately strncat doesn't put the terminating 0 on the end if it reaches 'n' for (j = GameArg.SysUsePlayersDir? 8 : 0; filename[j] != '\0'; j++) { switch (filename[j]) { case ' ': filename[j] = '\0'; } } if(!strstr(filename,".plr")) // if player hasn't specified .plr extension in argument, add it strcat(filename,".plr"); if(PHYSFSX_exists(filename,0)) { strcpy(strstr(filename,".plr"),"\0"); strcpy(Players[Player_num].callsign, GameArg.SysUsePlayersDir? &filename[8] : filename); read_player_file(); WriteConfigFile(); } } Game_mode = GM_GAME_OVER; DoMenu(); setjmp(LeaveEvents); while (window_get_front()) // Send events to windows and the default handler event_process(); // Tidy up - avoids a crash on exit { window *wind; show_menus(); while ((wind = window_get_front())) window_close(wind); } WriteConfigFile(); show_order_form(); con_printf( CON_DEBUG, "\nCleanup...\n" ); close_game(); texmerge_close(); gamedata_close(); gamefont_close(); free_text(); args_exit(); newmenu_free_background(); free_mission(); PHYSFSX_removeArchiveContent(); return(0); //presumably successful exit }