diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-03-06 01:04:27 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-03-06 01:04:27 +0300 |
commit | 577ecda421be086b8cd501b21a2d5d40c0fd2ff8 (patch) | |
tree | 83c9a884fdbd63074ca96b2a91b84a0e1c90bab7 /src | |
parent | f27e666d3c7001d62d5292644cae8b3cfaa9af01 (diff) | |
download | manaverse-577ecda421be086b8cd501b21a2d5d40c0fd2ff8.tar.gz manaverse-577ecda421be086b8cd501b21a2d5d40c0fd2ff8.tar.bz2 manaverse-577ecda421be086b8cd501b21a2d5d40c0fd2ff8.tar.xz manaverse-577ecda421be086b8cd501b21a2d5d40c0fd2ff8.zip |
Add radio button in quit dialog for rate application in google play (only for Android)
Diffstat (limited to 'src')
-rw-r--r-- | src/defaults.cpp | 2 | ||||
-rw-r--r-- | src/gui/quitdialog.cpp | 51 | ||||
-rw-r--r-- | src/gui/quitdialog.h | 2 |
3 files changed, 42 insertions, 13 deletions
diff --git a/src/defaults.cpp b/src/defaults.cpp index 04c2d19cb..7c56d8ccf 100644 --- a/src/defaults.cpp +++ b/src/defaults.cpp @@ -307,6 +307,8 @@ DefaultsData* getConfigDefaults() AddDEF("autoresizeminimaps", false); AddDEF("showGuildOnline", false); AddDEF("enableGmTab", true); + AddDEF("gamecount", 0); + AddDEF("rated", false); return configData; } diff --git a/src/gui/quitdialog.cpp b/src/gui/quitdialog.cpp index fd6724aa3..b2e3f7d94 100644 --- a/src/gui/quitdialog.cpp +++ b/src/gui/quitdialog.cpp @@ -23,6 +23,7 @@ #include "gui/quitdialog.h" #include "client.h" +#include "configuration.h" #include "game.h" #include "keydata.h" #include "keyevent.h" @@ -44,6 +45,7 @@ #include "net/net.h" #include "utils/gettext.h" +#include "utils/process.h" #include "debug.h" @@ -57,6 +59,7 @@ QuitDialog::QuitDialog(QuitDialog **const pointerToMe): _("Switch server"), "quitdialog")), mSwitchCharacter(new RadioButton(this, _("Switch character"), "quitdialog")), + mRate(nullptr), mOkButton(new Button(this, _("OK"), "ok", this)), mCancelButton(new Button(this, _("Cancel"), "cancel", this)), mMyPointer(pointerToMe) @@ -67,14 +70,13 @@ QuitDialog::QuitDialog(QuitDialog **const pointerToMe): const State state = Client::getState(); + mNeedForceQuit = state == STATE_CHOOSE_SERVER + || state == STATE_CONNECT_SERVER || state == STATE_LOGIN + || state == STATE_PRE_LOGIN || state == STATE_LOGIN_ATTEMPT + || state == STATE_UPDATE || state == STATE_LOAD_DATA; + // All states, when we're not logged in to someone. - if (state == STATE_CHOOSE_SERVER || - state == STATE_CONNECT_SERVER || - state == STATE_LOGIN || - state == STATE_PRE_LOGIN || - state == STATE_LOGIN_ATTEMPT || - state == STATE_UPDATE || - state == STATE_LOAD_DATA) + if (mNeedForceQuit) { placeOption(placer, mForceQuit); } @@ -89,10 +91,21 @@ QuitDialog::QuitDialog(QuitDialog **const pointerToMe): placeOption(placer, mSwitchCharacter); } - mOptions[0]->setSelected(true); +#ifdef ANDROID + if (config.getBoolValue("rated") == false + && config.getIntValue("gamecount") > 3) + { + mRate = new RadioButton(this, _("Rate in google play"), "quitdialog"); + placeOption(placer, mRate); + mOptions[mOptions.size() - 1]->setSelected(true); + } + else +#endif + { + mOptions[0]->setSelected(true); + } placer = getPlacer(0, 1); - placer(1, 0, mOkButton, 1); placer(2, 0, mCancelButton, 1); @@ -129,6 +142,7 @@ void QuitDialog::placeOption(ContainerPlacer &placer, void QuitDialog::action(const gcn::ActionEvent &event) { + sound.playGuiSound(SOUND_HIDE_WINDOW); if (event.getId() == "ok") { if (viewport) @@ -147,6 +161,21 @@ void QuitDialog::action(const gcn::ActionEvent &event) Game::closeDialogs(); Client::setState(STATE_EXIT); } + else if (mRate && mRate->isSelected()) + { + openBrowser("https://play.google.com/store/apps/details?" + "id=org.evolonline.beta.manaplus"); + config.setValue("rated", true); + if (mNeedForceQuit) + { + Client::setState(STATE_FORCE_QUIT); + } + else + { + Game::closeDialogs(); + Client::setState(STATE_EXIT); + } + } else if (Net::getGameHandler()->isConnected() && mSwitchAccountServer->isSelected()) { @@ -162,10 +191,6 @@ void QuitDialog::action(const gcn::ActionEvent &event) } } } - else - { - sound.playGuiSound(SOUND_HIDE_WINDOW); - } scheduleDelete(); } diff --git a/src/gui/quitdialog.h b/src/gui/quitdialog.h index 760030e26..7f570bc1c 100644 --- a/src/gui/quitdialog.h +++ b/src/gui/quitdialog.h @@ -72,10 +72,12 @@ class QuitDialog final : public Window, public gcn::ActionListener, RadioButton *mForceQuit; RadioButton *mSwitchAccountServer; RadioButton *mSwitchCharacter; + RadioButton *mRate; Button *mOkButton; Button *mCancelButton; QuitDialog **mMyPointer; + bool mNeedForceQuit; }; #endif |