summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-10-31 22:20:54 +0300
committerAndrei Karas <akaras@inbox.ru>2015-10-31 22:20:54 +0300
commit8c11a0235e6ed4e3ed6370014cff3cd0322ed6c5 (patch)
treec800007dc9b9904b3b235c4663abda8b14c8e94c /src
parent06720edd93b51a84650e2d385a24043cc4fb932e (diff)
downloadmanaverse-8c11a0235e6ed4e3ed6370014cff3cd0322ed6c5.tar.gz
manaverse-8c11a0235e6ed4e3ed6370014cff3cd0322ed6c5.tar.bz2
manaverse-8c11a0235e6ed4e3ed6370014cff3cd0322ed6c5.tar.xz
manaverse-8c11a0235e6ed4e3ed6370014cff3cd0322ed6c5.zip
Add strong typed bool enum usebase64.
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/Makefile.am1
-rw-r--r--src/enums/simpletypes/usebase64.h28
-rw-r--r--src/gui/widgets/setupitem.cpp14
-rw-r--r--src/gui/widgets/setupitem.h9
-rw-r--r--src/gui/widgets/tabs/setup_chat.cpp6
-rw-r--r--src/gui/widgets/tabs/setup_other.cpp2
7 files changed, 47 insertions, 14 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index c04351494..7032922e5 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1131,6 +1131,7 @@ SET(SRCS
enums/simpletypes/trading.h
enums/simpletypes/tryremovecolors.h
enums/simpletypes/useargs.h
+ enums/simpletypes/usebase64.h
enums/simpletypes/useresman.h
enums/simpletypes/visible.h
statuseffect.cpp
diff --git a/src/Makefile.am b/src/Makefile.am
index 8863d482b..d5695a327 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -594,6 +594,7 @@ SRC += events/actionevent.h \
enums/simpletypes/trading.h \
enums/simpletypes/tryremovecolors.h \
enums/simpletypes/useargs.h \
+ enums/simpletypes/usebase64.h \
enums/simpletypes/useresman.h \
enums/simpletypes/visible.h \
render/surfacegraphics.cpp \
diff --git a/src/enums/simpletypes/usebase64.h b/src/enums/simpletypes/usebase64.h
new file mode 100644
index 000000000..f66dda29a
--- /dev/null
+++ b/src/enums/simpletypes/usebase64.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_USEBASE64_H
+#define ENUMS_SIMPLETYPES_USEBASE64_H
+
+#include "enums/simpletypes/booldefines.h"
+
+defBoolEnum(UseBase64);
+
+#endif // ENUMS_SIMPLETYPES_USEBASE64_H
diff --git a/src/gui/widgets/setupitem.cpp b/src/gui/widgets/setupitem.cpp
index c066c55eb..6e9e2bf96 100644
--- a/src/gui/widgets/setupitem.cpp
+++ b/src/gui/widgets/setupitem.cpp
@@ -275,7 +275,7 @@ SetupItemTextField::SetupItemTextField(const std::string &restrict text,
SetupTabScroll *restrict const parent,
const std::string &restrict eventName,
const MainConfig mainConfig,
- const bool useBase64) :
+ const UseBase64 useBase64) :
SetupItem(text, description, keyName, parent, eventName, mainConfig),
mHorizont(nullptr),
mLabel(nullptr),
@@ -295,7 +295,7 @@ SetupItemTextField::SetupItemTextField(const std::string &restrict text,
const std::string &restrict eventName,
const std::string &restrict def,
const MainConfig mainConfig,
- const bool useBase64) :
+ const UseBase64 useBase64) :
SetupItem(text, description, keyName, parent, eventName, def, mainConfig),
mHorizont(nullptr),
mLabel(nullptr),
@@ -319,7 +319,7 @@ SetupItemTextField::~SetupItemTextField()
void SetupItemTextField::save()
{
- if (mUseBase64)
+ if (mUseBase64 == UseBase64_true)
{
std::string normalValue = mValue;
mValue = encodeBase64String(mValue);
@@ -335,7 +335,7 @@ void SetupItemTextField::save()
void SetupItemTextField::cancel(const std::string &eventName A_UNUSED)
{
load();
- if (mUseBase64)
+ if (mUseBase64 == UseBase64_true)
mValue = decodeBase64String(mValue);
toWidget();
}
@@ -343,7 +343,7 @@ void SetupItemTextField::cancel(const std::string &eventName A_UNUSED)
void SetupItemTextField::externalUpdated(const std::string &eventName A_UNUSED)
{
load();
- if (mUseBase64)
+ if (mUseBase64 == UseBase64_true)
mValue = decodeBase64String(mValue);
toWidget();
}
@@ -351,7 +351,7 @@ void SetupItemTextField::externalUpdated(const std::string &eventName A_UNUSED)
void SetupItemTextField::rereadValue()
{
load();
- if (mUseBase64)
+ if (mUseBase64 == UseBase64_true)
mValue = decodeBase64String(mValue);
toWidget();
}
@@ -359,7 +359,7 @@ void SetupItemTextField::rereadValue()
void SetupItemTextField::createControls()
{
load();
- if (mUseBase64)
+ if (mUseBase64 == UseBase64_true)
mValue = decodeBase64String(mValue);
mHorizont = new HorizontContainer(this, 32, 2);
diff --git a/src/gui/widgets/setupitem.h b/src/gui/widgets/setupitem.h
index f1a2b9484..80b7658ba 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/usebase64.h"
#include "gui/widgets/widget2.h"
@@ -187,7 +188,7 @@ class SetupItemTextField final : public SetupItem
SetupTabScroll *restrict const parent,
const std::string &restrict eventName,
const MainConfig mainConfig = MainConfig_true,
- const bool useBase64 = false);
+ const UseBase64 useBase64 = UseBase64_false);
SetupItemTextField(const std::string &restrict text,
const std::string &restrict description,
@@ -196,7 +197,7 @@ class SetupItemTextField final : public SetupItem
const std::string &restrict eventName,
const std::string &restrict def,
const MainConfig mainConfig = MainConfig_true,
- const bool useBase64 = false);
+ const UseBase64 useBase64 = UseBase64_false);
A_DELETE_COPY(SetupItemTextField)
@@ -221,7 +222,7 @@ class SetupItemTextField final : public SetupItem
void save() override final;
- void setUseBase64(const bool b)
+ void setUseBase64(const UseBase64 b)
{ mUseBase64 = b; }
protected:
@@ -230,7 +231,7 @@ class SetupItemTextField final : public SetupItem
TextField *mTextField;
Button *mButton;
EditDialog *mEditDialog;
- bool mUseBase64;
+ UseBase64 mUseBase64;
};
class SetupItemIntTextField final : public SetupItem
diff --git a/src/gui/widgets/tabs/setup_chat.cpp b/src/gui/widgets/tabs/setup_chat.cpp
index c82bc64d9..ce14d3ceb 100644
--- a/src/gui/widgets/tabs/setup_chat.cpp
+++ b/src/gui/widgets/tabs/setup_chat.cpp
@@ -213,7 +213,8 @@ Setup_Chat::Setup_Chat(const Widget2 *const widget) :
new SetupItemCheckBox(_("Enable language tab"),
_("If this feature enabled, language tab will appear if server "
"supports this feature.\n\nNote: only supported by Evol server yet."),
- "enableLangTab", this, "enableLangTabEvent", false);
+ "enableLangTab", this, "enableLangTabEvent",
+ MainConfig_false);
// TRANSLATORS: settings option
new SetupItemCheckBox(_("Show all languages messages"),
@@ -221,7 +222,8 @@ Setup_Chat::Setup_Chat(const Widget2 *const widget) :
"for different languages, you will see messages for all languages, "
"regardless of your language preferences.\n\nNote: it only works "
"on servers supporting language tabs feature, like Evol."),
- "showAllLang", this, "showAllLangEvent", false);
+ "showAllLang", this, "showAllLangEvent",
+ MainConfig_false);
// TRANSLATORS: settings option
new SetupItemCheckBox(_("Enable battle tab"),
diff --git a/src/gui/widgets/tabs/setup_other.cpp b/src/gui/widgets/tabs/setup_other.cpp
index 4a1fc1302..8a8705b38 100644
--- a/src/gui/widgets/tabs/setup_other.cpp
+++ b/src/gui/widgets/tabs/setup_other.cpp
@@ -410,7 +410,7 @@ Setup_Other::Setup_Other(const Widget2 *const widget) :
new SetupItemTextField(_("Screenshot directory"), "",
"screenshotDirectory3", this, "screenshotDirectory3Event",
MainConfig_true,
- true);
+ UseBase64_true);
#endif
// TRANSLATORS: settings option