void BootMode::Update() { // Update the game mode generic members. GameMode::Update(); if(_exiting_to_new_game) { // When the fade out is done, we start a new game. if (!VideoManager->IsFading() && _new_game_called == false) { GlobalManager->NewGame(); _new_game_called = true; } return; } // The intro is being played if(_boot_state == BOOT_STATE_INTRO) { if(InputManager->AnyRegisteredKeyPress()) { ChangeState(BOOT_STATE_MENU); return; } else { return; // Otherwise skip rest of the event handling for now } } // Test whether the welcome sequence should be shown once static bool language_selection_shown = false; if(!language_selection_shown) { _ShowLanguageSelectionWindow(); language_selection_shown = true; } HelpWindow *help_window = ModeManager->GetHelpWindow(); if(help_window && help_window->IsActive()) { // Any key, except F1 if(!InputManager->HelpPress() && (InputManager->AnyKeyboardKeyPress() || InputManager->AnyJoystickKeyPress())) { GlobalManager->Media().PlaySound("confirm"); help_window->Hide(); } return; } // Updates the main menu when the option menu handler isn't active. bool is_menu_active = _menu_handler.IsActive(); if(is_menu_active) { bool was_showing_first_run_dlg = _menu_handler.IsShowingFirstRunLanguageMenu(); _menu_handler.Update(); // We do this to prevent unwanted input going to the main menu // after the first app run sequence. if (was_showing_first_run_dlg) return; } else { _main_menu.Update(); } // Update also the bar and f1 help text alpha uint32_t time_expired = SystemManager->GetUpdateTime(); _boot_timer.Update(time_expired); if (_boot_timer.GetTimeExpired() >= 4000.0 && _boot_timer.GetTimeExpired() < 12000.0) { _help_text_alpha += 0.001f * time_expired; if (_help_text_alpha > 1.0f) _help_text_alpha = 1.0f; } else if (_boot_timer.GetTimeExpired() >= 12000.0 && _boot_timer.GetTimeExpired() < 14000.0) { _help_text_alpha -= 0.001f * time_expired; if (_help_text_alpha < 0.0f) _help_text_alpha = 0.0f; } if (_menu_bar_alpha < 0.6f) { _menu_bar_alpha = _menu_bar_alpha + 0.001f * time_expired; if (_menu_bar_alpha >= 0.6f) _menu_bar_alpha = 0.6f; } if (is_menu_active) return; #ifdef DEBUG_FEATURES if (_debug_script_menu_open) { _debug_script_menu.Update(); // Check whether we can quit the debug menu. if (InputManager->UpPress()) { _debug_script_menu.InputUp(); } else if (InputManager->DownPress()) { _debug_script_menu.InputDown(); } else if (InputManager->CancelPress()) { _debug_script_menu_open = false; _debug_scripts_window.Hide(); } else if (InputManager->ConfirmPress()) { _DEBUG_OnDebugScriptRun(); } return; } #endif // Handles the main menu input. // Only quit when we are at the main menu level. if(InputManager->QuitPress()) { // Don't quit the game when using the joystick, // as it is confusing for the user. SDL_Event ev = InputManager->GetMostRecentEvent(); if (ev.type == SDL_KEYDOWN) SystemManager->ExitGame(); } if (InputManager->LeftPress()) { GlobalManager->Media().PlaySound("bump"); _main_menu.InputLeft(); return; } else if (InputManager->RightPress()) { GlobalManager->Media().PlaySound("bump"); _main_menu.InputRight(); return; } else if (!InputManager->ConfirmPress()) return; // Confirm press int32_t selection = _main_menu.GetSelection(); switch(selection) { default: break; case 0: // New Game _OnNewGame(); break; case 1: _OnLoadGame(); break; case 2: _OnOptions(); break; #ifdef DEBUG_FEATURES // Insert the debug option. case 3: _DEBUG_OnDebugScriptList(); break; case 4: _OnQuit(); break; #else case 3: _OnQuit(); break; #endif } }
void BootMode::Update() { _options_window.Update(SystemManager->GetUpdateTime()); // Update the game mode generic members. GameMode::Update(); if(_exiting_to_new_game) { // When the dae out is done, we start a new game. if(!VideoManager->IsFading()) GlobalManager->NewGame(); return; } // The intro is being played if(_boot_state == BOOT_STATE_INTRO) { if(InputManager->AnyKeyPress()) { ChangeState(BOOT_STATE_MENU); return; } else { return; // Otherwise skip rest of the event handling for now } } // Test whether the welcome sequence should be shown once static bool language_selection_shown = false; if(!language_selection_shown) { _ShowLanguageSelectionWindow(); language_selection_shown = true; } // On first app run, show the language menu and apply language on any key press. if (_first_run && _active_menu == &_language_options_menu) { _active_menu->Update(); if (InputManager->UpPress()) { _active_menu->InputUp(); } else if (InputManager->DownPress()) { _active_menu->InputDown(); } else if (InputManager->AnyKeyPress()) { // Set the language _active_menu->InputConfirm(); // Go directly back to the main menu when first selecting the language. _options_window.Hide(); _active_menu = &_main_menu; // And show the help window ModeManager->GetHelpWindow()->Show(); // save the settings (automatically changes the first_start variable to 0) _has_modified_settings = true; _SaveSettingsFile(); _first_run = false; // Terminate the first run sequence } return; } HelpWindow *help_window = ModeManager->GetHelpWindow(); if(help_window && help_window->IsActive()) { // Any key, except F1 if(!InputManager->HelpPress() && InputManager->AnyKeyPress()) { AudioManager->PlaySound("snd/confirm.wav"); help_window->Hide(); } return; } // Check for waiting keypresses or joystick button presses SDL_Event ev = InputManager->GetMostRecentEvent(); if(_joy_setting_function != NULL) { if(InputManager->AnyKeyPress() && ev.type == SDL_JOYBUTTONDOWN) { (this->*_joy_setting_function)(InputManager->GetMostRecentEvent().jbutton.button); _joy_setting_function = NULL; _has_modified_settings = true; _RefreshJoySettings(); _message_window.Hide(); } if(InputManager->CancelPress()) { _joy_setting_function = NULL; _message_window.Hide(); } return; } if(_joy_axis_setting_function != NULL) { int8 x = InputManager->GetLastAxisMoved(); if(x != -1) { (this->*_joy_axis_setting_function)(x); _joy_axis_setting_function = NULL; _has_modified_settings = true; _RefreshJoySettings(); _message_window.Hide(); } if(InputManager->CancelPress()) { _joy_axis_setting_function = NULL; _message_window.Hide(); } return; } if(_key_setting_function != NULL) { if(InputManager->AnyKeyPress() && ev.type == SDL_KEYDOWN) { (this->*_key_setting_function)(InputManager->GetMostRecentEvent().key.keysym.sym); _key_setting_function = NULL; _has_modified_settings = true; _RefreshKeySettings(); _message_window.Hide(); } if(InputManager->CancelPress()) { _key_setting_function = NULL; _message_window.Hide(); } return; } _active_menu->Update(); // Update also the bar and f1 help text alpha uint32 time_expired = SystemManager->GetUpdateTime(); _boot_timer.Update(time_expired); if (_boot_timer.GetTimeExpired() >= 4000.0 && _boot_timer.GetTimeExpired() < 12000.0) { _help_text_alpha += 0.001f * time_expired; if (_help_text_alpha > 1.0f) _help_text_alpha = 1.0f; } else if (_boot_timer.GetTimeExpired() >= 12000.0 && _boot_timer.GetTimeExpired() < 14000.0) { _help_text_alpha -= 0.001f * time_expired; if (_help_text_alpha < 0.0f) _help_text_alpha = 0.0f; } if (_menu_bar_alpha < 0.6f) { _menu_bar_alpha = _menu_bar_alpha + 0.001f * time_expired; if (_menu_bar_alpha >= 0.6f) _menu_bar_alpha = 0.6f; } // Only quit when we are at the main menu level if(_active_menu == &_main_menu && InputManager->QuitPress()) { SystemManager->ExitGame(); return; } if(InputManager->ConfirmPress()) { // Play 'confirm sound' if the selection isn't grayed out and it has a confirm handler if(_active_menu->IsOptionEnabled(_active_menu->GetSelection())) { // Don't play the sound on New Games as they have their own sound if(_active_menu != &_main_menu && _active_menu->GetSelection() != -1) AudioManager->PlaySound("snd/confirm.wav"); } else { // Otherwise play a different sound AudioManager->PlaySound("snd/bump.wav"); } _active_menu->InputConfirm(); } else if(InputManager->LeftPress()) { _active_menu->InputLeft(); } else if(InputManager->RightPress()) { _active_menu->InputRight(); } else if(InputManager->UpPress()) { _active_menu->InputUp(); } else if(InputManager->DownPress()) { _active_menu->InputDown(); } else if(InputManager->CancelPress() || InputManager->QuitPress()) { if(_active_menu == &_main_menu) { } else if(_active_menu == &_options_menu) { _options_window.Hide(); _active_menu = &_main_menu; } else if(_active_menu == &_video_options_menu) { _active_menu = &_options_menu; } else if(_active_menu == &_audio_options_menu) { _active_menu = &_options_menu; } else if(_active_menu == &_language_options_menu) { _active_menu = &_options_menu; } else if(_active_menu == &_key_settings_menu) { _active_menu = &_options_menu; } else if(_active_menu == &_joy_settings_menu) { _active_menu = &_options_menu; } else if(_active_menu == &_resolution_menu) { _active_menu = &_video_options_menu; } // Play cancel sound AudioManager->PlaySound("snd/cancel.wav"); } } // void BootMode::Update()