void PincodeListener::action(const ActionEvent &event) { const EditDialog *const dialog = dynamic_cast<EditDialog*>( event.getSource()); if (dialog) { const std::string pincode = dialog->getMsg(); charServerHandler->setNewPincode(pincode); } }
void TabbedArea::action(const ActionEvent& actionEvent) { Widget* source = actionEvent.getSource(); Tab* tab = dynamic_cast<Tab*>(source); if (tab == NULL) { throw GCN_EXCEPTION("Received an action from a widget that's not a tab!"); } setSelectedTab(tab); }
void ChangePincodeListener::action(const ActionEvent &event) { if (event.getId() == "ok") { const PincodeDialog *const dialog = dynamic_cast<PincodeDialog*>( event.getSource()); if (dialog != nullptr) { const std::string &pincode = dialog->getMsg(); pincodeManager.changePincode(pincode); } } else { client->setState(State::SWITCH_LOGIN); } }
void Setup_Joystick::action(const ActionEvent &event) { const Widget *const source = event.getSource(); if (source == mJoystickEnabled) { setTempEnabled(mJoystickEnabled->isSelected()); } else if (source == mNamesDropDown) { if (joystick != nullptr) joystick->setNumber(mNamesDropDown->getSelected()); } else if (source == mDetectButton) { if (joystick != nullptr) { joystick->reload(); Joystick::getNames(mNamesModel->getNames()); mNamesDropDown->setSelected(joystick->getNumber()); } } else { if (joystick == nullptr) return; if (joystick->isCalibrating()) { // TRANSLATORS: joystick settings tab button mCalibrateButton->setCaption(_("Calibrate")); mCalibrateLabel->setCaption // TRANSLATORS: joystick settings tab label (_("Press the button to start calibration")); joystick->finishCalibration(); } else { // TRANSLATORS: joystick settings tab button mCalibrateButton->setCaption(_("Stop")); mCalibrateLabel->setCaption( // TRANSLATORS: joystick settings tab label _("Rotate the stick and don't press buttons")); joystick->startCalibration(); } } }
void SocialWindow::action(const ActionEvent &event) { const std::string &eventId = event.getId(); if (event.getSource() == mPartyAcceptDialog) { if (eventId == "yes") { if (localChatTab) { localChatTab->chatLog( // TRANSLATORS: chat message strprintf(_("Accepted party invite from %s."), mPartyInviter.c_str()), ChatMsgType::BY_SERVER); } partyHandler->inviteResponse(mPartyInviter, mPartyId, true); } else if (eventId == "no") { if (localChatTab) { localChatTab->chatLog( // TRANSLATORS: chat message strprintf(_("Rejected party invite from %s."), mPartyInviter.c_str()), ChatMsgType::BY_SERVER); } partyHandler->inviteResponse(mPartyInviter, mPartyId, false); } mPartyInviter.clear(); mPartyAcceptDialog = nullptr; } else if (event.getSource() == mGuildAcceptDialog) { if (eventId == "yes") { if (localChatTab) { localChatTab->chatLog( // TRANSLATORS: chat message strprintf(_("Accepted guild invite from %s."), mPartyInviter.c_str()), ChatMsgType::BY_SERVER); } #ifdef TMWA_SUPPORT if (!guildManager || !GuildManager::getEnableGuildBot()) guildHandler->inviteResponse(mGuildInvited, true); else guildManager->inviteResponse(true); #else guildHandler->inviteResponse(mGuildInvited, true); #endif } else if (eventId == "no") { if (localChatTab) { localChatTab->chatLog( // TRANSLATORS: chat message strprintf(_("Rejected guild invite from %s."), mPartyInviter.c_str()), ChatMsgType::BY_SERVER); } #ifdef TMWA_SUPPORT if (!guildManager || !GuildManager::getEnableGuildBot()) guildHandler->inviteResponse(mGuildInvited, false); else guildManager->inviteResponse(false); #else guildHandler->inviteResponse(mGuildInvited, false); #endif } mGuildInvited = 0; mGuildAcceptDialog = nullptr; } else if (eventId == "create") { showPartyCreate(); } else if (eventId == "invite" && mTabs->getSelectedTabIndex() > -1) { if (mTabs->getSelectedTab()) static_cast<SocialTab*>(mTabs->getSelectedTab())->invite(); } else if (eventId == "leave" && mTabs->getSelectedTabIndex() > -1) { if (mTabs->getSelectedTab()) static_cast<SocialTab*>(mTabs->getSelectedTab())->leave(); } else if (eventId == "create guild") { if (!serverFeatures->haveNativeGuilds()) return; std::string name = mGuildCreateDialog->getText(); if (name.size() > 16) return; guildHandler->create(name); if (localChatTab) { // TRANSLATORS: chat message localChatTab->chatLog(strprintf(_("Creating guild called %s."), name.c_str()), ChatMsgType::BY_SERVER); } mGuildCreateDialog = nullptr; } else if (eventId == "~create guild") { mGuildCreateDialog = nullptr; } else if (eventId == "create party") { std::string name = mPartyCreateDialog->getText(); if (name.size() > 24) return; partyHandler->create(name); if (localChatTab) { // TRANSLATORS: chat message localChatTab->chatLog(strprintf(_("Creating party called %s."), name.c_str()), ChatMsgType::BY_SERVER); } mPartyCreateDialog = nullptr; } else if (eventId == "~create party") { mPartyCreateDialog = nullptr; } }
void Setup_Input::action(const ActionEvent &event) { const std::string &id = event.getId(); const int selectedData = mKeyListModel->getSelectedData(); if (event.getSource() == mKeyList) { if (!mKeySetting) { const int i(mKeyList->getSelected()); if (i >= 0 && i < mActionDataSize[selectedData]) { if (setupActionData[selectedData][i].actionId == InputAction::NO_VALUE) { mAssignKeyButton->setEnabled(false); mUnassignKeyButton->setEnabled(false); } else { mAssignKeyButton->setEnabled(true); mUnassignKeyButton->setEnabled(true); } } } } else if (id == "assign") { mKeySetting = true; mAssignKeyButton->setEnabled(false); keyboard.setEnabled(false); const int i(mKeyList->getSelected()); if (i >= 0 && i < mActionDataSize[selectedData]) { const SetupActionData &key = setupActionData[selectedData][i]; const InputActionT ik = key.actionId; inputManager.setNewKeyIndex(ik); mKeyListModel->setElementAt(i, std::string( gettext(key.name.c_str())).append(": ?")); } } else if (id == "unassign") { const int i(mKeyList->getSelected()); if (i >= 0 && i < mActionDataSize[selectedData]) { const SetupActionData &key = setupActionData[selectedData][i]; const InputActionT ik = key.actionId; inputManager.setNewKeyIndex(ik); refreshAssignedKey(mKeyList->getSelected()); inputManager.unassignKey(); inputManager.setNewKeyIndex(InputAction::NO_VALUE); } mAssignKeyButton->setEnabled(true); } else if (id == "resetkeys") { inputManager.resetKeys(); InputManager::update(); refreshKeys(); } else if (id == "default") { const int i(mKeyList->getSelected()); if (i >= 0 && i < mActionDataSize[selectedData]) { const SetupActionData &key = setupActionData[selectedData][i]; const InputActionT ik = key.actionId; inputManager.makeDefault(ik); refreshKeys(); } } else if (strStartWith(id, "tabs_")) { int k = 0; std::string str("tabs_"); while (pages[k] != nullptr) { if (str + pages[k] == id) break; k ++; } if ((pages[k] != nullptr) && str + pages[k] == id) { mKeyListModel->setSelectedData(k); mKeyListModel->setSize(mActionDataSize[k]); refreshKeys(); mKeyList->setSelected(0); } } }