From 914b7555f6b2b28497f70eaaadc6650961ef7f6b Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 2 Dec 2015 19:59:32 +0300 Subject: Add strong typed bool type IsSell. --- src/CMakeLists.txt | 1 + src/Makefile.am | 1 + src/enums/simpletypes/issell.h | 28 ++++++++++++++++++++++++++++ src/gui/widgets/selldialog.cpp | 4 ++-- src/gui/widgets/selldialog.h | 5 +++-- src/gui/windows/buyingstoreselldialog.cpp | 2 +- src/gui/windows/eggselectiondialog.cpp | 2 +- src/gui/windows/insertcarddialog.cpp | 2 +- src/gui/windows/npcselldialog.cpp | 2 +- src/gui/windows/shopselldialog.cpp | 2 +- 10 files changed, 40 insertions(+), 9 deletions(-) create mode 100644 src/enums/simpletypes/issell.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d14ad4a7f..afaf58575 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1123,6 +1123,7 @@ SET(SRCS enums/simpletypes/identified.h enums/simpletypes/ignorerecord.h enums/simpletypes/intdefines.h + enums/simpletypes/issell.h enums/simpletypes/itemcolor.h enums/simpletypes/keep.h enums/simpletypes/mainconfig.h diff --git a/src/Makefile.am b/src/Makefile.am index 605d01089..cb587d7db 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -580,6 +580,7 @@ SRC += events/actionevent.h \ enums/simpletypes/identified.h \ enums/simpletypes/ignorerecord.h \ enums/simpletypes/intdefines.h \ + enums/simpletypes/issell.h \ enums/simpletypes/itemcolor.h \ enums/simpletypes/keep.h \ enums/simpletypes/mainconfig.h \ diff --git a/src/enums/simpletypes/issell.h b/src/enums/simpletypes/issell.h new file mode 100644 index 000000000..94f192396 --- /dev/null +++ b/src/enums/simpletypes/issell.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_ISSELL_H +#define ENUMS_SIMPLETYPES_ISSELL_H + +#include "enums/simpletypes/booldefines.h" + +defBoolEnum(IsSell); + +#endif // ENUMS_SIMPLETYPES_ISSELL_H diff --git a/src/gui/widgets/selldialog.cpp b/src/gui/widgets/selldialog.cpp index 76cea21f2..956cacb2f 100644 --- a/src/gui/widgets/selldialog.cpp +++ b/src/gui/widgets/selldialog.cpp @@ -47,7 +47,7 @@ SellDialog::DialogList SellDialog::instances; -SellDialog::SellDialog(const bool isSell, +SellDialog::SellDialog(const IsSell isSell, const bool advanced) : // TRANSLATORS: sell dialog name Window(_("Sell"), Modal_false, nullptr, "sell.xml"), @@ -122,7 +122,7 @@ void SellDialog::postInit() ContainerPlacer placer; placer = getPlacer(0, 0); - if (mIsSell) + if (mIsSell == IsSell_true) { // TRANSLATORS: sell dialog button mIncreaseButton = new Button(this, _("+"), "inc", this); diff --git a/src/gui/widgets/selldialog.h b/src/gui/widgets/selldialog.h index e94619f1f..709756990 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/issell.h" #include "enums/simpletypes/itemcolor.h" #include "gui/widgets/window.h" @@ -52,7 +53,7 @@ class SellDialog notfinal : public Window, /** * Constructor. */ - SellDialog(const bool isSell, + SellDialog(const IsSell isSell, const bool advanced); A_DELETE_COPY(SellDialog) @@ -144,7 +145,7 @@ class SellDialog notfinal : public Window, int mMaxItems; int mAmountItems; - bool mIsSell; + IsSell mIsSell; bool mAdvanced; }; diff --git a/src/gui/windows/buyingstoreselldialog.cpp b/src/gui/windows/buyingstoreselldialog.cpp index af3d9d8ff..bfb3a5ca3 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(true, false), + SellDialog(IsSell_true, false), mAccountId(accountId), mStoreId(storeId) { diff --git a/src/gui/windows/eggselectiondialog.cpp b/src/gui/windows/eggselectiondialog.cpp index 266e3519b..03c10a87b 100644 --- a/src/gui/windows/eggselectiondialog.cpp +++ b/src/gui/windows/eggselectiondialog.cpp @@ -36,7 +36,7 @@ #include "debug.h" EggSelectionDialog::EggSelectionDialog() : - SellDialog(false, false) + SellDialog(IsSell_false, false) { // TRANSLATORS: egg selection dialog name setWindowName(_("Select egg")); diff --git a/src/gui/windows/insertcarddialog.cpp b/src/gui/windows/insertcarddialog.cpp index 8620b06f7..7261e0f39 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(false, false), + SellDialog(IsSell_false, false), mItemIndex(itemIndex) { // TRANSLATORS: insert card dialog name diff --git a/src/gui/windows/npcselldialog.cpp b/src/gui/windows/npcselldialog.cpp index ab9ae47d0..98972ef8f 100644 --- a/src/gui/windows/npcselldialog.cpp +++ b/src/gui/windows/npcselldialog.cpp @@ -45,7 +45,7 @@ #include "debug.h" NpcSellDialog::NpcSellDialog(const BeingId npcId) : - SellDialog(true, + SellDialog(IsSell_true, serverFeatures ? serverFeatures->haveAdvancedBuySell() : false), mNpcId(npcId) { diff --git a/src/gui/windows/shopselldialog.cpp b/src/gui/windows/shopselldialog.cpp index 081ffea7f..c14e09fee 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(true, false), + SellDialog(IsSell_true, false), mNick(nick) { } -- cgit v1.2.3-60-g2f50