Fix issues with in-game screens

This commit is contained in:
Flakebi 2014-07-16 03:11:46 +02:00
parent a9a46a2dd6
commit 53fd34f7b8
12 changed files with 171 additions and 72 deletions

View File

@ -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());

View File

@ -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

View File

@ -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")
{

View File

@ -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")
{

View File

@ -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")
{

View File

@ -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")
{

View File

@ -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")
{

View File

@ -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<ButtonWidget>("add_device")->setDeactivated();
}
else
{
getWidget<ButtonWidget>("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")
{

View File

@ -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<ButtonWidget>("delete")->setDeactivated();
} else
{
getWidget<ButtonWidget>("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")
{

View File

@ -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")
{

View File

@ -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<ButtonWidget>("custom")->setActivated();
}
// --- get resolution list from irrlicht the first time
if (!m_inited)
@ -342,6 +333,15 @@ void OptionsScreenVideo::init()
gfx->setDeactivated();
getWidget<ButtonWidget>("custom")->setDeactivated();
}
else
{
// Enable back widgets if they were visited in-game previously
res->setActivated();
full->setActivated();
applyBtn->setActivated();
gfx->setActivated();
getWidget<ButtonWidget>("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")

View File

@ -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<IconButtonWidget>("ok")->setDeactivated();
getWidget<IconButtonWidget>("new_user")->setDeactivated();
getWidget<IconButtonWidget>("rename")->setDeactivated();
getWidget<IconButtonWidget>("delete")->setDeactivated();
}
else
{
getWidget<IconButtonWidget>("ok")->setActivated();
getWidget<IconButtonWidget>("new_user")->setActivated();
getWidget<IconButtonWidget>("rename")->setActivated();
getWidget<IconButtonWidget>("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);