summaryrefslogtreecommitdiff
path: root/src/gui/quitdialog.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-03-06 01:04:27 +0300
committerAndrei Karas <akaras@inbox.ru>2013-03-06 01:04:27 +0300
commit577ecda421be086b8cd501b21a2d5d40c0fd2ff8 (patch)
tree83c9a884fdbd63074ca96b2a91b84a0e1c90bab7 /src/gui/quitdialog.cpp
parentf27e666d3c7001d62d5292644cae8b3cfaa9af01 (diff)
downloadmanaverse-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/gui/quitdialog.cpp')
-rw-r--r--src/gui/quitdialog.cpp51
1 files changed, 38 insertions, 13 deletions
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();
}