From 9f4a190245f94df7feb322059672e501b48a5ce1 Mon Sep 17 00:00:00 2001 From: Alayan <25536748+Alayan-stk-2@users.noreply.github.com> Date: Sat, 21 Dec 2024 18:40:56 +0100 Subject: [PATCH] Disable unusable in-game option tabs (fix #5163) --- src/states_screens/options/options_common.cpp | 15 +++++++++++++++ src/states_screens/options/options_common.hpp | 1 + .../options/options_screen_audio.cpp | 3 ++- .../options/options_screen_device.cpp | 6 +++--- .../options/options_screen_display.cpp | 2 ++ .../options/options_screen_general.cpp | 2 ++ .../options/options_screen_input.cpp | 2 ++ src/states_screens/options/options_screen_ui.cpp | 1 + .../options/options_screen_video.cpp | 2 ++ 9 files changed, 30 insertions(+), 4 deletions(-) diff --git a/src/states_screens/options/options_common.cpp b/src/states_screens/options/options_common.cpp index d134301ba26..104fedc09ed 100644 --- a/src/states_screens/options/options_common.cpp +++ b/src/states_screens/options/options_common.cpp @@ -43,4 +43,19 @@ namespace OptionsCommon if(screen) StateManager::get()->replaceTopMostScreen(screen); } + + // In the in-game pause options, disable the players and language tabs + void setTabStatus() + { + if (StateManager::get()->getGameState() == GUIEngine::INGAME_MENU) + { + GUIEngine::getWidget("tab_players")->setActive(false); + GUIEngine::getWidget("tab_language")->setActive(false); + } + else + { + GUIEngine::getWidget("tab_players")->setActive(true); + GUIEngine::getWidget("tab_language")->setActive(true); + } + } // setTabStatus } \ No newline at end of file diff --git a/src/states_screens/options/options_common.hpp b/src/states_screens/options/options_common.hpp index 9bafe3e26c3..9a618f06070 100644 --- a/src/states_screens/options/options_common.hpp +++ b/src/states_screens/options/options_common.hpp @@ -52,6 +52,7 @@ namespace OptionsCommon { void switchTab(std::string selected_tab); + void setTabStatus(); } #endif \ No newline at end of file diff --git a/src/states_screens/options/options_screen_audio.cpp b/src/states_screens/options/options_screen_audio.cpp index 0bcad71bfc4..97174de5d00 100644 --- a/src/states_screens/options/options_screen_audio.cpp +++ b/src/states_screens/options/options_screen_audio.cpp @@ -41,6 +41,8 @@ void OptionsScreenAudio::loadedFromFile() void OptionsScreenAudio::init() { Screen::init(); + OptionsCommon::setTabStatus(); + RibbonWidget* ribbon = this->getWidget("options_choice"); assert(ribbon != NULL); ribbon->setFocusForPlayer(PLAYER_ID_GAME_MASTER); @@ -70,7 +72,6 @@ void OptionsScreenAudio::init() getWidget("sfx_volume")->setActive(false); if(!UserConfigParams::m_music) getWidget("music_volume")->setActive(false); - } // init // ----------------------------------------------------------------------------- diff --git a/src/states_screens/options/options_screen_device.cpp b/src/states_screens/options/options_screen_device.cpp index 209f21113be..7f0fbd32cab 100644 --- a/src/states_screens/options/options_screen_device.cpp +++ b/src/states_screens/options/options_screen_device.cpp @@ -63,6 +63,8 @@ void OptionsScreenDevice::beforeAddingWidget() void OptionsScreenDevice::init() { Screen::init(); + OptionsCommon::setTabStatus(); + RibbonWidget* tabBar = getWidget("options_choice"); assert(tabBar != NULL); // Focus is set to the actions list later in the init @@ -182,9 +184,7 @@ void OptionsScreenDevice::init() actions->setSelectionID(0); // Disable deleting or disabling configuration mid-race - bool in_game = StateManager::get()->getGameState() == GUIEngine::INGAME_MENU; - - if (in_game) + if (StateManager::get()->getGameState() == GUIEngine::INGAME_MENU) { delete_button->setActive(false); disable_toggle->setActive(false); diff --git a/src/states_screens/options/options_screen_display.cpp b/src/states_screens/options/options_screen_display.cpp index 68f1bc81434..09148348eda 100644 --- a/src/states_screens/options/options_screen_display.cpp +++ b/src/states_screens/options/options_screen_display.cpp @@ -66,6 +66,8 @@ void OptionsScreenDisplay::loadedFromFile() void OptionsScreenDisplay::init() { Screen::init(); + OptionsCommon::setTabStatus(); + RibbonWidget* ribbon = getWidget("options_choice"); assert(ribbon != NULL); ribbon->setFocusForPlayer(PLAYER_ID_GAME_MASTER); diff --git a/src/states_screens/options/options_screen_general.cpp b/src/states_screens/options/options_screen_general.cpp index 1dca1dc2cb5..b83e7c4b1cf 100644 --- a/src/states_screens/options/options_screen_general.cpp +++ b/src/states_screens/options/options_screen_general.cpp @@ -72,6 +72,8 @@ void OptionsScreenGeneral::init() assert( show_login!= NULL ); show_login->setState( UserConfigParams::m_always_show_login_screen); + OptionsCommon::setTabStatus(); + #ifdef MOBILE_STK if (ExtractMobileAssets::hasFullAssets()) { diff --git a/src/states_screens/options/options_screen_input.cpp b/src/states_screens/options/options_screen_input.cpp index 15289a5ea67..b58a50744ff 100644 --- a/src/states_screens/options/options_screen_input.cpp +++ b/src/states_screens/options/options_screen_input.cpp @@ -154,6 +154,8 @@ void OptionsScreenInput::buildDeviceList() void OptionsScreenInput::init() { Screen::init(); + OptionsCommon::setTabStatus(); + RibbonWidget* tabBar = this->getWidget("options_choice"); assert(tabBar != NULL); tabBar->setFocusForPlayer(PLAYER_ID_GAME_MASTER); diff --git a/src/states_screens/options/options_screen_ui.cpp b/src/states_screens/options/options_screen_ui.cpp index de9ee66b39e..6caa85f3df8 100644 --- a/src/states_screens/options/options_screen_ui.cpp +++ b/src/states_screens/options/options_screen_ui.cpp @@ -148,6 +148,7 @@ void OptionsScreenUI::loadedFromFile() void OptionsScreenUI::init() { Screen::init(); + OptionsCommon::setTabStatus(); bool in_game = StateManager::get()->getGameState() == GUIEngine::INGAME_MENU; diff --git a/src/states_screens/options/options_screen_video.cpp b/src/states_screens/options/options_screen_video.cpp index 98807468938..3cfa5db2910 100644 --- a/src/states_screens/options/options_screen_video.cpp +++ b/src/states_screens/options/options_screen_video.cpp @@ -230,6 +230,8 @@ void OptionsScreenVideo::loadedFromFile() void OptionsScreenVideo::init() { Screen::init(); + OptionsCommon::setTabStatus(); + m_prev_adv_pipline = UserConfigParams::m_dynamic_lights; m_prev_img_quality = getImageQuality(); RibbonWidget* ribbon = getWidget("options_choice");