WorldSelectDialog::WorldSelectDialog(Worlds worlds): Window(_("Select World")) { mWorldListModel = new WorldListModel(worlds); mWorldList = new ListBox(mWorldListModel); ScrollArea *worldsScroll = new ScrollArea(mWorldList); mChangeLoginButton = new Button(_("Change Login"), "login", this); mChooseWorld = new Button(_("Choose World"), "world", this); worldsScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); place(0, 0, worldsScroll, 3, 5).setPadding(2); place(1, 5, mChangeLoginButton); place(2, 5, mChooseWorld); // Make sure the list has enough height getLayout().setRowHeight(0, 60); reflowLayout(0, 0); if (worlds.size() == 0) // Disable Ok button mChooseWorld->setEnabled(false); else // Select first server mWorldList->setSelected(0); addKeyListener(this); center(); setVisible(true); mChooseWorld->requestFocus(); }
void CharCreateDialog::fontChanged() { Window::fontChanged(); if (mWidgets.size() > 0) clear(); ContainerPlacer place; place = getPlacer(0, 0); place(0, 0, mNameLabel, 1); place(1, 0, mNameField, 6); place(0, 1, mHairStyleLabel, 1); place(1, 1, mPrevHairStyleButton); place(2, 1, mBeingBox, 1, 8).setPadding(3); place(3, 1, mNextHairStyleButton); place(0, 2, mHairColorLabel, 1); place(1, 2, mPrevHairColorButton); place(3, 2, mNextHairColorButton); place.getCell().matchColWidth(0, 2); place = getPlacer(0, 2); place(4, 0, mCancelButton); place(5, 0, mCreateButton); reflowLayout(225, 0); restoreFocus(); }
ConnectionDialog::ConnectionDialog(const std::string &text, const StateT cancelState) : Window("", Modal_false, nullptr, "connection.xml"), ActionListener(), mCancelState(cancelState) { mTitleBarHeight = 0; setMovable(false); setMinWidth(0); ProgressIndicator *const progressIndicator = new ProgressIndicator(this); Label *const label = new Label(this, text); Button *const cancelButton = new Button( // TRANSLATORS: connection dialog button this, _("Cancel"), "cancelButton", this); place(0, 0, progressIndicator); place(0, 1, label); place(0, 2, cancelButton).setHAlign(LayoutCell::CENTER); reflowLayout(); center(); if ((mSearchHash ^ 0x202020U) == 0x70E9296C) mStatsReUpdated = true; }
void LoginDialog::postInit() { Window::postInit(); setVisible(Visible_true); const int h = 200; if (mUpdateHostLabel) setContentSize(310, 250); setContentSize(310, h); #ifdef ANDROID setDefaultSize(310, h, ImageRect::UPPER_CENTER, 0, 0); #else setDefaultSize(310, h, ImageRect::CENTER, 0, 0); #endif center(); loadWindowState(); reflowLayout(); if (mUserField->getText().empty()) mUserField->requestFocus(); else mPassField->requestFocus(); mLoginButton->setEnabled(canSubmit()); if (loginHandler) { mRegisterButton->setEnabled(loginHandler->isRegistrationEnabled() || !mLoginData->registerUrl.empty()); } else { mRegisterButton->setEnabled(false); } }
ListWidget::ListWidget(Dialog *boss, int x, int y, int w, int h, const char *tooltip, uint32 cmd) : EditableWidget(boss, x, y, w, h, tooltip), _cmd(cmd) { _scrollBar = NULL; _textWidth = NULL; // This ensures that _entriesPerPage is properly initialised. reflowLayout(); _scrollBar = new ScrollBarWidget(this, _w - _scrollBarWidth + 1, 0, _scrollBarWidth, _h); _scrollBar->setTarget(this); setFlags(WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS | WIDGET_WANT_TICKLE); _type = kListWidget; _editMode = false; _numberingMode = kListNumberingOne; _currentPos = 0; _selectedItem = -1; _currentKeyDown = 0; _quickSelectTime = 0; // The item is selected, thus _bgcolor is used to draw the caret and _textcolorhi to erase it _caretInverse = true; // FIXME: This flag should come from widget definition _editable = true; }
ChangePasswordDialog::ChangePasswordDialog(Window *parent, LoginData *loginData): Window(_("Change Password"), true, parent), mWrongDataNoticeListener(new WrongDataNoticeListener), mLoginData(loginData) { gcn::Label *accountLabel = new Label( strprintf(_("Account: %s"), mLoginData->username.c_str())); mOldPassField = new PasswordField; mFirstPassField = new PasswordField; mSecondPassField = new PasswordField; mChangePassButton = new Button(_("Change Password"), "change_password", this); mCancelButton = new Button(_("Cancel"), "cancel", this); place(0, 0, accountLabel, 3); place(0, 1, new Label(_("Password:"******"Type new password twice:")), 3); place(0, 4, mFirstPassField, 3).setPadding(1); place(0, 5, mSecondPassField, 3).setPadding(1); place(1, 6, mCancelButton); place(2, 6, mChangePassButton); reflowLayout(200); setLocationRelativeTo(getParent()); setVisible(true); mOldPassField->requestFocus(); mOldPassField->setActionEventId("change_password"); mFirstPassField->setActionEventId("change_password"); mSecondPassField->setActionEventId("change_password"); }
CharSelectDialog::CharSelectDialog(LoginData *loginData): Window(_("Account and Character Management")), mLocked(false), mUnregisterButton(0), mChangeEmailButton(0), mCharacterEntries(0), mLoginData(loginData), mCharHandler(Net::getCharHandler()) { setCloseButton(false); mAccountNameLabel = new Label(loginData->username); mSwitchLoginButton = new Button(_("Switch Login"), "switch", this); mChangePasswordButton = new Button(_("Change Password"), "change_password", this); int optionalActions = Net::getLoginHandler()->supportedOptionalActions(); ContainerPlacer place; place = getPlacer(0, 0); place(0, 0, mAccountNameLabel, 2); place(0, 1, mSwitchLoginButton); if (optionalActions & Net::LoginHandler::Unregister) { mUnregisterButton = new Button(_("Unregister"), "unregister", this); place(3, 1, mUnregisterButton); } place(0, 2, mChangePasswordButton); if (optionalActions & Net::LoginHandler::ChangeEmail) { mChangeEmailButton = new Button(_("Change Email"), "change_email", this); place(3, 2, mChangeEmailButton); } place = getPlacer(0, 1); for (int i = 0; i < (int)mLoginData->characterSlots; i++) { mCharacterEntries.push_back(new CharacterDisplay(this)); place(i % SLOTS_PER_ROW, (int)i / SLOTS_PER_ROW, mCharacterEntries[i]); } reflowLayout(); addKeyListener(this); center(); setVisible(true); Net::getCharHandler()->setCharSelectDialog(this); mCharacterEntries[0]->requestFocus(); }
AboutDialog::AboutDialog() : Dialog(10, 20, 300, 174), _scrollPos(0), _scrollTime(0), _willClose(false) { reflowLayout(); int i; for (i = 0; i < 1; i++) _lines.push_back(""); Common::String version("C0""ResidualVM "); version += gScummVMVersion; _lines.push_back(version); Common::String date = Common::String::format(_("(built on %s)"), gScummVMBuildDate); _lines.push_back("C2" + date); for (i = 0; i < ARRAYSIZE(copyright_text); i++) addLine(copyright_text[i]); Common::String features("C1"); features += _("Features compiled in:"); addLine(features.c_str()); Common::String featureList("C0"); featureList += gScummVMFeatures; addLine(featureList.c_str()); _lines.push_back(""); Common::String engines("C1"); engines += _("Available engines:"); addLine(engines.c_str()); const EnginePlugin::List &plugins = EngineMan.getPlugins(); EnginePlugin::List::const_iterator iter = plugins.begin(); for (; iter != plugins.end(); ++iter) { Common::String str; str = "C0"; str += (**iter).getName(); addLine(str.c_str()); str = "C2"; str += (**iter)->getOriginalCopyright(); addLine(str.c_str()); //addLine(""); } for (i = 0; i < ARRAYSIZE(gpl_text); i++) addLine(gpl_text[i]); _lines.push_back(""); for (i = 0; i < ARRAYSIZE(credits); i++) addLine(credits[i]); }
void DownloadDialog::open() { Dialog::open(); CloudMan.setDownloadTarget(this); if (!CloudMan.isDownloading()) if (!selectDirectories()) close(); reflowLayout(); draw(); }
void ScrollContainerWidget::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) { Widget::handleCommand(sender, cmd, data); switch (cmd) { case kSetPositionCmd: _scrolledY = _verticalScroll->_currentPos; reflowLayout(); draw(); g_gui.doFullRedraw(); break; } }
CharCreateDialog::CharCreateDialog(Window *parent, int slot, Gender gender): Window(_("Create Character"), true, parent), mSlot(slot) { mPlayer = new Player(0, 0, NULL); mPlayer->setGender(gender); int numberOfHairColors = ColorDB::size(); mPlayer->setHairStyle(rand() % mPlayer->getNumOfHairstyles(), rand() % numberOfHairColors); mNameField = new TextField(""); mNameLabel = new Label(_("Name:")); mNextHairColorButton = new Button(">", "nextcolor", this); mPrevHairColorButton = new Button("<", "prevcolor", this); mHairColorLabel = new Label(_("Hair Color:")); mNextHairStyleButton = new Button(">", "nextstyle", this); mPrevHairStyleButton = new Button("<", "prevstyle", this); mHairStyleLabel = new Label(_("Hair Style:")); mCreateButton = new Button(_("Create"), "create", this); mCancelButton = new Button(_("Cancel"), "cancel", this); mBeingBox = new BeingBox(mPlayer); mBeingBox->setWidth(74); mNameField->setActionEventId("create"); mNameField->addActionListener(this); ContainerPlacer place; place = getPlacer(0, 0); place(0, 0, mNameLabel, 1); place(1, 0, mNameField, 6); place(0, 1, mHairStyleLabel, 1); place(1, 1, mPrevHairStyleButton); place(2, 1, mBeingBox, 1, 8).setPadding(3); place(3, 1, mNextHairStyleButton); place(0, 2, mHairColorLabel, 1); place(1, 2, mPrevHairColorButton); place(3, 2, mNextHairColorButton); place.getCell().matchColWidth(0, 2); place = getPlacer(0, 2); place(4, 0, mCancelButton); place(5, 0, mCreateButton); reflowLayout(225, 0); setLocationRelativeTo(getParent()); setVisible(true); mNameField->requestFocus(); }
CharSelectDialog::CharSelectDialog(LockedArray<LocalPlayer*> *charInfo, Gender gender): Window(_("Select Character")), mCharInfo(charInfo), mGender(gender), mCharSelected(false) { // Control that shows the Player mBeingBox = new BeingBox(); mBeingBox->setWidth(74); mNameLabel = new Label(strprintf(_("Name: %s"), "")); mLevelLabel = new Label(strprintf(_("Level: %d"), 0)); mJobLevelLabel = new Label(strprintf(_("Job Level: %d"), 0)); mMoneyLabel = new Label(strprintf(_("Money: %d"), 0)); const std::string tempString = getFont()->getWidth(_("New")) < getFont()->getWidth(_("Delete")) ? _("Delete") : _("New"); mPreviousButton = new Button(_("Previous"), "previous", this); mNextButton = new Button(_("Next"), "next", this); mNewDelCharButton = new Button(tempString, "newdel", this); mSelectButton = new Button(_("OK"), "ok", this); mCancelButton = new Button(_("Cancel"), "cancel", this); ContainerPlacer place; place = getPlacer(0, 0); place(0, 0, mBeingBox, 1, 6).setPadding(3); place(1, 0, mNewDelCharButton); place(1, 1, mNameLabel, 5); place(1, 2, mLevelLabel, 5); place(1, 3, mJobLevelLabel, 5); place(1, 4, mMoneyLabel, 5); place.getCell().matchColWidth(1, 4); place = getPlacer(0, 2); place(0, 0, mPreviousButton); place(1, 0, mNextButton); place(4, 0, mCancelButton); place(5, 0, mSelectButton); reflowLayout(250, 0); setLocationRelativeTo(getParent()); setVisible(true); mSelectButton->requestFocus(); updatePlayerInfo(); }
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(); }
LoginDialog::LoginDialog(LoginData *loginData): Window(_("Login")), mLoginData(loginData) { gcn::Label *userLabel = new Label(_("Name:")); gcn::Label *passLabel = new Label(_("Password:"******"Remember username"), mLoginData->remember); mRegisterButton = new Button(_("Register"), "register", this); mServerButton = new Button(_("Change Server"), "server", this); mLoginButton = new Button(_("Login"), "login", this); mUserField->setActionEventId("login"); mPassField->setActionEventId("login"); mUserField->addKeyListener(this); mPassField->addKeyListener(this); mUserField->addActionListener(this); mPassField->addActionListener(this); place(0, 0, userLabel); place(0, 1, passLabel); place(1, 0, mUserField, 3).setPadding(1); place(1, 1, mPassField, 3).setPadding(1); place(0, 5, mKeepCheck, 4); place(0, 6, mRegisterButton).setHAlign(LayoutCell::LEFT); place(2, 6, mServerButton); place(3, 6, mLoginButton); reflowLayout(); addKeyListener(this); center(); setVisible(true); if (mUserField->getText().empty()) mUserField->requestFocus(); else mPassField->requestFocus(); mLoginButton->setEnabled(canSubmit()); }
WorldSelectDialog::WorldSelectDialog(Worlds worlds) : // TRANSLATORS: world select dialog name Window(_("Select World"), Modal_false, nullptr, "world.xml"), ActionListener(), KeyListener(), mWorldListModel(new WorldListModel(worlds)), mWorldList(new ListBox(this, mWorldListModel, "")), // TRANSLATORS: world dialog button mChangeLoginButton(new Button(this, _("Change Login"), "login", this)), // TRANSLATORS: world dialog button mChooseWorld(new Button(this, _("Choose World"), "world", this)) { mWorldList->postInit(); ScrollArea *const worldsScroll = new ScrollArea(this, mWorldList, getOptionBool("showbackground"), "world_background.xml"); worldsScroll->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER); place(0, 0, worldsScroll, 3, 5).setPadding(2); place(1, 5, mChangeLoginButton); place(2, 5, mChooseWorld); // Make sure the list has enough height getLayout().setRowHeight(0, 60); reflowLayout(0, 0); if (worlds.empty()) { // Disable Ok button mChooseWorld->setEnabled(false); } else { // Select first server mWorldList->setSelected(0); } addKeyListener(this); center(); }
ConnectionDialog::ConnectionDialog(const std::string &text, State cancelState): Window(""), mCancelState(cancelState) { setTitleBarHeight(0); setMovable(false); setMinWidth(0); ProgressIndicator *progressIndicator = new ProgressIndicator; gcn::Label *label = new Label(text); Button *cancelButton = new Button(_("Cancel"), "cancelButton", this); place(0, 0, progressIndicator); place(0, 1, label); place(0, 2, cancelButton).setHAlign(LayoutCell::CENTER); reflowLayout(); center(); setVisible(true); }
ConnectionDialog::ConnectionDialog(const std::string &text, const State cancelState): Window(""), gcn::ActionListener(), mCancelState(cancelState) { setTitleBarHeight(0); setMovable(false); setMinWidth(0); ProgressIndicator *const progressIndicator = new ProgressIndicator; Label *const label = new Label(this, text); Button *const cancelButton = new Button( // TRANSLATORS: connection dialog button this, _("Cancel"), "cancelButton", this); place(0, 0, progressIndicator); place(0, 1, label); place(0, 2, cancelButton).setHAlign(LayoutCell::CENTER); reflowLayout(); center(); }
BankWindow::BankWindow() : // TRANSLATORS: bank window name Window(_("Bank"), Modal_false, nullptr, "bank.xml"), ActionListener(), BankListener(), mBankMoneyLabel(new Label(this, strprintf( // TRANSLATORS: bank window money label _("Money in bank: %s"), " "))), mInputMoneyTextField(new IntTextField(this, 0, 0, 2147483647)), // TRANSLATORS: bank window button mWithdrawButton(new Button(this, _("Withdraw"), "withdraw", this)), // TRANSLATORS: bank window button mDepositButton(new Button(this, _("Deposit"), "deposit", this)) { setWindowName("Bank"); setCloseButton(true); if (setupWindow) setupWindow->registerWindowForReset(this); mBankMoneyLabel->adjustSize(); ContainerPlacer placer = getPlacer(0, 0); placer(0, 0, mBankMoneyLabel, 7); placer(0, 1, mInputMoneyTextField, 10); placer(0, 2, mDepositButton, 5); placer(5, 2, mWithdrawButton, 5); setContentSize(300, 100); setDefaultSize(300, 100, ImagePosition::CENTER, 0, 0); center(); setDefaultSize(); loadWindowState(); reflowLayout(300); enableVisibleSound(true); }
RegisterDialog::RegisterDialog(LoginData &data) : // TRANSLATORS: register dialog name Window(_("Register"), Modal_false, nullptr, "register.xml"), ActionListener(), KeyListener(), mLoginData(&data), mUserField(new TextField(this, mLoginData->username)), mPasswordField(new PasswordField(this, mLoginData->password)), mConfirmField(new PasswordField(this)), mEmailField(nullptr), // TRANSLATORS: register dialog. button. mRegisterButton(new Button(this, _("Register"), "register", this)), // TRANSLATORS: register dialog. button. mCancelButton(new Button(this, _("Cancel"), "cancel", this)), mMaleButton(nullptr), mFemaleButton(nullptr), mOtherButton(nullptr), mWrongDataNoticeListener(new WrongDataNoticeListener) { setCloseButton(true); // TRANSLATORS: register dialog. label. Label *const userLabel = new Label(this, _("Name:")); // TRANSLATORS: register dialog. label. Label *const passwordLabel = new Label(this, _("Password:"******"Confirm:")); ContainerPlacer placer; placer = getPlacer(0, 0); placer(0, 0, userLabel); placer(0, 1, passwordLabel); placer(0, 2, confirmLabel); placer(1, 0, mUserField, 3).setPadding(2); placer(1, 1, mPasswordField, 3).setPadding(2); placer(1, 2, mConfirmField, 3).setPadding(2); int row = 3; if (features.getIntValue("forceAccountGender") == -1) { // TRANSLATORS: register dialog. button. mMaleButton = new RadioButton(this, _("Male"), "sex", true); // TRANSLATORS: register dialog. button. mFemaleButton = new RadioButton(this, _("Female"), "sex", false); if (serverFeatures->haveAccountOtherGender()) { // TRANSLATORS: register dialog. button. mOtherButton = new RadioButton(this, _("Other"), "sex", false); placer(0, row, mMaleButton); placer(1, row, mFemaleButton); placer(2, row, mOtherButton); } else { placer(1, row, mMaleButton); placer(2, row, mFemaleButton); } row++; } if (serverFeatures->haveEmailOnRegister()) { // TRANSLATORS: register dialog. label. Label *const emailLabel = new Label(this, _("Email:")); mEmailField = new TextField(this); placer(0, row, emailLabel); placer(1, row, mEmailField, 3).setPadding(2); mEmailField->addKeyListener(this); mEmailField->setActionEventId("register"); mEmailField->addActionListener(this); // row++; } placer = getPlacer(0, 2); placer(1, 0, mRegisterButton); placer(2, 0, mCancelButton); reflowLayout(250, 0); mUserField->addKeyListener(this); mPasswordField->addKeyListener(this); mConfirmField->addKeyListener(this); mUserField->setActionEventId("register"); mPasswordField->setActionEventId("register"); mConfirmField->setActionEventId("register"); mUserField->addActionListener(this); mPasswordField->addActionListener(this); mConfirmField->addActionListener(this); center(); }
TextCommandEditor::TextCommandEditor(TextCommand *const command) : // TRANSLATORS: command editor name Window(_("Command Editor"), Modal_false, nullptr, "commandeditor.xml"), ActionListener(), mIsMagicCommand(command ? (command->getCommandType() == TEXT_COMMAND_MAGIC) : false), mCommand(command), // TRANSLATORS: command editor button mIsMagic(new RadioButton(this, _("magic"), "magic", mIsMagicCommand)), // TRANSLATORS: command editor button mIsOther(new RadioButton(this, _("other"), "magic", !mIsMagicCommand)), // TRANSLATORS: command editor label mSymbolLabel(new Label(this, _("Symbol:"))), mSymbolTextField(new TextField(this)), // TRANSLATORS: command editor label mCommandLabel(new Label(this, _("Command:"))), mCommandTextField(new TextField(this)), // TRANSLATORS: command editor label mCommentLabel(new Label(this, _("Comment:"))), mCommentTextField(new TextField(this)), mTargetTypeModel(new TargetTypeModel), // TRANSLATORS: command editor label mTypeLabel(new Label(this, _("Target Type:"))), mTypeDropDown(new DropDown(this, mTargetTypeModel)), mIconsModel(new IconsModel), // TRANSLATORS: command editor label mIconLabel(new Label(this, _("Icon:"))), mIconDropDown(new DropDown(this, mIconsModel)), // TRANSLATORS: command editor label mManaLabel(new Label(this, _("Mana:"))), mManaField(new IntTextField(this, 0)), // TRANSLATORS: command editor label mMagicLvlLabel(new Label(this, _("Magic level:"))), mMagicLvlField(new IntTextField(this, 0)), mMagicSchoolModel(new MagicSchoolModel), // TRANSLATORS: command editor label mSchoolLabel(new Label(this, _("Magic School:"))), mSchoolDropDown(new DropDown(this, mMagicSchoolModel)), // TRANSLATORS: command editor label mSchoolLvlLabel(new Label(this, _("School level:"))), mSchoolLvlField(new IntTextField(this, 0)), // TRANSLATORS: command editor button mCancelButton(new Button(this, _("Cancel"), "cancel", this)), // TRANSLATORS: command editor button mSaveButton(new Button(this, _("Save"), "save", this)), // TRANSLATORS: command editor button mDeleteButton(new Button(this, _("Delete"), "delete", this)), mEnabledKeyboard(keyboard.isEnabled()) { const int w = 350; const int h = 370; keyboard.setEnabled(false); setWindowName("TextCommandEditor"); setDefaultSize(w, h, ImageRect::CENTER); mIsMagic->setActionEventId("magic"); mIsMagic->addActionListener(this); mIsOther->setActionEventId("other"); mIsOther->addActionListener(this); mManaField->setRange(0, 500); mManaField->setWidth(20); mTypeDropDown->setActionEventId("type"); mTypeDropDown->addActionListener(this); mIconDropDown->setActionEventId("icon"); mIconDropDown->addActionListener(this); mIconDropDown->setSelectedString(mCommand->getIcon()); mMagicLvlField->setRange(0, 5); mMagicLvlField->setWidth(20); mSchoolDropDown->setActionEventId("school"); mSchoolDropDown->addActionListener(this); mSchoolDropDown->setSelected(0); mSchoolLvlField->setRange(0, 5); mSchoolLvlField->setWidth(20); mSaveButton->adjustSize(); mCancelButton->adjustSize(); mDeleteButton->adjustSize(); if (command) { if (command->getCommandType() == TEXT_COMMAND_MAGIC) showControls(Visible_true); else showControls(Visible_false); mSymbolTextField->setText(command->getSymbol()); mCommandTextField->setText(command->getCommand()); mCommentTextField->setText(command->getComment()); mManaField->setValue(command->getMana()); mTypeDropDown->setSelected(static_cast<int>(command->getTargetType())); mMagicLvlField->setValue(command->getBaseLvl()); mSchoolDropDown->setSelected(static_cast<int>(command->getSchool()) - MAGIC_START_ID); mSchoolLvlField->setValue(command->getSchoolLvl()); } ContainerPlacer placer; placer = getPlacer(0, 0); placer(0, 0, mIsMagic, 1); placer(2, 0, mIsOther, 1); placer(0, 1, mSymbolLabel, 2).setPadding(3); placer(2, 1, mSymbolTextField, 3).setPadding(3); placer(0, 2, mCommandLabel, 2).setPadding(3); placer(2, 2, mCommandTextField, 4).setPadding(3); placer(0, 3, mCommentLabel, 2).setPadding(3); placer(2, 3, mCommentTextField, 4).setPadding(3); placer(0, 4, mTypeLabel, 2).setPadding(3); placer(2, 4, mTypeDropDown, 3).setPadding(3); placer(0, 5, mIconLabel, 2).setPadding(3); placer(2, 5, mIconDropDown, 3).setPadding(3); placer(0, 6, mManaLabel, 2).setPadding(3); placer(2, 6, mManaField, 3).setPadding(3); placer(0, 7, mMagicLvlLabel, 2).setPadding(3); placer(2, 7, mMagicLvlField, 3).setPadding(3); placer(0, 8, mSchoolLabel, 2).setPadding(3); placer(2, 8, mSchoolDropDown, 3).setPadding(3); placer(0, 9, mSchoolLvlLabel, 2).setPadding(3); placer(2, 9, mSchoolLvlField, 3).setPadding(3); placer(0, 10, mSaveButton, 2).setPadding(3); placer(2, 10, mCancelButton, 2).setPadding(3); placer(4, 10, mDeleteButton, 2).setPadding(3); setWidth(w); setHeight(h); reflowLayout(w); center(); }
void TopMenu::handleCommand(GUI::CommandSender *sender, uint32 command, uint32 data) { switch (command) { case kCmdWhat: close(); _vm->getGameStatus().helpFl = true; break; case kCmdMusic: _vm->_sound->toggleMusic(); _musicButton->setGfx(arrayBmp[4 * kMenuMusic + (g_system->getOverlayWidth() > 320 ? 2 : 1) - 1 + ((_vm->_config.musicFl) ? 0 : 2)]); _musicButton->draw(); g_gui.theme()->updateScreen(); g_system->updateScreen(); g_system->delayMillis(500); close(); break; case kCmdSoundFX: _vm->_sound->toggleSound(); reflowLayout(); _soundFXButton->draw(); g_gui.theme()->updateScreen(); g_system->updateScreen(); g_system->delayMillis(500); close(); break; case kCmdSave: close(); if (_vm->getGameStatus().viewState == kViewPlay) { if (_vm->getGameStatus().gameOverFl) _vm->gameOverMsg(); else _vm->_file->saveGame(-1, Common::String()); } break; case kCmdLoad: close(); _vm->_file->restoreGame(-1); break; case kCmdRecall: close(); _vm->getGameStatus().recallFl = true; break; case kCmdTurbo: _vm->_parser->switchTurbo(); reflowLayout(); _turboButton->draw(); g_gui.theme()->updateScreen(); g_system->updateScreen(); g_system->delayMillis(500); close(); break; case kCmdLook: close(); _vm->_parser->command("look around"); break; case kCmdInvent: close(); _vm->_parser->showInventory(); break; default: Dialog::handleCommand(sender, command, data); } }
ItemAmountWindow::ItemAmountWindow(Usage usage, Window *parent, Item *item, int maxRange): Window("", true, parent, "amount.xml"), mItemPriceTextField(nullptr), mGPLabel(nullptr), mItem(item), mMax(maxRange), mUsage(usage), mItemPriceSlide(nullptr), mItemsModal(nullptr), mPrice(0) { if (!mItem) { setVisible(false); return; } if (usage == ShopBuyAdd) mMax = 10000; else if (!mMax) mMax = mItem->getQuantity(); // Save keyboard state mEnabledKeyboard = keyboard.isEnabled(); keyboard.setEnabled(false); // Integer field mItemAmountTextField = new IntTextField(1); mItemAmountTextField->setRange(1, mMax); mItemAmountTextField->setWidth(35); mItemAmountTextField->addKeyListener(this); // Slider mItemAmountSlide = new Slider(1.0, mMax); mItemAmountSlide->setHeight(10); mItemAmountSlide->setActionEventId("slide"); mItemAmountSlide->addActionListener(this); if (mUsage == ShopBuyAdd || mUsage == ShopSellAdd) { // Integer field mItemPriceTextField = new IntTextField(1); mItemPriceTextField->setRange(1, 10000000); mItemPriceTextField->setWidth(35); mItemPriceTextField->addKeyListener(this); // Slider mItemPriceSlide = new Slider(1.0, 10000000); mItemPriceSlide->setHeight(10); mItemPriceSlide->setActionEventId("slidePrice"); mItemPriceSlide->addActionListener(this); mGPLabel = new Label(" GP"); } if (mUsage == ShopBuyAdd) { mItemsModal = new ItemsModal; mItemDropDown = new DropDown(mItemsModal); mItemDropDown->setActionEventId("itemType"); mItemDropDown->addActionListener(this); } //Item icon Image *image = item->getImage(); mItemIcon = new Icon(image); // Buttons Button *minusAmountButton = new Button(_("-"), "dec", this); Button *plusAmountButton = new Button(_("+"), "inc", this); Button *okButton = new Button(_("OK"), "ok", this); Button *cancelButton = new Button(_("Cancel"), "cancel", this); Button *addAllButton = new Button(_("All"), "all", this); minusAmountButton->adjustSize(); minusAmountButton->setWidth(plusAmountButton->getWidth()); // Set positions ContainerPlacer placer; placer = getPlacer(0, 0); int n = 0; if (mUsage == ShopBuyAdd) { placer(0, n, mItemDropDown, 8); n++; } placer(1, n, minusAmountButton); placer(2, n, mItemAmountTextField, 3); placer(5, n, plusAmountButton); placer(6, n, addAllButton); placer(0, n, mItemIcon, 1, 3); placer(1, n + 1, mItemAmountSlide, 7); if (mUsage == ShopBuyAdd || mUsage == ShopSellAdd) { Button *minusPriceButton = new Button(_("-"), "decPrice", this); Button *plusPriceButton = new Button(_("+"), "incPrice", this); minusPriceButton->adjustSize(); minusPriceButton->setWidth(plusPriceButton->getWidth()); placer(1, n + 2, minusPriceButton); placer(2, n + 2, mItemPriceTextField, 3); placer(5, n + 2, plusPriceButton); placer(6, n + 2, mGPLabel); placer(1, n + 3, mItemPriceSlide, 7); placer(4, n + 5, cancelButton); placer(5, n + 5, okButton); } else { placer(4, n + 2, cancelButton); placer(5, n + 2, okButton); } reflowLayout(225, 0); resetAmount(); switch (usage) { case TradeAdd: setCaption(_("Select amount of items to trade.")); break; case ItemDrop: setCaption(_("Select amount of items to drop.")); break; case StoreAdd: setCaption(_("Select amount of items to store.")); break; case StoreRemove: setCaption(_("Select amount of items to retrieve.")); break; case ItemSplit: setCaption(_("Select amount of items to split.")); break; case ShopBuyAdd: setCaption(_("Add to buy shop.")); break; case ShopSellAdd: setCaption(_("Add to sell shop.")); break; default: setCaption(_("Unknown.")); break; } setLocationRelativeTo(getParentWindow()); setVisible(true); mItemPopup = new ItemPopup; mItemIcon->addMouseListener(this); }
RegisterDialog::RegisterDialog(LoginData *loginData): Window(_("Register")), mEmailField(0), mMaleButton(0), mFemaleButton(0), mWrongDataNoticeListener(new WrongDataNoticeListener), mLoginData(loginData) { int optionalActions = Net::getLoginHandler()->supportedOptionalActions(); gcn::Label *userLabel = new Label(_("Name:")); gcn::Label *passwordLabel = new Label(_("Password:"******"Confirm:")); mUserField = new TextField(loginData->username); mPasswordField = new PasswordField(loginData->password); mConfirmField = new PasswordField; mRegisterButton = new Button(_("Register"), "register", this); mCancelButton = new Button(_("Cancel"), "cancel", this); ContainerPlacer place; place = getPlacer(0, 0); place(0, 0, userLabel); place(0, 1, passwordLabel); place(0, 2, confirmLabel); place(1, 0, mUserField, 3).setPadding(2); place(1, 1, mPasswordField, 3).setPadding(2); place(1, 2, mConfirmField, 3).setPadding(2); int row = 3; if (optionalActions & Net::LoginHandler::SetGenderOnRegister) { mMaleButton = new RadioButton(_("Male"), "sex", true); mFemaleButton = new RadioButton(_("Female"), "sex", false); place(1, row, mMaleButton); place(2, row, mFemaleButton); row++; } if (optionalActions & Net::LoginHandler::SetEmailOnRegister) { gcn::Label *emailLabel = new Label(_("Email:")); mEmailField = new TextField; place(0, row, emailLabel); place(1, row, mEmailField, 3).setPadding(2); row++; } place = getPlacer(0, 2); place(1, 0, mRegisterButton); place(2, 0, mCancelButton); reflowLayout(250, 0); mUserField->addKeyListener(this); mPasswordField->addKeyListener(this); mConfirmField->addKeyListener(this); /* TODO: * This is a quick and dirty way to respond to the ENTER key, regardless of * which text field is selected. There may be a better way now with the new * input system of Guichan 0.6.0. See also the login dialog. */ mUserField->setActionEventId("register"); mPasswordField->setActionEventId("register"); mConfirmField->setActionEventId("register"); mUserField->addActionListener(this); mPasswordField->addActionListener(this); mConfirmField->addActionListener(this); center(); setVisible(true); mUserField->requestFocus(); mUserField->setCaretPosition(mUserField->getText().length()); mRegisterButton->setEnabled(canSubmit()); }
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); }
GuiObject::GuiObject(const Common::String &name) : _x(-1000), _y(-1000), _w(0), _h(0), _name(name), _firstWidget(0) { reflowLayout(); }
CharCreateDialog::CharCreateDialog(Window *parent, int slot): Window(_("Create Character"), true, parent), mSlot(slot) { mPlayer = new Player(0, 0, NULL); mPlayer->setGender(GENDER_MALE); ResourceManager *resman = ResourceManager::getInstance(); mBackGround = resman->getImage("graphics/elektrik/gui_login_window.png"); gcn::Label *girisLabel = new gcn::Label(_("-=KARAKTER OLUŞTUR=-")); girisLabel->setPosition(150,140); girisLabel->setFont(font_bas_b_1_16); girisLabel->setForegroundColor(gcn::Color(0xaa,0xbb,0xcc)); girisLabel->adjustSize(); add(girisLabel); int numberOfHairColors = ColorDB::size(); srand((unsigned)time(0)); mHairStyle = rand() % mPlayer->getNumOfHairstyles(); mHairColor = rand() % numberOfHairColors; updateHair(); mNameField = new TextField(""); mNameLabel = new Label(_("Name:")); // TRANSLATORS: This is a narrow symbol used to denote 'next'. // You may change this symbol if your language uses another. mNextHairColorButton = new Button(_(">"), "nextcolor", this); // TRANSLATORS: This is a narrow symbol used to denote 'previous'. // You may change this symbol if your language uses another. mPrevHairColorButton = new Button(_("<"), "prevcolor", this); mHairColorLabel = new Label(_("Hair color:")); mNextHairStyleButton = new Button(_(">"), "nextstyle", this); mPrevHairStyleButton = new Button(_("<"), "prevstyle", this); mHairStyleLabel = new Label(_("Hair style:")); mCreateButton = new Button(_("Create"), "create", this); mCancelButton = new Button(_("Cancel"), "cancel", this); mMale = new RadioButton(_("Male"), "gender"); mFemale = new RadioButton(_("Female"), "gender"); // Default to a Male character mMale->setSelected(true); mMale->setActionEventId("gender"); mFemale->setActionEventId("gender"); mMale->addActionListener(this); mFemale->addActionListener(this); mPlayerBox = new PlayerBox(mPlayer); mPlayerBox->setWidth(74); mNameField->setActionEventId("create"); mNameField->addActionListener(this); mAttributesLeft = new Label(strprintf(_("Please distribute %d points"), 99)); int w = 200; int h = 330; ContainerPlacer place; place = getPlacer(5,15); place(0,0,mNameLabel); place(1,0,mNameField,2); place = getPlacer(5,16); place(0,0,mHairColorLabel); place(1,0,mPrevHairColorButton); place(2,0,mPlayerBox,1,10).setPadding(3); place(3,0,mNextHairColorButton); place(0,1,mHairStyleLabel); place(1,1,mPrevHairStyleButton); place(3,1,mNextHairStyleButton); reflowLayout(350,335); mCreateButton->setPosition(200,345); mCancelButton->setPosition(260,345); mCancelButton->setWidth(mCreateButton->getWidth()); add(mPlayerBox); add(mNameField); add(mNameLabel); add(mNextHairColorButton); add(mPrevHairColorButton); add(mHairColorLabel); add(mNextHairStyleButton); add(mPrevHairStyleButton); add(mHairStyleLabel); add(mCreateButton); add(mCancelButton); // add(mAttributesLeft); // add(mMale); // add(mFemale); setSize(573,507); center(); setVisible(true); mNameField->requestFocus(); }
ItemAmountWindow::ItemAmountWindow(Usage usage, Window *parent, Item *item, int maxRange): Window("", true, parent), mItem(item), mMax(maxRange), mUsage(usage) { if (!mMax) mMax = mItem->getQuantity(); // Save keyboard state mEnabledKeyboard = keyboard.isEnabled(); keyboard.setEnabled(false); // Integer field mItemAmountTextField = new IntTextField(1); mItemAmountTextField->setRange(1, mMax); mItemAmountTextField->setWidth(35); mItemAmountTextField->addKeyListener(this); // Slider mItemAmountSlide = new Slider(1.0, mMax); mItemAmountSlide->setHeight(10); mItemAmountSlide->setActionEventId("slide"); mItemAmountSlide->addActionListener(this); //Item icon Image *image = item->getImage(); mItemIcon = new Icon(image); // Buttons Button *minusButton = new Button(_("-"), "dec", this); Button *plusButton = new Button(_("+"), "inc", this); Button *okButton = new Button(_("OK"), "ok", this); Button *cancelButton = new Button(_("Cancel"), "cancel", this); Button *addAllButton = new Button(_("All"), "all", this); minusButton->adjustSize(); minusButton->setWidth(plusButton->getWidth()); // Set positions ContainerPlacer place; place = getPlacer(0, 0); place(1, 0, minusButton); place(2, 0, mItemAmountTextField); place(3, 0, plusButton); place(4, 0, addAllButton); place(0, 0, mItemIcon, 1, 3); place(1, 1, mItemAmountSlide, 5); place(4, 2, cancelButton); place(5, 2, okButton); reflowLayout(225, 0); resetAmount(); switch (usage) { case TradeAdd: setCaption(_("Select amount of items to trade.")); break; case ItemDrop: setCaption(_("Select amount of items to drop.")); break; case StoreAdd: setCaption(_("Select amount of items to store.")); break; case StoreRemove: setCaption(_("Select amount of items to retrieve.")); break; case ItemSplit: setCaption(_("Select amount of items to split.")); break; } setLocationRelativeTo(getParentWindow()); setVisible(true); mItemPopup = new ItemPopup; mItemIcon->addMouseListener(this); }
GuiObject::GuiObject(const Common::String &name) : _x(-1000), _y(-1000), _w(0), _h(0), _name(name), _firstWidget(0), _textDrawableArea(Common::Rect(0, 0, 0, 0)) { reflowLayout(); }