From 6ea2440a8662c4ffae8f7b6b53e84ddd25d69971 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 25 Jul 2015 17:54:03 +0300 Subject: Move state handler STATE_GAME into separate function. --- src/client.cpp | 79 +++++++++++++++++++++++++++++++--------------------------- src/client.h | 2 ++ 2 files changed, 44 insertions(+), 37 deletions(-) (limited to 'src') diff --git a/src/client.cpp b/src/client.cpp index 02626dcd4..f5fba647e 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -784,6 +784,47 @@ void Client::stateWorldSelect1() } } +void Client::stateGame1() +{ + if (!gui) + return; + + BasicContainer2 *const top = static_cast( + gui->getTop()); + + if (!top) + return; + + CREATEWIDGETV(desktop, Desktop, nullptr); + top->add(desktop); + int x = top->getWidth() - mButtonPadding; + ADDBUTTON(mSetupButton, new Button(desktop, + // TRANSLATORS: setup tab quick button + _("Setup"), "Setup", this)) + ADDBUTTON(mPerfomanceButton, new Button(desktop, + // TRANSLATORS: perfoamance tab quick button + _("Performance"), "Perfomance", this)) + ADDBUTTON(mVideoButton, new Button(desktop, + // TRANSLATORS: video tab quick button + _("Video"), "Video", this)) + ADDBUTTON(mThemesButton, new Button(desktop, + // TRANSLATORS: theme tab quick button + _("Theme"), "Themes", this)) + ADDBUTTON(mAboutButton, new Button(desktop, + // TRANSLATORS: theme tab quick button + _("About"), "about", this)) + ADDBUTTON(mHelpButton, new Button(desktop, + // TRANSLATORS: theme tab quick button + _("Help"), "help", this)) +#ifdef ANDROID + ADDBUTTON(mCloseButton, new Button(desktop, + // TRANSLATORS: close quick button + _("Close"), "close", this)) +#endif + desktop->setSize(mainGraphics->getWidth(), + mainGraphics->getHeight()); +} + int Client::gameExec() { int lastTickTime = tick_time; @@ -861,43 +902,7 @@ int Client::gameExec() else if (mOldState == STATE_START || (mOldState == STATE_GAME && mState != STATE_GAME)) { - if (!gui) - break; - - BasicContainer2 *const top = static_cast( - gui->getTop()); - - if (!top) - break; - - CREATEWIDGETV(desktop, Desktop, nullptr); - top->add(desktop); - int x = top->getWidth() - mButtonPadding; - ADDBUTTON(mSetupButton, new Button(desktop, - // TRANSLATORS: setup tab quick button - _("Setup"), "Setup", this)) - ADDBUTTON(mPerfomanceButton, new Button(desktop, - // TRANSLATORS: perfoamance tab quick button - _("Performance"), "Perfomance", this)) - ADDBUTTON(mVideoButton, new Button(desktop, - // TRANSLATORS: video tab quick button - _("Video"), "Video", this)) - ADDBUTTON(mThemesButton, new Button(desktop, - // TRANSLATORS: theme tab quick button - _("Theme"), "Themes", this)) - ADDBUTTON(mAboutButton, new Button(desktop, - // TRANSLATORS: theme tab quick button - _("About"), "about", this)) - ADDBUTTON(mHelpButton, new Button(desktop, - // TRANSLATORS: theme tab quick button - _("Help"), "help", this)) -#ifdef ANDROID - ADDBUTTON(mCloseButton, new Button(desktop, - // TRANSLATORS: close quick button - _("Close"), "close", this)) -#endif - desktop->setSize(mainGraphics->getWidth(), - mainGraphics->getHeight()); + stateGame1(); } BLOCK_END("Client::gameExec 6") diff --git a/src/client.h b/src/client.h index a1fea903d..8c36ec888 100644 --- a/src/client.h +++ b/src/client.h @@ -118,6 +118,8 @@ class Client final : public ConfigListener, void stateWorldSelect1(); + void stateGame1(); + ServerInfo mCurrentServer; Game *mGame; -- cgit v1.2.3-70-g09d2