diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-11-01 13:03:27 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-11-01 13:03:27 +0300 |
commit | 1b2001d45ea6ee99490d4b1c374b1a03d73bbc86 (patch) | |
tree | 1677f727de2185b8abd56f3917f2a759d26fb3f8 /src/gui/widgets | |
parent | ec9116cd7f52e61afc4267b21e35325f4e7fc705 (diff) | |
download | manaplus-1b2001d45ea6ee99490d4b1c374b1a03d73bbc86.tar.gz manaplus-1b2001d45ea6ee99490d4b1c374b1a03d73bbc86.tar.bz2 manaplus-1b2001d45ea6ee99490d4b1c374b1a03d73bbc86.tar.xz manaplus-1b2001d45ea6ee99490d4b1c374b1a03d73bbc86.zip |
Add strong typed bool enum on the fly.
Diffstat (limited to 'src/gui/widgets')
-rw-r--r-- | src/gui/widgets/setupitem.cpp | 23 | ||||
-rw-r--r-- | src/gui/widgets/setupitem.h | 23 | ||||
-rw-r--r-- | src/gui/widgets/tabs/setup_audio.cpp | 9 | ||||
-rw-r--r-- | src/gui/widgets/tabs/setup_visual.cpp | 12 |
4 files changed, 38 insertions, 29 deletions
diff --git a/src/gui/widgets/setupitem.cpp b/src/gui/widgets/setupitem.cpp index 94e6231f9..be26265c3 100644 --- a/src/gui/widgets/setupitem.cpp +++ b/src/gui/widgets/setupitem.cpp @@ -728,7 +728,7 @@ SetupItemSlider::SetupItemSlider(const std::string &restrict text, const double max, const double step, const int width, - const bool onTheFly, + const OnTheFly onTheFly, const MainConfig mainConfig) : SetupItem(text, description, keyName, parent, eventName, mainConfig), mHorizont(nullptr), @@ -754,7 +754,7 @@ SetupItemSlider::SetupItemSlider(const std::string &restrict text, const double step, const std::string &restrict def, const int width, - const bool onTheFly, + const OnTheFly onTheFly, const MainConfig mainConfig) : SetupItem(text, description, keyName, parent, eventName, def, mainConfig), mHorizont(nullptr), @@ -823,7 +823,7 @@ void SetupItemSlider::toWidget() void SetupItemSlider::action(const ActionEvent &event A_UNUSED) { fromWidget(); - if (mOnTheFly) + if (mOnTheFly == OnTheFly_true) save(); } @@ -846,7 +846,7 @@ SetupItemSlider2::SetupItemSlider2(const std::string &restrict text, const int max, const int step, SetupItemNames *restrict const values, - const bool onTheFly, + const OnTheFly onTheFly, const MainConfig mainConfig, const bool doNotAlign) : SetupItem(text, description, keyName, parent, eventName, mainConfig), @@ -877,7 +877,7 @@ SetupItemSlider2::SetupItemSlider2(const std::string &restrict text, const int step, SetupItemNames *restrict const values, const std::string &restrict def, - const bool onTheFly, + const OnTheFly onTheFly, const MainConfig mainConfig, const bool doNotAlign) : SetupItem(text, description, keyName, parent, eventName, def, mainConfig), @@ -987,7 +987,7 @@ void SetupItemSlider2::action(const ActionEvent &event A_UNUSED) { fromWidget(); updateLabel(); - if (mOnTheFly) + if (mOnTheFly == OnTheFly_true) save(); } @@ -1033,7 +1033,7 @@ SetupItemSliderList::SetupItemSliderList(const std::string &restrict text, const std::string &restrict eventName, ListModel *restrict const model, const int width, - const bool onTheFly, + const OnTheFly onTheFly, const MainConfig mainConfig) : SetupItem(text, description, keyName, parent, eventName, mainConfig), mHorizont(nullptr), @@ -1055,7 +1055,7 @@ SetupItemSliderList::SetupItemSliderList(const std::string &restrict text, ListModel *restrict const model, const std::string &restrict def, const int width, - const bool onTheFly, + const OnTheFly onTheFly, const MainConfig mainConfig) : SetupItem(text, description, keyName, parent, eventName, def, mainConfig), mHorizont(nullptr), @@ -1120,7 +1120,7 @@ void SetupItemSliderList::toWidget() void SetupItemSliderList::action(const ActionEvent &event A_UNUSED) { fromWidget(); - if (mOnTheFly) + if (mOnTheFly == OnTheFly_true) save(); } @@ -1139,7 +1139,8 @@ SetupItemSound::SetupItemSound(const std::string &restrict text, SetupTabScroll *restrict const parent, const std::string &restrict eventName, ListModel *restrict const model, - const int width, const bool onTheFly, + const int width, + const OnTheFly onTheFly, const MainConfig mainConfig) : SetupItemSliderList(text, description, keyName, parent, eventName, model, width, onTheFly, mainConfig), @@ -1179,7 +1180,7 @@ SetupItemSliderInt::SetupItemSliderInt(const std::string &restrict text, ListModel *restrict const model, const int min, const int width, - const bool onTheFly, + const OnTheFly onTheFly, const MainConfig mainConfig) : SetupItemSliderList(text, description, keyName, parent, eventName, model, width, onTheFly, mainConfig), diff --git a/src/gui/widgets/setupitem.h b/src/gui/widgets/setupitem.h index 0d817a4b4..2bfa9e04c 100644 --- a/src/gui/widgets/setupitem.h +++ b/src/gui/widgets/setupitem.h @@ -22,6 +22,7 @@ #define GUI_WIDGETS_SETUPITEM_H #include "enums/simpletypes/mainconfig.h" +#include "enums/simpletypes/onthefly.h" #include "enums/simpletypes/usebase64.h" #include "enums/simpletypes/separator.h" @@ -358,7 +359,7 @@ class SetupItemSlider final : public SetupItem const double max, const double step, const int width, - const bool onTheFly, + const OnTheFly onTheFly, const MainConfig mainConfig); SetupItemSlider(const std::string &restrict text, @@ -371,7 +372,7 @@ class SetupItemSlider final : public SetupItem const double step, const std::string &restrict def, const int width, - const bool onTheFly, + const OnTheFly onTheFly, const MainConfig mainConfig); A_DELETE_COPY(SetupItemSlider) @@ -398,7 +399,7 @@ class SetupItemSlider final : public SetupItem double mMax; double mStep; int mWidth; - bool mOnTheFly; + OnTheFly mOnTheFly; }; typedef std::vector<std::string> SetupItemNames; @@ -415,7 +416,7 @@ class SetupItemSlider2 final : public SetupItem const std::string &restrict eventName, const int min, const int max, const int step, SetupItemNames *restrict const values, - const bool onTheFly, + const OnTheFly onTheFly, const MainConfig mainConfig, const bool doNotAlign); @@ -427,7 +428,7 @@ class SetupItemSlider2 final : public SetupItem const int min, const int max, const int step, SetupItemNames *restrict const values, const std::string &restrict def, - const bool onTheFly, + const OnTheFly onTheFly, const MainConfig mainConfig, const bool doNotAlign); @@ -462,7 +463,7 @@ class SetupItemSlider2 final : public SetupItem int mStep; int mInvertValue; bool mInvert; - bool mOnTheFly; + OnTheFly mOnTheFly; bool mDoNotAlign; }; @@ -493,7 +494,7 @@ class SetupItemSliderList notfinal : public SetupItem const std::string &restrict eventName, ListModel *restrict const model, const int width = 150, - const bool onTheFly = false, + const OnTheFly onTheFly = OnTheFly_false, const MainConfig mainConfig = MainConfig_true); SetupItemSliderList(const std::string &restrict text, @@ -504,7 +505,7 @@ class SetupItemSliderList notfinal : public SetupItem ListModel *restrict const model, const std::string &restrict def, const int width = 150, - const bool onTheFly = false, + const OnTheFly onTheFly = OnTheFly_false, const MainConfig mainConfig = MainConfig_true); HorizontContainer *mHorizont; @@ -512,7 +513,7 @@ class SetupItemSliderList notfinal : public SetupItem SliderList *mSlider; ListModel *mModel; int mWidth; - bool mOnTheFly; + OnTheFly mOnTheFly; }; class SetupItemSound final : public SetupItemSliderList @@ -525,7 +526,7 @@ class SetupItemSound final : public SetupItemSliderList const std::string &restrict eventName, ListModel *restrict const model, const int width = 150, - const bool onTheFly = false, + const OnTheFly onTheFly = OnTheFly_false, const MainConfig mainConfig = MainConfig_true); A_DELETE_COPY(SetupItemSound) @@ -549,7 +550,7 @@ class SetupItemSliderInt final : public SetupItemSliderList ListModel *restrict const model, const int min, const int width = 150, - const bool onTheFly = false, + const OnTheFly onTheFly = OnTheFly_false, const MainConfig mainConfig = MainConfig_true); A_DELETE_COPY(SetupItemSliderInt) diff --git a/src/gui/widgets/tabs/setup_audio.cpp b/src/gui/widgets/tabs/setup_audio.cpp index 32445f1c6..0aa824813 100644 --- a/src/gui/widgets/tabs/setup_audio.cpp +++ b/src/gui/widgets/tabs/setup_audio.cpp @@ -73,13 +73,15 @@ Setup_Audio::Setup_Audio(const Widget2 *const widget) : // TRANSLATORS: settings option new SetupItemSlider(_("Sfx volume"), "", "sfxVolume", this, "sfxVolumeEvent", 0, soundManager.getMaxVolume(), 1, - 150, true, + 150, + OnTheFly_true, MainConfig_true); // TRANSLATORS: settings option new SetupItemSlider(_("Music volume"), "", "musicVolume", this, "musicVolumeEvent", 0, soundManager.getMaxVolume(), 1, - 150, true, + 150, + OnTheFly_true, MainConfig_true); // TRANSLATORS: settings option @@ -100,7 +102,8 @@ Setup_Audio::Setup_Audio(const Widget2 *const widget) : mChannelsList->push_back(_("surround+center+lfe")); // TRANSLATORS: settings option new SetupItemSlider2(_("Audio channels"), "", "audioChannels", this, - "audioChannels", 1, 4, 1, mChannelsList, false, + "audioChannels", 1, 4, 1, mChannelsList, + OnTheFly_false, MainConfig_true, false); diff --git a/src/gui/widgets/tabs/setup_visual.cpp b/src/gui/widgets/tabs/setup_visual.cpp index 4bcb041ca..f33a9a5d3 100644 --- a/src/gui/widgets/tabs/setup_visual.cpp +++ b/src/gui/widgets/tabs/setup_visual.cpp @@ -141,7 +141,8 @@ Setup_Visual::Setup_Visual(const Widget2 *const widget) : // TRANSLATORS: settings option new SetupItemSlider(_("Gui opacity"), "", "guialpha", - this, "guialphaEvent", 0.1, 1.01, 0.1, 150, true, + this, "guialphaEvent", 0.1, 1.01, 0.1, 150, + OnTheFly_true, MainConfig_true); // TRANSLATORS: settings option @@ -171,8 +172,10 @@ Setup_Visual::Setup_Visual(const Widget2 *const widget) : // TRANSLATORS: particle details mParticleList->push_back(_("max")); (new SetupItemSlider2(_("Particle detail"), "", "particleEmitterSkip", - this, "particleEmitterSkipEvent", 0, 3, 1, - mParticleList, true, MainConfig_true, false))->setInvertValue(3); + this, "particleEmitterSkipEvent", 0, 3, 1, mParticleList, + OnTheFly_true, + MainConfig_true, + false))->setInvertValue(3); mParticleTypeList->fillFromArray(&particleTypeList[0], particleTypeListSize); @@ -190,7 +193,8 @@ Setup_Visual::Setup_Visual(const Widget2 *const widget) : // TRANSLATORS: settings option new SetupItemSlider(_("Gamma"), "", "gamma", - this, "gammeEvent", 1, 20, 1, 350, true, + this, "gammeEvent", 1, 20, 1, 350, + OnTheFly_true, MainConfig_true); |