void PincodeManager::changePincode(const std::string &pincode) { if (mOldPincode.empty()) { // set old pincode mOldPincode = pincode; CREATEWIDGETV(mDialog, PincodeDialog, // TRANSLATORS: dialog caption _("Change pincode"), // TRANSLATORS: dialog label _("Enter new pincode"), mSeed, nullptr); mDialog->requestFocus(); mDialog->setActionEventId("ok"); mDialog->addActionListener(&changePincodeListener); } else if (mNewPincode.empty()) { // set first new pincode mNewPincode = pincode; CREATEWIDGETV(mDialog, PincodeDialog, // TRANSLATORS: dialog caption _("Change pincode"), // TRANSLATORS: dialog label _("Confirm new pincode"), mSeed, nullptr); mDialog->requestFocus(); mDialog->setActionEventId("ok"); mDialog->addActionListener(&changePincodeListener); } else { // new pincode confirmation if (mNewPincode != pincode) { mOldPincode.clear(); mNewPincode.clear(); CREATEWIDGETV(mDialog, OkDialog, // TRANSLATORS: error header _("Pincode"), // TRANSLATORS: error message _("Wrong pincode confirmation!"), // TRANSLATORS: ok dialog button _("OK"), DialogType::ERROR, Modal_true, ShowCenter_true, nullptr, 260); mDialog->addActionListener(&newPincodeRetryListener); } else { charServerHandler->changePincode(mAccountId, mOldPincode, mNewPincode); mOldPincode.clear(); mNewPincode.clear(); } } }
void PincodeManager::updateState() { switch (mState) { case PincodeState::Ask: CREATEWIDGETV(mDialog, PincodeDialog, // TRANSLATORS: dialog caption _("Pincode"), // TRANSLATORS: dialog label _("Enter pincode"), mSeed, nullptr); mDialog->requestFocus(); mDialog->setActionEventId("ok"); mDialog->addActionListener(&pincodeListener); break; case PincodeState::Create: mNewPincode.clear(); CREATEWIDGETV(mDialog, PincodeDialog, // TRANSLATORS: dialog caption _("New pincode"), // TRANSLATORS: dialog label _("Enter new pincode"), mSeed, nullptr); mDialog->requestFocus(); mDialog->setActionEventId("ok"); mDialog->addActionListener(&newPincodeListener); break; case PincodeState::Change: mOldPincode.clear(); mNewPincode.clear(); CREATEWIDGETV(mDialog, PincodeDialog, // TRANSLATORS: dialog caption _("Change pincode"), // TRANSLATORS: dialog label _("Enter old pincode"), mSeed, nullptr); mDialog->requestFocus(); mDialog->setActionEventId("ok"); mDialog->addActionListener(&changePincodeListener); break; case PincodeState::None: default: break; } }
void FamilyRecv::processAskForChild(Net::MessageIn &msg) { if (!localPlayer) { mParent1 = msg.readBeingId("account id who ask"); mParent2 = msg.readBeingId("acoount id for other parent"); msg.readString(24, "name who ask"); return; } mParent1 = msg.readBeingId("account id who ask"); mParent2 = msg.readBeingId("acoount id for other parent"); const std::string name1 = msg.readString(24, "name who ask"); const Party *const party = localPlayer->getParty(); if (party) { const PartyMember *const member = party->getMember(mParent2); if (member) { const std::string name2 = member->getName(); CREATEWIDGETV(confirmDlg, ConfirmDialog, // TRANSLATORS: adopt child message _("Request parents"), // TRANSLATORS: adopt child message strprintf(_("Do you accept %s and %s as parents?"), name1.c_str(), name2.c_str()), SOUND_REQUEST, false); confirmDlg->addActionListener(&listener); } } }
void VendingHandler::processItemsList(Net::MessageIn &msg) { const int count = (msg.readInt16("len") - 12) / 22; const BeingId id = msg.readBeingId("id"); Being *const being = actorManager->findBeing(id); if (!being) return; int cards[4]; CREATEWIDGETV(mBuyDialog, BuyDialog, being->getName()); mBuyDialog->setMoney(PlayerInfo::getAttribute(Attributes::MONEY)); msg.readInt32("vender id"); for (int f = 0; f < count; f ++) { const int value = msg.readInt32("price"); const int amount = msg.readInt16("amount"); const int index = msg.readInt16("inv index"); const int type = msg.readUInt8("item type"); const int itemId = msg.readInt16("item id"); msg.readUInt8("identify"); msg.readUInt8("attribute"); msg.readUInt8("refine"); for (int d = 0; d < 4; d ++) cards[d] = msg.readInt16("card"); const ItemColor color = ItemColorManager::getColorFromCards(&cards[0]); ShopItem *const item = mBuyDialog->addItem(itemId, type, color, amount, value); if (item) item->setInvIndex(index); } mBuyDialog->sort(); }
BeingId NpcHandler::getNpc(Net::MessageIn &msg) { if (msg.getId() == SMSG_NPC_CHOICE || msg.getId() == SMSG_NPC_MESSAGE || msg.getId() == SMSG_NPC_CHANGETITLE) { msg.readInt16("len"); } const BeingId npcId = msg.readBeingId("npc id"); const NpcDialogs::const_iterator diag = NpcDialog::mNpcDialogs.find(npcId); mDialog = nullptr; if (msg.getId() == SMSG_NPC_VIEWPOINT) return npcId; if (diag == NpcDialog::mNpcDialogs.end()) { // Empty dialogs don't help if (msg.getId() == SMSG_NPC_CLOSE) { closeDialog(npcId); return npcId; } else if (msg.getId() == SMSG_NPC_NEXT) { nextDialog(npcId); return npcId; } else { CREATEWIDGETV(mDialog, NpcDialog, npcId); mDialog->saveCamera(); if (localPlayer) localPlayer->stopWalking(false); NpcDialog::mNpcDialogs[npcId] = mDialog; } } else { NpcDialog *const dialog = diag->second; if (mDialog && mDialog != dialog) mDialog->restoreCamera(); mDialog = dialog; if (mDialog) mDialog->saveCamera(); } return npcId; }
void MarketRecv::processMarketOpen(Net::MessageIn &msg) { const int len = (msg.readInt16("len") - 4) / 13; CREATEWIDGETV(mBuyDialog, BuyDialog, fromInt(BuyDialog::Market, BeingId)); mBuyDialog->setMoney(PlayerInfo::getAttribute(Attributes::MONEY)); for (int f = 0; f < len; f ++) { const int itemId = msg.readInt16("item id"); const ItemTypeT type = static_cast<ItemTypeT>(msg.readUInt8("type")); const int value = msg.readInt32("price"); const int amount = msg.readInt32("amount"); msg.readInt16("view"); const ItemColor color = ItemColor_one; mBuyDialog->addItem(itemId, type, color, amount, value); } mBuyDialog->sort(); }
void CashShopHandler::processCashShopOpen(Net::MessageIn &msg) { const int count = (msg.readInt16("len") - 12) / 11; CREATEWIDGETV(mBuyDialog, BuyDialog, fromInt(BuyDialog::Cash, BeingId)); mBuyDialog->setMoney(PlayerInfo::getAttribute(Attributes::MONEY)); msg.readInt32("cash points"); msg.readInt32("kafra points"); for (int f = 0; f < count; f ++) { msg.readInt32("price"); const int value = msg.readInt32("discount price"); const int type = msg.readUInt8("item type"); const int itemId = msg.readInt16("item id"); const ItemColor color = ItemColor_one; mBuyDialog->addItem(itemId, type, color, 0, value); } mBuyDialog->sort(); }
void BuySellRecv::processNpcBuy(Net::MessageIn &msg) { msg.readInt16("len"); const unsigned int n_items = (msg.getLength() - 4U) / 11; CREATEWIDGETV(Ea::BuySellRecv::mBuyDialog, BuyDialog, Ea::BuySellRecv::mNpcId); Ea::BuySellRecv::mBuyDialog->setMoney( PlayerInfo::getAttribute(Attributes::MONEY)); for (unsigned int k = 0; k < n_items; k++) { const int value = msg.readInt32("price"); msg.readInt32("dc value?"); const int type = msg.readUInt8("type"); const int itemId = msg.readInt16("item id"); const ItemColor color = ItemColor_one; Ea::BuySellRecv::mBuyDialog->addItem(itemId, type, color, 0, value); } Ea::BuySellRecv::mBuyDialog->sort(); }
void Setup_Video::action(const ActionEvent &event) { const std::string &id = event.getId(); if (id == "videomode") { std::string mode = mModeListModel->getElementAt( mModeList->getSelected()); if (mode == "custom") { if (mDialog) { mode = mDialog->getText(); mDialog = nullptr; } else { CREATEWIDGETV(mDialog, TextDialog, // TRANSLATORS: resolution question dialog _("Custom resolution (example: 1024x768)"), // TRANSLATORS: resolution question dialog _("Enter new resolution: ")); mDialog->setActionEventId("videomode"); mDialog->addActionListener(this); return; } } const int width = atoi(mode.substr(0, mode.find("x")).c_str()); const int height = atoi(mode.substr(mode.find("x") + 1).c_str()); if (!width || !height) return; if (width != mainGraphics->mActualWidth || height != mainGraphics->mActualHeight) { #if defined(WIN32) || defined(__APPLE__) || defined(ANDROID) if (intToRenderType(config.getIntValue("opengl")) == RENDER_SOFTWARE) { WindowManager::doResizeVideo(width, height, false); } else { if (width < mainGraphics->mActualWidth || height < mainGraphics->mActualHeight) { CREATEWIDGET(OkDialog, // TRANSLATORS: video settings warning _("Screen Resolution Changed"), // TRANSLATORS: video settings warning _("Restart your client for the change to take effect.") // TRANSLATORS: video settings warning + std::string("\n") + _("Some windows may be moved to " "fit the lowered resolution."), // TRANSLATORS: ok dialog button _("OK"), DialogType::OK, Modal_true, ShowCenter_true, nullptr, 260); } else { CREATEWIDGET(OkDialog, // TRANSLATORS: video settings warning _("Screen Resolution Changed"), // TRANSLATORS: video settings warning _("Restart your client for the change" " to take effect."), // TRANSLATORS: ok dialog button _("OK"), DialogType::OK, Modal_true, ShowCenter_true, nullptr, 260); } } #else // defined(WIN32) || defined(__APPLE__) || defined(ANDROID) mainGraphics->setWindowSize(width, height); WindowManager::doResizeVideo(width, height, false); #endif // defined(WIN32) || defined(__APPLE__) || defined(ANDROID) } config.setValue("oldscreen", config.getBoolValue("screen")); config.setValue("oldscreenwidth", mainGraphics->mActualWidth); config.setValue("oldscreenheight", mainGraphics->mActualHeight); config.setValue("screenwidth", width); config.setValue("screenheight", height); } if (id == "~videomode") { mDialog = nullptr; } else if (id == "customcursor") { config.setValue("customcursor", mCustomCursorCheckBox->isSelected()); } else if (id == "fpslimitcheckbox" || id == "fpslimitslider") { int tempFps = CAST_S32(mFpsSlider->getValue()); if (id == "fpslimitcheckbox" && !mFpsSlider->isEnabled()) tempFps = 60; else tempFps = tempFps > 0 ? tempFps : 60; mFps = mFpsCheckBox->isSelected() ? tempFps : 0; // TRANSLATORS: video settings label const std::string text = mFps > 0 ? toString(mFps) : _("None"); mFpsLabel->setCaption(text); mFpsSlider->setEnabled(mFps > 0); mFpsSlider->setValue(mFps); } else if (id == "altfpslimitslider") { int tempFps = CAST_S32(mAltFpsSlider->getValue()); tempFps = tempFps > 0 ? tempFps : CAST_S32( mAltFpsSlider->getScaleStart()); mAltFps = tempFps; // TRANSLATORS: video settings label const std::string text = mAltFps > 0 ? toString(mAltFps) : _("None"); // TRANSLATORS: video settings label mAltFpsLabel->setCaption(_("Alt FPS limit: ") + text); mAltFpsSlider->setEnabled(mAltFps > 0); mAltFpsSlider->setValue(mAltFps); } else if (id == "enableresize") { config.setValue("enableresize", mEnableResizeCheckBox->isSelected()); } else if (id == "noframe") { config.setValue("noframe", mNoFrameCheckBox->isSelected()); } #if defined(USE_OPENGL) && !defined(ANDROID) && !defined(__APPLE__) else if (id == "detect") { TestMain *test = graphicsManager.startDetection(); if (test) { Configuration &conf = test->getConfig(); const int val = conf.getValueInt("opengl", -1); if (val >= 0 && CAST_U32(val) < sizeof(renderToIndex) / sizeof(int)) { mOpenGLDropDown->setSelected(renderToIndex[val]); } config.setValue("textureSize", conf.getValue("textureSize", "1024,1024,1024,1024,1024,1024")); config.setValue("testInfo", conf.getValue("testInfo", "")); delete test; } } #endif // defined(USE_OPENGL) && !defined(ANDROID) && !defined(__APPLE__) }