From 53fd34f7b8e4883f26d7f11e1c09f182ecc50e3b Mon Sep 17 00:00:00 2001 From: Flakebi Date: Wed, 16 Jul 2014 03:11:46 +0200 Subject: [PATCH] Fix issues with in-game screens --- src/guiengine/abstract_state_manager.cpp | 3 ++ src/guiengine/abstract_state_manager.hpp | 6 ++- src/states_screens/help_screen_1.cpp | 18 ++++++--- src/states_screens/help_screen_2.cpp | 17 ++++++--- src/states_screens/help_screen_3.cpp | 18 ++++++--- src/states_screens/help_screen_4.cpp | 17 +++++++-- src/states_screens/options_screen_audio.cpp | 20 +++++++--- src/states_screens/options_screen_input.cpp | 29 +++++++++++--- src/states_screens/options_screen_input2.cpp | 30 ++++++++++----- src/states_screens/options_screen_ui.cpp | 19 +++++++--- src/states_screens/options_screen_video.cpp | 26 ++++++------- src/states_screens/user_screen.cpp | 40 +++++++++++++++----- 12 files changed, 171 insertions(+), 72 deletions(-) diff --git a/src/guiengine/abstract_state_manager.cpp b/src/guiengine/abstract_state_manager.cpp index 3b7989370..bafed2a3a 100644 --- a/src/guiengine/abstract_state_manager.cpp +++ b/src/guiengine/abstract_state_manager.cpp @@ -140,6 +140,9 @@ void AbstractStateManager::pushScreen(Screen* screen) void AbstractStateManager::replaceTopMostScreen(Screen* screen, GUIEngine::GameState gameState) { + if (gameState == GUIEngine::CURRENT) + gameState = getGameState(); + //assert(m_game_mode != GAME); // you need to close any dialog before calling this assert(!ModalDialog::isADialogActive()); diff --git a/src/guiengine/abstract_state_manager.hpp b/src/guiengine/abstract_state_manager.hpp index b8ace0901..07f8bf8fd 100644 --- a/src/guiengine/abstract_state_manager.hpp +++ b/src/guiengine/abstract_state_manager.hpp @@ -40,7 +40,9 @@ namespace GUIEngine { MENU, GAME, - INGAME_MENU + INGAME_MENU, + /** Dummy GameState e. g. for parameters. */ + CURRENT = MENU | GAME | INGAME_MENU }; // GameState /** @@ -82,7 +84,7 @@ namespace GUIEngine * without displaying the second-topmost menu of the stack * in-between) */ - void replaceTopMostScreen(Screen* screen, GUIEngine::GameState gameState = GUIEngine::MENU); + void replaceTopMostScreen(Screen* screen, GUIEngine::GameState gameState = GUIEngine::CURRENT); /** * \brief removes the menu at the top of the screens stack diff --git a/src/states_screens/help_screen_1.cpp b/src/states_screens/help_screen_1.cpp index 2323be697..380e342a5 100644 --- a/src/states_screens/help_screen_1.cpp +++ b/src/states_screens/help_screen_1.cpp @@ -89,13 +89,19 @@ void HelpScreen1::eventCallback(Widget* widget, const std::string& name, const i } else if (name == "category") { - std::string selection = ((RibbonWidget*)widget)->getSelectionIDString(PLAYER_ID_GAME_MASTER).c_str(); + std::string selection = ((RibbonWidget*)widget)->getSelectionIDString(PLAYER_ID_GAME_MASTER); - //if (selection == "page1") StateManager::get()->replaceTopMostScreen(Help1Screen::getInstance()); - //else - if (selection == "page2") StateManager::get()->replaceTopMostScreen(HelpScreen2::getInstance()); - else if (selection == "page3") StateManager::get()->replaceTopMostScreen(HelpScreen3::getInstance()); - else if (selection == "page4") StateManager::get()->replaceTopMostScreen(HelpScreen4::getInstance()); + Screen *screen = NULL; + //if (selection == "page1") + // screen = HelpScreen1::getInstance(); + if (selection == "page2") + screen = HelpScreen2::getInstance(); + else if (selection == "page3") + screen = HelpScreen3::getInstance(); + else if (selection == "page4") + screen = HelpScreen4::getInstance(); + if(screen) + StateManager::get()->replaceTopMostScreen(screen); } else if (name == "back") { diff --git a/src/states_screens/help_screen_2.cpp b/src/states_screens/help_screen_2.cpp index f3c751474..b2b08a0a1 100644 --- a/src/states_screens/help_screen_2.cpp +++ b/src/states_screens/help_screen_2.cpp @@ -46,12 +46,19 @@ void HelpScreen2::eventCallback(Widget* widget, const std::string& name, const i { if (name == "category") { - std::string selection = ((RibbonWidget*)widget)->getSelectionIDString(PLAYER_ID_GAME_MASTER).c_str(); + std::string selection = ((RibbonWidget*)widget)->getSelectionIDString(PLAYER_ID_GAME_MASTER); - if(selection == "page1") StateManager::get()->replaceTopMostScreen(HelpScreen1::getInstance()); - //else if(selection == "page2") StateManager::get()->replaceTopMostScreen(HelpScreen2::getInstance()); - else if(selection == "page3") StateManager::get()->replaceTopMostScreen(HelpScreen3::getInstance()); - else if(selection == "page4") StateManager::get()->replaceTopMostScreen(HelpScreen4::getInstance()); + Screen *screen = NULL; + if (selection == "page1") + screen = HelpScreen1::getInstance(); + //else if (selection == "page2") + // screen = HelpScreen2::getInstance(); + else if (selection == "page3") + screen = HelpScreen3::getInstance(); + else if (selection == "page4") + screen = HelpScreen4::getInstance(); + if(screen) + StateManager::get()->replaceTopMostScreen(screen); } else if (name == "back") { diff --git a/src/states_screens/help_screen_3.cpp b/src/states_screens/help_screen_3.cpp index 35693dd94..a8a7cb4f6 100644 --- a/src/states_screens/help_screen_3.cpp +++ b/src/states_screens/help_screen_3.cpp @@ -47,12 +47,20 @@ void HelpScreen3::eventCallback(Widget* widget, const std::string& name, const i { if (name == "category") { - std::string selection = ((RibbonWidget*)widget)->getSelectionIDString(PLAYER_ID_GAME_MASTER).c_str(); + + std::string selection = ((RibbonWidget*)widget)->getSelectionIDString(PLAYER_ID_GAME_MASTER); - if (selection == "page1") StateManager::get()->replaceTopMostScreen(HelpScreen1::getInstance()); - else if (selection == "page2") StateManager::get()->replaceTopMostScreen(HelpScreen2::getInstance()); - //else if(selection == "page3") StateManager::get()->replaceTopMostScreen(Help3Screen::getInstance()); - else if(selection == "page4") StateManager::get()->replaceTopMostScreen(HelpScreen4::getInstance()); + Screen *screen = NULL; + if (selection == "page1") + screen = HelpScreen1::getInstance(); + else if (selection == "page2") + screen = HelpScreen2::getInstance(); + //else if (selection == "page3") + // screen = HelpScreen3::getInstance(); + else if (selection == "page4") + screen = HelpScreen4::getInstance(); + if(screen) + StateManager::get()->replaceTopMostScreen(screen); } else if (name == "back") { diff --git a/src/states_screens/help_screen_4.cpp b/src/states_screens/help_screen_4.cpp index 97ddf3809..c271467db 100644 --- a/src/states_screens/help_screen_4.cpp +++ b/src/states_screens/help_screen_4.cpp @@ -47,11 +47,20 @@ void HelpScreen4::eventCallback(Widget* widget, const std::string& name, const i { if (name == "category") { - std::string selection = ((RibbonWidget*)widget)->getSelectionIDString(PLAYER_ID_GAME_MASTER).c_str(); + + std::string selection = ((RibbonWidget*)widget)->getSelectionIDString(PLAYER_ID_GAME_MASTER); - if (selection == "page1") StateManager::get()->replaceTopMostScreen(HelpScreen1::getInstance()); - else if (selection == "page2") StateManager::get()->replaceTopMostScreen(HelpScreen2::getInstance()); - else if(selection == "page3") StateManager::get()->replaceTopMostScreen(HelpScreen3::getInstance()); + Screen *screen = NULL; + if (selection == "page1") + screen = HelpScreen1::getInstance(); + else if (selection == "page2") + screen = HelpScreen2::getInstance(); + else if (selection == "page3") + screen = HelpScreen3::getInstance(); + //else if (selection == "page4") + // screen = HelpScreen4::getInstance(); + if(screen) + StateManager::get()->replaceTopMostScreen(screen); } else if (name == "back") { diff --git a/src/states_screens/options_screen_audio.cpp b/src/states_screens/options_screen_audio.cpp index 10df8ed22..1cad3443e 100644 --- a/src/states_screens/options_screen_audio.cpp +++ b/src/states_screens/options_screen_audio.cpp @@ -103,13 +103,21 @@ void OptionsScreenAudio::eventCallback(Widget* widget, const std::string& name, { if (name == "options_choice") { - std::string selection = ((RibbonWidget*)widget)->getSelectionIDString(PLAYER_ID_GAME_MASTER).c_str(); + std::string selection = ((RibbonWidget*)widget)->getSelectionIDString(PLAYER_ID_GAME_MASTER); - if (selection == "tab_audio") StateManager::get()->replaceTopMostScreen(OptionsScreenAudio::getInstance()); - else if (selection == "tab_video") StateManager::get()->replaceTopMostScreen(OptionsScreenVideo::getInstance()); - else if (selection == "tab_players") StateManager::get()->replaceTopMostScreen(TabbedUserScreen::getInstance()); - else if (selection == "tab_controls") StateManager::get()->replaceTopMostScreen(OptionsScreenInput::getInstance()); - else if (selection == "tab_ui") StateManager::get()->replaceTopMostScreen(OptionsScreenUI::getInstance()); + Screen *screen = NULL; + //if (selection == "tab_audio") + // screen = OptionsScreenAudio::getInstance(); + if (selection == "tab_video") + screen = OptionsScreenVideo::getInstance(); + else if (selection == "tab_players") + screen = TabbedUserScreen::getInstance(); + else if (selection == "tab_controls") + screen = OptionsScreenInput::getInstance(); + else if (selection == "tab_ui") + screen = OptionsScreenUI::getInstance(); + if(screen) + StateManager::get()->replaceTopMostScreen(screen); } else if(name == "back") { diff --git a/src/states_screens/options_screen_input.cpp b/src/states_screens/options_screen_input.cpp index 2570d2d38..41b6396dc 100644 --- a/src/states_screens/options_screen_input.cpp +++ b/src/states_screens/options_screen_input.cpp @@ -154,6 +154,15 @@ void OptionsScreenInput::init() const std::string name2("devices"); eventCallback(devices, name2, PLAYER_ID_GAME_MASTER); */ + // Disable adding keyboard configurations + if (StateManager::get()->getGameState() == GUIEngine::INGAME_MENU) + { + getWidget("add_device")->setDeactivated(); + } + else + { + getWidget("add_device")->setActivated(); + } } // init // ----------------------------------------------------------------------------- @@ -184,13 +193,21 @@ void OptionsScreenInput::eventCallback(Widget* widget, const std::string& name, if (name == "options_choice") { - std::string selection = ((RibbonWidget*)widget)->getSelectionIDString(PLAYER_ID_GAME_MASTER).c_str(); + std::string selection = ((RibbonWidget*)widget)->getSelectionIDString(PLAYER_ID_GAME_MASTER); - if (selection == "tab_audio") StateManager::get()->replaceTopMostScreen(OptionsScreenAudio::getInstance()); - else if (selection == "tab_video") StateManager::get()->replaceTopMostScreen(OptionsScreenVideo::getInstance()); - else if (selection == "tab_players") StateManager::get()->replaceTopMostScreen(TabbedUserScreen::getInstance()); - else if (selection == "tab_controls") StateManager::get()->replaceTopMostScreen(OptionsScreenInput::getInstance()); - else if (selection == "tab_ui") StateManager::get()->replaceTopMostScreen(OptionsScreenUI::getInstance()); + Screen *screen = NULL; + if (selection == "tab_audio") + screen = OptionsScreenAudio::getInstance(); + else if (selection == "tab_video") + screen = OptionsScreenVideo::getInstance(); + else if (selection == "tab_players") + screen = TabbedUserScreen::getInstance(); + //else if (selection == "tab_controls") + // screen = OptionsScreenInput::getInstance(); + else if (selection == "tab_ui") + screen = OptionsScreenUI::getInstance(); + if(screen) + StateManager::get()->replaceTopMostScreen(screen); } else if (name == "add_device") { diff --git a/src/states_screens/options_screen_input2.cpp b/src/states_screens/options_screen_input2.cpp index 6e941a2ae..0ed577dea 100644 --- a/src/states_screens/options_screen_input2.cpp +++ b/src/states_screens/options_screen_input2.cpp @@ -150,6 +150,15 @@ void OptionsScreenInput2::init() actions->addItem(KartActionStrings[PA_MENU_CANCEL], L"" ); updateInputButtons(); + + // Disable deletion keyboard configurations + if (StateManager::get()->getGameState() == GUIEngine::INGAME_MENU) + { + getWidget("delete")->setDeactivated(); + } else + { + getWidget("delete")->setActivated(); + } } // init // ----------------------------------------------------------------------------- @@ -443,18 +452,21 @@ void OptionsScreenInput2::eventCallback(Widget* widget, StateManager *sm = StateManager::get(); if (name == "options_choice") { - const std::string &selection = - ((RibbonWidget*)widget)->getSelectionIDString(PLAYER_ID_GAME_MASTER); + std::string selection = ((RibbonWidget*)widget)->getSelectionIDString(PLAYER_ID_GAME_MASTER); - if (selection == "tab_audio") - sm->replaceTopMostScreen(OptionsScreenAudio::getInstance()); - else if (selection == "tab_video") - sm->replaceTopMostScreen(OptionsScreenVideo::getInstance()); + Screen *screen = NULL; + if (selection == "tab_audio") + screen = OptionsScreenAudio::getInstance(); + //else if (selection == "tab_video") + // screen = OptionsScreenVideo::getInstance(); else if (selection == "tab_players") - sm->replaceTopMostScreen(TabbedUserScreen::getInstance()); + screen = TabbedUserScreen::getInstance(); + //else if (selection == "tab_controls") + // screen = OptionsScreenInput::getInstance(); else if (selection == "tab_ui") - sm->replaceTopMostScreen(OptionsScreenUI::getInstance()); - else if (selection == "tab_controls") {} + screen = OptionsScreenUI::getInstance(); + if(screen) + StateManager::get()->replaceTopMostScreen(screen); } else if (name == "back_to_device_list") { diff --git a/src/states_screens/options_screen_ui.cpp b/src/states_screens/options_screen_ui.cpp index 73ba03208..23d370022 100644 --- a/src/states_screens/options_screen_ui.cpp +++ b/src/states_screens/options_screen_ui.cpp @@ -206,12 +206,21 @@ void OptionsScreenUI::eventCallback(Widget* widget, const std::string& name, con { if (name == "options_choice") { - std::string selection = ((RibbonWidget*)widget)->getSelectionIDString(PLAYER_ID_GAME_MASTER).c_str(); + std::string selection = ((RibbonWidget*)widget)->getSelectionIDString(PLAYER_ID_GAME_MASTER); - if (selection == "tab_audio") StateManager::get()->replaceTopMostScreen(OptionsScreenAudio::getInstance()); - else if (selection == "tab_video") StateManager::get()->replaceTopMostScreen(OptionsScreenVideo::getInstance()); - else if (selection == "tab_players") StateManager::get()->replaceTopMostScreen(TabbedUserScreen::getInstance()); - else if (selection == "tab_controls") StateManager::get()->replaceTopMostScreen(OptionsScreenInput::getInstance()); + Screen *screen = NULL; + if (selection == "tab_audio") + screen = OptionsScreenAudio::getInstance(); + else if (selection == "tab_video") + screen = OptionsScreenVideo::getInstance(); + else if (selection == "tab_players") + screen = TabbedUserScreen::getInstance(); + else if (selection == "tab_controls") + screen = OptionsScreenInput::getInstance(); + //else if (selection == "tab_ui") + // screen = OptionsScreenUI::getInstance(); + if(screen) + StateManager::get()->replaceTopMostScreen(screen); } else if(name == "back") { diff --git a/src/states_screens/options_screen_video.cpp b/src/states_screens/options_screen_video.cpp index 5c6a16a4c..c433c6a0c 100644 --- a/src/states_screens/options_screen_video.cpp +++ b/src/states_screens/options_screen_video.cpp @@ -167,15 +167,6 @@ void OptionsScreenVideo::init() if (UserConfigParams::m_fullscreen) rememberWinpos->setDeactivated(); else rememberWinpos->setActivated(); - // Enable back widgets if they were visited in-game previously - if (StateManager::get()->getGameState() != GUIEngine::INGAME_MENU) - { - res->setActivated(); - full->setActivated(); - applyBtn->setActivated(); - gfx->setActivated(); - getWidget("custom")->setActivated(); - } // --- get resolution list from irrlicht the first time if (!m_inited) @@ -342,6 +333,15 @@ void OptionsScreenVideo::init() gfx->setDeactivated(); getWidget("custom")->setDeactivated(); } + else + { + // Enable back widgets if they were visited in-game previously + res->setActivated(); + full->setActivated(); + applyBtn->setActivated(); + gfx->setActivated(); + getWidget("custom")->setActivated(); + } } // init // ---------------------------------------------------------------------------- @@ -469,15 +469,13 @@ void OptionsScreenVideo::eventCallback(Widget* widget, const std::string& name, { if (name == "options_choice") { - std::string selection = - ((RibbonWidget*)widget) - ->getSelectionIDString(PLAYER_ID_GAME_MASTER); + std::string selection = ((RibbonWidget*)widget)->getSelectionIDString(PLAYER_ID_GAME_MASTER); Screen *screen = NULL; if (selection == "tab_audio") screen = OptionsScreenAudio::getInstance(); - else if (selection == "tab_video") - screen = OptionsScreenVideo::getInstance(); + //else if (selection == "tab_video") + // screen = OptionsScreenVideo::getInstance(); else if (selection == "tab_players") screen = TabbedUserScreen::getInstance(); else if (selection == "tab_controls") diff --git a/src/states_screens/user_screen.cpp b/src/states_screens/user_screen.cpp index de5b1fa72..64b93630c 100644 --- a/src/states_screens/user_screen.cpp +++ b/src/states_screens/user_screen.cpp @@ -108,6 +108,21 @@ void BaseUserScreen::init() else if (PlayerManager::get()->getNumPlayers() > 0) selectUser(0); + // Disable changing the user while in game + if (StateManager::get()->getGameState() == GUIEngine::INGAME_MENU) + { + getWidget("ok")->setDeactivated(); + getWidget("new_user")->setDeactivated(); + getWidget("rename")->setDeactivated(); + getWidget("delete")->setDeactivated(); + } + else + { + getWidget("ok")->setActivated(); + getWidget("new_user")->setActivated(); + getWidget("rename")->setActivated(); + getWidget("delete")->setActivated(); + } } // init // ---------------------------------------------------------------------------- @@ -572,16 +587,21 @@ void TabbedUserScreen::eventCallback(GUIEngine::Widget* widget, { if (name == "options_choice") { - const std::string &selection = - ((RibbonWidget*)widget)->getSelectionIDString(PLAYER_ID_GAME_MASTER); - Screen *s; - if (selection=="tab_audio" ) s = OptionsScreenAudio::getInstance(); - else if (selection=="tab_video" ) s = OptionsScreenVideo::getInstance(); - else if (selection=="tab_players" ) s = TabbedUserScreen::getInstance(); - else if (selection=="tab_controls") s = OptionsScreenInput::getInstance(); - else if (selection=="tab_ui" ) s = OptionsScreenUI::getInstance(); - assert(s); - StateManager::get()->replaceTopMostScreen(s); + std::string selection = ((RibbonWidget*)widget)->getSelectionIDString(PLAYER_ID_GAME_MASTER); + + Screen *screen = NULL; + if (selection == "tab_audio") + screen = OptionsScreenAudio::getInstance(); + else if (selection == "tab_video") + screen = OptionsScreenVideo::getInstance(); + //else if (selection == "tab_players") + // screen = TabbedUserScreen::getInstance(); + else if (selection == "tab_controls") + screen = OptionsScreenInput::getInstance(); + else if (selection == "tab_ui") + screen = OptionsScreenUI::getInstance(); + if(screen) + StateManager::get()->replaceTopMostScreen(screen); } else BaseUserScreen::eventCallback(widget, name, player_id);