QuitDialog::QuitDialog(QuitDialog** pointerToMe): Window(_("Quit"), true, NULL), mMyPointer(pointerToMe) { mForceQuit = new RadioButton(_("Quit"), "quitdialog"); mLogoutQuit = new RadioButton(_("Quit"), "quitdialog"); mSwitchAccountServer = new RadioButton(_("Switch server"), "quitdialog"); mSwitchCharacter = new RadioButton(_("Switch character"), "quitdialog"); mOkButton = new Button(_("OK"), "ok", this); mCancelButton = new Button(_("Cancel"), "cancel", this); addKeyListener(this); ContainerPlacer place = getPlacer(0, 0); const State state = Client::getState(); // All states, when we're not logged in to someone. if (state == STATE_CHOOSE_SERVER || state == STATE_CONNECT_SERVER || state == STATE_LOGIN || state == STATE_LOGIN_ATTEMPT || state == STATE_UPDATE || state == STATE_LOAD_DATA) { placeOption(place, mForceQuit); } else { // Only added if we are connected to an accountserver or gameserver placeOption(place, mLogoutQuit); placeOption(place, mSwitchAccountServer); // Only added if we are connected to a gameserver if (state == STATE_GAME) placeOption(place, mSwitchCharacter); } mOptions[0]->setSelected(true); place = getPlacer(0, 1); place(1, 0, mOkButton); place(2, 0, mCancelButton); reflowLayout(150, 0); setLocationRelativeTo(getParent()); setVisible(true); requestModalFocus(); mOkButton->requestFocus(); }
QuitDialog::QuitDialog(QuitDialog **const pointerToMe) : // TRANSLATORS: quit dialog name Window(_("Quit"), true, nullptr, "quit.xml"), ActionListener(), KeyListener(), mOptions(), // TRANSLATORS: quit dialog button mLogoutQuit(new RadioButton(this, _("Quit"), "quitdialog")), // TRANSLATORS: quit dialog button mForceQuit(new RadioButton(this, _("Quit"), "quitdialog")), mSwitchAccountServer(new RadioButton(this, // TRANSLATORS: quit dialog button _("Switch server"), "quitdialog")), mSwitchCharacter(new RadioButton(this, // TRANSLATORS: quit dialog button _("Switch character"), "quitdialog")), mRate(nullptr), // TRANSLATORS: quit dialog button mOkButton(new Button(this, _("OK"), "ok", this)), // TRANSLATORS: quit dialog button mCancelButton(new Button(this, _("Cancel"), "cancel", this)), mMyPointer(pointerToMe), mNeedForceQuit(false) { addKeyListener(this); ContainerPlacer placer = getPlacer(0, 0); 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 (mNeedForceQuit) { placeOption(placer, mForceQuit); } else { // Only added if we are connected to an accountserver or gameserver placeOption(placer, mLogoutQuit); placeOption(placer, mSwitchAccountServer); // Only added if we are connected to a gameserver if (state == STATE_GAME) placeOption(placer, mSwitchCharacter); } /* #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); reflowLayout(200, 0); }