diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-05-21 23:53:20 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-05-22 12:23:26 +0300 |
commit | 5dd673aa6abe2a070de45388a885d03fcc037d70 (patch) | |
tree | b5bf80507501e7b77c4dbdbfc39989ebd6209a20 /src/gui | |
parent | 66bc17a4099842f9a54c13c183842f561d63963f (diff) | |
download | plus-5dd673aa6abe2a070de45388a885d03fcc037d70.tar.gz plus-5dd673aa6abe2a070de45388a885d03fcc037d70.tar.bz2 plus-5dd673aa6abe2a070de45388a885d03fcc037d70.tar.xz plus-5dd673aa6abe2a070de45388a885d03fcc037d70.zip |
allow open updater window from inside game.
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/windowmenu.cpp | 4 | ||||
-rw-r--r-- | src/gui/windows/updaterwindow.cpp | 30 | ||||
-rw-r--r-- | src/gui/windows/updaterwindow.h | 5 |
3 files changed, 33 insertions, 6 deletions
diff --git a/src/gui/windowmenu.cpp b/src/gui/windowmenu.cpp index b30306c3f..a4908d2a6 100644 --- a/src/gui/windowmenu.cpp +++ b/src/gui/windowmenu.cpp @@ -139,6 +139,10 @@ WindowMenu::WindowMenu(const Widget2 *const widget) : addButton(N_("OU"), // TRANSLATORS: full button name _("Outfits"), x, h, InputAction::WINDOW_OUTFIT, false); + // TRANSLATORS: short button name for updates window. + addButton(N_("UP"), + // TRANSLATORS: full button name + _("Updates"), x, h, InputAction::WINDOW_UPDATER, false); // TRANSLATORS: short button name for debug window. addButton(N_("DBG"), // TRANSLATORS: full button name diff --git a/src/gui/windows/updaterwindow.cpp b/src/gui/windows/updaterwindow.cpp index ff194ada4..9835279cc 100644 --- a/src/gui/windows/updaterwindow.cpp +++ b/src/gui/windows/updaterwindow.cpp @@ -276,8 +276,15 @@ void UpdaterWindow::enable() mPlayButton->setEnabled(true); mPlayButton->requestFocus(); - if (mUpdateType & UpdateType::Close) - client->setState(STATE_LOAD_DATA); + if (client->getState() != STATE_GAME) + { + if (mUpdateType & UpdateType::Close) + client->setState(STATE_LOAD_DATA); + } + else + { + deleteSelf(); + } } void UpdaterWindow::action(const ActionEvent &event) @@ -296,7 +303,10 @@ void UpdaterWindow::action(const ActionEvent &event) } else if (eventId == "play") { - client->setState(STATE_LOAD_DATA); + if (client->getState() != STATE_GAME) + client->setState(STATE_LOAD_DATA); + else + deleteSelf(); } } @@ -306,7 +316,10 @@ void UpdaterWindow::keyPressed(KeyEvent &event) if (actionId == static_cast<int>(InputAction::GUI_CANCEL)) { action(ActionEvent(nullptr, mCancelButton->getActionEventId())); - client->setState(STATE_LOGIN); + if (client->getState() != STATE_GAME) + client->setState(STATE_LOGIN); + else + deleteSelf(); } else if (actionId == static_cast<int>(InputAction::GUI_SELECT) || actionId == static_cast<int>(InputAction::GUI_SELECT2)) @@ -503,7 +516,8 @@ int UpdaterWindow::updateProgress(void *ptr, DownloadStatus::Type status, uw->setProgress(progress); - if (client->getState() != STATE_UPDATE + if ((client->getState() != STATE_UPDATE + && client->getState() != STATE_GAME) || uw->mDownloadStatus == UPDATE_ERROR) { // If the action was canceled return an error code to stop the mThread @@ -1134,3 +1148,9 @@ void UpdaterWindow::unloadMods(const std::string &dir) } } } + +void UpdaterWindow::deleteSelf() +{ + scheduleDelete(); + updaterWindow = nullptr; +} diff --git a/src/gui/windows/updaterwindow.h b/src/gui/windows/updaterwindow.h index eaca25e9f..fec31fce0 100644 --- a/src/gui/windows/updaterwindow.h +++ b/src/gui/windows/updaterwindow.h @@ -117,6 +117,8 @@ class UpdaterWindow final : public Window, void loadFile(std::string file); + void deleteSelf(); + static void loadLocalUpdates(const std::string &dir); static void unloadUpdates(const std::string &dir); @@ -156,7 +158,6 @@ private: */ void loadUpdates(); - /** * A download callback for progress updates. */ @@ -259,4 +260,6 @@ private: bool mValidateXml; }; +extern UpdaterWindow *updaterWindow; + #endif // GUI_WINDOWS_UPDATERWINDOW_H |