Minimap::Minimap() : // TRANSLATORS: mini map window name Window(_("Map"), Modal_false, nullptr, "map.xml"), mWidthProportion(0.5), mHeightProportion(0.5), mMapImage(nullptr), mMapOriginX(0), mMapOriginY(0), mCustomMapImage(false), mAutoResize(config.getBoolValue("autoresizeminimaps")) { setWindowName("Minimap"); mShow = config.getValueBool(getWindowName() + "Show", true); config.addListener("autoresizeminimaps", this); setDefaultSize(5, 25, 100, 100); // set this to false as the minimap window size is changed // depending on the map size setResizable(true); if (setupWindow) setupWindow->registerWindowForReset(this); setDefaultVisible(true); setSaveVisible(true); setStickyButton(true); setSticky(false); loadWindowState(); setVisible(fromBool(mShow, Visible), isSticky()); enableVisibleSound(true); }
void SkillDialog::postInit() { Window::postInit(); setLocationRelativeTo(getParent()); loadWindowState(); enableVisibleSound(true); }
void ShopWindow::postInit() { Window::postInit(); setVisible(Visible_false); enableVisibleSound(true); updateSelection(); }
WhoIsOnline::WhoIsOnline() : // TRANSLATORS: who is online window name Window(_("Who Is Online - Updating"), false, nullptr, "whoisonline.xml"), mThread(nullptr), mDownloadStatus(UPDATE_LIST), mDownloadComplete(true), mDownloadedBytes(0), mMemoryBuffer(nullptr), mCurlError(new char[CURL_ERROR_SIZE]), mBrowserBox(new BrowserBox(this)), mScrollArea(new ScrollArea(mBrowserBox, false)), mUpdateTimer(0), mOnlinePlayers(), mOnlineNicks(), // TRANSLATORS: who is online. button. mUpdateButton(new Button(this, _("Update"), "update", this)), mAllowUpdate(true), mShowLevel(false), mUpdateOnlineList(config.getBoolValue("updateOnlineList")), mGroupFriends(true) { mCurlError[0] = 0; setWindowName("WhoIsOnline"); const int h = 350; const int w = 200; setDefaultSize(w, h, ImageRect::CENTER); setVisible(false); setCloseButton(true); setResizable(true); setStickyButtonLock(true); setSaveVisible(true); mUpdateButton->setEnabled(false); mUpdateButton->setDimension(gcn::Rectangle(5, 5, w - 10, 20 + 5)); mBrowserBox->setOpaque(false); mBrowserBox->setHighlightMode(BrowserBox::BACKGROUND); mScrollArea->setDimension(gcn::Rectangle(5, 20 + 10, w - 10, h - 10 - 30)); mScrollArea->setSize(w - 10, h - 10 - 30); mBrowserBox->setLinkHandler(this); add(mUpdateButton); add(mScrollArea); setLocationRelativeTo(getParent()); loadWindowState(); enableVisibleSound(true); download(); widgetResized(gcn::Event(nullptr)); config.addListener("updateOnlineList", this); config.addListener("groupFriends", this); mGroupFriends = config.getBoolValue("groupFriends"); }
MailWindow::MailWindow() : // TRANSLATORS: mail window name Window(_("Mail"), Modal_false, nullptr, "mail.xml"), ActionListener(), mMessages(), mMessagesMap(), mMailModel(new ExtendedNamesModel), mListBox(CREATEWIDGETR(ExtendedListBox, this, mMailModel, "extendedlistbox.xml")), mListScrollArea(new ScrollArea(this, mListBox, fromBool(getOptionBool("showlistbackground"), Opaque), "mail_listbackground.xml")), // TRANSLATORS: mail window button mRefreshButton(new Button(this, _("Refresh"), "refresh", this)), // TRANSLATORS: mail window button mNewButton(new Button(this, _("New"), "new", this)), // TRANSLATORS: mail window button mDeleteButton(new Button(this, _("Delete"), "delete", this)), // TRANSLATORS: mail window button mReturnButton(new Button(this, _("Return"), "return", this)), // TRANSLATORS: mail window button mOpenButton(new Button(this, _("Open"), "open", this)) { setWindowName("Mail"); setCloseButton(true); setResizable(true); setCloseButton(true); setSaveVisible(true); setStickyButtonLock(true); if (setupWindow) setupWindow->registerWindowForReset(this); setDefaultSize(310, 180, ImagePosition::CENTER); setMinWidth(310); setMinHeight(250); center(); mListScrollArea->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER); ContainerPlacer placer; placer = getPlacer(0, 0); placer(0, 0, mListScrollArea, 4, 5).setPadding(3); placer(4, 0, mRefreshButton); placer(4, 1, mOpenButton); placer(4, 2, mNewButton); placer(4, 3, mDeleteButton); placer(4, 4, mReturnButton); Layout &layout = getLayout(); layout.setRowHeight(0, LayoutType::SET); loadWindowState(); enableVisibleSound(true); }
DidYouKnowWindow::DidYouKnowWindow() : // TRANSLATORS: did you know window name Window(_("Did You Know?"), Modal_false, nullptr, "didyouknow.xml"), ActionListener(), mItemLinkHandler(new ItemLinkHandler), mBrowserBox(new BrowserBox(this, BrowserBox::AUTO_SIZE, Opaque_true, "browserbox.xml")), mScrollArea(new ScrollArea(this, mBrowserBox, Opaque_true, "didyouknow_background.xml")), // TRANSLATORS: did you know window button mButtonPrev(new Button(this, _("< Previous"), "prev", this)), // TRANSLATORS: did you know window button mButtonNext(new Button(this, _("Next >"), "next", this)), // TRANSLATORS: did you know window checkbox mOpenAgainCheckBox(new CheckBox(this, _("Auto open this window"), config.getBoolValue("showDidYouKnow"), this, "openagain")) { setMinWidth(300); setMinHeight(220); setContentSize(455, 350); setWindowName("DidYouKnow"); setCloseButton(true); setResizable(true); setStickyButtonLock(true); if (setupWindow) setupWindow->registerWindowForReset(this); setDefaultSize(500, 400, ImagePosition::CENTER); mBrowserBox->setOpaque(Opaque_false); // TRANSLATORS: did you know window button Button *const okButton = new Button(this, _("Close"), "close", this); mBrowserBox->setLinkHandler(mItemLinkHandler); if (gui) mBrowserBox->setFont(gui->getHelpFont()); mBrowserBox->setProcessVars(true); mBrowserBox->setEnableImages(true); mBrowserBox->setEnableKeys(true); mBrowserBox->setEnableTabs(true); place(0, 0, mScrollArea, 5, 3).setPadding(3); place(0, 3, mOpenAgainCheckBox, 5); place(1, 4, mButtonPrev, 1); place(2, 4, mButtonNext, 1); place(4, 4, okButton); Layout &layout = getLayout(); layout.setRowHeight(0, LayoutType::SET); loadWindowState(); enableVisibleSound(true); }
CutInWindow::CutInWindow() : Window("", Modal_false, nullptr, "cutin.xml"), mImage(nullptr), mOldTitleBarHeight(mTitleBarHeight) { setWindowName("CutIn"); setShowTitle(false); setResizable(false); setDefaultVisible(false); setSaveVisible(false); setVisible(Visible_false); enableVisibleSound(false); }
HelpWindow::HelpWindow() : // TRANSLATORS: help window name Window(_("Help"), Modal_false, nullptr, "help.xml"), LinkHandler(), ActionListener(), // TRANSLATORS: help window. button. mDYKButton(new Button(this, _("Did you know..."), "DYK", BUTTON_SKIN, this)), mBrowserBox(new StaticBrowserBox(this, Opaque_true, "browserbox.xml")), mScrollArea(new ScrollArea(this, mBrowserBox, Opaque_true, "help_background.xml")), mTagFileMap() { setMinWidth(300); setMinHeight(220); setContentSize(455, 350); setWindowName("Help"); setCloseButton(true); setResizable(true); setStickyButtonLock(true); if (setupWindow != nullptr) setupWindow->registerWindowForReset(this); setDefaultSize(500, 400, ImagePosition::CENTER, 0, 0); mBrowserBox->setOpaque(Opaque_false); mBrowserBox->setLinkHandler(this); if (gui != nullptr) mBrowserBox->setFont(gui->getHelpFont()); mBrowserBox->setProcessVars(true); mBrowserBox->setEnableImages(true); mBrowserBox->setEnableKeys(true); mBrowserBox->setEnableTabs(true); place(4, 3, mDYKButton, 1, 1); place(0, 0, mScrollArea, 5, 3).setPadding(3); Layout &layout = getLayout(); layout.setRowHeight(0, LayoutType::SET); loadWindowState(); loadTags(); enableVisibleSound(true); widgetResized(Event(nullptr)); }
void BuySellDialog::init() { setWindowName("BuySell"); setCloseButton(true); static const char *buttonNames[] = { // TRANSLATORS: shop window button N_("Buy"), // TRANSLATORS: shop window button N_("Sell"), // TRANSLATORS: shop window button N_("Cancel"), nullptr }; const int buttonPadding = getOption("buttonpadding", 10); int x = buttonPadding; const int y = buttonPadding; for (const char *const *curBtn = buttonNames; *curBtn; curBtn++) { Button *const btn = new Button(this, gettext(*curBtn), *curBtn, this); if (!mBuyButton) mBuyButton = btn; // For focus request btn->setPosition(x, y); add(btn); x += btn->getWidth() + buttonPadding; } if (mBuyButton) { mBuyButton->requestFocus(); setContentSize(x, 2 * y + mBuyButton->getHeight()); } center(); setDefaultSize(); loadWindowState(); enableVisibleSound(true); dialogInstances.push_back(this); setVisible(true); }
void NpcPostDialog::postInit() { // create text field for receiver // TRANSLATORS: label in npc post dialog Label *const senderText = new Label(this, _("To:")); senderText->setPosition(5, 5); mSender->setPosition(senderText->getWidth() + 5, 5); mSender->setWidth(65); // create button for sending // TRANSLATORS: button in npc post dialog Button *const sendButton = new Button(this, _("Send"), "send", this); sendButton->setPosition(400 - sendButton->getWidth(), 170 - sendButton->getHeight()); // TRANSLATORS: button in npc post dialog Button *const cancelButton = new Button(this, _("Cancel"), "cancel", this); cancelButton->setPosition(sendButton->getX() - (cancelButton->getWidth() + 2), sendButton->getY()); // create textfield for letter mText->setHeight(400 - (mSender->getHeight() + sendButton->getHeight())); mText->setEditable(true); // create scroll box for letter text ScrollArea *const scrollArea = new ScrollArea(this, mText); scrollArea->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER); scrollArea->setDimension(Rect( 5, mSender->getHeight() + 5, 380, 140 - (mSender->getHeight() + sendButton->getHeight()))); add(senderText); add(mSender); add(scrollArea); add(sendButton); add(cancelButton); setLocationRelativeTo(getParent()); instances.push_back(this); setVisible(true); enableVisibleSound(true); }
void NpcDialog::postInit() { Window::postInit(); setVisible(Visible_true); requestFocus(); enableVisibleSound(true); soundManager.playGuiSound(SOUND_SHOW_WINDOW); if (actorManager) { const Being *const being = actorManager->findBeing(mNpcId); if (being) { showAvatar(NPCDB::getAvatarFor(fromInt( being->getSubType(), BeingTypeId))); setCaption(being->getName()); } } config.addListener("logNpcInGui", this); }
void WhoIsOnline::postInit() { Window::postInit(); const int h = 350; const int w = 200; setDefaultSize(w, h, ImagePosition::CENTER); setVisible(Visible_false); setCloseButton(true); setResizable(true); setStickyButtonLock(true); setSaveVisible(true); if (setupWindow) setupWindow->registerWindowForReset(this); mUpdateButton->setEnabled(false); mUpdateButton->setDimension(Rect(5, 5, w - 10, 20 + 5)); mBrowserBox->setOpaque(Opaque_false); mScrollArea->setDimension(Rect(5, 20 + 10, w - 10, h - 10 - 30)); mScrollArea->setSize(w - 10, h - 10 - 30); mScrollArea->setSelectable(false); mBrowserBox->setLinkHandler(this); add(mUpdateButton); add(mScrollArea); setLocationRelativeTo(getParent()); loadWindowState(); enableVisibleSound(true); download(); widgetResized(Event(nullptr)); config.addListener("updateOnlineList", this); config.addListener("groupFriends", this); mGroupFriends = config.getBoolValue("groupFriends"); }
DebugWindow::DebugWindow() : // TRANSLATORS: debug window name Window(_("Debug"), Modal_false, nullptr, "debug.xml"), mTabs(CREATEWIDGETR(TabbedArea, this)), mMapWidget(new MapDebugTab(this)), mTargetWidget(new TargetDebugTab(this)), mNetWidget(new NetDebugTab(this)) { setWindowName("Debug"); if (setupWindow) setupWindow->registerWindowForReset(this); setResizable(true); setCloseButton(true); setSaveVisible(true); setStickyButtonLock(true); setDefaultSize(400, 300, ImagePosition::CENTER); mTabs->setSelectable(false); mTabs->getWidgetContainer()->setSelectable(false); mTabs->getTabContainer()->setSelectable(false); // TRANSLATORS: debug window tab mTabs->addTab(std::string(_("Map")), mMapWidget); // TRANSLATORS: debug window tab mTabs->addTab(std::string(_("Target")), mTargetWidget); // TRANSLATORS: debug window tab mTabs->addTab(std::string(_("Net")), mNetWidget); mTabs->setDimension(Rect(0, 0, 600, 300)); const int w = mDimension.width; const int h = mDimension.height; mMapWidget->resize(w, h); mTargetWidget->resize(w, h); mNetWidget->resize(w, h); loadWindowState(); enableVisibleSound(true); }
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); }
ServerInfoWindow::ServerInfoWindow(ServerInfo &serverInfo) : // TRANSLATORS: servers dialog name Window(_("Server info"), Modal_false, nullptr, "serverinfo.xml"), LinkHandler(), mServerInfo(serverInfo), mBrowserBox(new StaticBrowserBox(this, Opaque_true, "browserbox.xml")), mScrollArea(new ScrollArea(this, mBrowserBox, Opaque_true, "serverinfo_background.xml")) { setMinWidth(300); setMinHeight(220); setContentSize(455, 350); setWindowName("ServerInfoWindow"); setCloseButton(true); setResizable(true); setStickyButtonLock(true); setDefaultSize(500, 400, ImagePosition::CENTER, 0, 0); mBrowserBox->setOpaque(Opaque_false); mBrowserBox->setLinkHandler(this); if (gui != nullptr) mBrowserBox->setFont(gui->getHelpFont()); mBrowserBox->setProcessVars(true); mBrowserBox->setEnableTabs(true); place(0, 0, mScrollArea, 5, 3).setPadding(3); Layout &layout = getLayout(); layout.setRowHeight(0, LayoutType::SET); loadWindowState(); enableVisibleSound(true); widgetResized(Event(nullptr)); }
EquipmentWindow::EquipmentWindow(Equipment *const equipment, Being *const being, const bool foring): // TRANSLATORS: equipment window name Window(_("Equipment"), false, nullptr, "equipment.xml"), gcn::ActionListener(), mEquipment(equipment), mItemPopup(new ItemPopup), mPlayerBox(new PlayerBox("equipment_playerbox.xml", "equipment_selectedplayerbox.xml")), // TRANSLATORS: equipment window button mUnequip(new Button(this, _("Unequip"), "unequip", this)), mSelected(-1), mForing(foring), mImageSet(nullptr), mBeing(being), mBoxes(), mHighlightColor(getThemeColor(Theme::HIGHLIGHT)), mBorderColor(getThemeColor(Theme::BORDER)), mLabelsColor(getThemeColor(Theme::LABEL)), mLabelsColor2(getThemeColor(Theme::LABEL_OUTLINE)), mSlotBackground(), mSlotHighlightedBackground(), mVertexes(new ImageCollection), mItemPadding(getOption("itemPadding")), mBoxSize(getOption("boxSize")), mButtonPadding(getOption("buttonPadding", 5)), mMinX(180), mMinY(345), mMaxX(0), mMaxY(0) { if (setupWindow) setupWindow->registerWindowForReset(this); if (!mBoxSize) mBoxSize = 36; // Control that shows the Player mPlayerBox->setDimension(gcn::Rectangle(50, 80, 74, 168)); mPlayerBox->setPlayer(being); if (foring) setWindowName("Being equipment"); else setWindowName("Equipment"); setCloseButton(true); setSaveVisible(true); setStickyButtonLock(true); mBoxes.reserve(BOX_COUNT); for (int f = 0; f < BOX_COUNT; f ++) mBoxes.push_back(nullptr); fillBoxes(); recalcSize(); loadWindowState(); const gcn::Rectangle &area = getChildrenArea(); mUnequip->setPosition(area.width - mUnequip->getWidth() - mButtonPadding, area.height - mUnequip->getHeight() - mButtonPadding); mUnequip->setEnabled(false); ImageRect rect; Theme::instance()->loadRect(rect, "equipment_background.xml", "", 0, 1); mSlotBackground = rect.grid[0]; mSlotHighlightedBackground = rect.grid[1]; add(mPlayerBox); add(mUnequip); enableVisibleSound(true); }
MailViewWindow::MailViewWindow(const MailMessage *const message) : // TRANSLATORS: mail view window name Window(_("View mail"), Modal_false, nullptr, "mailview.xml"), ActionListener(), mMessage(message), // TRANSLATORS: mail view window button mGetAttachButton(nullptr), // TRANSLATORS: mail view window button mCloseButton(new Button(this, _("Close"), "close", this)), mPrevButton(new Button(this, "<", "prev", this)), mNextButton(new Button(this, ">", "next", this)), // TRANSLATORS: mail view window button mReplyButton(new Button(this, _("Reply"), "reply", this)), // TRANSLATORS: mail view window label mTimeLabel(new Label(this, strprintf("%s %s", _("Time:"), message->strTime.c_str()))), mMoneyLabel(nullptr), // TRANSLATORS: mail view window label mFromLabel(new Label(this, strprintf("%s %s", _("From:"), message->sender.c_str()))), // TRANSLATORS: mail view window label mSubjectLabel(new Label(this, strprintf("%s %s", _("Subject:"), message->title.c_str()))), // TRANSLATORS: mail view window label mMessageLabel(new Label(this, strprintf("%s %s", _("Message:"), message->text.c_str()))), // TRANSLATORS: mail view window label mItemLabel(nullptr), mIcon(nullptr) { setWindowName("MailView"); setCloseButton(true); setResizable(true); setSaveVisible(false); setStickyButtonLock(true); setVisible(Visible_true); setDefaultSize(380, 230, ImageRect::CENTER); setMinWidth(200); setMinHeight(100); center(); ContainerPlacer placer; placer = getPlacer(0, 0); int n = 0; placer(0, n++, mTimeLabel); placer(0, n++, mFromLabel); placer(0, n++, mSubjectLabel); if (message->money) { // TRANSLATORS: mail view window label mMoneyLabel = new Label(this, strprintf("%s %d", _("Money:"), message->money)); placer(0, n++, mMoneyLabel); } placer(0, n++, mMessageLabel); if (message->itemId) { const ItemInfo &item = ItemDB::get(message->itemId); // +++ need use message->cards and ItemColorManager for colors Image *const image = resourceManager->getImage(combineDye2( paths.getStringValue("itemIcons").append( item.getDisplay().image), item.getDyeIconColorsString(ItemColor_one))); mIcon = new Icon(this, image); if (message->itemAmount != 1) { mItemLabel = new Label(this, std::string(_("Item:")).append( " (").append(toString(message->itemAmount)).append(") ")); } else { mItemLabel = new Label(this, std::string(_("Item:")).append(" ")); } placer(0, n, mItemLabel); placer(1, n++, mIcon); } if (message->money || message->itemId) { mGetAttachButton = new Button(this, _("Get attach"), "attach", this); placer(0, n++, mGetAttachButton); } ContainerPlacer placer2; placer2 = getPlacer(0, n); placer2(0, 0, mPrevButton); placer2(1, 0, mNextButton); placer2(3, 0, mReplyButton); placer2(4, 0, mCloseButton); loadWindowState(); enableVisibleSound(true); }
void BuyDialog::init() { setWindowName("Buy"); setResizable(true); setCloseButton(true); setStickyButtonLock(true); setMinWidth(260); setMinHeight(220); setDefaultSize(260, 230, ImageRect::CENTER); if (setupWindow) setupWindow->registerWindowForReset(this); mShopItems = new ShopItems; mShopItemList = new ShopListBox(this, mShopItems, mShopItems); mShopItemList->postInit(); mScrollArea = new ScrollArea(this, mShopItemList, getOptionBool("showbackground"), "buy_background.xml"); mScrollArea->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER); mSlider = new Slider(this, 1.0, 1.0); mQuantityLabel = new Label(this, strprintf( "%d / %d", mAmountItems, mMaxItems)); mQuantityLabel->setAlignment(Graphics::CENTER); // TRANSLATORS: buy dialog label mMoneyLabel = new Label(this, strprintf( _("Price: %s / Total: %s"), "", "")); mAmountField = new IntTextField(this, 1, 1, 123); mAmountField->setActionEventId("amount"); mAmountField->addActionListener(this); mAmountField->setSendAlwaysEvents(true); mAmountField->setEnabled(false); // TRANSLATORS: buy dialog label mAmountLabel = new Label(this, _("Amount:")); mAmountLabel->adjustSize(); // TRANSLATORS: This is a narrow symbol used to denote 'increasing'. // You may change this symbol if your language uses another. mIncreaseButton = new Button(this, _("+"), "inc", this); // TRANSLATORS: This is a narrow symbol used to denote 'decreasing'. // You may change this symbol if your language uses another. mDecreaseButton = new Button(this, _("-"), "dec", this); // TRANSLATORS: buy dialog button mBuyButton = new Button(this, mNpcId == fromInt(Items, BeingId) ? _("Create") :_("Buy"), "buy", this); // TRANSLATORS: buy dialog button mQuitButton = new Button(this, _("Quit"), "quit", this); // TRANSLATORS: buy dialog button mAddMaxButton = new Button(this, _("Max"), "max", this); mDecreaseButton->adjustSize(); mDecreaseButton->setWidth(mIncreaseButton->getWidth()); mIncreaseButton->setEnabled(false); mDecreaseButton->setEnabled(false); mBuyButton->setEnabled(false); mSlider->setEnabled(false); mSlider->setActionEventId("slider"); mSlider->addActionListener(this); mShopItemList->setDistributeMousePressed(false); mShopItemList->setActionEventId("buy"); mShopItemList->addActionListener(this); mShopItemList->addSelectionListener(this); mFilterTextField->setWidth(100); ContainerPlacer placer = getPlacer(0, 0); placer(0, 0, mScrollArea, 9, 5).setPadding(3); placer(0, 5, mDecreaseButton); placer(1, 5, mSlider, 4); placer(5, 5, mIncreaseButton); placer(6, 5, mQuantityLabel, 2); placer(8, 5, mAddMaxButton); placer(0, 6, mAmountLabel, 2); placer(2, 6, mAmountField, 2); placer(0, 7, mMoneyLabel, 8); if (mSortDropDown) { placer(0, 8, mSortDropDown, 2); } else { // TRANSLATORS: buy dialog label mFilterLabel = new Label(this, _("Filter:")); mFilterLabel->adjustSize(); placer(0, 8, mFilterLabel, 2); } placer(2, 8, mFilterTextField, 2); placer(7, 8, mBuyButton); placer(8, 8, mQuitButton); Layout &layout = getLayout(); layout.setRowHeight(0, LayoutType::SET); center(); loadWindowState(); enableVisibleSound(true); instances.push_back(this); setVisible(Visible_true); if (mSortDropDown) mSortDropDown->setSelected(config.getIntValue("buySortOrder")); }
void TextCommandEditor::postInit() { Window::postInit(); enableVisibleSound(true); setVisible(Visible_true); }
void SocialWindow::postInit() { Window::postInit(); setWindowName("Social"); setVisible(Visible_false); setSaveVisible(true); setResizable(true); setSaveVisible(true); setCloseButton(true); setStickyButtonLock(true); setMinWidth(120); setMinHeight(55); setDefaultSize(590, 200, 180, 300); if (setupWindow) setupWindow->registerWindowForReset(this); place(0, 0, mCreateButton); place(1, 0, mInviteButton); place(2, 0, mLeaveButton); place(0, 1, mCountLabel); place(0, 2, mTabs, 4, 4); widgetResized(Event(nullptr)); loadWindowState(); mTabs->addTab(mPlayers, mPlayers->mScroll); mTabs->addTab(mFriends, mFriends->mScroll); mTabs->addTab(mNavigation, mNavigation->mScroll); if (config.getBoolValue("enableAttackFilter")) { mAttackFilter = new SocialAttackTab(this, getOptionBool("showtabbackground")); mTabs->addTab(mAttackFilter, mAttackFilter->mScroll); } else { mAttackFilter = nullptr; } if (config.getBoolValue("enablePickupFilter")) { mPickupFilter = new SocialPickupTab(this, getOptionBool("showtabbackground")); mTabs->addTab(mPickupFilter, mPickupFilter->mScroll); } else { mPickupFilter = nullptr; } if (localPlayer && localPlayer->getParty()) addTab(localPlayer->getParty()); if (localPlayer && localPlayer->getGuild()) addTab(localPlayer->getGuild()); enableVisibleSound(true); updateButtons(); player_relations.addListener(this); }
void SellDialog::postInit() { setWindowName("Sell"); setResizable(true); setCloseButton(true); setStickyButtonLock(true); setMinWidth(260); setMinHeight(220); setDefaultSize(260, 230, ImagePosition::CENTER); if (setupWindow) setupWindow->registerWindowForReset(this); // Create a ShopItems instance, that is aware of duplicate entries. mShopItems = new ShopItems(true); if (mAdvanced == Advanced_true) mShopItems->setMergeDuplicates(false); mShopItemList = CREATEWIDGETR(ShopListBox, this, mShopItems, mShopItems, ShopListBoxType::Unknown); mShopItemList->setProtectItems(true); mScrollArea = new ScrollArea(this, mShopItemList, fromBool(getOptionBool("showbackground"), Opaque), "sell_background.xml"); mScrollArea->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER); mSellButton = new Button(this, // TRANSLATORS: sell dialog button mAdvanced == Advanced_true ? _("Add") : _("Sell"), "presell", this); // TRANSLATORS: sell dialog button mQuitButton = new Button(this, _("Quit"), "quit", this); initButtons(); mSellButton->setEnabled(false); mShopItemList->setDistributeMousePressed(false); mShopItemList->setPriceCheck(false); mShopItemList->addSelectionListener(this); mShopItemList->setActionEventId("sell"); mShopItemList->addActionListener(this); ContainerPlacer placer; placer = getPlacer(0, 0); if (mIsSell == IsSell_true) { // TRANSLATORS: sell dialog button mIncreaseButton = new Button(this, _("+"), "inc", this); // TRANSLATORS: sell dialog button mDecreaseButton = new Button(this, _("-"), "dec", this); // TRANSLATORS: sell dialog button mAddMaxButton = new Button(this, _("Max"), "max", this); mSlider = new Slider(this, 1.0, 1.0); mQuantityLabel = new Label(this, strprintf( "%d / %d", mAmountItems, mMaxItems)); mQuantityLabel->setAlignment(Graphics::CENTER); // TRANSLATORS: sell dialog label mMoneyLabel = new Label(this, strprintf(_("Price: %s / Total: %s"), "", "")); if (mAdvanced == Advanced_true) { // TRANSLATORS: sell dialog button mConfirmButton = new Button(this, _("Sell"), "confirm", this); mConfirmButton->setEnabled(false); } mDecreaseButton->adjustSize(); mDecreaseButton->setWidth(mIncreaseButton->getWidth()); mIncreaseButton->setEnabled(false); mDecreaseButton->setEnabled(false); mSlider->setEnabled(false); mSlider->setActionEventId("slider"); mSlider->addActionListener(this); placer(0, 0, mScrollArea, 8, 5).setPadding(3); placer(0, 5, mDecreaseButton); placer(1, 5, mSlider, 3); placer(4, 5, mIncreaseButton); placer(5, 5, mQuantityLabel, 2); placer(7, 5, mAddMaxButton); placer(0, 6, mMoneyLabel, 8); if (mAdvanced == Advanced_true) { placer(5, 7, mSellButton); placer(6, 7, mConfirmButton); } else { placer(6, 7, mSellButton); } placer(7, 7, mQuitButton); } else { placer(0, 0, mScrollArea, 8, 5).setPadding(3); placer(6, 5, mSellButton); placer(7, 5, mQuitButton); } Layout &layout = getLayout(); layout.setRowHeight(0, LayoutType::SET); center(); loadWindowState(); instances.push_back(this); setVisible(Visible_true); enableVisibleSound(true); }
QuestsWindow::QuestsWindow() : // TRANSLATORS: quests window name Window(_("Quests"), false, nullptr, "quests.xml"), ActionListener(), mQuestsModel(new QuestsModel), mQuestsListBox(new ExtendedListBox(this, mQuestsModel, "extendedlistbox.xml")), mQuestScrollArea(new ScrollArea(this, mQuestsListBox, getOptionBool("showlistbackground"), "quests_list_background.xml")), mItemLinkHandler(new ItemLinkHandler), mText(new BrowserBox(this, BrowserBox::AUTO_WRAP, true, "browserbox.xml")), mTextScrollArea(new ScrollArea(this, mText, getOptionBool("showtextbackground"), "quests_text_background.xml")), // TRANSLATORS: quests window button mCloseButton(new Button(this, _("Close"), "close", this)), mCompleteIcon(Theme::getImageFromThemeXml("complete_icon.xml", "")), mIncompleteIcon(Theme::getImageFromThemeXml("incomplete_icon.xml", "")), mVars(), mQuests(), mAllEffects(), mMapEffects(), mNpcEffects(), mQuestLinks(), mNewQuestEffectId(paths.getIntValue("newQuestEffectId")), mCompleteQuestEffectId(paths.getIntValue("completeQuestEffectId")), mMap(nullptr) { mQuestsListBox->postInit(); setWindowName("Quests"); setResizable(true); setCloseButton(true); setStickyButtonLock(true); setSaveVisible(true); setDefaultSize(400, 350, ImageRect::RIGHT); setMinWidth(310); setMinHeight(220); mQuestsListBox->setActionEventId("select"); mQuestsListBox->addActionListener(this); mQuestScrollArea->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER); mText->setOpaque(false); mText->setLinkHandler(mItemLinkHandler); mTextScrollArea->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER); mQuestsListBox->setWidth(500); if (!gui || gui->getNpcFont()->getHeight() < 20) mQuestsListBox->setRowHeight(20); else mQuestsListBox->setRowHeight(gui->getNpcFont()->getHeight()); ContainerPlacer placer; placer = getPlacer(0, 0); placer(0, 0, mQuestScrollArea, 4, 3).setPadding(3); placer(4, 0, mTextScrollArea, 4, 3).setPadding(3); placer(7, 3, mCloseButton); Layout &layout = getLayout(); layout.setRowHeight(0, LayoutType::SET); loadWindowState(); enableVisibleSound(true); loadXmlFile(paths.getStringValue("questsFile")); loadXmlFile(paths.getStringValue("questsPatchFile")); loadXmlDir("questsPatchDir", loadXmlFile); }
MailEditWindow::MailEditWindow() : // TRANSLATORS: mail edit window name Window(_("Edit mail"), Modal_false, nullptr, "mailedit.xml"), ActionListener(), // TRANSLATORS: mail edit window button mSendButton(new Button(this, _("Send"), "send", this)), // TRANSLATORS: mail edit window button mCloseButton(new Button(this, _("Close"), "close", this)), // TRANSLATORS: mail edit window button mAddButton(new Button(this, _("Add"), "add", this)), // TRANSLATORS: mail edit window label mToLabel(new Label(this, _("To:"))), // TRANSLATORS: mail edit window label mSubjectLabel(new Label(this, _("Subject:"))), // TRANSLATORS: mail edit window label mMoneyLabel(new Label(this, _("Money:"))), // TRANSLATORS: mail edit window label mItemLabel(new Label(this, _("Item:"))), // TRANSLATORS: mail edit window label mMessageLabel(new Label(this, _("Message:"))), mToField(new TextField(this)), mSubjectField(new TextField(this)), mMoneyField(new IntTextField(this, 0, 0, 10000000)), mMessageField(new TextField(this)), mInventory(new Inventory(InventoryType::MAIL, 1)), mItemContainer(new ItemContainer(this, mInventory)), mItemScrollArea(new ScrollArea(this, mItemContainer, getOptionBool("showitemsbackground"), "mailedit_listbackground.xml")) { setWindowName("MailEdit"); setCloseButton(true); setResizable(true); setCloseButton(true); setSaveVisible(false); setStickyButtonLock(true); setVisible(Visible_true); setDefaultSize(380, 200, ImageRect::CENTER); setMinWidth(200); setMinHeight(200); center(); ContainerPlacer placer; placer = getPlacer(0, 0); mToField->setWidth(100); mSubjectField->setWidth(100); mMessageField->setWidth(100); mItemScrollArea->setHeight(70); mItemScrollArea->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER); mItemScrollArea->setVerticalScrollPolicy(ScrollArea::SHOW_NEVER); placer(0, 0, mToLabel); placer(1, 0, mToField, 3); placer(0, 1, mSubjectLabel); placer(1, 1, mSubjectField, 3); placer(0, 2, mMoneyLabel); placer(1, 2, mMoneyField, 3); placer(0, 3, mItemLabel); placer(1, 3, mItemScrollArea, 2, 2); placer(3, 4, mAddButton, 1); placer(0, 5, mMessageLabel); placer(1, 5, mMessageField, 3); placer(0, 6, mSendButton); placer(3, 6, mCloseButton); loadWindowState(); enableVisibleSound(true); }
TradeWindow::TradeWindow(): // TRANSLATORS: trade window caption Window(_("Trade: You"), false, nullptr, "trade.xml"), gcn::ActionListener(), gcn::SelectionListener(), mMyInventory(new Inventory(Inventory::TRADE)), mPartnerInventory(new Inventory(Inventory::TRADE)), mMyItemContainer(new ItemContainer(this, mMyInventory.get())), mPartnerItemContainer(new ItemContainer(this, mPartnerInventory.get())), // TRANSLATORS: trade window money label mMoneyLabel(new Label(this, strprintf(_("You get %s"), ""))), // TRANSLATORS: trade window button mAddButton(new Button(this, _("Add"), "add", this)), mOkButton(new Button(this, "", "", this)), // Will be filled in later // TRANSLATORS: trade window money change button mMoneyChangeButton(new Button(this, _("Change"), "money", this)), mMoneyField(new TextField(this)), mStatus(PROPOSING), mAutoAddItem(nullptr), mAutoAddToNick(""), mGotMoney(0), mGotMaxMoney(0), mAutoMoney(0), mAutoAddAmount(0), mOkOther(false), mOkMe(false) { logger->log1("TradeWindow::TradeWindow nick"); setWindowName("Trade"); setResizable(true); setCloseButton(true); setStickyButtonLock(true); setDefaultSize(386, 180, ImageRect::CENTER); setMinWidth(310); setMinHeight(180); if (setupWindow) setupWindow->registerWindowForReset(this); const gcn::Font *const fnt = mOkButton->getFont(); int width = std::max(fnt->getWidth(CAPTION_PROPOSE), fnt->getWidth(CAPTION_CONFIRMED)); width = std::max(width, fnt->getWidth(CAPTION_ACCEPT)); width = std::max(width, fnt->getWidth(CAPTION_ACCEPTED)); mOkButton->setWidth(8 + width); mMyItemContainer->addSelectionListener(this); ScrollArea *const myScroll = new ScrollArea(mMyItemContainer, true, "trade_background.xml"); myScroll->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER); mPartnerItemContainer->addSelectionListener(this); ScrollArea *const partnerScroll = new ScrollArea(mPartnerItemContainer, true, "trade_background.xml"); partnerScroll->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER); // TRANSLATORS: trade window money label Label *const moneyLabel2 = new Label(this, _("You give:")); mMoneyField->setWidth(40); place(1, 0, mMoneyLabel); place(0, 1, myScroll).setPadding(3); place(1, 1, partnerScroll).setPadding(3); ContainerPlacer placer; placer = getPlacer(0, 0); placer(0, 0, moneyLabel2); placer(1, 0, mMoneyField, 2); placer(3, 0, mMoneyChangeButton).setHAlign(LayoutCell::LEFT); placer = getPlacer(0, 2); placer(0, 0, mAddButton); placer(1, 0, mOkButton); Layout &layout = getLayout(); layout.extend(0, 2, 2, 1); layout.setRowHeight(1, Layout::AUTO_SET); layout.setRowHeight(2, 0); layout.setColWidth(0, Layout::AUTO_SET); layout.setColWidth(1, Layout::AUTO_SET); loadWindowState(); enableVisibleSound(true); reset(); }
OutfitWindow::OutfitWindow() : // TRANSLATORS: outfits window name Window(_("Outfits"), Modal_false, nullptr, "outfits.xml"), ActionListener(), // TRANSLATORS: outfits window button mPreviousButton(new Button(this, _("<"), "previous", this)), // TRANSLATORS: outfits window button mNextButton(new Button(this, _(">"), "next", this)), // TRANSLATORS: outfits window button mEquipButtom(new Button(this, _("Equip"), "equip", this)), // TRANSLATORS: outfits window label mCurrentLabel(new Label(this, strprintf(_("Outfit: %d"), 1))), // TRANSLATORS: outfits window checkbox mUnequipCheck(new CheckBox(this, _("Unequip first"), serverConfig.getValueBool("OutfitUnequip0", true))), // TRANSLATORS: outfits window checkbox mAwayOutfitCheck(new CheckBox(this, _("Away outfit"), serverConfig.getValue("OutfitAwayIndex", OUTFITS_COUNT - 1))), // TRANSLATORS: outfits window label mKeyLabel(new Label(this, strprintf(_("Key: %s"), keyName(0).c_str()))), mBorderColor(getThemeColor(Theme::BORDER, 64)), mCurrentOutfit(0), mBoxWidth(33), mBoxHeight(33), mGridWidth(4), mGridHeight(4), mItems(), mAwayOutfit(0), mItemColors(), mItemClicked(false), mItemsUnequip() { setWindowName("Outfits"); setResizable(true); setCloseButton(true); setStickyButtonLock(true); mBackgroundColor = getThemeColor(Theme::BACKGROUND, 32); setDefaultSize(250, 400, 150, 290); setMinWidth(145); setMinHeight(220); if (setupWindow) setupWindow->registerWindowForReset(this); mCurrentLabel->setAlignment(Graphics::CENTER); mKeyLabel->setAlignment(Graphics::CENTER); mUnequipCheck->setActionEventId("unequip"); mUnequipCheck->addActionListener(this); mAwayOutfitCheck->setActionEventId("away"); mAwayOutfitCheck->addActionListener(this); place(1, 3, mEquipButtom, 2); place(0, 4, mKeyLabel, 4); place(0, 5, mPreviousButton, 1); place(1, 5, mCurrentLabel, 2); place(3, 5, mNextButton, 1); place(0, 6, mUnequipCheck, 4); place(0, 7, mAwayOutfitCheck, 4); Layout &layout = getLayout(); layout.setRowHeight(0, LayoutType::SET); layout.setColWidth(4, Layout::CENTER); loadWindowState(); enableVisibleSound(true); load(); }
KillStats::KillStats() : // TRANSLATORS: kill stats window name Window(_("Kill stats"), false, nullptr, "killstats.xml"), gcn::ActionListener(), mKillCounter(0), mExpCounter(0), mKillTCounter(0), mExpTCounter(0), mKillTimer(0), // TRANSLATORS: kill stats window button mResetButton(new Button(this, _("Reset stats"), "reset", this)), // TRANSLATORS: kill stats window button mTimerButton(new Button(this, _("Reset timer"), "timer", this)), mLine1(nullptr), mLine2(nullptr), mLine3(nullptr), // TRANSLATORS: kill stats window label mLine4(new Label(this, strprintf(_("Kills: %s, total exp: %s"), "?", "?"))), // TRANSLATORS: kill stats window label mLine5(new Label(this, strprintf(_("Avg Exp: %s"), "?"))), // TRANSLATORS: kill stats window label mLine6(new Label(this, strprintf(_("No. of avg mob to next level: %s"), "?"))), // TRANSLATORS: kill stats window label mLine7(new Label(this, strprintf(_("Kills/Min: %s, Exp/Min: %s"), "?", "?"))), mExpSpeed1Label(new Label(this, strprintf(ngettext( // TRANSLATORS: kill stats window label "Exp speed per %d min: %s", "Exp speed per %d min: %s", 1), 1, "?"))), mExpTime1Label(new Label(this, strprintf(ngettext( "Time for next level per %d min: %s", "Time for next level per %d min: %s", 1), 1, "?"))), mExpSpeed5Label(new Label(this, strprintf(ngettext( "Exp speed per %d min: %s", "Exp speed per %d min: %s", 5), 5, "?"))), mExpTime5Label(new Label(this, strprintf(ngettext( "Time for next level per %d min: %s", "Time for next level per %d min: %s", 5), 5, "?"))), mExpSpeed15Label(new Label(this, strprintf(ngettext( "Exp speed per %d min: %s", "Exp speed per %d min: %s", 15), 15, "?"))), mExpTime15Label(new Label(this, strprintf(ngettext( "Time for next level per %d min: %s", "Time for next level per %d min: %s", 15), 15, "?"))), // TRANSLATORS: kill stats window label mLastKillExpLabel(new Label(this, strprintf("%s ?", _("Last kill exp:")))), mTimeBeforeJackoLabel(new Label(this, strprintf( // TRANSLATORS: kill stats window label "%s ?", _("Time before jacko spawn:")))), m1minExpTime(0), m1minExpNum(0), m1minSpeed(0), m5minExpTime(0), m5minExpNum(0), m5minSpeed(0), m15minExpTime(0), m15minExpNum(0), m15minSpeed(0), mJackoSpawnTime(0), mValidateJackoTime(0), mJackoId(0), mIsJackoAlive(false), mIsJackoMustSpawn(true), mIsJackoSpawnTimeUnknown(true) { setWindowName("Kill stats"); setCloseButton(true); setResizable(true); setSaveVisible(true); setStickyButtonLock(true); setDefaultSize(250, 250, 350, 300); listen(CHANNEL_ATTRIBUTES); const int xp(PlayerInfo::getAttribute(PlayerInfo::EXP)); int xpNextLevel(PlayerInfo::getAttribute(PlayerInfo::EXP_NEEDED)); if (!xpNextLevel) xpNextLevel = 1; // TRANSLATORS: kill stats window label mLine1 = new Label(this, strprintf(_("Level: %d at %f%%"), player_node->getLevel(), static_cast<double>(xp) / static_cast<double>(xpNextLevel) * 100.0)); // TRANSLATORS: kill stats window label mLine2 = new Label(this, strprintf(_("Exp: %d/%d Left: %d"), xp, xpNextLevel, xpNextLevel - xp)); // TRANSLATORS: kill stats window label mLine3 = new Label(this, strprintf(_("1%% = %d exp, avg mob for 1%%: %s"), xpNextLevel / 100, "?")); place(0, 0, mLine1, 6).setPadding(0); place(0, 1, mLine2, 6).setPadding(0); place(0, 2, mLine3, 6).setPadding(0); place(0, 3, mLine4, 6).setPadding(0); place(0, 4, mLine5, 6).setPadding(0); place(0, 5, mLine6, 6).setPadding(0); place(0, 6, mLine7, 6).setPadding(0); place(0, 7, mLastKillExpLabel, 6).setPadding(0); place(0, 8, mTimeBeforeJackoLabel, 6).setPadding(0); place(0, 9, mExpSpeed1Label, 6).setPadding(0); place(0, 10, mExpTime1Label, 6).setPadding(0); place(0, 11, mExpSpeed5Label, 6).setPadding(0); place(0, 12, mExpTime5Label, 6).setPadding(0); place(0, 13, mExpSpeed15Label, 6).setPadding(0); place(0, 14, mExpTime15Label, 6).setPadding(0); place(5, 13, mTimerButton).setPadding(0); place(5, 14, mResetButton).setPadding(0); loadWindowState(); enableVisibleSound(true); }
void TextSelectDialog::postInit() { Window::postInit(); setWindowName("TextSelectDialog"); setResizable(true); setCloseButton(mAllowQuit == AllowQuit_true); setStickyButtonLock(true); setMinWidth(260); setMinHeight(220); setDefaultSize(260, 230, ImagePosition::CENTER, 0, 0); if (setupWindow != nullptr) setupWindow->registerWindowForReset(this); setActionEventId("OK"); mModel = new NamesModel; mItemList = CREATEWIDGETR(ListBox, this, mModel, "listbox.xml"); mScrollArea = new ScrollArea(this, mItemList, fromBool(getOptionBool("showbackground", false), Opaque), "sell_background.xml"); mScrollArea->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER); mSelectButton = new Button(this, mSelectButtonName, "select", BUTTON_SKIN, this); if (mAllowQuit == AllowQuit_true) { mQuitButton = new Button(this, // TRANSLATORS: sell dialog button _("Quit"), "quit", BUTTON_SKIN, this); } mSelectButton->setEnabled(false); mItemList->setDistributeMousePressed(false); mItemList->addSelectionListener(this); mItemList->setActionEventId("item"); mItemList->addActionListener(this); ContainerPlacer placer(nullptr, nullptr); placer = getPlacer(0, 0); placer(0, 0, mScrollArea, 8, 5).setPadding(3); if (mQuitButton != nullptr) { placer(6, 5, mSelectButton, 1, 1); placer(7, 5, mQuitButton, 1, 1); } else { placer(7, 5, mSelectButton, 1, 1); } Layout &layout = getLayout(); layout.setRowHeight(0, LayoutType::SET); center(); loadWindowState(); setVisible(Visible_true); enableVisibleSound(true); }
StatusWindow::StatusWindow() : Window(localPlayer ? localPlayer->getName() : "?", Modal_false, nullptr, "status.xml"), ActionListener(), AttributeListener(), StatListener(), // TRANSLATORS: status window label mLvlLabel(new Label(this, strprintf(_("Level: %d"), 0))), // TRANSLATORS: status window label mMoneyLabel(new Label(this, strprintf(_("Money: %s"), ""))), // TRANSLATORS: status window label mHpLabel(new Label(this, _("HP:"))), mMpLabel(nullptr), // TRANSLATORS: status window label mXpLabel(new Label(this, _("Exp:"))), mHpBar(nullptr), mMpBar(nullptr), mXpBar(nullptr), mJobLvlLabel(nullptr), mJobLabel(nullptr), mJobBar(nullptr), mAttrCont(new VertContainer(this, 32)), mAttrScroll(new ScrollArea(this, mAttrCont, false)), mDAttrCont(new VertContainer(this, 32)), mDAttrScroll(new ScrollArea(this, mDAttrCont, false)), mCharacterPointsLabel(new Label(this, "C")), mCorrectionPointsLabel(nullptr), // TRANSLATORS: status window button mCopyButton(new Button(this, _("Copy to chat"), "copy", this)), mAttrs() { setWindowName("Status"); if (setupWindow) setupWindow->registerWindowForReset(this); setResizable(true); setCloseButton(true); setSaveVisible(true); setStickyButtonLock(true); setDefaultSize((windowContainer->getWidth() - 480) / 2, (windowContainer->getHeight() - 500) / 2, 480, 500); if (localPlayer && !localPlayer->getRaceName().empty()) { setCaption(strprintf("%s (%s)", localPlayer->getName().c_str(), localPlayer->getRaceName().c_str())); } int max = PlayerInfo::getAttribute(Attributes::MAX_HP); if (!max) max = 1; mHpBar = new ProgressBar(this, static_cast<float>(PlayerInfo::getAttribute( Attributes::HP)) / static_cast<float>(max), 80, 0, ProgressColorId::PROG_HP, "hpprogressbar.xml", "hpprogressbar_fill.xml"); mHpBar->setColor(getThemeColor(ThemeColorId::HP_BAR), getThemeColor(ThemeColorId::HP_BAR_OUTLINE)); max = PlayerInfo::getAttribute(Attributes::EXP_NEEDED); mXpBar = new ProgressBar(this, max ? static_cast<float>(PlayerInfo::getAttribute(Attributes::EXP)) / static_cast<float>(max) : static_cast<float>(0), 80, 0, ProgressColorId::PROG_EXP, "xpprogressbar.xml", "xpprogressbar_fill.xml"); mXpBar->setColor(getThemeColor(ThemeColorId::XP_BAR), getThemeColor(ThemeColorId::XP_BAR_OUTLINE)); const bool magicBar = gameHandler->canUseMagicBar(); const bool job = serverConfig.getValueBool("showJob", true); if (magicBar) { max = PlayerInfo::getAttribute(Attributes::MAX_MP); // TRANSLATORS: status window label mMpLabel = new Label(this, _("MP:")); const bool useMagic = playerHandler->canUseMagic(); mMpBar = new ProgressBar(this, max ? static_cast<float>( PlayerInfo::getAttribute(Attributes::MAX_MP)) / static_cast<float>(max) : static_cast<float>(0), 80, 0, useMagic ? ProgressColorId::PROG_MP : ProgressColorId::PROG_NO_MP, useMagic ? "mpprogressbar.xml" : "nompprogressbar.xml", useMagic ? "mpprogressbar_fill.xml" : "nompprogressbar_fill.xml"); if (useMagic) { mMpBar->setColor(getThemeColor(ThemeColorId::MP_BAR), getThemeColor(ThemeColorId::MP_BAR_OUTLINE)); } else { mMpBar->setColor(getThemeColor(ThemeColorId::NO_MP_BAR), getThemeColor(ThemeColorId::NO_MP_BAR_OUTLINE)); } } else { mMpLabel = nullptr; mMpBar = nullptr; } place(0, 0, mLvlLabel, 3); place(0, 1, mHpLabel).setPadding(3); place(1, 1, mHpBar, 4); place(5, 1, mXpLabel).setPadding(3); place(6, 1, mXpBar, 5); if (magicBar) { place(0, 2, mMpLabel).setPadding(3); // 5, 2 and 6, 2 Job Progress Bar if (job) place(1, 2, mMpBar, 4); else place(1, 2, mMpBar, 10); } if (job) { // TRANSLATORS: status window label mJobLvlLabel = new Label(this, strprintf(_("Job: %d"), 0)); // TRANSLATORS: status window label mJobLabel = new Label(this, _("Job:")); mJobBar = new ProgressBar(this, 0.0F, 80, 0, ProgressColorId::PROG_JOB, "jobprogressbar.xml", "jobprogressbar_fill.xml"); mJobBar->setColor(getThemeColor(ThemeColorId::JOB_BAR), getThemeColor(ThemeColorId::JOB_BAR_OUTLINE)); place(3, 0, mJobLvlLabel, 3); place(5, 2, mJobLabel).setPadding(3); place(6, 2, mJobBar, 5); place(6, 0, mMoneyLabel, 3); } else { mJobLvlLabel = nullptr; mJobLabel = nullptr; mJobBar = nullptr; place(3, 0, mMoneyLabel, 3); } // ---------------------- // Stats Part // ---------------------- mAttrScroll->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER); mAttrScroll->setVerticalScrollPolicy(ScrollArea::SHOW_AUTO); place(0, 3, mAttrScroll, 5, 3); mDAttrScroll->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER); mDAttrScroll->setVerticalScrollPolicy(ScrollArea::SHOW_AUTO); place(6, 3, mDAttrScroll, 5, 3); getLayout().setRowHeight(3, LayoutType::SET); place(0, 6, mCharacterPointsLabel, 5); place(0, 5, mCopyButton); if (playerHandler->canCorrectAttributes()) { mCorrectionPointsLabel = new Label(this, "C"); place(0, 7, mCorrectionPointsLabel, 5); } loadWindowState(); enableVisibleSound(true); // Update bars updateHPBar(mHpBar, true); if (magicBar) updateMPBar(mMpBar, true); updateXPBar(mXpBar, false); // TRANSLATORS: status window label mMoneyLabel->setCaption(strprintf(_("Money: %s"), Units::formatCurrency( PlayerInfo::getAttribute(Attributes::MONEY)).c_str())); mMoneyLabel->adjustSize(); // TRANSLATORS: status window label mCharacterPointsLabel->setCaption(strprintf(_("Character points: %d"), PlayerInfo::getAttribute(Attributes::CHAR_POINTS))); mCharacterPointsLabel->adjustSize(); updateLevelLabel(); }
InventoryWindow::InventoryWindow(Inventory *const inventory) : Window("Inventory", Modal_false, nullptr, "inventory.xml"), ActionListener(), KeyListener(), SelectionListener(), InventoryListener(), AttributeListener(), mInventory(inventory), mItems(new ItemContainer(this, mInventory)), mUseButton(nullptr), mDropButton(nullptr), mOutfitButton(nullptr), mShopButton(nullptr), mCartButton(nullptr), mEquipmentButton(nullptr), mStoreButton(nullptr), mRetrieveButton(nullptr), mInvCloseButton(nullptr), mWeightBar(nullptr), mSlotsBar(new ProgressBar(this, 0.0F, 100, 0, ProgressColorId::PROG_INVY_SLOTS, "slotsprogressbar.xml", "slotsprogressbar_fill.xml")), mFilter(nullptr), mSortModel(new SortListModelInv), mSortDropDown(new DropDown(this, mSortModel, false, Modal_false, this, "sort")), mNameFilter(new TextField(this, "", true, this, "namefilter", true)), mSortDropDownCell(nullptr), mNameFilterCell(nullptr), mFilterCell(nullptr), mSlotsBarCell(nullptr), mSplit(false), mCompactMode(false) { mSlotsBar->setColor(getThemeColor(ThemeColorId::SLOTS_BAR), getThemeColor(ThemeColorId::SLOTS_BAR_OUTLINE)); if (inventory) { setCaption(gettext(inventory->getName().c_str())); setWindowName(inventory->getName()); switch (inventory->getType()) { case InventoryType::Inventory: case InventoryType::Trade: case InventoryType::Npc: #ifdef EATHENA_SUPPORT case InventoryType::Vending: case InventoryType::Mail: case InventoryType::Craft: #endif case InventoryType::TypeEnd: default: mSortDropDown->setSelected(config.getIntValue( "inventorySortOrder")); break; case InventoryType::Storage: mSortDropDown->setSelected(config.getIntValue( "storageSortOrder")); break; #ifdef EATHENA_SUPPORT case InventoryType::Cart: mSortDropDown->setSelected(config.getIntValue( "cartSortOrder")); break; #endif }; } else { // TRANSLATORS: inventory window name setCaption(_("Inventory")); setWindowName("Inventory"); mSortDropDown->setSelected(0); } if (setupWindow && inventory && inventory->getType() != InventoryType::Storage) { setupWindow->registerWindowForReset(this); } setResizable(true); setCloseButton(true); setSaveVisible(true); setStickyButtonLock(true); if (mainGraphics->mWidth > 600) setDefaultSize(450, 310, ImagePosition::CENTER); else setDefaultSize(387, 307, ImagePosition::CENTER); setMinWidth(310); setMinHeight(179); addKeyListener(this); mItems->addSelectionListener(this); ScrollArea *const invenScroll = new ScrollArea(this, mItems, getOptionBool("showbackground"), "inventory_background.xml"); invenScroll->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER); const int size = config.getIntValue("fontSize"); mFilter = new TabStrip(this, "filter_" + getWindowName(), size + 16); mFilter->addActionListener(this); mFilter->setActionEventId("tag_"); StringVect tags = ItemDB::getTags(); const size_t sz = tags.size(); for (size_t f = 0; f < sz; f ++) mFilter->addButton(tags[f], tags[f], false); if (!mInventory) { invInstances.push_back(this); return; } switch (mInventory->getType()) { case InventoryType::Inventory: { // TRANSLATORS: inventory button const std::string equip = _("Equip"); // TRANSLATORS: inventory button const std::string use = _("Use"); // TRANSLATORS: inventory button const std::string unequip = _("Unequip"); std::string longestUseString = getFont()->getWidth(equip) > getFont()->getWidth(use) ? equip : use; if (getFont()->getWidth(longestUseString) < getFont()->getWidth(unequip)) { longestUseString = unequip; } mUseButton = new Button(this, longestUseString, "use", this); // TRANSLATORS: inventory button mDropButton = new Button(this, _("Drop..."), "drop", this); // TRANSLATORS: inventory outfits button mOutfitButton = new Button(this, _("O"), "outfit", this); // TRANSLATORS: inventory cart button mCartButton = new Button(this, _("C"), "cart", this); // TRANSLATORS: inventory shop button mShopButton = new Button(this, _("S"), "shop", this); // TRANSLATORS: inventory equipment button mEquipmentButton = new Button(this, _("E"), "equipment", this); mWeightBar = new ProgressBar(this, 0.0F, 100, 0, ProgressColorId::PROG_WEIGHT, "weightprogressbar.xml", "weightprogressbar_fill.xml"); mWeightBar->setColor(getThemeColor(ThemeColorId::WEIGHT_BAR), getThemeColor(ThemeColorId::WEIGHT_BAR_OUTLINE)); // TRANSLATORS: outfits button tooltip mOutfitButton->setDescription(_("Outfits")); // TRANSLATORS: cart button tooltip mCartButton->setDescription(_("Cart")); // TRANSLATORS: shop button tooltip mShopButton->setDescription(_("Shop")); // TRANSLATORS: equipment button tooltip mEquipmentButton->setDescription(_("Equipment")); place(0, 0, mWeightBar, 4); mSlotsBarCell = &place(4, 0, mSlotsBar, 4); mSortDropDownCell = &place(8, 0, mSortDropDown, 3); mFilterCell = &place(0, 1, mFilter, 10).setPadding(3); mNameFilterCell = &place(8, 1, mNameFilter, 3); place(0, 2, invenScroll, 11).setPadding(3); place(0, 3, mUseButton); place(1, 3, mDropButton); ContainerPlacer placer = getPlacer(10, 3); placer(0, 0, mShopButton); placer(1, 0, mOutfitButton); placer(2, 0, mCartButton); placer(3, 0, mEquipmentButton); updateWeight(); break; } case InventoryType::Storage: { // TRANSLATORS: storage button mStoreButton = new Button(this, _("Store"), "store", this); // TRANSLATORS: storage button mRetrieveButton = new Button(this, _("Retrieve"), "retrieve", this); // TRANSLATORS: storage button mInvCloseButton = new Button(this, _("Close"), "close", this); mSlotsBarCell = &place(0, 0, mSlotsBar, 6); mSortDropDownCell = &place(6, 0, mSortDropDown, 1); mFilterCell = &place(0, 1, mFilter, 7).setPadding(3); mNameFilterCell = &place(6, 1, mNameFilter, 1); place(0, 2, invenScroll, 7, 4); place(0, 6, mStoreButton); place(1, 6, mRetrieveButton); place(6, 6, mInvCloseButton); break; } #ifdef EATHENA_SUPPORT case InventoryType::Cart: { // TRANSLATORS: storage button mStoreButton = new Button(this, _("Store"), "store", this); // TRANSLATORS: storage button mRetrieveButton = new Button(this, _("Retrieve"), "retrieve", this); // TRANSLATORS: storage button mInvCloseButton = new Button(this, _("Close"), "close", this); mWeightBar = new ProgressBar(this, 0.0F, 100, 0, ProgressColorId::PROG_WEIGHT, "weightprogressbar.xml", "weightprogressbar_fill.xml"); mWeightBar->setColor(getThemeColor(ThemeColorId::WEIGHT_BAR), getThemeColor(ThemeColorId::WEIGHT_BAR_OUTLINE)); mSlotsBarCell = &place(3, 0, mSlotsBar, 3); mSortDropDownCell = &place(6, 0, mSortDropDown, 1); mFilterCell = &place(0, 1, mFilter, 7).setPadding(3); mNameFilterCell = &place(6, 1, mNameFilter, 1); place(0, 0, mWeightBar, 3); place(0, 2, invenScroll, 7, 4); place(0, 6, mStoreButton); place(1, 6, mRetrieveButton); place(6, 6, mInvCloseButton); break; } #endif default: case InventoryType::Trade: case InventoryType::Npc: #ifdef EATHENA_SUPPORT case InventoryType::Vending: case InventoryType::Mail: case InventoryType::Craft: #endif case InventoryType::TypeEnd: break; }; Layout &layout = getLayout(); layout.setRowHeight(2, LayoutType::SET); mInventory->addInventoyListener(this); invInstances.push_back(this); if (inventory->isMainInventory()) { updateDropButton(); } else { if (!invInstances.empty()) invInstances.front()->updateDropButton(); } loadWindowState(); enableVisibleSound(true); }
InventoryWindow::InventoryWindow(Inventory *const inventory): Window("Inventory", false, nullptr, "inventory.xml"), gcn::ActionListener(), gcn::KeyListener(), gcn::SelectionListener(), InventoryListener(), mInventory(inventory), mItems(new ItemContainer(this, mInventory)), mWeight(), mSlots(), mUseButton(nullptr), mDropButton(nullptr), mSplitButton(nullptr), mOutfitButton(nullptr), mShopButton(nullptr), mEquipmentButton(nullptr), mStoreButton(nullptr), mRetrieveButton(nullptr), mInvCloseButton(nullptr), mWeightBar(nullptr), mSlotsBar(new ProgressBar(this, 0.0f, 100, 0, Theme::PROG_INVY_SLOTS)), mFilter(nullptr), mSortModel(new SortListModelInv), mSortDropDown(new DropDown(this, mSortModel, false, false, this, "sort")), mNameFilter(new TextField(this, "", true, this, "namefilter", true)), mSortDropDownCell(nullptr), mNameFilterCell(nullptr), mFilterCell(nullptr), mSlotsBarCell(nullptr), mSplit(false), mCompactMode(false) { if (inventory) { setCaption(gettext(inventory->getName().c_str())); setWindowName(inventory->getName()); } else { // TRANSLATORS: inventory window name setCaption(_("Inventory")); setWindowName("Inventory"); } listen(CHANNEL_ATTRIBUTES); if (setupWindow) setupWindow->registerWindowForReset(this); setResizable(true); setCloseButton(true); setSaveVisible(true); setStickyButtonLock(true); setDefaultSize(387, 307, ImageRect::CENTER); setMinWidth(310); setMinHeight(179); addKeyListener(this); mItems->addSelectionListener(this); gcn::ScrollArea *const invenScroll = new ScrollArea( mItems, getOptionBool("showbackground"), "inventory_background.xml"); invenScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); const int size = config.getIntValue("fontSize"); mFilter = new TabStrip(this, "filter_" + getWindowName(), size + 16); mFilter->addActionListener(this); mFilter->setActionEventId("tag_"); mSortDropDown->setSelected(0); StringVect tags = ItemDB::getTags(); for (unsigned f = 0; f < tags.size(); f ++) mFilter->addButton(tags[f]); if (isMainInventory()) { // TRANSLATORS: inventory button const std::string equip = _("Equip"); // TRANSLATORS: inventory button const std::string use = _("Use"); // TRANSLATORS: inventory button const std::string unequip = _("Unequip"); std::string longestUseString = getFont()->getWidth(equip) > getFont()->getWidth(use) ? equip : use; if (getFont()->getWidth(longestUseString) < getFont()->getWidth(unequip)) { longestUseString = unequip; } mUseButton = new Button(this, longestUseString, "use", this); // TRANSLATORS: inventory button mDropButton = new Button(this, _("Drop..."), "drop", this); // TRANSLATORS: inventory button mSplitButton = new Button(this, _("Split"), "split", this); // TRANSLATORS: inventory button mOutfitButton = new Button(this, _("Outfits"), "outfit", this); // TRANSLATORS: inventory button mShopButton = new Button(this, _("Shop"), "shop", this); // TRANSLATORS: inventory button mEquipmentButton = new Button(this, _("Equipment"), "equipment", this); mWeightBar = new ProgressBar(this, 0.0f, 100, 0, Theme::PROG_WEIGHT); place(0, 0, mWeightBar, 4); mSlotsBarCell = &place(4, 0, mSlotsBar, 5); mSortDropDownCell = &place(9, 0, mSortDropDown, 2); mFilterCell = &place(0, 1, mFilter, 10).setPadding(3); mNameFilterCell = &place(9, 1, mNameFilter, 2); place(0, 2, invenScroll, 11).setPadding(3); place(0, 3, mUseButton); place(1, 3, mDropButton); place(8, 2, mSplitButton); place(8, 3, mShopButton); place(9, 3, mOutfitButton); place(10, 3, mEquipmentButton); updateWeight(); } else { // TRANSLATORS: storage button mStoreButton = new Button(this, _("Store"), "store", this); // TRANSLATORS: storage button mRetrieveButton = new Button(this, _("Retrieve"), "retrieve", this); // TRANSLATORS: storage button mInvCloseButton = new Button(this, _("Close"), "close", this); mSlotsBarCell = &place(0, 0, mSlotsBar, 6); mSortDropDownCell = &place(6, 0, mSortDropDown, 1); mFilterCell = &place(0, 1, mFilter, 7).setPadding(3); mNameFilterCell = &place(6, 1, mNameFilter, 1); place(0, 2, invenScroll, 7, 4); place(0, 6, mStoreButton); place(1, 6, mRetrieveButton); place(6, 6, mInvCloseButton); } Layout &layout = getLayout(); layout.setRowHeight(2, Layout::AUTO_SET); mInventory->addInventoyListener(this); invInstances.push_back(this); if (inventory && inventory->isMainInventory()) { updateDropButton(); } else { if (!invInstances.empty()) invInstances.front()->updateDropButton(); } loadWindowState(); enableVisibleSound(true); slotsChanged(mInventory); widgetResized(gcn::Event(nullptr)); if (!isMainInventory()) setVisible(true); }