void PushNewMenu(MenuDefinition *menuDef) { SetCurrentMenu(menuDef); if(currentMenuDef) { int i = 0; MenuWindow *newMenuWindow = NULL; for(i = 0; i < MAX_MENU_WINDOWS; ++i) { if(!menuWindows[i].inUse) { newMenuWindow = &menuWindows[i]; break; } } if(!newMenuWindow) { window_stack_pop_all(true); return; } newMenuWindow->inUse = true; newMenuWindow->menu = currentMenuDef; newMenuWindow->window = InitializeMenuWindow(newMenuWindow, "Menu", currentMenuDef->animated, currentMenuDef->init ? currentMenuDef->init : MenuInit, currentMenuDef->deinit ? currentMenuDef->deinit : MenuDeinit, currentMenuDef->appear ? currentMenuDef->appear : MenuAppear, currentMenuDef->disappear ? currentMenuDef->disappear : MenuDisappear); } }
void CMenuCube::ChangeMenuOption(bool _bToRight) { switch(m_eMenuSelect) { case MENU_OPTION_PLAY: { if(true == _bToRight) { SetCurrentMenu(MENU_OPTION_INSTRUCTIONS); } else // to left { SetCurrentMenu(MENU_OPTION_EXIT); } break; } case MENU_OPTION_EXIT: { if(true == _bToRight) { SetCurrentMenu(MENU_OPTION_PLAY); } else // to left { SetCurrentMenu(MENU_OPTION_CREDITS); } break; } case MENU_OPTION_INSTRUCTIONS: { if(true == _bToRight) { SetCurrentMenu(MENU_OPTION_CREDITS); } else // to left { SetCurrentMenu(MENU_OPTION_PLAY); } break; } case MENU_OPTION_CREDITS: { if(true == _bToRight) { SetCurrentMenu(MENU_OPTION_EXIT); } else // to left { SetCurrentMenu(MENU_OPTION_INSTRUCTIONS); } break; } default:break; } }
// Handle a key press DBOOL CMainMenus::HandleKeyDown(int key, int rep) { if (key == VK_SHIFT || key == VK_LSHIFT || key == VK_RSHIFT) { m_bShiftState = DTRUE; CLTGUICtrl::SetShiftState(m_bShiftState); } // Pass the key to the message box if we are in one if ( m_bInMessageBox ) { return m_messageBox.HandleKeyDown(key, rep); } if (!m_pCurrentMenu) { return DFALSE; } if (!m_pCurrentMenu->HandleKeyDown(key, rep)) { switch ( key ) { case VK_ESCAPE: { if ( m_pCurrentMenu == m_pTopLevelMenu ) { // Return to the game if we are in a world if ( g_pBloodClientShell->IsInWorld() ) { g_pBloodClientShell->MenuReturnToGame(); } else { // We better be at the main menu! assert(m_pCurrentMenu == &m_mainMenu); } } else { // Play the sound PlayEscSound(); CMenuBase *pParentMenu; pParentMenu=m_pCurrentMenu->GetParentMenu(); if ( pParentMenu ) { assert(m_pTopLevelMenu); SetCurrentMenu(pParentMenu->GetMenuID(), m_pTopLevelMenu->GetMenuID()); } } break; } } } return DTRUE; }
void MenuAppear(Window *window) { int i; bool setSelected = false; MenuWindow *menuWindow = window_get_user_data(window); if(menuWindow) { SetCurrentMenu(menuWindow->menu); } WindowAppear(window); if(!currentMenuDef) { HideAllMenuLayers(); SetMenuDescription(NULL); return; } currentMenuDef->currentSelection = -1; for(i = 0; i < MAX_MENU_ENTRIES; ++i) { MenuEntry *entry = ¤tMenuDef->menuEntries[i]; if(MenuEntryIsActive(entry)) { ShowMenuLayer(i, entry->text); if(setSelected) { SetMenuHighlight(i, false); } else { SetMenuHighlight(i, true); setSelected = true; currentMenuDef->currentSelection = i; SetMenuDescription(entry->description); } } else { HideMenuLayer(i); } } if(menuWindow && menuWindow->menu && menuWindow->menu->mainImageId != -1) { LoadMainBmpImage(window, menuWindow->menu->mainImageId, menuWindow->menu->useFloorImage ? menuWindow->menu->floorImageId : -1); } }
LTBOOL CMenuMgr::PreviousMenu() { if (m_MenuArray.size() == 0) return LTFALSE; uint8 index = m_nMenuIndex; if (index == 0) index = m_MenuArray.size(); index--; while (index != m_nMenuIndex) { if (SetCurrentMenu(index)) return LTTRUE; else { if (index == 0) index = m_MenuArray.size(); index--; } } return LTFALSE; }
LTBOOL CMenuMgr::NextMenu() { if (m_MenuArray.size() == 0) return LTFALSE; uint8 index = m_nMenuIndex + 1; if (index >= m_MenuArray.size()) index = 0; while (index != m_nMenuIndex) { if (SetCurrentMenu(index)) return LTTRUE; else { index++; if (index >= m_MenuArray.size()) index = 0; } } return LTFALSE; }
// Initialization DBOOL CMainMenus::Init(CClientDE* pClientDE) { if (!pClientDE) { return DFALSE; } m_pClientDE = pClientDE; // Set the English flag HSTRING hString=m_pClientDE->FormatString(IDS_BLOOD2_LANGUAGE); if (hString && _mbsicmp((const unsigned char*)"english", (const unsigned char*)m_pClientDE->GetStringData(hString)) != 0) { m_bEnglish=DFALSE; } else { m_bEnglish=DTRUE; } m_pClientDE->FreeString(hString); hString=DNULL; // Load the virtual key codes for yes responses hString=m_pClientDE->FormatString(IDS_MENU_VKEY_YES); if (hString) { m_nYesVKeyCode=atoi(m_pClientDE->GetStringData(hString)); m_pClientDE->FreeString(hString); hString=DNULL; } // Load the virtual key codes for no responses hString=m_pClientDE->FormatString(IDS_MENU_VKEY_NO); if (hString) { m_nNoVKeyCode=atoi(m_pClientDE->GetStringData(hString)); m_pClientDE->FreeString(hString); hString=DNULL; } // Init the SharedResourceMgr class m_sharedResourceMgr.Init(m_pClientDE); // Determine if we need to set the low resolution flag RMode currentMode; if (m_pClientDE->GetRenderMode(¤tMode) == LT_OK) { if (currentMode.m_Width < 512 || currentMode.m_Height < 384) { m_bLowResolution=DTRUE; m_nMenuHeight=180; } } // Initialize the surfaces if ( !InitSurfaces() ) { return DFALSE; } // Initialize the fonts InitFonts(); // Initialize the message box m_messageBox.Create(m_pClientDE, "interface/mainmenus/dialog.pcx", GetSmallFont(), DNULL, DNULL); m_messageBox.SetTextColor(SETRGB(220,190,170)); // Initialize the individual menus m_mainMenu.Init (m_pClientDE, this, DNULL, MENU_ID_MAINMENU, m_nMenuHeight); m_singlePlayerMenu.Init (m_pClientDE, this, &m_mainMenu, MENU_ID_SINGLEPLAYER, m_nMenuHeight); m_bloodBathMenu.Init (m_pClientDE, this, &m_mainMenu, MENU_ID_BLOODBATH, m_nMenuHeight); m_optionsMenu.Init (m_pClientDE, this, &m_mainMenu, MENU_ID_OPTIONS, m_nMenuHeight); m_difficultyMenu.Init (m_pClientDE, this, &m_singlePlayerMenu,MENU_ID_DIFFICULTY, m_nMenuHeight); m_customLevelMenu.Init (m_pClientDE, this, &m_singlePlayerMenu,MENU_ID_CUSTOM_LEVEL, m_nMenuHeight); m_loadGameMenu.Init (m_pClientDE, this, &m_singlePlayerMenu,MENU_ID_LOAD_GAME, m_nMenuHeight); m_saveGameMenu.Init (m_pClientDE, this, &m_singlePlayerMenu,MENU_ID_SAVE_GAME, m_nMenuHeight); m_controlsMenu.Init (m_pClientDE, this, &m_optionsMenu, MENU_ID_CONTROLS, m_nMenuHeight); m_soundMenu.Init (m_pClientDE, this, &m_optionsMenu, MENU_ID_SOUND, m_nMenuHeight); m_displayMenu.Init (m_pClientDE, this, &m_optionsMenu, MENU_ID_DISPLAY, m_nMenuHeight); m_characterMenu.Init (m_pClientDE, this, &m_bloodBathMenu, MENU_ID_CHARACTER, m_nMenuHeight); m_characterFilesMenu.Init (m_pClientDE, this, &m_characterMenu, MENU_ID_CHARACTERFILES, 100); m_characterSelectMenu.Init (m_pClientDE, this, &m_singlePlayerMenu,MENU_ID_CHARACTERSELECT,m_nMenuHeight); m_mouseMenu.Init (m_pClientDE, this, &m_optionsMenu ,MENU_ID_MOUSE ,m_nMenuHeight); m_keyboardMenu.Init (m_pClientDE, this, &m_optionsMenu ,MENU_ID_KEYBOARD ,m_nMenuHeight); m_joystickMenu.Init (m_pClientDE, this, &m_optionsMenu ,MENU_ID_JOYSTICK ,m_nMenuHeight); // Add each menu to the array m_menuArray.SetSize(0); m_menuArray.Add(&m_mainMenu); m_menuArray.Add(&m_singlePlayerMenu); m_menuArray.Add(&m_bloodBathMenu); m_menuArray.Add(&m_optionsMenu); m_menuArray.Add(&m_difficultyMenu); m_menuArray.Add(&m_customLevelMenu); m_menuArray.Add(&m_loadGameMenu); m_menuArray.Add(&m_saveGameMenu); m_menuArray.Add(&m_controlsMenu); m_menuArray.Add(&m_soundMenu); m_menuArray.Add(&m_characterMenu); m_menuArray.Add(&m_characterFilesMenu); m_menuArray.Add(&m_characterSelectMenu); m_menuArray.Add(&m_mouseMenu); m_menuArray.Add(&m_keyboardMenu); m_menuArray.Add(&m_joystickMenu); // Build each menu unsigned int i; for (i=0; i < m_menuArray.GetSize(); i++) { m_menuArray[i]->Build(); } // This is done after the build above because it shouldn't be built until the user // actually wants to go into the menu. m_menuArray.Add(&m_displayMenu); SetCurrentMenu(MENU_ID_MAINMENU, MENU_ID_MAINMENU); // Load the version string m_hstrVersion = m_pClientDE->FormatString(IDS_VERSION); return DTRUE; }
int AppWarmux::Main(void) { DisplayLoadingPicture(); // Now that we are displaying a kind of 'please wait', do preload sounds JukeBox::GetInstance()->Init(); #ifdef HAVE_LIBCURL OptionMenu::CheckUpdates(); #endif Action_Handler_Init(); // Is a replay filename set so that we play it? if (!replay.empty()) { StartPlaying(replay); replay.clear(); End(); return 0; } do { if (choice == MainMenu::NONE) { MainMenu main_menu; SetCurrentMenu(&main_menu); choice = main_menu.Run(); } ActionHandler::GetInstance()->Flush(); switch (choice) { case MainMenu::PLAY: { GameMenu game_menu; SetCurrentMenu(&game_menu); game_menu.Run(skip_menu); break; } case MainMenu::NETWORK: { NetworkConnectionMenu network_connection_menu(net_action); SetCurrentMenu(&network_connection_menu); network_connection_menu.Run(skip_menu); break; } case MainMenu::OPTIONS: { OptionMenu options_menu; SetCurrentMenu(&options_menu); options_menu.Run(); break; } case MainMenu::BENCHMARK: { BenchmarkMenu bench_menu; SetCurrentMenu(&bench_menu); bench_menu.Run(); break; } case MainMenu::HELP: { HelpMenu help_menu; SetCurrentMenu(&help_menu); help_menu.Run(); break; } case MainMenu::CREDITS: { CreditsMenu credits_menu; SetCurrentMenu(&credits_menu); credits_menu.Run(); break; } case MainMenu::REPLAY: { ReplayMenu replay_menu; SetCurrentMenu(&replay_menu); replay_menu.Run(); break; } case MainMenu::QUIT: quit_game = true; break; default: break; } SetCurrentMenu(NULL); choice = MainMenu::NONE; skip_menu = false; net_action = NetworkConnectionMenu::NET_NOTHING; } while (!quit_game); End(); return 0; }