From b0388c5ad0a49f65becdee1120d4df476410dd01 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 30 Oct 2015 17:30:52 +0300 Subject: Add strong typed bool enum ForceQuantity. --- src/CMakeLists.txt | 1 + src/Makefile.am | 1 + src/enums/simpletypes/forcequantity.h | 28 ++++++++++++++++++++++++++++ src/gui/widgets/itemcontainer.cpp | 8 +++++--- src/gui/widgets/itemcontainer.h | 6 ++++-- 5 files changed, 39 insertions(+), 5 deletions(-) create mode 100644 src/enums/simpletypes/forcequantity.h (limited to 'src') 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 . + */ + +#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; }; -- cgit v1.2.3-70-g09d2