Skip to content

Commit

Permalink
Disable unusable in-game option tabs (fix #5163)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alayan-stk-2 committed Dec 21, 2024
1 parent 7e34f60 commit 9f4a190
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 4 deletions.
15 changes: 15 additions & 0 deletions src/states_screens/options/options_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
1 change: 1 addition & 0 deletions src/states_screens/options/options_common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
namespace OptionsCommon
{
void switchTab(std::string selected_tab);
void setTabStatus();
}

#endif
3 changes: 2 additions & 1 deletion src/states_screens/options/options_screen_audio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ void OptionsScreenAudio::loadedFromFile()
void OptionsScreenAudio::init()
{
Screen::init();
OptionsCommon::setTabStatus();

RibbonWidget* ribbon = this->getWidget<RibbonWidget>("options_choice");
assert(ribbon != NULL);
ribbon->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
Expand Down Expand Up @@ -70,7 +72,6 @@ void OptionsScreenAudio::init()
getWidget<SpinnerWidget>("sfx_volume")->setActive(false);
if(!UserConfigParams::m_music)
getWidget<SpinnerWidget>("music_volume")->setActive(false);

} // init

// -----------------------------------------------------------------------------
Expand Down
6 changes: 3 additions & 3 deletions src/states_screens/options/options_screen_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ void OptionsScreenDevice::beforeAddingWidget()
void OptionsScreenDevice::init()
{
Screen::init();
OptionsCommon::setTabStatus();

RibbonWidget* tabBar = getWidget<RibbonWidget>("options_choice");
assert(tabBar != NULL);
// Focus is set to the actions list later in the init
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions src/states_screens/options/options_screen_display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ void OptionsScreenDisplay::loadedFromFile()
void OptionsScreenDisplay::init()
{
Screen::init();
OptionsCommon::setTabStatus();

RibbonWidget* ribbon = getWidget<RibbonWidget>("options_choice");
assert(ribbon != NULL);
ribbon->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
Expand Down
2 changes: 2 additions & 0 deletions src/states_screens/options/options_screen_general.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
{
Expand Down
2 changes: 2 additions & 0 deletions src/states_screens/options/options_screen_input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ void OptionsScreenInput::buildDeviceList()
void OptionsScreenInput::init()
{
Screen::init();
OptionsCommon::setTabStatus();

RibbonWidget* tabBar = this->getWidget<RibbonWidget>("options_choice");
assert(tabBar != NULL);
tabBar->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
Expand Down
1 change: 1 addition & 0 deletions src/states_screens/options/options_screen_ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ void OptionsScreenUI::loadedFromFile()
void OptionsScreenUI::init()
{
Screen::init();
OptionsCommon::setTabStatus();

bool in_game = StateManager::get()->getGameState() == GUIEngine::INGAME_MENU;

Expand Down
2 changes: 2 additions & 0 deletions src/states_screens/options/options_screen_video.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<RibbonWidget>("options_choice");
Expand Down

0 comments on commit 9f4a190

Please sign in to comment.