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 | |
parent | 072b727ae4d072d6c84f3331d78ca5a2ac76d271 (diff) | |
download | plus-01a0e4b658241cc3dbd8a5d11d34a6de48dab159.tar.gz plus-01a0e4b658241cc3dbd8a5d11d34a6de48dab159.tar.bz2 plus-01a0e4b658241cc3dbd8a5d11d34a6de48dab159.tar.xz plus-01a0e4b658241cc3dbd8a5d11d34a6de48dab159.zip |
Add strong typed bool type Visible.
98 files changed, 342 insertions, 284 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9d4934b16..b60871194 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1081,6 +1081,7 @@ SET(SRCS enums/simpletypes/tryremovecolors.h enums/simpletypes/useargs.h enums/simpletypes/useresman.h + enums/simpletypes/visible.h statuseffect.cpp statuseffect.h render/surfacegraphics.cpp diff --git a/src/Makefile.am b/src/Makefile.am index e97f60e9e..8464b8222 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1210,6 +1210,7 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ enums/simpletypes/tryremovecolors.h \ enums/simpletypes/useargs.h \ enums/simpletypes/useresman.h \ + enums/simpletypes/visible.h \ statuseffect.cpp \ statuseffect.h \ render/surfacegraphics.cpp \ diff --git a/src/actions/actions.cpp b/src/actions/actions.cpp index aacd40406..a666d01a2 100644 --- a/src/actions/actions.cpp +++ b/src/actions/actions.cpp @@ -341,7 +341,7 @@ impHandler0(ok) // Close the Browser if opened if (helpWindow && helpWindow->isWindowVisible()) { - helpWindow->setVisible(false); + helpWindow->setVisible(Visible_false); return true; } // Close the config window, cancelling changes if opened diff --git a/src/actions/windows.cpp b/src/actions/windows.cpp index 6a917c5b5..bd82521d4 100644 --- a/src/actions/windows.cpp +++ b/src/actions/windows.cpp @@ -76,7 +76,7 @@ impHandler0(setupWindowShow) } else { - setupWindow->setVisible(true); + setupWindow->setVisible(Visible_true); setupWindow->requestMoveToTop(); } return true; @@ -97,7 +97,7 @@ static bool showHelpPage(const std::string &page, const bool showHide) { if (showHide && helpWindow->isWindowVisible()) { - helpWindow->setVisible(false); + helpWindow->setVisible(Visible_false); } else { @@ -151,7 +151,8 @@ static void showHideWindow(Window *const window) { if (window) { - window->setVisible(!window->isWindowVisible()); + window->setVisible(fromBool( + !window->isWindowVisible(), Visible)); if (window->isWindowVisible()) window->requestMoveToTop(); } @@ -318,7 +319,7 @@ impHandler0(quickWindowShow) { setupWindow->doCancel(); } - setupWindow->setVisible(true); + setupWindow->setVisible(Visible_true); setupWindow->activateTab(_("Quick")); setupWindow->requestMoveToTop(); return true; diff --git a/src/being/being.cpp b/src/being/being.cpp index a4ffbbf3f..482dd14eb 100644 --- a/src/being/being.cpp +++ b/src/being/being.cpp @@ -1854,7 +1854,7 @@ void Being::drawSpeech(const int offsetX, const int offsetY) if (mSpeechTime == 0) { if (mSpeechBubble && mSpeechBubble->isVisibleLocal()) - mSpeechBubble->setVisible(false); + mSpeechBubble->setVisible(Visible_false); mSpeech.clear(); } else if (mSpeechTime > 0 && (speech == BeingSpeech::NAME_IN_BUBBLE || @@ -1866,14 +1866,14 @@ void Being::drawSpeech(const int offsetX, const int offsetY) { mSpeechBubble->setPosition(px - (mSpeechBubble->getWidth() / 2), py - getHeight() - (mSpeechBubble->getHeight())); - mSpeechBubble->setVisible(true); + mSpeechBubble->setVisible(Visible_true); mSpeechBubble->requestMoveToBackground(); } } else if (mSpeechTime > 0 && speech == BeingSpeech::TEXT_OVERHEAD) { if (mSpeechBubble) - mSpeechBubble->setVisible(false); + mSpeechBubble->setVisible(Visible_false); if (!mText && userPalette) { @@ -1888,7 +1888,7 @@ void Being::drawSpeech(const int offsetX, const int offsetY) else if (speech == BeingSpeech::NO_SPEECH) { if (mSpeechBubble) - mSpeechBubble->setVisible(false); + mSpeechBubble->setVisible(Visible_false); delete2(mText) } } diff --git a/src/client.cpp b/src/client.cpp index b23ddd11d..bf0bc99ba 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -1452,7 +1452,7 @@ int Client::gameExec() logger->log1("State: CHANGE PASSWORD"); mCurrentDialog = new ChangePasswordDialog(&loginData); mCurrentDialog->postInit(); - mCurrentDialog->setVisible(true); + mCurrentDialog->setVisible(Visible_true); BLOCK_END("Client::gameExec STATE_CHANGEPASSWORD") break; @@ -1492,7 +1492,7 @@ int Client::gameExec() logger->log1("State: CHANGE EMAIL"); mCurrentDialog = new ChangeEmailDialog(&loginData); mCurrentDialog->postInit(); - mCurrentDialog->setVisible(true); + mCurrentDialog->setVisible(Visible_true); break; case STATE_CHANGEEMAIL_ATTEMPT: @@ -1721,7 +1721,8 @@ void Client::action(const ActionEvent &event) if (setupWindow) { - setupWindow->setVisible(!setupWindow->isWindowVisible()); + setupWindow->setVisible(fromBool( + !setupWindow->isWindowVisible(), Visible)); if (setupWindow->isWindowVisible()) { if (!tab.empty()) diff --git a/src/game.cpp b/src/game.cpp index 3a47f0716..12706cdf1 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -192,7 +192,7 @@ static void createGuiWindows() equipmentWindow->postInit(); beingEquipmentWindow = new EquipmentWindow(nullptr, nullptr, true); beingEquipmentWindow->postInit(); - beingEquipmentWindow->setVisible(false); + beingEquipmentWindow->setVisible(Visible_false); statusWindow = new StatusWindow; statusWindow->postInit(); miniStatusWindow = new MiniStatusWindow; @@ -225,7 +225,7 @@ static void createGuiWindows() } if (config.getBoolValue("showDidYouKnow")) { - didYouKnowWindow->setVisible(true); + didYouKnowWindow->setVisible(Visible_true); didYouKnowWindow->loadData(); } diff --git a/src/gui/buttoninfo.h b/src/gui/buttoninfo.h index 7de7375f9..a6c7eb9e0 100644 --- a/src/gui/buttoninfo.h +++ b/src/gui/buttoninfo.h @@ -21,13 +21,15 @@ #ifndef GUI_BUTTONINFO_H #define GUI_BUTTONINFO_H +#include "enums/simpletypes/visible.h" + #include "localconsts.h" class Button; struct ButtonInfo final { - ButtonInfo(Button *const button0, const int key0, const bool visible0) : + ButtonInfo(Button *const button0, const int key0, const Visible visible0) : button(button0), key(key0), visible(visible0) @@ -38,6 +40,6 @@ struct ButtonInfo final Button *button; int key; - bool visible; + Visible visible; }; #endif // GUI_BUTTONINFO_H diff --git a/src/gui/models/skillmodel.cpp b/src/gui/models/skillmodel.cpp index 8bb1bdbf8..ea6781c8d 100644 --- a/src/gui/models/skillmodel.cpp +++ b/src/gui/models/skillmodel.cpp @@ -54,7 +54,7 @@ void SkillModel::updateVisibilities() FOR_EACH (SkillList::const_iterator, it, mSkills) { - if ((*it) && (*it)->visible) + if ((*it) && (*it)->visible == Visible_true) mVisibleSkills.push_back((*it)); } } diff --git a/src/gui/popupmanager.cpp b/src/gui/popupmanager.cpp index d2b1328b9..3749a6502 100644 --- a/src/gui/popupmanager.cpp +++ b/src/gui/popupmanager.cpp @@ -49,19 +49,19 @@ void PopupManager::closePopupMenu() void PopupManager::hideBeingPopup() { if (beingPopup) - beingPopup->setVisible(false); + beingPopup->setVisible(Visible_false); } void PopupManager::hideTextPopup() { if (textPopup) - textPopup->setVisible(false); + textPopup->setVisible(Visible_false); } void PopupManager::hidePopupMenu() { if (popupMenu) - popupMenu->setVisible(false); + popupMenu->setVisible(Visible_false); } bool PopupManager::isPopupMenuVisible() diff --git a/src/gui/popups/beingpopup.cpp b/src/gui/popups/beingpopup.cpp index 16a60150a..167767e74 100644 --- a/src/gui/popups/beingpopup.cpp +++ b/src/gui/popups/beingpopup.cpp @@ -107,7 +107,7 @@ void BeingPopup::show(const int x, const int y, Being *const b) { if (!b) { - setVisible(false); + setVisible(Visible_false); return; } @@ -123,7 +123,7 @@ void BeingPopup::show(const int x, const int y, Being *const b) if (b->getType() == ActorType::Npc && b->getComment().empty()) { - setVisible(false); + setVisible(Visible_false); return; } diff --git a/src/gui/popups/createpartypopup.h b/src/gui/popups/createpartypopup.h index b7f596e36..971c9a2cd 100644 --- a/src/gui/popups/createpartypopup.h +++ b/src/gui/popups/createpartypopup.h @@ -75,7 +75,7 @@ class CreatePartyPopup final : public Popup, socialWindow->showPartyCreate(); } - setVisible(false); + setVisible(Visible_false); } void show(Widget *parent) @@ -87,7 +87,7 @@ class CreatePartyPopup final : public Popup, parent->getAbsolutePosition(x, y); y += parent->getHeight(); setPosition(x, y); - setVisible(true); + setVisible(Visible_true); requestMoveToTop(); } diff --git a/src/gui/popups/itempopup.cpp b/src/gui/popups/itempopup.cpp index ad0628afa..705c7c50f 100644 --- a/src/gui/popups/itempopup.cpp +++ b/src/gui/popups/itempopup.cpp @@ -278,7 +278,7 @@ void ItemPopup::mouseMoved(MouseEvent &event) Popup::mouseMoved(event); // When the mouse moved on top of the popup, hide it - setVisible(false); + setVisible(Visible_false); mLastName.clear(); mLastColor = 1; mLastId = 0; diff --git a/src/gui/popups/popupmenu.cpp b/src/gui/popups/popupmenu.cpp index 7bf1aa5a6..dd48da369 100644 --- a/src/gui/popups/popupmenu.cpp +++ b/src/gui/popups/popupmenu.cpp @@ -939,7 +939,7 @@ void PopupMenu::showChangePos(const int x, const int y) mType = ActorType::Unknown; mX = 0; mY = 0; - setVisible(false); + setVisible(Visible_false); } } @@ -1334,14 +1334,14 @@ void PopupMenu::handleLink(const std::string &link, if (being == localPlayer) { if (equipmentWindow && !equipmentWindow->isWindowVisible()) - equipmentWindow->setVisible(true); + equipmentWindow->setVisible(Visible_true); } else { if (beingEquipmentWindow) { beingEquipmentWindow->setBeing(being); - beingEquipmentWindow->setVisible(true); + beingEquipmentWindow->setVisible(Visible_true); } } } @@ -1503,22 +1503,22 @@ void PopupMenu::handleLink(const std::string &link, else if (!link.compare(0, 12, "hide button_")) { if (windowMenu) - windowMenu->showButton(link.substr(12), false); + windowMenu->showButton(link.substr(12), Visible_false); } else if (!link.compare(0, 12, "show button_")) { if (windowMenu) - windowMenu->showButton(link.substr(12), true); + windowMenu->showButton(link.substr(12), Visible_true); } else if (!link.compare(0, 9, "hide bar_")) { if (miniStatusWindow) - miniStatusWindow->showBar(link.substr(9), false); + miniStatusWindow->showBar(link.substr(9), Visible_false); } else if (!link.compare(0, 9, "show bar_")) { if (miniStatusWindow) - miniStatusWindow->showBar(link.substr(9), true); + miniStatusWindow->showBar(link.substr(9), Visible_false); } else if (!link.compare(0, 12, "show window_")) { @@ -1581,7 +1581,7 @@ void PopupMenu::handleLink(const std::string &link, logger->log("PopupMenu: Warning, unknown action '%s'", link.c_str()); } - setVisible(false); + setVisible(Visible_false); mBeingId = 0; mFloorItemId = 0; @@ -2234,7 +2234,7 @@ void PopupMenu::showPopup(int x, int y) y = mainGraphics->mHeight - getHeight(); mScrollArea->setHeight(height); setPosition(x, y); - setVisible(true); + setVisible(Visible_true); requestMoveToTop(); } diff --git a/src/gui/popups/skillpopup.cpp b/src/gui/popups/skillpopup.cpp index 8a6f26b26..ecd085a99 100644 --- a/src/gui/popups/skillpopup.cpp +++ b/src/gui/popups/skillpopup.cpp @@ -125,6 +125,6 @@ void SkillPopup::mouseMoved(MouseEvent &event) Popup::mouseMoved(event); // When the mouse moved on top of the popup, hide it - setVisible(false); + setVisible(Visible_false); mLastId = 0; } diff --git a/src/gui/popups/spellpopup.cpp b/src/gui/popups/spellpopup.cpp index 8e901cfb9..be741bb32 100644 --- a/src/gui/popups/spellpopup.cpp +++ b/src/gui/popups/spellpopup.cpp @@ -110,7 +110,7 @@ void SpellPopup::view(const int x, const int y) } setPosition(posX, posY); - setVisible(true); + setVisible(Visible_true); requestMoveToTop(); } @@ -119,5 +119,5 @@ void SpellPopup::mouseMoved(MouseEvent &event) Popup::mouseMoved(event); // When the mouse moved on top of the popup, hide it - setVisible(false); + setVisible(Visible_false); } diff --git a/src/gui/popups/statuspopup.cpp b/src/gui/popups/statuspopup.cpp index 17894f04c..f69d72574 100644 --- a/src/gui/popups/statuspopup.cpp +++ b/src/gui/popups/statuspopup.cpp @@ -118,7 +118,7 @@ void StatusPopup::view(const int x, const int y) update(); setPosition(posX, posY); - setVisible(true); + setVisible(Visible_true); requestMoveToTop(); } diff --git a/src/gui/popups/textboxpopup.cpp b/src/gui/popups/textboxpopup.cpp index 1d8d85a14..9006fe49f 100644 --- a/src/gui/popups/textboxpopup.cpp +++ b/src/gui/popups/textboxpopup.cpp @@ -68,7 +68,7 @@ void TextBoxPopup::show(const int x, const int y, const std::string &str) posY = y - rect.height - distance; setPosition(posX, posY); - setVisible(true); + setVisible(Visible_true); requestMoveToTop(); } @@ -77,5 +77,5 @@ void TextBoxPopup::mouseMoved(MouseEvent &event) Popup::mouseMoved(event); // When the mouse moved on top of the popup, hide it - setVisible(false); + setVisible(Visible_false); } diff --git a/src/gui/popups/textpopup.cpp b/src/gui/popups/textpopup.cpp index 8387e394d..511816586 100644 --- a/src/gui/popups/textpopup.cpp +++ b/src/gui/popups/textpopup.cpp @@ -99,7 +99,7 @@ void TextPopup::show(const int x, const int y, const std::string &str1, posY = y - rect.height - distance; setPosition(posX, posY); - setVisible(true); + setVisible(Visible_true); requestMoveToTop(); } @@ -108,5 +108,5 @@ void TextPopup::mouseMoved(MouseEvent &event) Popup::mouseMoved(event); // When the mouse moved on top of the popup, hide it - setVisible(false); + setVisible(Visible_false); } diff --git a/src/gui/widgets/basiccontainer.cpp b/src/gui/widgets/basiccontainer.cpp index e8f29ff9b..bcf30a27f 100644 --- a/src/gui/widgets/basiccontainer.cpp +++ b/src/gui/widgets/basiccontainer.cpp @@ -220,7 +220,7 @@ Widget *BasicContainer::getWidgetAt(int x, int y) void BasicContainer::logic() { BLOCK_START("BasicContainer::logic") - if (!mVisible) + if (mVisible == Visible_false) { BLOCK_END("BasicContainer::logic") return; diff --git a/src/gui/widgets/characterdisplay.cpp b/src/gui/widgets/characterdisplay.cpp index de4b4bc00..df0032990 100644 --- a/src/gui/widgets/characterdisplay.cpp +++ b/src/gui/widgets/characterdisplay.cpp @@ -113,12 +113,12 @@ void CharacterDisplay::update() void CharacterDisplay::widgetHidden(const Event &event A_UNUSED) { - textPopup->setVisible(false); + textPopup->setVisible(Visible_false); } void CharacterDisplay::mouseExited(MouseEvent &event A_UNUSED) { - textPopup->setVisible(false); + textPopup->setVisible(Visible_false); } void CharacterDisplay::mouseMoved(MouseEvent &event A_UNUSED) @@ -140,7 +140,7 @@ void CharacterDisplay::mouseMoved(MouseEvent &event A_UNUSED) } else { - textPopup->setVisible(false); + textPopup->setVisible(Visible_false); } } diff --git a/src/gui/widgets/characterviewnormal.cpp b/src/gui/widgets/characterviewnormal.cpp index a4b9271e3..c28723004 100644 --- a/src/gui/widgets/characterviewnormal.cpp +++ b/src/gui/widgets/characterviewnormal.cpp @@ -41,7 +41,7 @@ CharacterViewNormal::CharacterViewNormal(CharSelectDialog *const widget, { CharacterDisplay *const character = *it; add(character); - character->setVisible(true); + character->setVisible(Visible_true); } const size_t sz = mCharacterEntries->size(); if (mSelected >= 0 && mSelected < static_cast<signed>(sz)) diff --git a/src/gui/widgets/characterviewsmall.cpp b/src/gui/widgets/characterviewsmall.cpp index fd9240936..36749022a 100644 --- a/src/gui/widgets/characterviewsmall.cpp +++ b/src/gui/widgets/characterviewsmall.cpp @@ -52,7 +52,7 @@ CharacterViewSmall::CharacterViewSmall(CharSelectDialog *const widget, { mSelected = 0; mSelectedEntry = (*mCharacterEntries)[mSelected]; - mSelectedEntry->setVisible(true); + mSelectedEntry->setVisible(Visible_true); mNumber->setCaption(strprintf("%d / %d", mSelected + 1, sz)); mNumber->adjustSize(); } @@ -82,7 +82,7 @@ void CharacterViewSmall::show(const int i) if (sz <= 0) return; if (mSelectedEntry) - mSelectedEntry->setVisible(false); + mSelectedEntry->setVisible(Visible_false); if (i >= sz) mSelected = 0; else if (i < 0) @@ -90,7 +90,7 @@ void CharacterViewSmall::show(const int i) else mSelected = i; mSelectedEntry = (*mCharacterEntries)[mSelected]; - mSelectedEntry->setVisible(true); + mSelectedEntry->setVisible(Visible_true); mNumber->setCaption(strprintf("%d / %d", mSelected + 1, sz)); mNumber->adjustSize(); } diff --git a/src/gui/widgets/chatinput.h b/src/gui/widgets/chatinput.h index b1a22d3fb..592299312 100644 --- a/src/gui/widgets/chatinput.h +++ b/src/gui/widgets/chatinput.h @@ -23,6 +23,8 @@ #ifndef GUI_WIDGETS_CHATINPUT_H #define GUI_WIDGETS_CHATINPUT_H +#include "enums/simpletypes/visible.h" + #include "gui/windows/chatwindow.h" #include "configuration.h" @@ -44,7 +46,7 @@ class ChatInput final : public TextField mWindow(window), mFocusGaining(false) { - setVisible(false); + setVisible(Visible_false); addFocusListener(this); } @@ -59,7 +61,7 @@ class ChatInput final : public TextField TextField::focusLost(event); if (mFocusGaining || !config.getBoolValue("protectChatFocus")) { - processVisible(false); + processVisible(Visible_false); if (chatWindow) chatWindow->updateVisibility(); mFocusGaining = false; @@ -70,12 +72,12 @@ class ChatInput final : public TextField mFocusGaining = false; } - void processVisible(const bool n) + void processVisible(const Visible n) { - if (!mWindow || isVisible() == n) + if (!mWindow || isVisible() == (n == Visible_true)) return; - if (!n) + if (n == Visible_false) mFocusGaining = true; setVisible(n); if (config.getBoolValue("hideChatInput") @@ -92,7 +94,7 @@ class ChatInput final : public TextField void unprotectFocus() { mFocusGaining = true; } - void setVisible(bool visible) + void setVisible(Visible visible) { TextField::setVisible(visible); } diff --git a/src/gui/widgets/checkbox.cpp b/src/gui/widgets/checkbox.cpp index 27e7d563b..90192c74a 100644 --- a/src/gui/widgets/checkbox.cpp +++ b/src/gui/widgets/checkbox.cpp @@ -218,7 +218,7 @@ void CheckBox::drawBox(Graphics *const graphics) const ImageRect &rect = mSkin->getBorder(); int index = 0; - if (mEnabled && mVisible) + if (mEnabled && mVisible == Visible_true) { if (mSelected) { diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp index a16381c2a..db5caf6f7 100644 --- a/src/gui/widgets/dropdown.cpp +++ b/src/gui/widgets/dropdown.cpp @@ -373,7 +373,7 @@ void DropDown::hideDrop(bool event) { if (event) distributeActionEvent(); - mPopup->setVisible(false); + mPopup->setVisible(Visible_false); } void DropDown::mousePressed(MouseEvent& event) diff --git a/src/gui/widgets/emoteshortcutcontainer.cpp b/src/gui/widgets/emoteshortcutcontainer.cpp index 97f012e89..05037cd51 100644 --- a/src/gui/widgets/emoteshortcutcontainer.cpp +++ b/src/gui/widgets/emoteshortcutcontainer.cpp @@ -248,7 +248,7 @@ void EmoteShortcutContainer::mouseMoved(MouseEvent &event) if (index == -1) return; - textPopup->setVisible(false); + textPopup->setVisible(Visible_false); if (static_cast<size_t>(index) < mEmoteImg.size() && mEmoteImg[index]) { @@ -261,11 +261,11 @@ void EmoteShortcutContainer::mouseMoved(MouseEvent &event) void EmoteShortcutContainer::mouseExited(MouseEvent &event A_UNUSED) { if (textPopup) - textPopup->setVisible(false); + textPopup->setVisible(Visible_false); } void EmoteShortcutContainer::widgetHidden(const Event &event A_UNUSED) { if (textPopup) - textPopup->setVisible(false); + textPopup->setVisible(Visible_false); } diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp index ee95f1e61..9024f74be 100644 --- a/src/gui/widgets/itemcontainer.cpp +++ b/src/gui/widgets/itemcontainer.cpp @@ -683,13 +683,13 @@ void ItemContainer::mouseMoved(MouseEvent &event) } else { - itemPopup->setVisible(false); + itemPopup->setVisible(Visible_false); } } void ItemContainer::mouseExited(MouseEvent &event A_UNUSED) { - itemPopup->setVisible(false); + itemPopup->setVisible(Visible_false); } void ItemContainer::widgetResized(const Event &event A_UNUSED) diff --git a/src/gui/widgets/itemlinkhandler.cpp b/src/gui/widgets/itemlinkhandler.cpp index 7008602de..70b4e19e5 100644 --- a/src/gui/widgets/itemlinkhandler.cpp +++ b/src/gui/widgets/itemlinkhandler.cpp @@ -116,7 +116,7 @@ void ItemLinkHandler::handleLink(const std::string &link, MouseEvent *event) itemPopup->setItem(itemInfo, color, true); if (itemPopup->isPopupVisible()) { - itemPopup->setVisible(false); + itemPopup->setVisible(Visible_false); } else if (viewport) { diff --git a/src/gui/widgets/itemshortcutcontainer.cpp b/src/gui/widgets/itemshortcutcontainer.cpp index a0c807963..6a2aa4c93 100644 --- a/src/gui/widgets/itemshortcutcontainer.cpp +++ b/src/gui/widgets/itemshortcutcontainer.cpp @@ -545,7 +545,7 @@ void ItemShortcutContainer::mouseMoved(MouseEvent &event) if (itemId < SPELL_MIN_ID) { - spellPopup->setVisible(false); + spellPopup->setVisible(Visible_false); Inventory *const inv = PlayerInfo::getInventory(); if (!inv) @@ -559,12 +559,12 @@ void ItemShortcutContainer::mouseMoved(MouseEvent &event) } else { - itemPopup->setVisible(false); + itemPopup->setVisible(Visible_false); } } else if (itemId < SKILL_MIN_ID && spellManager) { - itemPopup->setVisible(false); + itemPopup->setVisible(Visible_false); const TextCommand *const spell = spellManager->getSpellByItem(itemId); if (spell && viewport) { @@ -573,12 +573,12 @@ void ItemShortcutContainer::mouseMoved(MouseEvent &event) } else { - spellPopup->setVisible(false); + spellPopup->setVisible(Visible_false); } } else if (skillDialog) { - itemPopup->setVisible(false); + itemPopup->setVisible(Visible_false); } } @@ -586,15 +586,15 @@ void ItemShortcutContainer::mouseMoved(MouseEvent &event) void ItemShortcutContainer::mouseExited(MouseEvent &event A_UNUSED) { if (itemPopup) - itemPopup->setVisible(false); + itemPopup->setVisible(Visible_false); if (spellPopup) - spellPopup->setVisible(false); + spellPopup->setVisible(Visible_false); } void ItemShortcutContainer::widgetHidden(const Event &event A_UNUSED) { if (itemPopup) - itemPopup->setVisible(false); + itemPopup->setVisible(Visible_false); if (spellPopup) - spellPopup->setVisible(false); + spellPopup->setVisible(Visible_false); } diff --git a/src/gui/widgets/popup.cpp b/src/gui/widgets/popup.cpp index 1f064329d..181d6a46b 100644 --- a/src/gui/widgets/popup.cpp +++ b/src/gui/widgets/popup.cpp @@ -74,7 +74,7 @@ Popup::Popup(const std::string &name, windowContainer->add(this); // Popups are invisible by default - setVisible(false); + setVisible(Visible_false); } Popup::~Popup() @@ -241,7 +241,7 @@ void Popup::position(const int x, const int y) posY = y - height - distance; setPosition(posX, posY); - setVisible(true); + setVisible(Visible_true); requestMoveToTop(); mRedraw = true; } @@ -258,7 +258,7 @@ void Popup::mouseMoved(MouseEvent &event A_UNUSED) void Popup::hide() { - setVisible(false); + setVisible(Visible_false); mRedraw = true; } diff --git a/src/gui/widgets/popup.h b/src/gui/widgets/popup.h index d1dbb4829..fb00930bb 100644 --- a/src/gui/widgets/popup.h +++ b/src/gui/widgets/popup.h @@ -171,7 +171,7 @@ class Popup notfinal : public Container, void widgetMoved(const Event &event) override final; bool isPopupVisible() const - { return mVisible; } + { return mVisible == Visible_true; } virtual void postInit() { mInit = true; } diff --git a/src/gui/widgets/popuplist.cpp b/src/gui/widgets/popuplist.cpp index d8c1d79dc..17f026388 100644 --- a/src/gui/widgets/popuplist.cpp +++ b/src/gui/widgets/popuplist.cpp @@ -88,7 +88,7 @@ void PopupList::show(int x, int y) if (mainGraphics->mHeight < (y + height + 5)) y = mainGraphics->mHeight - height; setPosition(x, y); - setVisible(true); + setVisible(Visible_true); requestMoveToTop(); if (mModal == Modal_true) requestModalFocus(); @@ -154,7 +154,7 @@ void PopupList::mouseReleased(MouseEvent& event) return; if (mDropDown) mDropDown->updateSelection(); - setVisible(false); + setVisible(Visible_false); if (mModal == Modal_true) releaseModalFocus(); } @@ -162,15 +162,18 @@ void PopupList::mouseReleased(MouseEvent& event) void PopupList::focusGained(const Event& event) { const Widget *const source = event.getSource(); - if (!mVisible || source == this || source == mListBox - || source == mScrollArea || source == mDropDown) + if (mVisible == Visible_false || + source == this || + source == mListBox || + source == mScrollArea || + source == mDropDown) { return; } if (mDropDown) mDropDown->updateSelection(); - setVisible(false); + setVisible(Visible_false); if (mModal == Modal_true) releaseModalFocus(); } diff --git a/src/gui/widgets/radiobutton.cpp b/src/gui/widgets/radiobutton.cpp index 30749da66..f1730b367 100644 --- a/src/gui/widgets/radiobutton.cpp +++ b/src/gui/widgets/radiobutton.cpp @@ -187,7 +187,7 @@ void RadioButton::drawBox(Graphics* graphics) const ImageRect &rect = mSkin->getBorder(); int index = 0; - if (mEnabled && mVisible) + if (mEnabled && mVisible == Visible_true) { if (mSelected) { diff --git a/src/gui/widgets/selldialog.cpp b/src/gui/widgets/selldialog.cpp index 5422ea3b0..3864fd46c 100644 --- a/src/gui/widgets/selldialog.cpp +++ b/src/gui/widgets/selldialog.cpp @@ -159,7 +159,7 @@ void SellDialog::postInit() loadWindowState(); instances.push_back(this); - setVisible(true); + setVisible(Visible_true); enableVisibleSound(true); } @@ -327,11 +327,11 @@ void SellDialog::updateButtonsAndLabels() item->update(); } -void SellDialog::setVisible(bool visible) +void SellDialog::setVisible(Visible visible) { Window::setVisible(visible); - if (visible) + if (visible == Visible_true) { if (mShopItemList) mShopItemList->requestFocus(); diff --git a/src/gui/widgets/selldialog.h b/src/gui/widgets/selldialog.h index 1d0bed7e1..439042a10 100644 --- a/src/gui/widgets/selldialog.h +++ b/src/gui/widgets/selldialog.h @@ -23,6 +23,8 @@ #ifndef GUI_WIDGETS_SELLDIALOG_H #define GUI_WIDGETS_SELLDIALOG_H +#include "enums/simpletypes/visible.h" + #include "gui/widgets/window.h" #include "listeners/actionlistener.h" @@ -88,7 +90,7 @@ class SellDialog notfinal : public Window, /** * Sets the visibility of this window. */ - void setVisible(bool visible) override final; + void setVisible(Visible visible) override final; void addItem(const int id, const int type, diff --git a/src/gui/widgets/shoplistbox.cpp b/src/gui/widgets/shoplistbox.cpp index 63a295c1e..a5e5937ef 100644 --- a/src/gui/widgets/shoplistbox.cpp +++ b/src/gui/widgets/shoplistbox.cpp @@ -223,7 +223,7 @@ void ShopListBox::mouseMoved(MouseEvent &event) } else { - itemPopup->setVisible(false); + itemPopup->setVisible(Visible_false); } } } diff --git a/src/gui/widgets/skillinfo.cpp b/src/gui/widgets/skillinfo.cpp index 80783a4b2..d16994bae 100644 --- a/src/gui/widgets/skillinfo.cpp +++ b/src/gui/widgets/skillinfo.cpp @@ -59,8 +59,8 @@ SkillInfo::SkillInfo() : type(SkillType::Unknown), owner(SkillOwner::Player), modifiable(Modifiable_false), - visible(false), - alwaysVisible(false) + visible(Visible_false), + alwaysVisible(Visible_false) { dataMap[0] = new SkillData(); data = dataMap[0]; @@ -80,17 +80,17 @@ void SkillInfo::update() if (modifiable == Modifiable_false && baseLevel == 0 && exp.second == 0) { - if (visible) + if (visible == Visible_true) { - visible = false; + visible = Visible_false; if (model) model->updateVisibilities(); } return; } - const bool updateVisibility = !visible; - visible = true; + const bool updateVisibility = (visible == Visible_false); + visible = Visible_true; if (baseLevel == 0) { diff --git a/src/gui/widgets/skillinfo.h b/src/gui/widgets/skillinfo.h index 8919ed30a..e2679713d 100644 --- a/src/gui/widgets/skillinfo.h +++ b/src/gui/widgets/skillinfo.h @@ -24,6 +24,7 @@ #define GUI_WIDGETS_SKILLINFO_H #include "enums/simpletypes/modifiable.h" +#include "enums/simpletypes/visible.h" #include "gui/color.h" @@ -69,8 +70,8 @@ struct SkillInfo final SkillType::SkillType type; SkillOwner::Type owner; Modifiable modifiable; - bool visible; - bool alwaysVisible; + Visible visible; + Visible alwaysVisible; SkillInfo(); A_DELETE_COPY(SkillInfo) diff --git a/src/gui/widgets/spellshortcutcontainer.cpp b/src/gui/widgets/spellshortcutcontainer.cpp index 5a0de0995..7971e0d33 100644 --- a/src/gui/widgets/spellshortcutcontainer.cpp +++ b/src/gui/widgets/spellshortcutcontainer.cpp @@ -336,7 +336,7 @@ void SpellShortcutContainer::mouseMoved(MouseEvent &event) return; const int itemId = getItemByIndex(index); - spellPopup->setVisible(false); + spellPopup->setVisible(Visible_false); const TextCommand *const spell = spellManager->getSpell(itemId); if (spell && !spell->isEmpty()) { @@ -345,20 +345,20 @@ void SpellShortcutContainer::mouseMoved(MouseEvent &event) } else { - spellPopup->setVisible(false); + spellPopup->setVisible(Visible_false); } } void SpellShortcutContainer::mouseExited(MouseEvent &event A_UNUSED) { if (spellPopup) - spellPopup->setVisible(false); + spellPopup->setVisible(Visible_false); } void SpellShortcutContainer::widgetHidden(const Event &event A_UNUSED) { if (spellPopup) - spellPopup->setVisible(false); + spellPopup->setVisible(Visible_false); } int SpellShortcutContainer::getItemByIndex(const int index) const diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp index eb70c8012..e00123af6 100644 --- a/src/gui/widgets/tabbedarea.cpp +++ b/src/gui/widgets/tabbedarea.cpp @@ -646,13 +646,13 @@ void TabbedArea::updateArrowEnableState() - mArrowButton[0]->getWidth() - mArrowButton[1]->getWidth() - mRightMargin) { - mArrowButton[0]->setVisible(true); - mArrowButton[1]->setVisible(true); + mArrowButton[0]->setVisible(Visible_true); + mArrowButton[1]->setVisible(Visible_true); } else { - mArrowButton[0]->setVisible(false); - mArrowButton[1]->setVisible(false); + mArrowButton[0]->setVisible(Visible_false); + mArrowButton[1]->setVisible(Visible_false); mTabScrollIndex = 0; } diff --git a/src/gui/widgets/virtshortcutcontainer.cpp b/src/gui/widgets/virtshortcutcontainer.cpp index 138d3f5a6..30dbe3770 100644 --- a/src/gui/widgets/virtshortcutcontainer.cpp +++ b/src/gui/widgets/virtshortcutcontainer.cpp @@ -365,18 +365,18 @@ void VirtShortcutContainer::mouseMoved(MouseEvent &event) } else { - itemPopup->setVisible(false); + itemPopup->setVisible(Visible_false); } } void VirtShortcutContainer::mouseExited(MouseEvent &event A_UNUSED) { if (itemPopup) - itemPopup->setVisible(false); + itemPopup->setVisible(Visible_false); } void VirtShortcutContainer::widgetHidden(const Event &event A_UNUSED) { if (itemPopup) - itemPopup->setVisible(false); + itemPopup->setVisible(Visible_false); } diff --git a/src/gui/widgets/widget.cpp b/src/gui/widgets/widget.cpp index f6f3854f4..3be80c772 100644 --- a/src/gui/widgets/widget.cpp +++ b/src/gui/widgets/widget.cpp @@ -99,7 +99,7 @@ Widget::Widget(const Widget2 *const widget) : mCurrentFont(nullptr), mFrameSize(0), mFocusable(false), - mVisible(true), + mVisible(Visible_true), mTabIn(true), mTabOut(true), mEnabled(true), @@ -217,12 +217,12 @@ void Widget::requestMoveToBottom() mParent->moveToBottom(this); } -void Widget::setVisible(bool visible) +void Widget::setVisible(Visible visible) { - if (!visible && isFocused() && mFocusHandler) + if (visible == Visible_false && isFocused() && mFocusHandler) mFocusHandler->focusNone(); - if (visible) + if (visible == Visible_true) distributeShownEvent(); else distributeHiddenEvent(); diff --git a/src/gui/widgets/widget.h b/src/gui/widgets/widget.h index 2c8c121e0..3abc8d232 100644 --- a/src/gui/widgets/widget.h +++ b/src/gui/widgets/widget.h @@ -64,10 +64,11 @@ #ifndef GUI_WIDGETS_WIDGET_H #define GUI_WIDGETS_WIDGET_H -#include <list> +#include "enums/simpletypes/visible.h" #include "gui/widgets/widget2.h" +#include <list> #include "localconsts.h" class ActionListener; @@ -387,7 +388,7 @@ class Widget notfinal : public Widget2 * @see isVisible * @since 0.1.0 */ - void setVisible(bool visible); + void setVisible(Visible visible); /** * Checks if the widget is visible. @@ -397,10 +398,12 @@ class Widget notfinal : public Widget2 * @since 0.1.0 */ bool isVisible() const A_WARN_UNUSED - { return mVisible && (!mParent || mParent->isVisible()); } + { return mVisible == Visible_true && + (!mParent || mParent->isVisible()); + } bool isVisibleLocal() const A_WARN_UNUSED - { return mVisible; } + { return mVisible == Visible_true; } /** * Sets the base color of the widget. @@ -1216,7 +1219,7 @@ class Widget notfinal : public Widget2 /** * True if the widget visible, false otherwise. */ - bool mVisible; + Visible mVisible; /** * True if the widget has tab in enabled, false otherwise. diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index f4921e7ca..a48b2c062 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -221,7 +221,7 @@ Window::Window(const std::string &caption, } // Windows are invisible by default - setVisible(false); + setVisible(Visible_false); addWidgetListener(this); mForegroundColor = getThemeColor(Theme::WINDOW); @@ -737,27 +737,32 @@ void Window::setStickyButtonLock(const bool lock) mStickyButton = lock; } -void Window::setVisible(bool visible) +void Window::setVisible(Visible visible) { setVisible(visible, false); } -void Window::setVisible(const bool visible, const bool forceSticky) +void Window::setVisible(const Visible visible, const bool forceSticky) { if (visible == mVisible) return; // Check if the window is off screen... - if (visible) + if (visible == Visible_true) ensureOnScreen(); else mResizeHandles = 0; if (mStickyButtonLock) + { BasicContainer2::setVisible(visible); + } else - BasicContainer2::setVisible((!forceSticky && mSticky) || visible); - if (visible) + { + BasicContainer2::setVisible(fromBool((!forceSticky && mSticky) || + visible == Visible_true, Visible)); + } + if (visible == Visible_true) { if (mPlayVisibleSound) soundManager.playGuiSound(SOUND_SHOW_WINDOW); @@ -852,7 +857,7 @@ void Window::mousePressed(MouseEvent &event) void Window::close() { - setVisible(false); + setVisible(Visible_false); } void Window::mouseReleased(MouseEvent &event A_UNUSED) @@ -1044,8 +1049,8 @@ void Window::loadWindowState() if (mSaveVisible) { - setVisible(config.getValueBool(name - + "Visible", mDefaultVisible)); + setVisible(fromBool(config.getValueBool(name + + "Visible", mDefaultVisible), Visible)); } if (mStickyButton) diff --git a/src/gui/widgets/window.h b/src/gui/widgets/window.h index 102aedf73..f6e777e03 100644 --- a/src/gui/widgets/window.h +++ b/src/gui/widgets/window.h @@ -67,6 +67,7 @@ #define GUI_WIDGETS_WINDOW_H #include "enums/simpletypes/modal.h" +#include "enums/simpletypes/visible.h" #include "listeners/mouselistener.h" #include "listeners/widgetlistener.h" @@ -257,13 +258,13 @@ class Window notfinal : public BasicContainer2, * Overloads window setVisible by Guichan to allow sticky window * handling. */ - virtual void setVisible(bool visible); + virtual void setVisible(Visible visible); /** * Overloads window setVisible by Guichan to allow sticky window * handling, or not, if you force the sticky state. */ - void setVisible(const bool visible, const bool forceSticky); + void setVisible(const Visible visible, const bool forceSticky); /** * Returns whether the window is visible by default. @@ -466,7 +467,7 @@ class Window notfinal : public BasicContainer2, { mPlayVisibleSound = b; } bool isWindowVisible() const A_WARN_UNUSED - { return mVisible; } + { return mVisible == Visible_true; } /** * Sets the padding of the window. The padding is the distance between the diff --git a/src/gui/windowmenu.cpp b/src/gui/windowmenu.cpp index 1e1f236df..012fd5a49 100644 --- a/src/gui/windowmenu.cpp +++ b/src/gui/windowmenu.cpp @@ -82,9 +82,9 @@ WindowMenu::WindowMenu(const Widget2 *const widget) : addButton(N_("CH"), _("Chat"), x, h, InputAction::WINDOW_CHAT, #ifdef ANDROID - true); + Visible_true); #else - false); + Visible_false); #endif // TRANSLATORS: short button name for status window. addButton(N_("STA"), @@ -100,7 +100,8 @@ WindowMenu::WindowMenu(const Widget2 *const widget) : _("Cart"), x, h, InputAction::WINDOW_CART); // TRANSLATORS: short button name for map window. addButton(N_("MAP"), - _("Map"), x, h, InputAction::WINDOW_MINIMAP, false); + _("Map"), x, h, InputAction::WINDOW_MINIMAP, + Visible_false); if (skillDialog->hasSkills()) { @@ -124,44 +125,52 @@ WindowMenu::WindowMenu(const Widget2 *const widget) : // TRANSLATORS: short button name for drops window. addButton(N_("DR"), // TRANSLATORS: full button name - _("Drop"), x, h, InputAction::WINDOW_DROP, false); + _("Drop"), x, h, InputAction::WINDOW_DROP, + Visible_false); // TRANSLATORS: short button name for did you know window. addButton(N_("YK"), // TRANSLATORS: full button name - _("Did you know"), x, h, InputAction::WINDOW_DIDYOUKNOW, false); + _("Did you know"), x, h, InputAction::WINDOW_DIDYOUKNOW, + Visible_false); // TRANSLATORS: short button name for shop window. addButton(N_("SHP"), // TRANSLATORS: full button name - _("Shop"), x, h, InputAction::WINDOW_SHOP, false); + _("Shop"), x, h, InputAction::WINDOW_SHOP, + Visible_false); // TRANSLATORS: short button name for outfits window. addButton(N_("OU"), // TRANSLATORS: full button name - _("Outfits"), x, h, InputAction::WINDOW_OUTFIT, false); + _("Outfits"), x, h, InputAction::WINDOW_OUTFIT, + Visible_false); // TRANSLATORS: short button name for updates window. addButton(N_("UP"), // TRANSLATORS: full button name - _("Updates"), x, h, InputAction::WINDOW_UPDATER, false); + _("Updates"), x, h, InputAction::WINDOW_UPDATER, + Visible_false); // TRANSLATORS: short button name for bank window. addButton(N_("BA"), // TRANSLATORS: full button name - _("Bank"), x, h, InputAction::WINDOW_BANK, false); + _("Bank"), x, h, InputAction::WINDOW_BANK, + Visible_false); // TRANSLATORS: short button name for mail window. addButton(N_("MA"), // TRANSLATORS: full button name - _("Mail"), x, h, InputAction::WINDOW_MAIL, false), + _("Mail"), x, h, InputAction::WINDOW_MAIL, + Visible_false), // TRANSLATORS: short button name for debug window. addButton(N_("DBG"), // TRANSLATORS: full button name _("Debug"), x, h, InputAction::WINDOW_DEBUG, #ifdef ANDROID - true); + Visible_true); #else - false); + Visible_false); #endif // TRANSLATORS: short button name for windows list menu. addButton(N_("WIN"), // TRANSLATORS: full button name - _("Windows"), x, h, InputAction::SHOW_WINDOWS, false); + _("Windows"), x, h, InputAction::SHOW_WINDOWS, + Visible_false); // TRANSLATORS: short button name for setup window. addButton(N_("SET"), // TRANSLATORS: full button name @@ -174,7 +183,7 @@ WindowMenu::WindowMenu(const Widget2 *const widget) : loadButtons(); addMouseListener(this); - setVisible(true); + setVisible(Visible_true); config.addListener("autohideButtons", this); mAutoHide = config.getIntValue("autohideButtons"); @@ -230,7 +239,7 @@ void WindowMenu::addButton(const char *const text, int &restrict x, int &restrict h, const int key, - const bool visible) + const Visible visible) { Button *const btn = new Button(this, gettext(text), text, this); btn->setPosition(x, mPadding); @@ -316,7 +325,8 @@ void WindowMenu::mouseExited(MouseEvent& event A_UNUSED) textPopup->hide(); } -void WindowMenu::showButton(const std::string &name, const bool visible) +void WindowMenu::showButton(const std::string &name, + const Visible visible) { const ButtonInfo *const info = mButtonNames[name]; if (!info || !info->button) @@ -363,9 +373,9 @@ void WindowMenu::loadButtons() it_end = mButtonNames.end(); it != it_end; ++it) { const ButtonInfo *const info = (*it).second; - if (!info || !info->button || info->visible) + if (!info || !info->button || info->visible == Visible_true) continue; - info->button->setVisible(false); + info->button->setVisible(Visible_false); } updateButtons(); return; @@ -380,7 +390,7 @@ void WindowMenu::loadButtons() const ButtonInfo *const info = mButtonNames[str]; if (!info || !info->button) continue; - info->button->setVisible(false); + info->button->setVisible(Visible_false); } } else @@ -394,7 +404,8 @@ void WindowMenu::loadButtons() continue; Button *const button = info->button; const std::string &str = button->getActionEventId(); - button->setVisible(str == "SET" || str == "WIN"); + button->setVisible(fromBool( + str == "SET" || str == "WIN", Visible)); } } updateButtons(); diff --git a/src/gui/windowmenu.h b/src/gui/windowmenu.h index 9a26ae603..03bd86592 100644 --- a/src/gui/windowmenu.h +++ b/src/gui/windowmenu.h @@ -23,6 +23,8 @@ #ifndef GUI_WINDOWMENU_H #define GUI_WINDOWMENU_H +#include "enums/simpletypes/visible.h" + #include "gui/widgets/container.h" #include "listeners/actionlistener.h" @@ -72,7 +74,7 @@ class WindowMenu final : public Container, std::vector <ButtonText*> &getButtonTexts() A_WARN_UNUSED { return mButtonTexts; } - void showButton(const std::string &name, const bool visible); + void showButton(const std::string &name, const Visible visible); void loadButtons(); @@ -92,8 +94,9 @@ class WindowMenu final : public Container, private: inline void addButton(const char *const text, const std::string &description, - int &restrict x, int &restrict h, const int key, - const bool visible = true); + int &restrict x, int &restrict h, + const int key, + const Visible visible = Visible_true); void updateButtons(); 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(); } diff --git a/src/net/ea/tradehandler.cpp b/src/net/ea/tradehandler.cpp index 9c6f8f387..a0c84c24e 100644 --- a/src/net/ea/tradehandler.cpp +++ b/src/net/ea/tradehandler.cpp @@ -86,7 +86,7 @@ void TradeHandler::processTradeResponseContinue(const uint8_t type) tradeWindow->setCaption(strprintf(_("Trade: You and %s"), tradePartnerName.c_str())); tradeWindow->initTrade(tradePartnerName); - tradeWindow->setVisible(true); + tradeWindow->setVisible(Visible_true); } break; case 4: // Trade cancelled @@ -100,7 +100,7 @@ void TradeHandler::processTradeResponseContinue(const uint8_t type) if (tradeWindow) { - tradeWindow->setVisible(false); + tradeWindow->setVisible(Visible_false); // tradeWindow->clear(); } PlayerInfo::setTrading(Trading_false); @@ -132,7 +132,7 @@ void TradeHandler::processTradeCancel(Net::MessageIn &msg A_UNUSED) NotifyManager::notify(NotifyTypes::TRADE_CANCELLED); if (tradeWindow) { - tradeWindow->setVisible(false); + tradeWindow->setVisible(Visible_false); tradeWindow->reset(); } PlayerInfo::setTrading(Trading_false); @@ -143,7 +143,7 @@ void TradeHandler::processTradeComplete(Net::MessageIn &msg A_UNUSED) NotifyManager::notify(NotifyTypes::TRADE_COMPLETE); if (tradeWindow) { - tradeWindow->setVisible(false); + tradeWindow->setVisible(Visible_false); tradeWindow->reset(); } PlayerInfo::setTrading(Trading_false); diff --git a/src/net/eathena/generalhandler.cpp b/src/net/eathena/generalhandler.cpp index 3c442af82..704f7787d 100644 --- a/src/net/eathena/generalhandler.cpp +++ b/src/net/eathena/generalhandler.cpp @@ -380,7 +380,7 @@ void GeneralHandler::clearHandlers() void GeneralHandler::gameStarted() const { if (inventoryWindow) - inventoryWindow->setSplitAllowed(false); + inventoryWindow->setSplitAllowed(Visible_false); if (skillDialog) skillDialog->loadSkills(); diff --git a/src/net/tmwa/generalhandler.cpp b/src/net/tmwa/generalhandler.cpp index 548ee7b8f..78052a5f8 100644 --- a/src/net/tmwa/generalhandler.cpp +++ b/src/net/tmwa/generalhandler.cpp @@ -331,7 +331,7 @@ void GeneralHandler::clearHandlers() void GeneralHandler::gameStarted() const { if (inventoryWindow) - inventoryWindow->setSplitAllowed(false); + inventoryWindow->setSplitAllowed(Visible_false); if (skillDialog) skillDialog->loadSkills(); |