Update chat and counter even if there is dialog window opened

This commit is contained in:
Deve 2018-11-28 23:50:45 +01:00
parent 72b36e1512
commit 443919b6b7
4 changed files with 26 additions and 2 deletions

View File

@ -1183,17 +1183,25 @@ namespace GUIEngine
// ---- some menus may need updating
if (gamestate != GAME)
{
bool dialog_opened = false;
if (ScreenKeyboard::isActive())
{
ScreenKeyboard::getCurrent()->onUpdate(dt);
dialog_opened = true;
}
else if (ModalDialog::isADialogActive())
{
ModalDialog::getCurrent()->onUpdate(dt);
dialog_opened = true;
}
else
Screen* screen = getCurrentScreen();
if (screen != NULL &&
(!dialog_opened || screen->getUpdateInBackground()))
{
getCurrentScreen()->onUpdate(elapsed_time);
screen->onUpdate(elapsed_time);
}
}
else

View File

@ -58,6 +58,7 @@ Screen::Screen(const char* file, bool pause_race)
m_render_3d = false;
m_loaded = false;
m_pause_race = pause_race;
m_update_in_background = false;
} // Screen
// -----------------------------------------------------------------------------
@ -71,6 +72,7 @@ Screen::Screen(bool pause_race)
m_loaded = false;
m_render_3d = false;
m_pause_race = pause_race;
m_update_in_background = false;
} // Screen
// -----------------------------------------------------------------------------

View File

@ -113,6 +113,11 @@ namespace GUIEngine
/** to catch errors as early as possible, for debugging purposes only */
unsigned int m_magic_number;
/** When set to true it updates the screen even if modal dialog is
* opened
*/
bool m_update_in_background;
protected:
bool m_throttle_FPS;
@ -155,6 +160,12 @@ namespace GUIEngine
void manualAddWidget(Widget* w);
void manualRemoveWidget(Widget* w);
/** When set to true it updates the screen even if modal dialog is
* opened
*/
void setUpdateInBackground(bool value) {m_update_in_background = value;}
bool getUpdateInBackground() {return m_update_in_background;}
/** \return the name of this menu (which is the name of the file) */
const std::string& getName() const { return m_filename; }

View File

@ -75,6 +75,9 @@ NetworkingLobby::NetworkingLobby() : Screen("online/networking_lobby.stkgui")
m_chat_box = NULL;
m_send_button = NULL;
m_icon_bank = NULL;
// Allows to update chat and counter even if dialog window is opened
setUpdateInBackground(true);
} // NetworkingLobby
// ----------------------------------------------------------------------------