diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-10-30 17:30:52 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-10-30 18:19:54 +0300 |
commit | b0388c5ad0a49f65becdee1120d4df476410dd01 (patch) | |
tree | 3e883d2e3ee1ed79569f999e5fdc24a30614cc13 | |
parent | e196607ec6a16204579f8e37e1c88c133bf1db37 (diff) | |
download | manaplus-b0388c5ad0a49f65becdee1120d4df476410dd01.tar.gz manaplus-b0388c5ad0a49f65becdee1120d4df476410dd01.tar.bz2 manaplus-b0388c5ad0a49f65becdee1120d4df476410dd01.tar.xz manaplus-b0388c5ad0a49f65becdee1120d4df476410dd01.zip |
Add strong typed bool enum ForceQuantity.
-rw-r--r-- | src/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/Makefile.am | 1 | ||||
-rw-r--r-- | src/enums/simpletypes/forcequantity.h | 28 | ||||
-rw-r--r-- | src/gui/widgets/itemcontainer.cpp | 8 | ||||
-rw-r--r-- | src/gui/widgets/itemcontainer.h | 6 |
5 files changed, 39 insertions, 5 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f3ffede8d..1a1f51580 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1108,6 +1108,7 @@ SET(SRCS enums/simpletypes/equipped.h enums/simpletypes/favorite.h enums/simpletypes/forcedisplay.h + enums/simpletypes/forcequantity.h enums/simpletypes/identified.h enums/simpletypes/ignorerecord.h enums/simpletypes/intdefines.h diff --git a/src/Makefile.am b/src/Makefile.am index c09192a9c..65c1bbfc7 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -571,6 +571,7 @@ SRC += events/actionevent.h \ enums/simpletypes/equipped.h \ enums/simpletypes/favorite.h \ enums/simpletypes/forcedisplay.h \ + enums/simpletypes/forcequantity.h \ enums/simpletypes/identified.h \ enums/simpletypes/ignorerecord.h \ enums/simpletypes/intdefines.h \ diff --git a/src/enums/simpletypes/forcequantity.h b/src/enums/simpletypes/forcequantity.h new file mode 100644 index 000000000..3425b33b4 --- /dev/null +++ b/src/enums/simpletypes/forcequantity.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_FORCEQUANTITY_H +#define ENUMS_SIMPLETYPES_FORCEQUANTITY_H + +#include "enums/simpletypes/booldefines.h" + +defBoolEnum(ForceQuantity); + +#endif // ENUMS_SIMPLETYPES_FORCEQUANTITY_H diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp index 9d8a7e264..d9d2b5f4b 100644 --- a/src/gui/widgets/itemcontainer.cpp +++ b/src/gui/widgets/itemcontainer.cpp @@ -159,7 +159,7 @@ namespace ItemContainer::ItemContainer(const Widget2 *const widget, Inventory *const inventory, - const bool forceQuantity) : + const ForceQuantity forceQuantity) : Widget(widget), KeyListener(), MouseListener(), @@ -342,7 +342,8 @@ void ItemContainer::draw(Graphics *graphics) // Draw item caption std::string caption; - if (item->getQuantity() > 1 || mForceQuantity) + if (item->getQuantity() > 1 || + mForceQuantity == ForceQuantity_true) { caption = toString(item->getQuantity()); } @@ -460,7 +461,8 @@ void ItemContainer::safeDraw(Graphics *graphics) // Draw item caption std::string caption; - if (item->getQuantity() > 1 || mForceQuantity) + if (item->getQuantity() > 1 || + mForceQuantity == ForceQuantity_true) { caption = toString(item->getQuantity()); } diff --git a/src/gui/widgets/itemcontainer.h b/src/gui/widgets/itemcontainer.h index eb422e269..a8d7c794e 100644 --- a/src/gui/widgets/itemcontainer.h +++ b/src/gui/widgets/itemcontainer.h @@ -27,6 +27,8 @@ #include "listeners/mouselistener.h" #include "listeners/widgetlistener.h" +#include "enums/simpletypes/forcequantity.h" + #include "gui/widgets/widget.h" #include "localconsts.h" @@ -57,7 +59,7 @@ class ItemContainer final : public Widget, */ ItemContainer(const Widget2 *const widget, Inventory *const inventory, - const bool forceQuantity = false); + const ForceQuantity forceQuantity = ForceQuantity_false); A_DELETE_COPY(ItemContainer) @@ -204,7 +206,7 @@ class ItemContainer final : public Widget, int mPaddingItemX; int mPaddingItemY; SelectionState mSelectionStatus; - bool mForceQuantity; + ForceQuantity mForceQuantity; bool mDescItems; bool mRedraw; }; |