diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-05-28 00:55:13 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-05-28 00:55:13 +0300 |
commit | 01a0e4b658241cc3dbd8a5d11d34a6de48dab159 (patch) | |
tree | 37294c079b9a05768b7380f7595784eb73485769 /src/gui/windows | |
parent | 072b727ae4d072d6c84f3331d78ca5a2ac76d271 (diff) | |
download | manaplus-01a0e4b658241cc3dbd8a5d11d34a6de48dab159.tar.gz manaplus-01a0e4b658241cc3dbd8a5d11d34a6de48dab159.tar.bz2 manaplus-01a0e4b658241cc3dbd8a5d11d34a6de48dab159.tar.xz manaplus-01a0e4b658241cc3dbd8a5d11d34a6de48dab159.zip |
Add strong typed bool type Visible.
Diffstat (limited to 'src/gui/windows')
47 files changed, 148 insertions, 127 deletions
diff --git a/src/gui/windows/buydialog.cpp b/src/gui/windows/buydialog.cpp index db8bed23e..63925ff28 100644 --- a/src/gui/windows/buydialog.cpp +++ b/src/gui/windows/buydialog.cpp @@ -329,7 +329,7 @@ void BuyDialog::init() enableVisibleSound(true); instances.push_back(this); - setVisible(true); + setVisible(Visible_true); if (mSortDropDown) mSortDropDown->setSelected(config.getIntValue("buySortOrder")); @@ -629,11 +629,11 @@ void BuyDialog::updateButtonsAndLabels() Units::formatCurrency(mMoney - price).c_str())); } -void BuyDialog::setVisible(bool visible) +void BuyDialog::setVisible(Visible visible) { Window::setVisible(visible); - if (visible && mShopItemList) + if (visible == Visible_true && mShopItemList) mShopItemList->requestFocus(); else scheduleDelete(); diff --git a/src/gui/windows/buydialog.h b/src/gui/windows/buydialog.h index 504a63154..8dea72886 100644 --- a/src/gui/windows/buydialog.h +++ b/src/gui/windows/buydialog.h @@ -23,6 +23,8 @@ #ifndef GUI_WINDOWS_BUYDIALOG_H #define GUI_WINDOWS_BUYDIALOG_H +#include "enums/simpletypes/visible.h" + #include "gui/widgets/window.h" #include "listeners/actionlistener.h" @@ -130,7 +132,7 @@ class BuyDialog final : public Window, /** * Sets the visibility of this window. */ - void setVisible(bool visible) override final; + void setVisible(Visible visible) override final; void sort(); diff --git a/src/gui/windows/buyselldialog.cpp b/src/gui/windows/buyselldialog.cpp index ea90f756a..15d4165f3 100644 --- a/src/gui/windows/buyselldialog.cpp +++ b/src/gui/windows/buyselldialog.cpp @@ -100,7 +100,7 @@ void BuySellDialog::init() enableVisibleSound(true); dialogInstances.push_back(this); - setVisible(true); + setVisible(Visible_true); } BuySellDialog::~BuySellDialog() @@ -108,11 +108,11 @@ BuySellDialog::~BuySellDialog() dialogInstances.remove(this); } -void BuySellDialog::setVisible(bool visible) +void BuySellDialog::setVisible(Visible visible) { Window::setVisible(visible); - if (visible) + if (visible == Visible_true) { if (mBuyButton) mBuyButton->requestFocus(); diff --git a/src/gui/windows/buyselldialog.h b/src/gui/windows/buyselldialog.h index 14121715f..573435846 100644 --- a/src/gui/windows/buyselldialog.h +++ b/src/gui/windows/buyselldialog.h @@ -23,6 +23,8 @@ #ifndef GUI_WINDOWS_BUYSELLDIALOG_H #define GUI_WINDOWS_BUYSELLDIALOG_H +#include "enums/simpletypes/visible.h" + #include "gui/widgets/window.h" #include "listeners/actionlistener.h" @@ -54,7 +56,7 @@ class BuySellDialog final : public Window, void init(); - void setVisible(bool visible) override final; + void setVisible(Visible visible) override final; /** * Called when receiving actions from the widgets. diff --git a/src/gui/windows/charcreatedialog.cpp b/src/gui/windows/charcreatedialog.cpp index 5ba652072..6ada41158 100644 --- a/src/gui/windows/charcreatedialog.cpp +++ b/src/gui/windows/charcreatedialog.cpp @@ -227,7 +227,7 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *const parent, mGenderStrip->addButton(_("M"), "m", false); // TRANSLATORS: one char size unknown character gender mGenderStrip->addButton(_("U"), "u", true); - mGenderStrip->setVisible(true); + mGenderStrip->setVisible(Visible_true); add(mGenderStrip); mGenderStrip->setPosition(385, 130); @@ -323,7 +323,7 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *const parent, add(mCancelButton); center(); - setVisible(true); + setVisible(Visible_true); mNameField->requestFocus(); updateHair(); @@ -572,7 +572,7 @@ void CharCreateDialog::setAttributes(const StringVect &labels, updateSliders(); if (!available) { - mAttributesLeft->setVisible(false); + mAttributesLeft->setVisible(Visible_false); h = y; setContentSize(w, h); } diff --git a/src/gui/windows/charselectdialog.cpp b/src/gui/windows/charselectdialog.cpp index c6e040065..5663ab387 100644 --- a/src/gui/windows/charselectdialog.cpp +++ b/src/gui/windows/charselectdialog.cpp @@ -141,7 +141,7 @@ CharSelectDialog::CharSelectDialog(LoginData *const data) : for (int i = 0; i < static_cast<int>(mLoginData->characterSlots); i++) { CharacterDisplay *const character = new CharacterDisplay(this, this); - character->setVisible(false); + character->setVisible(Visible_false); mCharacterEntries.push_back(character); } @@ -188,7 +188,7 @@ CharSelectDialog::~CharSelectDialog() void CharSelectDialog::postInit() { Window::postInit(); - setVisible(true); + setVisible(Visible_true); requestFocus(); #ifdef EATHENA_SUPPORT if (charServerHandler->isNeedCreatePin()) @@ -493,7 +493,7 @@ void CharSelectDialog::attemptCharacterSelect(const int index) if (mLocked || !mCharacterEntries[index]) return; - setVisible(false); + setVisible(Visible_false); if (mCharServerHandler) { mCharServerHandler->chooseCharacter( diff --git a/src/gui/windows/chatwindow.cpp b/src/gui/windows/chatwindow.cpp index 824ba4882..713ad5e53 100644 --- a/src/gui/windows/chatwindow.cpp +++ b/src/gui/windows/chatwindow.cpp @@ -176,7 +176,8 @@ ChatWindow::ChatWindow() : // Add key listener to chat input to be able to respond to up/down mChatInput->addKeyListener(this); mCurHist = mHistory.end(); - mColorPicker->setVisible(config.getBoolValue("showChatColorsList")); + mColorPicker->setVisible(fromBool(config.getBoolValue( + "showChatColorsList"), Visible)); updateTabsMargin(); fillCommands(); @@ -285,13 +286,14 @@ void ChatWindow::adjustTabSize() w -= mEmoteButtonSpacing; y += mEmoteButtonY; mChatInput->setWidth(w); - mChatButton->setVisible(mChatInput->isVisibleLocal()); + mChatButton->setVisible(fromBool(mChatInput->isVisibleLocal(), + Visible)); mChatButton->setPosition(x, y); } else { mChatInput->setWidth(awFrame2); - mChatButton->setVisible(false); + mChatButton->setVisible(Visible_false); } const ChatTab *const tab = getFocused(); @@ -435,7 +437,7 @@ void ChatWindow::action(const ActionEvent &event) // If the chatWindow is shown up because you want to send a message // It should hide now if (mTmpVisible) - setVisible(false); + setVisible(Visible_false); } } else if (eventId == "emote") @@ -496,8 +498,8 @@ void ChatWindow::action(const ActionEvent &event) if (mColorPicker && mColorPicker->isVisibleLocal() != config.getBoolValue("showChatColorsList")) { - mColorPicker->setVisible(config.getBoolValue( - "showChatColorsList")); + mColorPicker->setVisible(fromBool(config.getBoolValue( + "showChatColorsList"), Visible)); } } @@ -506,7 +508,7 @@ bool ChatWindow::requestChatFocus() // Make sure chatWindow is visible if (!isWindowVisible()) { - setVisible(true); + setVisible(Visible_true); /* * This is used to hide chatWindow after sending the message. There is @@ -521,7 +523,7 @@ bool ChatWindow::requestChatFocus() return false; // Give focus to the chat input - mChatInput->processVisible(true); + mChatInput->processVisible(Visible_true); unHideWindow(); mChatInput->requestFocus(); return true; @@ -814,7 +816,7 @@ void ChatWindow::keyPressed(KeyEvent &event) else if (actionId == static_cast<int>(InputAction::GUI_CANCEL) && mChatInput->isVisibleLocal()) { - mChatInput->processVisible(false); + mChatInput->processVisible(Visible_false); } else if (actionId == static_cast<int>(InputAction::CHAT_PREV_HISTORY) && mChatInput->isVisibleLocal()) @@ -1022,7 +1024,7 @@ void ChatWindow::addItemText(const std::string &item) addInputText(text.str()); } -void ChatWindow::setVisible(bool visible) +void ChatWindow::setVisible(Visible visible) { Window::setVisible(visible); diff --git a/src/gui/windows/chatwindow.h b/src/gui/windows/chatwindow.h index e8d920897..a91178a97 100644 --- a/src/gui/windows/chatwindow.h +++ b/src/gui/windows/chatwindow.h @@ -26,6 +26,7 @@ #include "enums/gui/chatmsgtype.h" #include "enums/simpletypes/ignorerecord.h" +#include "enums/simpletypes/visible.h" #include "enums/simpletypes/tryremovecolors.h" #include "gui/widgets/window.h" @@ -156,7 +157,7 @@ class ChatWindow final : public Window, void addItemText(const std::string &item); /** Override to reset mTmpVisible */ - void setVisible(bool visible) override final; + void setVisible(Visible visible) override final; /** * Handles mouse when dragged. diff --git a/src/gui/windows/confirmdialog.cpp b/src/gui/windows/confirmdialog.cpp index 4298598d2..5b2ab5de0 100644 --- a/src/gui/windows/confirmdialog.cpp +++ b/src/gui/windows/confirmdialog.cpp @@ -105,7 +105,7 @@ void ConfirmDialog::postInit() center(); getParent()->moveToTop(this); } - setVisible(true); + setVisible(Visible_true); yesButton->requestFocus(); } diff --git a/src/gui/windows/connectiondialog.cpp b/src/gui/windows/connectiondialog.cpp index d7d099d38..4ccab789f 100644 --- a/src/gui/windows/connectiondialog.cpp +++ b/src/gui/windows/connectiondialog.cpp @@ -64,7 +64,7 @@ ConnectionDialog::ConnectionDialog(const std::string &text, void ConnectionDialog::postInit() { Window::postInit(); - setVisible(true); + setVisible(Visible_true); } void ConnectionDialog::action(const ActionEvent &) diff --git a/src/gui/windows/didyouknowwindow.cpp b/src/gui/windows/didyouknowwindow.cpp index 2916ad90c..ce078f8dd 100644 --- a/src/gui/windows/didyouknowwindow.cpp +++ b/src/gui/windows/didyouknowwindow.cpp @@ -112,7 +112,7 @@ void DidYouKnowWindow::action(const ActionEvent &event) const std::string &eventId = event.getId(); if (eventId == "close") { - setVisible(false); + setVisible(Visible_false); } else { @@ -177,10 +177,10 @@ void DidYouKnowWindow::loadFile(const int num) mBrowserBox->addRow(lines[i]); } -void DidYouKnowWindow::setVisible(bool visible) +void DidYouKnowWindow::setVisible(Visible visible) { Window::setVisible(visible); - if (visible || isWindowVisible()) + if (visible == Visible_true || isWindowVisible()) loadData(); } diff --git a/src/gui/windows/didyouknowwindow.h b/src/gui/windows/didyouknowwindow.h index 9d84a8256..4de462e97 100644 --- a/src/gui/windows/didyouknowwindow.h +++ b/src/gui/windows/didyouknowwindow.h @@ -23,6 +23,8 @@ #ifndef GUI_WINDOWS_DIDYOUKNOWWINDOW_H #define GUI_WINDOWS_DIDYOUKNOWWINDOW_H +#include "enums/simpletypes/visible.h" + #include "gui/widgets/linkhandler.h" #include "gui/widgets/window.h" @@ -63,7 +65,7 @@ class DidYouKnowWindow final : public Window, void loadData(int num = 0); - void setVisible(bool visible) override final; + void setVisible(Visible visible) override final; private: void loadFile(const int num); diff --git a/src/gui/windows/editdialog.cpp b/src/gui/windows/editdialog.cpp index 81710f06b..b18b5f23d 100644 --- a/src/gui/windows/editdialog.cpp +++ b/src/gui/windows/editdialog.cpp @@ -64,7 +64,7 @@ void EditDialog::postInit() add(okButton); center(); - setVisible(true); + setVisible(Visible_true); okButton->requestFocus(); } diff --git a/src/gui/windows/editserverdialog.cpp b/src/gui/windows/editserverdialog.cpp index 5f22a5389..0d1ed392f 100644 --- a/src/gui/windows/editserverdialog.cpp +++ b/src/gui/windows/editserverdialog.cpp @@ -190,7 +190,7 @@ EditServerDialog::~EditServerDialog() void EditServerDialog::postInit() { Window::postInit(); - setVisible(true); + setVisible(Visible_true); mNameField->requestFocus(); } diff --git a/src/gui/windows/emotewindow.cpp b/src/gui/windows/emotewindow.cpp index 2ab84819a..1734333e0 100644 --- a/src/gui/windows/emotewindow.cpp +++ b/src/gui/windows/emotewindow.cpp @@ -145,12 +145,12 @@ EmoteWindow::~EmoteWindow() void EmoteWindow::show() { - setVisible(true); + setVisible(Visible_true); } void EmoteWindow::hide() { - setVisible(false); + setVisible(Visible_false); } std::string EmoteWindow::getSelectedEmote() const @@ -170,7 +170,7 @@ void EmoteWindow::clearEmote() const int index = mEmotePage->getSelectedIndex(); mEmotePage->resetAction(); if (index >= 0) - setVisible(false); + setVisible(Visible_false); } std::string EmoteWindow::getSelectedColor() const @@ -188,7 +188,7 @@ std::string EmoteWindow::getSelectedColor() const void EmoteWindow::clearColor() { mColorPage->resetAction(); - setVisible(false); + setVisible(Visible_false); } std::string EmoteWindow::getSelectedFont() const @@ -206,7 +206,7 @@ std::string EmoteWindow::getSelectedFont() const void EmoteWindow::clearFont() { mFontPage->setSelected(-1); - setVisible(false); + setVisible(Visible_false); } void EmoteWindow::addListeners(ActionListener *const listener) diff --git a/src/gui/windows/equipmentwindow.cpp b/src/gui/windows/equipmentwindow.cpp index d569c3cc2..a847c3fff 100644 --- a/src/gui/windows/equipmentwindow.cpp +++ b/src/gui/windows/equipmentwindow.cpp @@ -389,9 +389,9 @@ void EquipmentWindow::action(const ActionEvent &event) void EquipmentWindow::updatePage() { EquipmentPage *const page = mPages[mSelectedTab]; - const bool visible = page->showPlayerBox; + const Visible visible = fromBool(page->showPlayerBox, Visible); mPlayerBox->setVisible(visible); - if (visible) + if (visible == Visible_true) { mPlayerBox->setDimension(Rect(page->x, page->y, page->width, page->height)); @@ -474,7 +474,7 @@ void EquipmentWindow::mousePressed(MouseEvent& event) if (Item *const item = getItem(x, y)) { if (itemPopup) - itemPopup->setVisible(false); + itemPopup->setVisible(Visible_false); /* Convert relative to the window coordinates to absolute screen * coordinates. @@ -575,7 +575,7 @@ void EquipmentWindow::mouseMoved(MouseEvent &event) } else { - itemPopup->setVisible(false); + itemPopup->setVisible(Visible_false); } } @@ -583,7 +583,7 @@ void EquipmentWindow::mouseMoved(MouseEvent &event) void EquipmentWindow::mouseExited(MouseEvent &event A_UNUSED) { if (itemPopup) - itemPopup->setVisible(false); + itemPopup->setVisible(Visible_false); } void EquipmentWindow::setSelected(const int index) @@ -593,7 +593,7 @@ void EquipmentWindow::setSelected(const int index) if (mUnequip) mUnequip->setEnabled(mSelected != -1); if (itemPopup) - itemPopup->setVisible(false); + itemPopup->setVisible(Visible_false); } void EquipmentWindow::setBeing(Being *const being) diff --git a/src/gui/windows/helpwindow.cpp b/src/gui/windows/helpwindow.cpp index 2a5c7b943..0d65582a9 100644 --- a/src/gui/windows/helpwindow.cpp +++ b/src/gui/windows/helpwindow.cpp @@ -124,7 +124,7 @@ void HelpWindow::loadHelp(const std::string &helpFile) loadFile(helpFile); loadFile("footer"); mScrollArea->setVerticalScrollAmount(0); - setVisible(true); + setVisible(Visible_true); } void HelpWindow::loadFile(std::string file) @@ -189,7 +189,7 @@ void HelpWindow::search(const std::string &text0) } loadFile("footer"); mScrollArea->setVerticalScrollAmount(0); - setVisible(true); + setVisible(Visible_true); } } } diff --git a/src/gui/windows/inventorywindow.cpp b/src/gui/windows/inventorywindow.cpp index 11ca2e359..6094ffc91 100644 --- a/src/gui/windows/inventorywindow.cpp +++ b/src/gui/windows/inventorywindow.cpp @@ -348,7 +348,7 @@ void InventoryWindow::postInit() mItems->setSortType(mSortDropDown->getSelected()); widgetResized(Event(nullptr)); if (mInventory && mInventory->getType() == InventoryType::STORAGE) - setVisible(true); + setVisible(Visible_true); } InventoryWindow::~InventoryWindow() @@ -541,7 +541,7 @@ void InventoryWindow::widgetHidden(const Event &event) { Window::widgetHidden(event); if (itemPopup) - itemPopup->setVisible(false); + itemPopup->setVisible(Visible_false); } void InventoryWindow::mouseClicked(MouseEvent &event) @@ -788,7 +788,7 @@ void InventoryWindow::updateButtons(const Item *item) } } -void InventoryWindow::setSplitAllowed(const bool allowed) +void InventoryWindow::setSplitAllowed(const Visible allowed) { if (mSplitButton) mSplitButton->setVisible(allowed); @@ -808,7 +808,7 @@ void InventoryWindow::close() #ifdef EATHENA_SUPPORT case InventoryType::CART: #endif - setVisible(false); + setVisible(Visible_false); break; case InventoryType::STORAGE: @@ -973,7 +973,7 @@ void InventoryWindow::widgetResized(const Event &event) { if (!mCompactMode) { - mNameFilter->setVisible(false); + mNameFilter->setVisible(Visible_false); mNameFilterCell->setType(LayoutCell::NONE); mFilterCell->setWidth(mFilterCell->getWidth() + 3); mCompactMode = true; @@ -981,16 +981,16 @@ void InventoryWindow::widgetResized(const Event &event) } else if (mCompactMode) { - mNameFilter->setVisible(true); + mNameFilter->setVisible(Visible_true); mNameFilterCell->setType(LayoutCell::WIDGET); mFilterCell->setWidth(mFilterCell->getWidth() - 3); mCompactMode = false; } } -void InventoryWindow::setVisible(bool visible) +void InventoryWindow::setVisible(Visible visible) { - if (!visible) + if (visible == Visible_false) mSortDropDown->hideDrop(); Window::setVisible(visible); } diff --git a/src/gui/windows/inventorywindow.h b/src/gui/windows/inventorywindow.h index 209e9c171..eb82b0fb5 100644 --- a/src/gui/windows/inventorywindow.h +++ b/src/gui/windows/inventorywindow.h @@ -25,6 +25,8 @@ #include "inventory.h" +#include "enums/simpletypes/visible.h" + #include "gui/widgets/window.h" #include "listeners/actionlistener.h" @@ -122,7 +124,7 @@ class InventoryWindow final : public Window, /** * Sets whether the split button should be shown. */ - void setSplitAllowed(const bool allowed); + void setSplitAllowed(const Visible allowed); /** * Closes the Storage Window, as well as telling the server that the @@ -153,7 +155,7 @@ class InventoryWindow final : public Window, void mouseExited(MouseEvent &event) override final; - void setVisible(bool visible) override final; + void setVisible(Visible visible) override final; void unsetInventory(); diff --git a/src/gui/windows/itemamountwindow.cpp b/src/gui/windows/itemamountwindow.cpp index 6b547c46b..61e48ab5f 100644 --- a/src/gui/windows/itemamountwindow.cpp +++ b/src/gui/windows/itemamountwindow.cpp @@ -285,7 +285,7 @@ ItemAmountWindow::ItemAmountWindow(const Usage usage, Window *const parent, void ItemAmountWindow::postInit() { Window::postInit(); - setVisible(mItem); + setVisible(fromBool(mItem, Visible)); } ItemAmountWindow::~ItemAmountWindow() @@ -311,7 +311,7 @@ void ItemAmountWindow::mouseMoved(MouseEvent &event) void ItemAmountWindow::mouseExited(MouseEvent &event A_UNUSED) { if (itemPopup) - itemPopup->setVisible(false); + itemPopup->setVisible(Visible_false); } void ItemAmountWindow::resetAmount() diff --git a/src/gui/windows/logindialog.cpp b/src/gui/windows/logindialog.cpp index 47b2ae447..644c9f2ad 100644 --- a/src/gui/windows/logindialog.cpp +++ b/src/gui/windows/logindialog.cpp @@ -132,7 +132,7 @@ LoginDialog::LoginDialog(LoginData *const data, | UpdateType::Custom) ^ UpdateType::Custom); if (!mCustomUpdateHost->isSelected()) - mUpdateHostText->setVisible(false); + mUpdateHostText->setVisible(Visible_false); mUserField->setActionEventId("login"); mPassField->setActionEventId("login"); @@ -170,7 +170,7 @@ LoginDialog::LoginDialog(LoginData *const data, void LoginDialog::postInit() { Window::postInit(); - setVisible(true); + setVisible(Visible_true); const int h = 200; if (mUpdateHostLabel) @@ -234,12 +234,13 @@ void LoginDialog::action(const ActionEvent &event) } else if (eventId == "customhost") { - mUpdateHostText->setVisible(mCustomUpdateHost->isSelected()); + mUpdateHostText->setVisible(fromBool( + mCustomUpdateHost->isSelected(), Visible)); } else if (eventId == "updateselect") { mCustomUpdateHost->setSelected(false); - mUpdateHostText->setVisible(false); + mUpdateHostText->setVisible(Visible_false); } } diff --git a/src/gui/windows/maileditwindow.cpp b/src/gui/windows/maileditwindow.cpp index f7ea62b22..74b214eb2 100644 --- a/src/gui/windows/maileditwindow.cpp +++ b/src/gui/windows/maileditwindow.cpp @@ -77,7 +77,7 @@ MailEditWindow::MailEditWindow() : setCloseButton(true); setSaveVisible(false); setStickyButtonLock(true); - setVisible(true); + setVisible(Visible_true); setDefaultSize(380, 200, ImageRect::CENTER); setMinWidth(200); diff --git a/src/gui/windows/mailviewwindow.cpp b/src/gui/windows/mailviewwindow.cpp index 023ea925a..5aed6d5e2 100644 --- a/src/gui/windows/mailviewwindow.cpp +++ b/src/gui/windows/mailviewwindow.cpp @@ -82,7 +82,7 @@ MailViewWindow::MailViewWindow(const MailMessage *const message) : setResizable(true); setSaveVisible(false); setStickyButtonLock(true); - setVisible(true); + setVisible(Visible_true); setDefaultSize(380, 230, ImageRect::CENTER); setMinWidth(200); diff --git a/src/gui/windows/minimap.cpp b/src/gui/windows/minimap.cpp index 6b2a8547a..279b3e840 100644 --- a/src/gui/windows/minimap.cpp +++ b/src/gui/windows/minimap.cpp @@ -83,7 +83,7 @@ Minimap::Minimap() : setSticky(false); loadWindowState(); - setVisible(mShow, isSticky()); + setVisible(fromBool(mShow, Visible), isSticky()); enableVisibleSound(true); } @@ -134,7 +134,7 @@ void Minimap::setMap(const Map *const map) if (!surface) { if (!isSticky()) - setVisible(false); + setVisible(Visible_false); BLOCK_END("Minimap::setMap") return; } @@ -145,7 +145,7 @@ void Minimap::setMap(const Map *const map) if (!data) { if (!isSticky()) - setVisible(false); + setVisible(Visible_false); BLOCK_END("Minimap::setMap") return; } @@ -218,19 +218,19 @@ void Minimap::setMap(const Map *const map) resetToDefaultSize(); if (mShow) - setVisible(true); + setVisible(Visible_true); } else { if (!isSticky()) - setVisible(false); + setVisible(Visible_false); } BLOCK_END("Minimap::setMap") } void Minimap::toggle() { - setVisible(!isWindowVisible(), isSticky()); + setVisible(fromBool(!isWindowVisible(), Visible), isSticky()); mShow = isWindowVisible(); } diff --git a/src/gui/windows/ministatuswindow.cpp b/src/gui/windows/ministatuswindow.cpp index b7e8e6430..80adb129c 100644 --- a/src/gui/windows/ministatuswindow.cpp +++ b/src/gui/windows/ministatuswindow.cpp @@ -138,7 +138,7 @@ MiniStatusWindow::MiniStatusWindow() : loadBars(); updateBars(); - setVisible(true); + setVisible(Visible_true); addMouseListener(this); Inventory *const inv = PlayerInfo::getInventory(); if (inv) @@ -468,7 +468,8 @@ void MiniStatusWindow::mouseExited(MouseEvent &event) mStatusPopup->hide(); } -void MiniStatusWindow::showBar(const std::string &name, const bool visible) +void MiniStatusWindow::showBar(const std::string &name, + const Visible visible) { ProgressBar *const bar = mBarNames[name]; if (!bar) @@ -483,17 +484,17 @@ void MiniStatusWindow::loadBars() if (!config.getIntValue("ministatussaved")) { if (mWeightBar) - mWeightBar->setVisible(false); + mWeightBar->setVisible(Visible_false); if (mInvSlotsBar) - mInvSlotsBar->setVisible(false); + mInvSlotsBar->setVisible(Visible_false); if (mMoneyBar) - mMoneyBar->setVisible(false); + mMoneyBar->setVisible(Visible_false); if (mArrowsBar) - mArrowsBar->setVisible(false); + mArrowsBar->setVisible(Visible_false); if (mStatusBar) - mStatusBar->setVisible(false); + mStatusBar->setVisible(Visible_false); if (mJobBar) - mJobBar->setVisible(true); + mJobBar->setVisible(Visible_true); return; } @@ -506,7 +507,7 @@ void MiniStatusWindow::loadBars() ProgressBar *const bar = mBarNames[str]; if (!bar) continue; - bar->setVisible(false); + bar->setVisible(Visible_false); } } diff --git a/src/gui/windows/ministatuswindow.h b/src/gui/windows/ministatuswindow.h index 8d46fbdf9..d31783b63 100644 --- a/src/gui/windows/ministatuswindow.h +++ b/src/gui/windows/ministatuswindow.h @@ -23,6 +23,8 @@ #ifndef GUI_WINDOWS_MINISTATUSWINDOW_H #define GUI_WINDOWS_MINISTATUSWINDOW_H +#include "enums/simpletypes/visible.h" + #include "listeners/arrowslistener.h" #include "listeners/attributelistener.h" #include "listeners/inventorylistener.h" @@ -79,7 +81,7 @@ class MiniStatusWindow final : public Window, void mouseExited(MouseEvent &event) override final; - void showBar(const std::string &name, const bool visible); + void showBar(const std::string &name, const Visible visible); void updateBars(); diff --git a/src/gui/windows/npcdialog.cpp b/src/gui/windows/npcdialog.cpp index 83a6e42b1..2c7c27f57 100644 --- a/src/gui/windows/npcdialog.cpp +++ b/src/gui/windows/npcdialog.cpp @@ -171,9 +171,9 @@ NpcDialog::NpcDialog(const int npcId) : setContentSize(260, 175); mListScrollArea->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER); mItemScrollArea->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER); - mItemList->setVisible(true); - mTextField->setVisible(true); - mIntField->setVisible(true); + mItemList->setVisible(Visible_true); + mTextField->setVisible(Visible_true); + mIntField->setVisible(Visible_true); const Font *const fnt = mButton->getFont(); int width = std::max(fnt->getWidth(CAPTION_WAITING), @@ -194,7 +194,7 @@ NpcDialog::NpcDialog(const int npcId) : void NpcDialog::postInit() { Window::postInit(); - setVisible(true); + setVisible(Visible_true); requestFocus(); enableVisibleSound(true); soundManager.playGuiSound(SOUND_SHOW_WINDOW); @@ -646,11 +646,11 @@ void NpcDialog::move(const int amount) } } -void NpcDialog::setVisible(bool visible) +void NpcDialog::setVisible(Visible visible) { Window::setVisible(visible); - if (!visible) + if (visible == Visible_false) scheduleDelete(); } diff --git a/src/gui/windows/npcdialog.h b/src/gui/windows/npcdialog.h index c74721b87..0ed4096e8 100644 --- a/src/gui/windows/npcdialog.h +++ b/src/gui/windows/npcdialog.h @@ -23,6 +23,8 @@ #ifndef GUI_WINDOWS_NPCDIALOG_H #define GUI_WINDOWS_NPCDIALOG_H +#include "enums/simpletypes/visible.h" + #include "gui/models/extendedlistmodel.h" #include "gui/widgets/window.h" @@ -162,7 +164,7 @@ class NpcDialog final : public Window, void move(const int amount); - void setVisible(bool visible) override final; + void setVisible(Visible visible) override final; void optionChanged(const std::string &name) override final; diff --git a/src/gui/windows/okdialog.cpp b/src/gui/windows/okdialog.cpp index 1a6c0c3c8..cdd73acc6 100644 --- a/src/gui/windows/okdialog.cpp +++ b/src/gui/windows/okdialog.cpp @@ -78,7 +78,7 @@ OkDialog::OkDialog(const std::string &restrict title, else centerHorisontally(); // +++ virtual method call - setVisible(true); + setVisible(Visible_true); okButton->requestFocus(); if (soundEvent == DialogType::OK) diff --git a/src/gui/windows/questswindow.cpp b/src/gui/windows/questswindow.cpp index 3a7fd8acc..9279220ac 100644 --- a/src/gui/windows/questswindow.cpp +++ b/src/gui/windows/questswindow.cpp @@ -272,7 +272,7 @@ void QuestsWindow::action(const ActionEvent &event) } else if (eventId == "close") { - setVisible(false); + setVisible(Visible_false); } } diff --git a/src/gui/windows/quitdialog.cpp b/src/gui/windows/quitdialog.cpp index 8af4db969..c605b7796 100644 --- a/src/gui/windows/quitdialog.cpp +++ b/src/gui/windows/quitdialog.cpp @@ -122,7 +122,7 @@ void QuitDialog::postInit() { Window::postInit(); setLocationRelativeTo(getParent()); - setVisible(true); + setVisible(Visible_true); soundManager.playGuiSound(SOUND_SHOW_WINDOW); requestModalFocus(); mOkButton->requestFocus(); diff --git a/src/gui/windows/registerdialog.cpp b/src/gui/windows/registerdialog.cpp index 021ebb938..14a7d61f5 100644 --- a/src/gui/windows/registerdialog.cpp +++ b/src/gui/windows/registerdialog.cpp @@ -148,7 +148,7 @@ RegisterDialog::RegisterDialog(LoginData *const data) : void RegisterDialog::postInit() { Window::postInit(); - setVisible(true); + setVisible(Visible_true); mUserField->requestFocus(); mUserField->setCaretPosition(static_cast<unsigned>( mUserField->getText().length())); diff --git a/src/gui/windows/serverdialog.cpp b/src/gui/windows/serverdialog.cpp index 30b1f312d..4dc0d5fc0 100644 --- a/src/gui/windows/serverdialog.cpp +++ b/src/gui/windows/serverdialog.cpp @@ -193,7 +193,7 @@ ServerDialog::ServerDialog(ServerInfo *const serverInfo, void ServerDialog::postInit() { Window::postInit(); - setVisible(true); + setVisible(Visible_true); mConnectButton->requestFocus(); diff --git a/src/gui/windows/setupwindow.cpp b/src/gui/windows/setupwindow.cpp index f5832320f..8dabbc36f 100644 --- a/src/gui/windows/setupwindow.cpp +++ b/src/gui/windows/setupwindow.cpp @@ -174,7 +174,7 @@ void SetupWindow::action(const ActionEvent &event) if (eventId == "Apply") { - setVisible(false); + setVisible(Visible_false); for_each(mTabs.begin(), mTabs.end(), std::mem_fun(&SetupTab::apply)); } else if (eventId == "Cancel") @@ -274,14 +274,14 @@ void SetupWindow::hideWindows() { Window *const window = *it; if (window && !window->isSticky()) - window->setVisible(false); + window->setVisible(Visible_false); } - setVisible(false); + setVisible(Visible_false); } void SetupWindow::doCancel() { - setVisible(false); + setVisible(Visible_false); for_each(mTabs.begin(), mTabs.end(), std::mem_fun(&SetupTab::cancel)); } @@ -291,9 +291,9 @@ void SetupWindow::activateTab(const std::string &name) mPanel->setSelectedTabByName(tmp); } -void SetupWindow::setVisible(bool visible) +void SetupWindow::setVisible(Visible visible) { - touchManager.setTempHide(visible); + touchManager.setTempHide(visible == Visible_true); Window::setVisible(visible); } diff --git a/src/gui/windows/setupwindow.h b/src/gui/windows/setupwindow.h index a21341cec..de274281f 100644 --- a/src/gui/windows/setupwindow.h +++ b/src/gui/windows/setupwindow.h @@ -23,6 +23,8 @@ #ifndef GUI_WINDOWS_SETUPWINDOW_H #define GUI_WINDOWS_SETUPWINDOW_H +#include "enums/simpletypes/visible.h" + #include "gui/widgets/window.h" #include "listeners/actionlistener.h" @@ -71,7 +73,7 @@ class SetupWindow final : public Window, void activateTab(const std::string &name); - void setVisible(bool visible) override final; + void setVisible(Visible visible) override final; void widgetResized(const Event &event) override final; diff --git a/src/gui/windows/shopwindow.cpp b/src/gui/windows/shopwindow.cpp index b173da568..ae5de90a1 100644 --- a/src/gui/windows/shopwindow.cpp +++ b/src/gui/windows/shopwindow.cpp @@ -224,7 +224,7 @@ ShopWindow::ShopWindow() : void ShopWindow::postInit() { Window::postInit(); - setVisible(false); + setVisible(Visible_false); enableVisibleSound(true); updateSelection(); } @@ -469,7 +469,7 @@ void ShopWindow::updateButtonsAndLabels() mRenameButton->setEnabled(!mEnableVending); } -void ShopWindow::setVisible(bool visible) +void ShopWindow::setVisible(Visible visible) { Window::setVisible(visible); } diff --git a/src/gui/windows/shopwindow.h b/src/gui/windows/shopwindow.h index 09b7da951..9a2074cf2 100644 --- a/src/gui/windows/shopwindow.h +++ b/src/gui/windows/shopwindow.h @@ -23,6 +23,8 @@ #ifndef GUI_WINDOWS_SHOPWINDOW_H #define GUI_WINDOWS_SHOPWINDOW_H +#include "enums/simpletypes/visible.h" + #include "gui/widgets/window.h" #include "listeners/actionlistener.h" @@ -97,7 +99,7 @@ class ShopWindow final : public Window, /** * Sets the visibility of this window. */ - void setVisible(bool visible) override final; + void setVisible(Visible visible) override final; /** * Returns true if any instances exist. diff --git a/src/gui/windows/skilldialog.cpp b/src/gui/windows/skilldialog.cpp index 22f673a13..6617c200c 100644 --- a/src/gui/windows/skilldialog.cpp +++ b/src/gui/windows/skilldialog.cpp @@ -165,7 +165,7 @@ void SkillDialog::action(const ActionEvent &event) } else if (eventId == "close") { - setVisible(false); + setVisible(Visible_false); } } @@ -242,8 +242,8 @@ void SkillDialog::hideSkills(const SkillOwner::Type owner) if (info && info->owner == owner) { PlayerInfo::setSkillLevel(info->id, 0); - if (!info->alwaysVisible) - info->visible = false; + if (info->alwaysVisible == Visible_false) + info->visible = Visible_false; } } } @@ -324,8 +324,8 @@ void SkillDialog::loadXmlFile(const std::string &fileName) node, "owner", "player")); skill->errorText = XML::getProperty( node, "errorText", name); - skill->alwaysVisible = XML::getBoolProperty( - node, "alwaysVisible", false); + skill->alwaysVisible = fromBool(XML::getBoolProperty( + node, "alwaysVisible", false), Visible); skill->castingSrcEffectId = XML::getProperty( node, "castingSrcEffectId", -1); skill->castingDstEffectId = XML::getProperty( @@ -336,7 +336,7 @@ void SkillDialog::loadXmlFile(const std::string &fileName) } std::string icon = XML::getProperty(node, "icon", ""); - const int level = skill->alwaysVisible + const int level = (skill->alwaysVisible == Visible_true) ? 0 : XML::getProperty(node, "level", 0); SkillData *data = skill->getData(level); if (!data) @@ -414,8 +414,8 @@ void SkillDialog::removeSkill(const int id) info->level = 0; info->update(); PlayerInfo::setSkillLevel(id, 0); - if (!info->alwaysVisible) - info->visible = false; + if (info->alwaysVisible == Visible_false) + info->visible = Visible_false; } } } @@ -474,8 +474,8 @@ void SkillDialog::addSkill(const SkillOwner::Type owner, data->setIcon(""); data->shortName = toString(skill->id); skill->modifiable = modifiable; - skill->visible = false; - skill->alwaysVisible = false; + skill->visible = Visible_false; + skill->alwaysVisible = Visible_false; skill->model = mDefaultModel; skill->level = level; // TRANSLATORS: skills dialog. skill level diff --git a/src/gui/windows/socialwindow.cpp b/src/gui/windows/socialwindow.cpp index 4f453e576..5889041e7 100644 --- a/src/gui/windows/socialwindow.cpp +++ b/src/gui/windows/socialwindow.cpp @@ -97,7 +97,7 @@ void SocialWindow::postInit() { Window::postInit(); setWindowName("Social"); - setVisible(false); + setVisible(Visible_false); setSaveVisible(true); setResizable(true); setSaveVisible(true); diff --git a/src/gui/windows/textcommandeditor.cpp b/src/gui/windows/textcommandeditor.cpp index 3051d4cc6..fdffe0e75 100644 --- a/src/gui/windows/textcommandeditor.cpp +++ b/src/gui/windows/textcommandeditor.cpp @@ -129,9 +129,9 @@ TextCommandEditor::TextCommandEditor(TextCommand *const command) : mDeleteButton->adjustSize(); if (command->getCommandType() == TEXT_COMMAND_MAGIC) - showControls(true); + showControls(Visible_true); else - showControls(false); + showControls(Visible_false); mSymbolTextField->setText(command->getSymbol()); mCommandTextField->setText(command->getCommand()); @@ -188,7 +188,7 @@ void TextCommandEditor::postInit() { Window::postInit(); enableVisibleSound(true); - setVisible(true); + setVisible(Visible_true); } TextCommandEditor::~TextCommandEditor() @@ -204,12 +204,12 @@ void TextCommandEditor::action(const ActionEvent &event) if (eventId == "magic") { mIsMagicCommand = true; - showControls(true); + showControls(Visible_true); } else if (eventId == "other") { mIsMagicCommand = false; - showControls(false); + showControls(Visible_false); } else if (eventId == "save") { @@ -227,7 +227,7 @@ void TextCommandEditor::action(const ActionEvent &event) } } -void TextCommandEditor::showControls(const bool show) +void TextCommandEditor::showControls(const Visible show) { mManaField->setVisible(show); mManaLabel->setVisible(show); diff --git a/src/gui/windows/textcommandeditor.h b/src/gui/windows/textcommandeditor.h index 7ee183f30..604971419 100644 --- a/src/gui/windows/textcommandeditor.h +++ b/src/gui/windows/textcommandeditor.h @@ -61,7 +61,7 @@ class TextCommandEditor final : public Window, void scheduleDelete() override final; private: - void showControls(const bool show); + void showControls(const Visible show); void save(); diff --git a/src/gui/windows/textdialog.cpp b/src/gui/windows/textdialog.cpp index a3e9bcc4b..642d574cc 100644 --- a/src/gui/windows/textdialog.cpp +++ b/src/gui/windows/textdialog.cpp @@ -90,7 +90,7 @@ void TextDialog::postInit() setLocationRelativeTo(getParent()); getParent()->moveToTop(this); } - setVisible(true); + setVisible(Visible_true); requestModalFocus(); if (mPasswordField) mPasswordField->requestFocus(); diff --git a/src/gui/windows/tradewindow.cpp b/src/gui/windows/tradewindow.cpp index dfa5b1339..6c48127c5 100644 --- a/src/gui/windows/tradewindow.cpp +++ b/src/gui/windows/tradewindow.cpp @@ -372,7 +372,7 @@ void TradeWindow::action(const ActionEvent &event) if (!inventoryWindow->isWindowVisible()) { - inventoryWindow->setVisible(true); + inventoryWindow->setVisible(Visible_true); return; } @@ -392,7 +392,7 @@ void TradeWindow::action(const ActionEvent &event) } else if (eventId == "cancel") { - setVisible(false); + setVisible(Visible_false); reset(); PlayerInfo::setTrading(Trading_false); tradeHandler->cancel(); diff --git a/src/gui/windows/unregisterdialog.cpp b/src/gui/windows/unregisterdialog.cpp index c8ec421a5..5e8df8298 100644 --- a/src/gui/windows/unregisterdialog.cpp +++ b/src/gui/windows/unregisterdialog.cpp @@ -91,7 +91,7 @@ void UnRegisterDialog::postInit() add(mCancelButton); center(); - setVisible(true); + setVisible(Visible_true); mPasswordField->requestFocus(); mPasswordField->setActionEventId("cancel"); } diff --git a/src/gui/windows/updaterwindow.cpp b/src/gui/windows/updaterwindow.cpp index ffa2aa123..48a3b4ebe 100644 --- a/src/gui/windows/updaterwindow.cpp +++ b/src/gui/windows/updaterwindow.cpp @@ -250,7 +250,7 @@ UpdaterWindow::UpdaterWindow(const std::string &restrict updateHost, void UpdaterWindow::postInit() { Window::postInit(); - setVisible(true); + setVisible(Visible_true); mCancelButton->requestFocus(); removeProtocol(mUpdateServerPath); diff --git a/src/gui/windows/whoisonline.cpp b/src/gui/windows/whoisonline.cpp index fe455c4fd..d0b896041 100644 --- a/src/gui/windows/whoisonline.cpp +++ b/src/gui/windows/whoisonline.cpp @@ -130,7 +130,7 @@ void WhoIsOnline::postInit() const int w = 200; setDefaultSize(w, h, ImageRect::CENTER); - setVisible(false); + setVisible(Visible_false); setCloseButton(true); setResizable(true); setStickyButtonLock(true); diff --git a/src/gui/windows/worldselectdialog.cpp b/src/gui/windows/worldselectdialog.cpp index a592f24ef..73c1a4f4e 100644 --- a/src/gui/windows/worldselectdialog.cpp +++ b/src/gui/windows/worldselectdialog.cpp @@ -89,7 +89,7 @@ WorldSelectDialog::WorldSelectDialog(Worlds worlds) : void WorldSelectDialog::postInit() { Window::postInit(); - setVisible(true); + setVisible(Visible_true); mChooseWorld->requestFocus(); } |