diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-12-02 20:43:51 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-12-02 20:43:51 +0300 |
commit | 1b47ede798838c9f50ad3175c9d05e1dfbad2474 (patch) | |
tree | 00704042c47be966eee5c0f13079aa35d99adfaf | |
parent | 914b7555f6b2b28497f70eaaadc6650961ef7f6b (diff) | |
download | manaplus-1b47ede798838c9f50ad3175c9d05e1dfbad2474.tar.gz manaplus-1b47ede798838c9f50ad3175c9d05e1dfbad2474.tar.bz2 manaplus-1b47ede798838c9f50ad3175c9d05e1dfbad2474.tar.xz manaplus-1b47ede798838c9f50ad3175c9d05e1dfbad2474.zip |
Add strong typed bool type Advanced.
-rw-r--r-- | src/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/Makefile.am | 1 | ||||
-rw-r--r-- | src/enums/simpletypes/advanced.h | 28 | ||||
-rw-r--r-- | src/gui/widgets/selldialog.cpp | 10 | ||||
-rw-r--r-- | src/gui/widgets/selldialog.h | 5 | ||||
-rw-r--r-- | src/gui/windows/buyingstoreselldialog.cpp | 2 | ||||
-rw-r--r-- | src/gui/windows/eggselectiondialog.cpp | 2 | ||||
-rw-r--r-- | src/gui/windows/insertcarddialog.cpp | 2 | ||||
-rw-r--r-- | src/gui/windows/npcselldialog.cpp | 5 | ||||
-rw-r--r-- | src/gui/windows/shopselldialog.cpp | 2 |
10 files changed, 45 insertions, 13 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index afaf58575..d26960d28 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1103,6 +1103,7 @@ SET(SRCS enums/screendensity.h enums/state.h enums/textcommandtype.h + enums/simpletypes/advanced.h enums/simpletypes/allowsort.h enums/simpletypes/allplayers.h enums/simpletypes/append.h diff --git a/src/Makefile.am b/src/Makefile.am index cb587d7db..e8d71f876 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -560,6 +560,7 @@ SRC += events/actionevent.h \ enums/screendensity.h \ enums/state.h \ enums/textcommandtype.h \ + enums/simpletypes/advanced.h \ enums/simpletypes/allowsort.h \ enums/simpletypes/allplayers.h \ enums/simpletypes/append.h \ diff --git a/src/enums/simpletypes/advanced.h b/src/enums/simpletypes/advanced.h new file mode 100644 index 000000000..4aad05406 --- /dev/null +++ b/src/enums/simpletypes/advanced.h @@ -0,0 +1,28 @@ +/* + * The ManaPlus Client + * Copyright (C) 2015 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef ENUMS_SIMPLETYPES_ADVANCED_H +#define ENUMS_SIMPLETYPES_ADVANCED_H + +#include "enums/simpletypes/booldefines.h" + +defBoolEnum(Advanced); + +#endif // ENUMS_SIMPLETYPES_ADVANCED_H diff --git a/src/gui/widgets/selldialog.cpp b/src/gui/widgets/selldialog.cpp index 956cacb2f..8488e4157 100644 --- a/src/gui/widgets/selldialog.cpp +++ b/src/gui/widgets/selldialog.cpp @@ -48,7 +48,7 @@ SellDialog::DialogList SellDialog::instances; SellDialog::SellDialog(const IsSell isSell, - const bool advanced) : + const Advanced advanced) : // TRANSLATORS: sell dialog name Window(_("Sell"), Modal_false, nullptr, "sell.xml"), ActionListener(), @@ -89,7 +89,7 @@ void SellDialog::postInit() // Create a ShopItems instance, that is aware of duplicate entries. mShopItems = new ShopItems(true); - if (mAdvanced) + if (mAdvanced == Advanced_true) mShopItems->setMergeDuplicates(false); mShopItemList = CREATEWIDGETR(ShopListBox, @@ -103,7 +103,7 @@ void SellDialog::postInit() mSellButton = new Button(this, // TRANSLATORS: sell dialog button - mAdvanced ? _("Add") : _("Sell"), + mAdvanced == Advanced_true ? _("Add") : _("Sell"), "presell", this); // TRANSLATORS: sell dialog button @@ -138,7 +138,7 @@ void SellDialog::postInit() // TRANSLATORS: sell dialog label mMoneyLabel = new Label(this, strprintf(_("Price: %s / Total: %s"), "", "")); - if (mAdvanced) + if (mAdvanced == Advanced_true) { // TRANSLATORS: sell dialog button mConfirmButton = new Button(this, _("Sell"), "confirm", this); @@ -160,7 +160,7 @@ void SellDialog::postInit() placer(5, 5, mQuantityLabel, 2); placer(7, 5, mAddMaxButton); placer(0, 6, mMoneyLabel, 8); - if (mAdvanced) + if (mAdvanced == Advanced_true) { placer(5, 7, mSellButton); placer(6, 7, mConfirmButton); diff --git a/src/gui/widgets/selldialog.h b/src/gui/widgets/selldialog.h index 709756990..5b907b882 100644 --- a/src/gui/widgets/selldialog.h +++ b/src/gui/widgets/selldialog.h @@ -23,6 +23,7 @@ #ifndef GUI_WIDGETS_SELLDIALOG_H #define GUI_WIDGETS_SELLDIALOG_H +#include "enums/simpletypes/advanced.h" #include "enums/simpletypes/issell.h" #include "enums/simpletypes/itemcolor.h" @@ -54,7 +55,7 @@ class SellDialog notfinal : public Window, * Constructor. */ SellDialog(const IsSell isSell, - const bool advanced); + const Advanced advanced); A_DELETE_COPY(SellDialog) @@ -146,7 +147,7 @@ class SellDialog notfinal : public Window, int mAmountItems; IsSell mIsSell; - bool mAdvanced; + Advanced mAdvanced; }; #endif // GUI_WIDGETS_SELLDIALOG_H diff --git a/src/gui/windows/buyingstoreselldialog.cpp b/src/gui/windows/buyingstoreselldialog.cpp index bfb3a5ca3..a93ee53f6 100644 --- a/src/gui/windows/buyingstoreselldialog.cpp +++ b/src/gui/windows/buyingstoreselldialog.cpp @@ -38,7 +38,7 @@ BuyingStoreSellDialog::BuyingStoreSellDialog(const BeingId accountId, const int storeId) : - SellDialog(IsSell_true, false), + SellDialog(IsSell_true, Advanced_false), mAccountId(accountId), mStoreId(storeId) { diff --git a/src/gui/windows/eggselectiondialog.cpp b/src/gui/windows/eggselectiondialog.cpp index 03c10a87b..81c283b8c 100644 --- a/src/gui/windows/eggselectiondialog.cpp +++ b/src/gui/windows/eggselectiondialog.cpp @@ -36,7 +36,7 @@ #include "debug.h" EggSelectionDialog::EggSelectionDialog() : - SellDialog(IsSell_false, false) + SellDialog(IsSell_false, Advanced_false) { // TRANSLATORS: egg selection dialog name setWindowName(_("Select egg")); diff --git a/src/gui/windows/insertcarddialog.cpp b/src/gui/windows/insertcarddialog.cpp index 7261e0f39..1c8800f88 100644 --- a/src/gui/windows/insertcarddialog.cpp +++ b/src/gui/windows/insertcarddialog.cpp @@ -38,7 +38,7 @@ InsertCardDialog::InsertCardDialog(const int itemIndex, const Item *const item) : - SellDialog(IsSell_false, false), + SellDialog(IsSell_false, Advanced_false), mItemIndex(itemIndex) { // TRANSLATORS: insert card dialog name diff --git a/src/gui/windows/npcselldialog.cpp b/src/gui/windows/npcselldialog.cpp index 98972ef8f..258487424 100644 --- a/src/gui/windows/npcselldialog.cpp +++ b/src/gui/windows/npcselldialog.cpp @@ -46,7 +46,8 @@ NpcSellDialog::NpcSellDialog(const BeingId npcId) : SellDialog(IsSell_true, - serverFeatures ? serverFeatures->haveAdvancedBuySell() : false), + (serverFeatures && serverFeatures->haveAdvancedBuySell()) ? + Advanced_true : Advanced_false), mNpcId(npcId) { } @@ -81,7 +82,7 @@ void NpcSellDialog::sellAction(const ActionEvent &event) } } - if (mAdvanced) + if (mAdvanced == Advanced_true) sellManyItems(event.getId()); else sellOneItem(); diff --git a/src/gui/windows/shopselldialog.cpp b/src/gui/windows/shopselldialog.cpp index c14e09fee..8accd511e 100644 --- a/src/gui/windows/shopselldialog.cpp +++ b/src/gui/windows/shopselldialog.cpp @@ -35,7 +35,7 @@ #include "debug.h" ShopSellDialog::ShopSellDialog(const std::string &nick) : - SellDialog(IsSell_true, false), + SellDialog(IsSell_true, Advanced_false), mNick(nick) { } |