summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2010-07-28 19:57:31 +0200
committerYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2010-07-28 19:57:31 +0200
commit2b1c0dcf269d617de1f6c203df547166661f089e (patch)
tree5d247d694f28ddbeb6e2da26b9db02eeab5c7480
parent44d8856c777790449df46e3b5348a6a7433a75d8 (diff)
downloadmana-2b1c0dcf269d617de1f6c203df547166661f089e.tar.gz
mana-2b1c0dcf269d617de1f6c203df547166661f089e.tar.bz2
mana-2b1c0dcf269d617de1f6c203df547166661f089e.tar.xz
mana-2b1c0dcf269d617de1f6c203df547166661f089e.zip
Centralized configuration default values using the VariableData system.
Please note that I didn't turned all the getValue() call into new ones, simply because I have to have config object initiated which is not forcefully the case the branding file. Resolves: Manasource Mantis #170.
-rw-r--r--mana.cbp2
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/Makefile.am2
-rw-r--r--src/being.cpp18
-rw-r--r--src/chatlog.cpp3
-rw-r--r--src/client.cpp50
-rw-r--r--src/configuration.cpp120
-rw-r--r--src/configuration.h28
-rw-r--r--src/defaults.cpp177
-rw-r--r--src/defaults.h34
-rw-r--r--src/gui/chat.cpp4
-rw-r--r--src/gui/emotepopup.cpp2
-rw-r--r--src/gui/gui.cpp6
-rw-r--r--src/gui/help.cpp4
-rw-r--r--src/gui/itempopup.cpp2
-rw-r--r--src/gui/npcdialog.cpp4
-rw-r--r--src/gui/serverdialog.cpp4
-rw-r--r--src/gui/setup_audio.cpp14
-rw-r--r--src/gui/setup_joystick.cpp2
-rw-r--r--src/gui/setup_players.cpp14
-rw-r--r--src/gui/setup_video.cpp68
-rw-r--r--src/gui/theme.cpp10
-rw-r--r--src/gui/updatewindow.cpp2
-rw-r--r--src/gui/viewport.cpp12
-rw-r--r--src/gui/widgets/button.cpp4
-rw-r--r--src/gui/widgets/chattab.cpp4
-rw-r--r--src/gui/widgets/checkbox.cpp4
-rw-r--r--src/gui/widgets/dropdown.cpp4
-rw-r--r--src/gui/widgets/emoteshortcutcontainer.cpp6
-rw-r--r--src/gui/widgets/itemshortcutcontainer.cpp6
-rw-r--r--src/gui/widgets/listbox.cpp4
-rw-r--r--src/gui/widgets/playerbox.cpp6
-rw-r--r--src/gui/widgets/progressbar.cpp4
-rw-r--r--src/gui/widgets/radiobutton.cpp4
-rw-r--r--src/gui/widgets/resizegrip.cpp4
-rw-r--r--src/gui/widgets/scrollarea.cpp10
-rw-r--r--src/gui/widgets/shoplistbox.cpp4
-rw-r--r--src/gui/widgets/slider.cpp4
-rw-r--r--src/gui/widgets/tab.cpp4
-rw-r--r--src/gui/widgets/table.cpp4
-rw-r--r--src/gui/widgets/textfield.cpp6
-rw-r--r--src/gui/widgets/textpreview.cpp4
-rw-r--r--src/gui/widgets/window.cpp4
-rw-r--r--src/item.cpp2
-rw-r--r--src/joystick.cpp10
-rw-r--r--src/map.cpp6
-rw-r--r--src/net/download.cpp4
-rw-r--r--src/net/manaserv/playerhandler.cpp4
-rw-r--r--src/net/tmwa/generalhandler.cpp2
-rw-r--r--src/particle.cpp8
-rw-r--r--src/resources/emotedb.cpp5
-rw-r--r--src/resources/itemdb.cpp2
-rw-r--r--src/resources/iteminfo.cpp2
-rw-r--r--src/resources/mapreader.cpp8
-rw-r--r--src/resources/spritedef.cpp11
-rw-r--r--src/resources/wallpaper.cpp18
-rw-r--r--src/sound.cpp6
-rw-r--r--src/statuseffect.cpp2
-rw-r--r--src/text.cpp4
-rw-r--r--src/utils/stringutils.cpp16
-rw-r--r--src/utils/stringutils.h8
-rw-r--r--src/variabledata.h25
62 files changed, 597 insertions, 220 deletions
diff --git a/mana.cbp b/mana.cbp
index 9091380c..3054a4e2 100644
--- a/mana.cbp
+++ b/mana.cbp
@@ -125,6 +125,8 @@
<Unit filename="src\configlistener.h" />
<Unit filename="src\configuration.cpp" />
<Unit filename="src\configuration.h" />
+ <Unit filename="src\defaults.cpp" />
+ <Unit filename="src\defaults.h" />
<Unit filename="src\effectmanager.cpp" />
<Unit filename="src\effectmanager.h" />
<Unit filename="src\emoteshortcut.cpp" />
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index ca6dddb2..4b2e0381 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -434,6 +434,8 @@ SET(SRCS
configlistener.h
configuration.cpp
configuration.h
+ defaults.cpp
+ defaults.h
effectmanager.cpp
effectmanager.h
emoteshortcut.cpp
diff --git a/src/Makefile.am b/src/Makefile.am
index 1ba073c3..fdec70be 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -333,6 +333,8 @@ mana_SOURCES = gui/widgets/avatarlistbox.cpp \
configlistener.h \
configuration.cpp \
configuration.h \
+ defaults.cpp \
+ defaults.h \
effectmanager.cpp \
effectmanager.h \
emoteshortcut.cpp \
diff --git a/src/being.cpp b/src/being.cpp
index 7a1f3eec..70ef55f9 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -112,7 +112,7 @@ Being::Being(int id, Type type, int subtype, Map *map):
mWalkSpeed = Net::getPlayerHandler()->getDefaultWalkSpeed();
if (getType() == PLAYER)
- mShowName = config.getValue("visiblenames", 1);
+ mShowName = config.getBoolValue("visiblenames");
config.addListener("visiblenames", this);
@@ -298,7 +298,7 @@ void Being::setSpeech(const std::string &text, int time)
if (!mSpeech.empty())
mSpeechTime = time <= SPEECH_MAX_TIME ? time : SPEECH_MAX_TIME;
- const int speech = (int) config.getValue("speech", TEXT_OVERHEAD);
+ const int speech = config.getIntValue("speech");
if (speech == TEXT_OVERHEAD)
{
if (mText)
@@ -887,7 +887,7 @@ void Being::drawSpeech(int offsetX, int offsetY)
{
const int px = getPixelX() - offsetX;
const int py = getPixelY() - offsetY;
- const int speech = (int) config.getValue("speech", TEXT_OVERHEAD);
+ const int speech = config.getIntValue("speech");
// Draw speech above this being
if (mSpeechTime == 0)
@@ -994,7 +994,7 @@ void Being::optionChanged(const std::string &value)
{
if (getType() == PLAYER && value == "visiblenames")
{
- setShowName(config.getValue("visiblenames", 1));
+ setShowName(config.getBoolValue("visiblenames"));
}
}
@@ -1010,7 +1010,7 @@ void Being::showName()
mDispName = 0;
std::string mDisplayName(mName);
- if (config.getValue("showgender", false))
+ if (config.getBoolValue("showgender"))
{
if (getGender() == GENDER_FEMALE)
mDisplayName += " \u2640";
@@ -1020,7 +1020,7 @@ void Being::showName()
if (getType() == MONSTER)
{
- if (config.getValue("showMonstersTakedDamage", false))
+ if (config.getBoolValue("showMonstersTakedDamage"))
{
mDisplayName += ", " + toString(getDamageTaken());
}
@@ -1113,8 +1113,8 @@ void Being::setSprite(unsigned int slot, int id, const std::string &color,
if (!color.empty())
filename += "|" + color;
- equipmentSprite = AnimatedSprite::load("graphics/sprites/" +
- filename);
+ equipmentSprite = AnimatedSprite::load(
+ paths.getStringValue("sprites") + filename);
}
if (equipmentSprite)
@@ -1154,7 +1154,7 @@ void Being::load()
int hairstyles = 1;
while (ItemDB::get(-hairstyles).getSprite(GENDER_MALE) !=
- paths.getValue("spriteErrorFile", "error.xml"))
+ paths.getStringValue("spriteErrorFile"))
hairstyles++;
mNumberOfHairstyles = hairstyles;
diff --git a/src/chatlog.cpp b/src/chatlog.cpp
index 1c43b403..d45bea22 100644
--- a/src/chatlog.cpp
+++ b/src/chatlog.cpp
@@ -150,8 +150,7 @@ void ChatLogger::setServerName(const std::string &serverName)
{
mServerName = serverName;
if (mServerName == "")
- mServerName = config.getValue("MostUsedServerName0",
- "server.themanaworld.org");
+ mServerName = config.getStringValue("MostUsedServerName0");
if (mLogFile.is_open())
mLogFile.close();
diff --git a/src/client.cpp b/src/client.cpp
index b64f9a89..2ebdb247 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -219,6 +219,7 @@ Client::Client(const Options &options):
if (!options.brandingPath.empty())
{
branding.init(options.brandingPath);
+ branding.setDefaultValues(getBrandingDefaults());
}
initHomeDir();
@@ -232,7 +233,7 @@ Client::Client(const Options &options):
// Configure logger
logger->setLogFile(mLocalDataDir + std::string("/mana.log"));
- logger->setLogToStandardOut(config.getValue("logToStandardOut", 0));
+ logger->setLogToStandardOut(config.getBoolValue("logToStandardOut"));
// Log the mana version
logger->log("Mana %s", FULL_VERSION);
@@ -336,11 +337,11 @@ Client::Client(const Options &options):
graphics = new Graphics;
#endif
- const int width = (int) config.getValue("screenwidth", defaultScreenWidth);
- const int height = (int) config.getValue("screenheight", defaultScreenHeight);
+ const int width = config.getIntValue("screenwidth");
+ const int height = config.getIntValue("screenheight");
const int bpp = 0;
- const bool fullscreen = ((int) config.getValue("screen", 0) == 1);
- const bool hwaccel = ((int) config.getValue("hwaccel", 0) == 1);
+ const bool fullscreen = config.getBoolValue("screen");
+ const bool hwaccel = config.getBoolValue("hwaccel");
// Try to set the desired video mode
if (!graphics->setVideoMode(width, height, bpp, fullscreen, hwaccel))
@@ -363,13 +364,11 @@ Client::Client(const Options &options):
// Initialize sound engine
try
{
- if (config.getValue("sound", 0) == 1)
+ if (config.getBoolValue("sound"))
sound.init();
- sound.setSfxVolume((int) config.getValue("sfxVolume",
- defaultSfxVolume));
- sound.setMusicVolume((int) config.getValue("musicVolume",
- defaultMusicVolume));
+ sound.setSfxVolume(config.getIntValue("sfxVolume"));
+ sound.setMusicVolume(config.getIntValue("musicVolume"));
}
catch (const char *err)
{
@@ -394,28 +393,25 @@ Client::Client(const Options &options):
mCurrentServer.port = options.serverPort;
loginData.username = options.username;
loginData.password = options.password;
- loginData.remember = config.getValue("remember", 0);
+ loginData.remember = config.getBoolValue("remember");
loginData.registerLogin = false;
if (mCurrentServer.hostname.empty())
- {
- mCurrentServer.hostname = branding.getValue("defaultServer",
- "").c_str();
- }
+ mCurrentServer.hostname = branding.getValue("defaultServer","").c_str();
if (mCurrentServer.port == 0)
{
mCurrentServer.port = (short) branding.getValue("defaultPort",
- DEFAULT_PORT);
+ DEFAULT_PORT);
mCurrentServer.type = ServerInfo::parseType(
- branding.getValue("defaultServerType", "tmwathena"));
+ branding.getValue("defaultServerType", "tmwathena"));
}
if (chatLogger)
chatLogger->setServerName(mCurrentServer.hostname);
if (loginData.username.empty() && loginData.remember)
- loginData.username = config.getValue("username", "");
+ loginData.username = config.getStringValue("username");
if (mState != STATE_ERROR)
mState = STATE_CHOOSE_SERVER;
@@ -577,10 +573,8 @@ int Client::exec()
- 3, 3);
top->add(mSetupButton);
- int screenWidth = (int) config.getValue("screenwidth",
- defaultScreenWidth);
- int screenHeight = (int) config.getValue("screenheight",
- defaultScreenHeight);
+ int screenWidth = config.getIntValue("screenwidth");
+ int screenHeight = config.getIntValue("screenheight");
mDesktop->setSize(screenWidth, screenHeight);
}
@@ -749,6 +743,7 @@ int Client::exec()
// Read default paths file 'data/paths.xml'
paths.init("paths.xml", true);
+ paths.setDefaultValues(getPathsDefaults());
// Load XML databases
ColorDB::load();
@@ -788,7 +783,7 @@ int Client::exec()
mOptions.character, CharSelectDialog::Choose))
{
((CharSelectDialog*) mCurrentDialog)->selectByName(
- config.getValue("lastCharacter", ""),
+ config.getStringValue("lastCharacter"),
mOptions.chooseDefault ?
CharSelectDialog::Choose :
CharSelectDialog::Focus);
@@ -1000,7 +995,7 @@ int Client::exec()
void Client::optionChanged(const std::string &name)
{
- const int fpsLimit = (int) config.getValue("fpslimit", 60);
+ const int fpsLimit = config.getIntValue("fpslimit");
mLimitFps = fpsLimit > 0;
if (mLimitFps)
SDL_setFramerate(&mFpsManager, fpsLimit);
@@ -1151,6 +1146,7 @@ void Client::initConfiguration()
{
fclose(configFile);
config.init(configPath);
+ config.setDefaultValues(getConfigDefaults());
}
}
@@ -1165,7 +1161,7 @@ void Client::initUpdatesDir()
// If updatesHost is currently empty, fill it from config file
if (mUpdateHost.empty())
{
- mUpdateHost = config.getValue("updatehost", "");
+ mUpdateHost = config.getStringValue("updatehost");
}
// Don't go out of range int he next check
@@ -1243,7 +1239,7 @@ void Client::initScreenshotDir()
else
{
std::string configScreenshotDir =
- config.getValue("screenshotDirectory", "");
+ config.getStringValue("screenshotDirectory");
if (!configScreenshotDir.empty())
mScreenshotDir = configScreenshotDir;
else
@@ -1258,7 +1254,7 @@ void Client::initScreenshotDir()
}
config.setValue("screenshotDirectory", mScreenshotDir);
- if (config.getValue("useScreenshotDirectorySuffix", true))
+ if (config.getBoolValue("useScreenshotDirectorySuffix"))
{
std::string configScreenshotSuffix =
config.getValue("screenshotDirectorySuffix",
diff --git a/src/configuration.cpp b/src/configuration.cpp
index d8b11034..a6f691d8 100644
--- a/src/configuration.cpp
+++ b/src/configuration.cpp
@@ -98,6 +98,126 @@ ConfigurationObject::~ConfigurationObject()
clear();
}
+void Configuration::cleanDefaults()
+{
+ if (mDefaultsData)
+ {
+ for (DefaultsData::const_iterator iter = mDefaultsData->begin();
+ iter != mDefaultsData->end(); iter++)
+ {
+ if (iter->second)
+ delete(iter->second);
+ }
+ mDefaultsData->clear();
+ delete mDefaultsData;
+ mDefaultsData = 0;
+ }
+}
+
+Configuration::~Configuration()
+{
+ cleanDefaults();
+}
+
+void Configuration::setDefaultValues(DefaultsData *defaultsData)
+{
+ cleanDefaults();
+ mDefaultsData = defaultsData;
+}
+
+int Configuration::getIntValue(const std::string &key) const
+{
+ int defaultValue = 0;
+ if (mDefaultsData)
+ {
+ DefaultsData::const_iterator itdef = mDefaultsData->find(key);
+
+ if (itdef != mDefaultsData->end() && itdef->second
+ && itdef->second->getType() == Mana::VariableData::DATA_INT)
+ {
+ defaultValue = ((Mana::IntData*)itdef->second)->getData();
+ }
+ else
+ {
+ logger->log("%s: No integer value in registry for key %s",
+ mConfigPath.c_str(), key.c_str());
+ }
+ }
+ Options::const_iterator iter = mOptions.find(key);
+ return (iter != mOptions.end()) ? atoi(iter->second.c_str()) : defaultValue;
+}
+
+std::string Configuration::getStringValue(const std::string &key) const
+{
+ std::string defaultValue = "";
+ if (mDefaultsData)
+ {
+ DefaultsData::const_iterator itdef = mDefaultsData->find(key);
+
+ if (itdef != mDefaultsData->end() && itdef->second
+ && itdef->second->getType() == Mana::VariableData::DATA_STRING)
+ {
+ defaultValue = ((Mana::StringData*)itdef->second)->getData();
+ }
+ else
+ {
+ logger->log("%s: No string value in registry for key %s",
+ mConfigPath.c_str(), key.c_str());
+ }
+ }
+ Options::const_iterator iter = mOptions.find(key);
+ return (iter != mOptions.end()) ? iter->second : defaultValue;
+}
+
+
+float Configuration::getFloatValue(const std::string &key) const
+{
+ float defaultValue = 0.0f;
+ if (mDefaultsData)
+ {
+ DefaultsData::const_iterator itdef = mDefaultsData->find(key);
+
+ if (itdef != mDefaultsData->end() && itdef->second
+ && itdef->second->getType() == Mana::VariableData::DATA_FLOAT)
+ {
+ defaultValue = ((Mana::FloatData*)itdef->second)->getData();
+ }
+ else
+ {
+ logger->log("%s: No float value in registry for key %s",
+ mConfigPath.c_str(), key.c_str());
+ }
+ }
+ Options::const_iterator iter = mOptions.find(key);
+ return (iter != mOptions.end()) ? atof(iter->second.c_str()) : defaultValue;
+}
+
+bool Configuration::getBoolValue(const std::string &key) const
+{
+ bool defaultValue = false;
+ if (mDefaultsData)
+ {
+ DefaultsData::const_iterator itdef = mDefaultsData->find(key);
+
+ if (itdef != mDefaultsData->end() && itdef->second
+ && itdef->second->getType() == Mana::VariableData::DATA_BOOL)
+ {
+ defaultValue = ((Mana::BoolData*)itdef->second)->getData();
+ }
+ else
+ {
+ logger->log("%s: No boolean value in registry for key %s",
+ mConfigPath.c_str(), key.c_str());
+ }
+ }
+
+ Options::const_iterator iter = mOptions.find(key);
+ if (iter != mOptions.end())
+ return getBoolFromString(iter->second);
+ else
+ return defaultValue;
+}
+
void ConfigurationObject::initFromXML(xmlNodePtr parent_node)
{
clear();
diff --git a/src/configuration.h b/src/configuration.h
index 908d13a4..761cc43b 100644
--- a/src/configuration.h
+++ b/src/configuration.h
@@ -23,6 +23,7 @@
#define CONFIGURATION_H
#include "utils/stringutils.h"
+#include "defaults.h"
#include <libxml/xmlwriter.h>
@@ -192,7 +193,7 @@ class ConfigurationObject
class Configuration : public ConfigurationObject
{
public:
- virtual ~Configuration() {}
+ ~Configuration();
/**
* Reads config file and parse all options into memory.
@@ -203,6 +204,13 @@ class Configuration : public ConfigurationObject
void init(const std::string &filename, bool useResManager = false);
/**
+ * Set the default values for each keys.
+ *
+ * @param defaultsData data used as defaults.
+ */
+ void setDefaultValues(DefaultsData *defaultsData);
+
+ /**
* Writes the current settings back to the config file.
*/
void write();
@@ -238,14 +246,30 @@ class Configuration : public ConfigurationObject
inline void setValue(const std::string &key, bool value)
{ setValue(key, value ? "1" : "0"); }
+ /**
+ * returns a value corresponding to the given key.
+ * The default value returned in based on fallbacks registry.
+ * @see defaults.h
+ */
+ int getIntValue(const std::string &key) const;
+ float getFloatValue(const std::string &key) const;
+ std::string getStringValue(const std::string &key) const;
+ bool getBoolValue(const std::string &key) const;
+
private:
+ /**
+ * Clean up the default values member.
+ */
+ void cleanDefaults();
+
typedef std::list<ConfigListener*> Listeners;
typedef Listeners::iterator ListenerIterator;
typedef std::map<std::string, Listeners> ListenerMap;
typedef ListenerMap::iterator ListenerMapIterator;
ListenerMap mListenerMap;
- std::string mConfigPath; /**< Location of config file */
+ std::string mConfigPath; /**< Location of config file */
+ DefaultsData *mDefaultsData; /**< Defaults of value for a given key */
};
extern Configuration branding;
diff --git a/src/defaults.cpp b/src/defaults.cpp
new file mode 100644
index 00000000..9be5971d
--- /dev/null
+++ b/src/defaults.cpp
@@ -0,0 +1,177 @@
+/*
+ * The Mana Client
+ * Copyright (C) 2010 The Mana Developers
+ *
+ * This file is part of The Mana 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/>.
+ */
+
+#include "defaults.h"
+
+#include "utils/stringutils.h"
+
+#include "being.h"
+#include "graphics.h"
+#include "client.h"
+
+#include <stdlib.h>
+
+using namespace Mana;
+
+VariableData* createData(int defData)
+{
+ return new IntData(defData);
+}
+
+VariableData* createData(float defData)
+{
+ return new FloatData(defData);
+}
+
+VariableData* createData(const std::string &defData)
+{
+ return new StringData(defData);
+}
+
+VariableData* createData(const char* defData)
+{
+ return new StringData(defData);
+}
+
+VariableData* createData(bool defData)
+{
+ return new BoolData(defData);
+}
+
+#define AddDEF(defaultsData, key, value) \
+ defaultsData->insert(std::pair<std::string, VariableData*> \
+ (key, createData(value)));
+
+
+DefaultsData* getConfigDefaults()
+{
+ DefaultsData* configData = new DefaultsData;
+ // Init main config defaults
+ AddDEF(configData, "OverlayDetail", 2);
+ AddDEF(configData, "speechBubblecolor", "000000");
+ AddDEF(configData, "speechBubbleAlpha", 1.0f);
+ AddDEF(configData, "MostUsedServerName0", "server.themanaworld.org");
+ AddDEF(configData, "visiblenames", true);
+ AddDEF(configData, "speech", Being::TEXT_OVERHEAD);
+ AddDEF(configData, "showgender", false);
+ AddDEF(configData, "showMonstersTakedDamage", false);
+ AddDEF(configData, "particleMaxCount", 3000);
+ AddDEF(configData, "particleFastPhysics", 0);
+ AddDEF(configData, "particleEmitterSkip", 1);
+ AddDEF(configData, "particleeffects", true);
+ AddDEF(configData, "logToStandardOut", false);
+ AddDEF(configData, "opengl", false);
+ AddDEF(configData, "screenwidth", defaultScreenWidth);
+ AddDEF(configData, "screenheight", defaultScreenHeight);
+ AddDEF(configData, "screen", false);
+ AddDEF(configData, "hwaccel", false);
+ AddDEF(configData, "sound", false);
+ AddDEF(configData, "sfxVolume", 100);
+ AddDEF(configData, "musicVolume", 60);
+ AddDEF(configData, "remember", false);
+ AddDEF(configData, "username", "");
+ AddDEF(configData, "lastCharacter", "");
+ AddDEF(configData, "fpslimit", 60);
+ AddDEF(configData, "updatehost", "");
+ AddDEF(configData, "screenshotDirectory", "");
+ AddDEF(configData, "useScreenshotDirectorySuffix", true);
+ AddDEF(configData, "screenshotDirectorySuffix", "");
+ AddDEF(configData, "EnableSync", false);
+ AddDEF(configData, "joystickEnabled", false);
+ AddDEF(configData, "upTolerance", 100);
+ AddDEF(configData, "downTolerance", 100);
+ AddDEF(configData, "leftTolerance", 100);
+ AddDEF(configData, "rightTolerance", 100);
+ AddDEF(configData, "logNpcInGui", true);
+ AddDEF(configData, "download-music", false);
+ AddDEF(configData, "guialpha", 0.8f);
+ AddDEF(configData, "ChatLogLength", 0);
+ AddDEF(configData, "enableChatLog", false);
+ AddDEF(configData, "whispertab", false);
+ AddDEF(configData, "customcursor", true);
+ AddDEF(configData, "showownname", false);
+ AddDEF(configData, "showpickupparticle", false);
+ AddDEF(configData, "showpickupchat", true);
+ AddDEF(configData, "fontSize", 11);
+ AddDEF(configData, "ReturnToggles", false);
+ AddDEF(configData, "ScrollLaziness", 16);
+ AddDEF(configData, "ScrollRadius", 0);
+ AddDEF(configData, "ScrollCenterOffsetX", 0);
+ AddDEF(configData, "ScrollCenterOffsetY", 0);
+ AddDEF(configData, "onlineServerList", "");
+ AddDEF(configData, "theme", "");
+
+ return configData;
+}
+
+DefaultsData* getBrandingDefaults()
+{
+ DefaultsData* brandingData = new DefaultsData;
+ // Init config defaults
+ AddDEF(brandingData, "wallpapersPath", "");
+ AddDEF(brandingData, "wallpapersFile", "");
+ AddDEF(brandingData, "appName", "Mana");
+ AddDEF(brandingData, "appIcon", "icons/mana.png");
+ AddDEF(brandingData, "loginMusic", "Magick - Real.ogg");
+ AddDEF(brandingData, "defaultServer", "");
+ AddDEF(brandingData, "defaultPort", DEFAULT_PORT);
+ AddDEF(brandingData, "defaultServerType", "tmwathena");
+ AddDEF(brandingData, "onlineServerList", "a");
+ AddDEF(brandingData, "appShort", "mana");
+ AddDEF(brandingData, "defaultUpdateHost", "");
+ AddDEF(brandingData, "helpPath", "");
+ AddDEF(brandingData, "onlineServerList", "");
+ AddDEF(brandingData, "guiThemePath", "");
+ AddDEF(brandingData, "theme", "");
+ AddDEF(brandingData, "font", "fonts/dejavusans.ttf");
+ AddDEF(brandingData, "boldFont", "fonts/dejavusans-bold.ttf");
+
+ return brandingData;
+}
+
+DefaultsData* getPathsDefaults()
+{
+ DefaultsData *pathsData = new DefaultsData;
+ // Init paths.xml defaults
+ AddDEF(pathsData, "itemIcons", "graphics/items/");
+ AddDEF(pathsData, "unknownItemFile", "unknown-item.png");
+ AddDEF(pathsData, "sprites", "graphics/sprites/");
+ AddDEF(pathsData, "spriteErrorFile", "error.xml");
+
+ AddDEF(pathsData, "particles", "graphics/particles/");
+ AddDEF(pathsData, "levelUpEffectFile", "levelup.particle.xml");
+ AddDEF(pathsData, "portalEffectFile", "warparea.particle.xml");
+
+ AddDEF(pathsData, "minimaps", "graphics/minimaps/");
+ AddDEF(pathsData, "maps", "maps/");
+
+ AddDEF(pathsData, "sfx", "sfx/");
+ AddDEF(pathsData, "attackSfxFile", "fist-swish.ogg");
+ AddDEF(pathsData, "music", "music/");
+
+ AddDEF(pathsData, "wallpapers", "graphics/images/");
+ AddDEF(pathsData, "wallpaperFile", "login_wallpaper.png");
+
+ AddDEF(pathsData, "help", "help/");
+
+ return pathsData;
+}
+
+#undef AddDEF
diff --git a/src/defaults.h b/src/defaults.h
new file mode 100644
index 00000000..b9dfa511
--- /dev/null
+++ b/src/defaults.h
@@ -0,0 +1,34 @@
+/*
+ * The Mana Client
+ * Copyright (C) 2010 The Mana Developers
+ *
+ * This file is part of The Mana 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 DEFAULTS_H
+#define DEFAULTS_H
+
+#include <map>
+#include <string>
+#include "variabledata.h"
+
+typedef std::map<std::string, Mana::VariableData*> DefaultsData;
+
+DefaultsData* getConfigDefaults();
+DefaultsData* getBrandingDefaults();
+DefaultsData* getPathsDefaults();
+
+#endif
diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp
index 103a2647..86dc9d4d 100644
--- a/src/gui/chat.cpp
+++ b/src/gui/chat.cpp
@@ -110,7 +110,7 @@ ChatWindow::ChatWindow():
mChatInput->addKeyListener(this);
mCurHist = mHistory.end();
- mReturnToggles = config.getValue("ReturnToggles", "0") == "1";
+ mReturnToggles = config.getBoolValue("ReturnToggles");
mRecorder = new Recorder(this);
}
@@ -478,7 +478,7 @@ void ChatWindow::whisper(const std::string &nick,
if (i != mWhispers.end())
tab = i->second;
- else if (config.getValue("whispertab", true))
+ else if (config.getBoolValue("whispertab"))
tab = addWhisperTab(nick);
if (tab)
diff --git a/src/gui/emotepopup.cpp b/src/gui/emotepopup.cpp
index 7c05e263..3e06fdcf 100644
--- a/src/gui/emotepopup.cpp
+++ b/src/gui/emotepopup.cpp
@@ -61,7 +61,7 @@ EmotePopup::EmotePopup():
if (!mSelectionImage)
logger->error("Unable to load selection.png");
- mSelectionImage->setAlpha(config.getValue("guialpha", 0.8));
+ mSelectionImage->setAlpha(config.getFloatValue("guialpha"));
addMouseListener(this);
recalculateSize();
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp
index df2ddadf..0fff3496 100644
--- a/src/gui/gui.cpp
+++ b/src/gui/gui.cpp
@@ -61,7 +61,7 @@ class GuiConfigListener : public ConfigListener
{
if (name == "customcursor")
{
- bool bCustomCursor = config.getValue("customcursor", 1) == 1;
+ bool bCustomCursor = config.getBoolValue("customcursor");
mGui->setUseCustomCursor(bCustomCursor);
}
}
@@ -104,7 +104,7 @@ Gui::Gui(Graphics *graphics):
ResourceManager *resman = ResourceManager::getInstance();
// Set global font
- const int fontSize = (int) config.getValue("fontSize", 11);
+ const int fontSize = config.getValue("fontSize", 11);
std::string fontFile = branding.getValue("font", "fonts/dejavusans.ttf");
std::string path = resman->getPath(fontFile);
@@ -135,7 +135,7 @@ Gui::Gui(Graphics *graphics):
gcn::Widget::setGlobalFont(mGuiFont);
// Initialize mouse cursor and listen for changes to the option
- setUseCustomCursor(config.getValue("customcursor", 1) == 1);
+ setUseCustomCursor(config.getBoolValue("customcursor"));
mConfigListener = new GuiConfigListener(this);
config.addListener("customcursor", mConfigListener);
}
diff --git a/src/gui/help.cpp b/src/gui/help.cpp
index f3c6a0af..aca036c1 100644
--- a/src/gui/help.cpp
+++ b/src/gui/help.cpp
@@ -94,9 +94,9 @@ void HelpWindow::loadHelp(const std::string &helpFile)
void HelpWindow::loadFile(const std::string &file)
{
ResourceManager *resman = ResourceManager::getInstance();
- std::string helpPath = branding.getValue("helpPath", "");
+ std::string helpPath = branding.getStringValue("helpPath");
if (helpPath.empty())
- helpPath = paths.getValue("help", "help/");
+ helpPath = paths.getStringValue("help");
std::vector<std::string> lines =
resman->loadTextFile(helpPath + file + ".txt");
diff --git a/src/gui/itempopup.cpp b/src/gui/itempopup.cpp
index 03e6e380..5e7271ea 100644
--- a/src/gui/itempopup.cpp
+++ b/src/gui/itempopup.cpp
@@ -103,7 +103,7 @@ void ItemPopup::setItem(const ItemInfo &item, bool showImage)
{
ResourceManager *resman = ResourceManager::getInstance();
Image *image = resman->getImage(
- paths.getValue("itemIcons", "graphics/items/")
+ paths.getStringValue("itemIcons")
+ item.getDisplay().image);
mIcon->setImage(image);
diff --git a/src/gui/npcdialog.cpp b/src/gui/npcdialog.cpp
index 4e9c0b01..828ed776 100644
--- a/src/gui/npcdialog.cpp
+++ b/src/gui/npcdialog.cpp
@@ -51,7 +51,7 @@ NpcDialog::DialogList NpcDialog::instances;
NpcDialog::NpcDialog(int npcId)
: Window(_("NPC")),
mNpcId(npcId),
- mLogInteraction(config.getValue("logNpcInGui", true)),
+ mLogInteraction(config.getBoolValue("logNpcInGui")),
mDefaultInt(0),
mInputState(NPC_INPUT_NONE),
mActionState(NPC_ACTION_WAIT)
@@ -369,7 +369,7 @@ void NpcDialog::optionChanged(const std::string &name)
{
if (name == "logNpcInGui")
{
- mLogInteraction = config.getValue("logNpcInGui", true);
+ mLogInteraction = config.getBoolValue("logNpcInGui");
}
}
diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp
index ad8ab3c8..b1375ad0 100644
--- a/src/gui/serverdialog.cpp
+++ b/src/gui/serverdialog.cpp
@@ -485,10 +485,10 @@ void ServerDialog::setFieldsReadOnly(bool readOnly)
void ServerDialog::downloadServerList()
{
// Try to load the configuration value for the onlineServerList
- std::string listFile = branding.getValue("onlineServerList", std::string());
+ std::string listFile = branding.getStringValue("onlineServerList");
if (listFile.empty())
- listFile = config.getValue("onlineServerList", std::string());
+ listFile = config.getStringValue("onlineServerList");
// Fall back to manasource.org when neither branding nor config set it
if (listFile.empty())
diff --git a/src/gui/setup_audio.cpp b/src/gui/setup_audio.cpp
index 2c6b89e8..8e9f5e98 100644
--- a/src/gui/setup_audio.cpp
+++ b/src/gui/setup_audio.cpp
@@ -35,10 +35,10 @@
#include "utils/gettext.h"
Setup_Audio::Setup_Audio():
- mMusicVolume((int)config.getValue("musicVolume", 60)),
- mSfxVolume((int)config.getValue("sfxVolume", 100)),
- mSoundEnabled(config.getValue("sound", 0)),
- mDownloadEnabled(config.getValue("download-music", false)),
+ mMusicVolume(config.getIntValue("musicVolume")),
+ mSfxVolume(config.getIntValue("sfxVolume")),
+ mSoundEnabled(config.getBoolValue("sound")),
+ mDownloadEnabled(config.getBoolValue("download-music")),
mSoundCheckBox(new CheckBox(_("Sound"), mSoundEnabled)),
mDownloadMusicCheckBox(new CheckBox(_("Download music"), mDownloadEnabled)),
mSfxSlider(new Slider(0, sound.getMaxVolume())),
@@ -82,14 +82,14 @@ void Setup_Audio::apply()
{
mSoundEnabled = mSoundCheckBox->isSelected();
mDownloadEnabled = mDownloadMusicCheckBox->isSelected();
- mSfxVolume = (int) config.getValue("sfxVolume", 100);
- mMusicVolume = (int) config.getValue("musicVolume", 60);
+ mSfxVolume = config.getIntValue("sfxVolume");
+ mMusicVolume = config.getIntValue("musicVolume");
config.setValue("sound", mSoundEnabled);
// Display a message if user has selected to download music,
// And if downloadmusic is not already enabled
- if (mDownloadEnabled && !config.getValue("download-music", false))
+ if (mDownloadEnabled && !config.getBoolValue("download-music"))
{
new OkDialog(_("Notice"),_("You may have to restart your client if you want to download new music"));
}
diff --git a/src/gui/setup_joystick.cpp b/src/gui/setup_joystick.cpp
index 965f5712..7ac5b5ed 100644
--- a/src/gui/setup_joystick.cpp
+++ b/src/gui/setup_joystick.cpp
@@ -40,7 +40,7 @@ Setup_Joystick::Setup_Joystick():
{
setName(_("Joystick"));
- mOriginalJoystickEnabled = !config.getValue("joystickEnabled", false);
+ mOriginalJoystickEnabled = !config.getBoolValue("joystickEnabled");
mJoystickEnabled->setSelected(mOriginalJoystickEnabled);
mJoystickEnabled->addActionListener(this);
diff --git a/src/gui/setup_players.cpp b/src/gui/setup_players.cpp
index f7a39240..cbe0e264 100644
--- a/src/gui/setup_players.cpp
+++ b/src/gui/setup_players.cpp
@@ -227,11 +227,11 @@ Setup_Players::Setup_Players():
mDefaultWhisper(new CheckBox(_("Allow whispers"),
player_relations.getDefault() & PlayerRelation::WHISPER)),
mDeleteButton(new Button(_("Delete"), ACTION_DELETE, this)),
- mWhisperTab(config.getValue("whispertab", false)),
+ mWhisperTab(config.getBoolValue("whispertab")),
mWhisperTabCheckBox(new CheckBox(_("Put all whispers in tabs"), mWhisperTab)),
- mShowGender(config.getValue("showgender", false)),
+ mShowGender(config.getBoolValue("showgender")),
mShowGenderCheckBox(new CheckBox(_("Show gender"), mShowGender)),
- mEnableChatLog(config.getValue("enableChatLog", false)),
+ mEnableChatLog(config.getBoolValue("enableChatLog")),
mEnableChatLogCheckBox(new CheckBox(_("Enable Chat log"), mEnableChatLog))
{
setName(_("Players"));
@@ -348,7 +348,7 @@ void Setup_Players::apply()
PlayerRelation::WHISPER : 0));
config.setValue("whispertab", mWhisperTab);
- bool showGender = config.getValue("showgender", false);
+ bool showGender = config.getBoolValue("showgender");
config.setValue("showgender", mShowGender);
@@ -360,11 +360,11 @@ void Setup_Players::apply()
void Setup_Players::cancel()
{
- mWhisperTab = config.getValue("whispertab", false);
+ mWhisperTab = config.getBoolValue("whispertab");
mWhisperTabCheckBox->setSelected(mWhisperTab);
- mShowGender = config.getValue("showgender", false);
+ mShowGender = config.getBoolValue("showgender");
mShowGenderCheckBox->setSelected(mShowGender);
- mEnableChatLog = config.getValue("enableChatLog", false);
+ mEnableChatLog = config.getBoolValue("enableChatLog");
mEnableChatLogCheckBox->setSelected(mEnableChatLog);
}
diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp
index 81ce8107..bbfae738 100644
--- a/src/gui/setup_video.cpp
+++ b/src/gui/setup_video.cpp
@@ -171,7 +171,7 @@ static const char *speechModeToString(Being::Speech mode)
const char *Setup_Video::overlayDetailToString(int detail)
{
if (detail == -1)
- detail = config.getValue("OverlayDetail", -1);
+ detail = config.getIntValue("OverlayDetail");
switch (detail)
{
@@ -185,7 +185,7 @@ const char *Setup_Video::overlayDetailToString(int detail)
const char *Setup_Video::particleDetailToString(int detail)
{
if (detail == -1)
- detail = 3 - config.getValue("particleEmitterSkip", -1);
+ detail = 3 - config.getIntValue("particleEmitterSkip");
switch (detail)
{
@@ -198,21 +198,19 @@ const char *Setup_Video::particleDetailToString(int detail)
}
Setup_Video::Setup_Video():
- mFullScreenEnabled(config.getValue("screen", false)),
- mOpenGLEnabled(config.getValue("opengl", false)),
- mCustomCursorEnabled(config.getValue("customcursor", true)),
- mShowMonsterDamageEnabled(config.getValue("showMonstersTakedDamage",
- false)),
- mVisibleNamesEnabled(config.getValue("visiblenames", true)),
- mParticleEffectsEnabled(config.getValue("particleeffects", true)),
- mNameEnabled(config.getValue("showownname", false)),
- mNPCLogEnabled(config.getValue("logNpcInGui", true)),
- mPickupChatEnabled(config.getValue("showpickupchat", true)),
- mPickupParticleEnabled(config.getValue("showpickupparticle", false)),
- mOpacity(config.getValue("guialpha", 0.8)),
- mFps((int) config.getValue("fpslimit", 60)),
- mSpeechMode(static_cast<Being::Speech>(
- config.getValue("speech", Being::TEXT_OVERHEAD))),
+ mFullScreenEnabled(config.getBoolValue("screen")),
+ mOpenGLEnabled(config.getBoolValue("opengl")),
+ mCustomCursorEnabled(config.getBoolValue("customcursor")),
+ mShowMonsterDamageEnabled(config.getBoolValue("showMonstersTakedDamage")),
+ mVisibleNamesEnabled(config.getBoolValue("visiblenames")),
+ mParticleEffectsEnabled(config.getBoolValue("particleeffects")),
+ mNameEnabled(config.getBoolValue("showownname")),
+ mNPCLogEnabled(config.getBoolValue("logNpcInGui")),
+ mPickupChatEnabled(config.getBoolValue("showpickupchat")),
+ mPickupParticleEnabled(config.getBoolValue("showpickupparticle")),
+ mOpacity(config.getFloatValue("guialpha")),
+ mFps(config.getIntValue("fpslimit")),
+ mSpeechMode(static_cast<Being::Speech>(config.getIntValue("speech"))),
mModeListModel(new ModeListModel),
mModeList(new ListBox(mModeListModel)),
mFsCheckBox(new CheckBox(_("Full screen"), mFullScreenEnabled)),
@@ -237,13 +235,13 @@ Setup_Video::Setup_Video():
mFpsCheckBox(new CheckBox(_("FPS limit:"))),
mFpsSlider(new Slider(10, 120)),
mFpsLabel(new Label),
- mOverlayDetail((int) config.getValue("OverlayDetail", 2)),
+ mOverlayDetail(config.getIntValue("OverlayDetail")),
mOverlayDetailSlider(new Slider(0, 2)),
mOverlayDetailField(new Label),
- mParticleDetail(3 - (int) config.getValue("particleEmitterSkip", 1)),
+ mParticleDetail(3 - config.getIntValue("particleEmitterSkip")),
mParticleDetailSlider(new Slider(0, 3)),
mParticleDetailField(new Label),
- mFontSize((int) config.getValue("fontSize", 11))
+ mFontSize(config.getIntValue("fontSize"))
{
setName(_("Video"));
@@ -388,7 +386,7 @@ void Setup_Video::apply()
{
// Full screen changes
bool fullscreen = mFsCheckBox->isSelected();
- if (fullscreen != (config.getValue("screen", false) == 1))
+ if (fullscreen != config.getBoolValue("screen"))
{
/* The OpenGL test is only necessary on Windows, since switching
* to/from full screen works fine on Linux. On Windows we'd have to
@@ -399,7 +397,7 @@ void Setup_Video::apply()
#if defined(WIN32) || defined(__APPLE__)
// checks for opengl usage
- if (!(config.getValue("opengl", false) == 1))
+ if (!config.getBoolValue("opengl"))
{
#endif
if (!graphics->setFullscreen(fullscreen))
@@ -452,20 +450,20 @@ void Setup_Video::apply()
config.setValue("fontSize", mFontSizeDropDown->getSelected() + 10);
// We sync old and new values at apply time
- mFullScreenEnabled = config.getValue("screen", false);
- mCustomCursorEnabled = config.getValue("customcursor", true);
- mShowMonsterDamageEnabled = config.getValue("showMonstersTakedDamage", false);
- mVisibleNamesEnabled = config.getValue("visiblenames", true);
- mParticleEffectsEnabled = config.getValue("particleeffects", true);
- mNameEnabled = config.getValue("showownname", false);
- mNPCLogEnabled = config.getValue("logNpcInGui", true);
+ mFullScreenEnabled = config.getBoolValue("screen");
+ mCustomCursorEnabled = config.getBoolValue("customcursor");
+ mShowMonsterDamageEnabled = config.getBoolValue("showMonstersTakedDamage");
+ mVisibleNamesEnabled = config.getBoolValue("visiblenames");
+ mParticleEffectsEnabled = config.getBoolValue("particleeffects");
+ mNameEnabled = config.getBoolValue("showownname");
+ mNPCLogEnabled = config.getBoolValue("logNpcInGui");
mSpeechMode = static_cast<Being::Speech>(
- config.getValue("speech", Being::TEXT_OVERHEAD));
- mOpacity = config.getValue("guialpha", 0.8);
- mOverlayDetail = (int) config.getValue("OverlayDetail", 2);
- mOpenGLEnabled = config.getValue("opengl", false);
- mPickupChatEnabled = config.getValue("showpickupchat", true);
- mPickupParticleEnabled = config.getValue("showpickupparticle", false);
+ config.getIntValue("speech"));
+ mOpacity = config.getFloatValue("guialpha");
+ mOverlayDetail = config.getIntValue("OverlayDetail");
+ mOpenGLEnabled = config.getBoolValue("opengl");
+ mPickupChatEnabled = config.getBoolValue("showpickupchat");
+ mPickupParticleEnabled = config.getBoolValue("showpickupparticle");
}
void Setup_Video::cancel()
diff --git a/src/gui/theme.cpp b/src/gui/theme.cpp
index 12de1f91..152bf773 100644
--- a/src/gui/theme.cpp
+++ b/src/gui/theme.cpp
@@ -48,7 +48,7 @@ Theme *Theme::mInstance = 0;
static void initDefaultThemePath()
{
ResourceManager *resman = ResourceManager::getInstance();
- defaultThemePath = branding.getValue("guiThemePath", "");
+ defaultThemePath = branding.getStringValue("guiThemePath");
if (!defaultThemePath.empty() && resman->isDirectory(defaultThemePath))
return;
@@ -81,8 +81,8 @@ Skin::~Skin()
void Skin::updateAlpha(float minimumOpacityAllowed)
{
- const float alpha = std::max((double)minimumOpacityAllowed,
- config.getValue("guialpha", 0.8f));
+ const float alpha = std::max(minimumOpacityAllowed,
+ config.getFloatValue("guialpha"));
for_each(mBorder.grid, mBorder.grid + 9,
std::bind2nd(std::mem_fun(&Image::setAlpha), alpha));
@@ -339,9 +339,9 @@ bool Theme::tryThemePath(std::string themePath)
void Theme::prepareThemePath()
{
// Try theme from settings
- if (!tryThemePath(config.getValue("theme", "")))
+ if (!tryThemePath(config.getStringValue("theme")))
// Try theme from branding
- if (!tryThemePath(branding.getValue("theme", "")))
+ if (!tryThemePath(branding.getStringValue("theme")))
// Use default
mThemePath = defaultThemePath;
diff --git a/src/gui/updatewindow.cpp b/src/gui/updatewindow.cpp
index 7448a102..23d23b5e 100644
--- a/src/gui/updatewindow.cpp
+++ b/src/gui/updatewindow.cpp
@@ -476,7 +476,7 @@ void UpdaterWindow::logic()
// This statement checks to see if the file type is music, and if download-music is true
// If it fails, this statement returns true, and results in not downloading the file
// Else it will ignore the break, and download the file.
- if ( !(thisFile.type == "music" && config.getValue("download-music", false)) )
+ if ( !(thisFile.type == "music" && config.getBoolValue("download-music")) )
{
mUpdateIndex++;
break;
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp
index 120106cb..f1cd38e4 100644
--- a/src/gui/viewport.cpp
+++ b/src/gui/viewport.cpp
@@ -58,10 +58,10 @@ Viewport::Viewport():
setOpaque(false);
addMouseListener(this);
- mScrollLaziness = (int) config.getValue("ScrollLaziness", 16);
- mScrollRadius = (int) config.getValue("ScrollRadius", 0);
- mScrollCenterOffsetX = (int) config.getValue("ScrollCenterOffsetX", 0);
- mScrollCenterOffsetY = (int) config.getValue("ScrollCenterOffsetY", 0);
+ mScrollLaziness = config.getIntValue("ScrollLaziness");
+ mScrollRadius = config.getIntValue("ScrollRadius");
+ mScrollCenterOffsetX = config.getIntValue("ScrollCenterOffsetX");
+ mScrollCenterOffsetY = config.getIntValue("ScrollCenterOffsetY");
config.addListener("ScrollLaziness", this);
config.addListener("ScrollRadius", this);
@@ -481,8 +481,8 @@ void Viewport::closePopupMenu()
void Viewport::optionChanged(const std::string &name)
{
- mScrollLaziness = (int) config.getValue("ScrollLaziness", 32);
- mScrollRadius = (int) config.getValue("ScrollRadius", 32);
+ mScrollLaziness = config.getIntValue("ScrollLaziness");
+ mScrollRadius = config.getIntValue("ScrollRadius");
}
void Viewport::mouseMoved(gcn::MouseEvent &event)
diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp
index 26e0ad90..dbaa357c 100644
--- a/src/gui/widgets/button.cpp
+++ b/src/gui/widgets/button.cpp
@@ -125,8 +125,8 @@ Button::~Button()
void Button::updateAlpha()
{
- float alpha = std::max(config.getValue("guialpha", 0.8f),
- (double) Theme::instance()->getMinimumOpacity());
+ float alpha = std::max(config.getFloatValue("guialpha"),
+ Theme::instance()->getMinimumOpacity());
if (mAlpha != alpha)
{
diff --git a/src/gui/widgets/chattab.cpp b/src/gui/widgets/chattab.cpp
index 03ff79d9..fbde2c9c 100644
--- a/src/gui/widgets/chattab.cpp
+++ b/src/gui/widgets/chattab.cpp
@@ -51,7 +51,7 @@ ChatTab::ChatTab(const std::string &name) : Tab()
mTextOutput = new BrowserBox(BrowserBox::AUTO_WRAP);
mTextOutput->setOpaque(false);
- mTextOutput->setMaxRow((int) config.getValue("ChatLogLength", 0));
+ mTextOutput->setMaxRow((int) config.getIntValue("ChatLogLength"));
mTextOutput->setLinkHandler(chatWindow->mItemLinkHandler);
mScrollArea = new ScrollArea(mTextOutput);
@@ -181,7 +181,7 @@ void ChatTab::chatLog(std::string line, Own own, bool ignoreRecord)
line = lineColor + timeStr.str() + tmp.nick + tmp.text;
- if (config.getValue("enableChatLog", false))
+ if (config.getBoolValue("enableChatLog"))
saveToLogFile(line);
// We look if the Vertical Scroll Bar is set at the max before
diff --git a/src/gui/widgets/checkbox.cpp b/src/gui/widgets/checkbox.cpp
index f9002166..64594940 100644
--- a/src/gui/widgets/checkbox.cpp
+++ b/src/gui/widgets/checkbox.cpp
@@ -92,8 +92,8 @@ void CheckBox::draw(gcn::Graphics* graphics)
void CheckBox::updateAlpha()
{
- float alpha = std::max(config.getValue("guialpha", 0.8f),
- (double) Theme::instance()->getMinimumOpacity());
+ float alpha = std::max(config.getFloatValue("guialpha"),
+ Theme::instance()->getMinimumOpacity());
if (mAlpha != alpha)
{
diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp
index 6c3417e7..e694137d 100644
--- a/src/gui/widgets/dropdown.cpp
+++ b/src/gui/widgets/dropdown.cpp
@@ -110,8 +110,8 @@ DropDown::~DropDown()
void DropDown::updateAlpha()
{
- float alpha = std::max(config.getValue("guialpha", 0.8f),
- (double) Theme::instance()->getMinimumOpacity());
+ float alpha = std::max(config.getFloatValue("guialpha"),
+ Theme::instance()->getMinimumOpacity());
if (mAlpha != alpha)
{
diff --git a/src/gui/widgets/emoteshortcutcontainer.cpp b/src/gui/widgets/emoteshortcutcontainer.cpp
index 82fb9f8d..28727429 100644
--- a/src/gui/widgets/emoteshortcutcontainer.cpp
+++ b/src/gui/widgets/emoteshortcutcontainer.cpp
@@ -51,7 +51,7 @@ EmoteShortcutContainer::EmoteShortcutContainer():
mBackgroundImg = Theme::getImageFromTheme("item_shortcut_bgr.png");
- mBackgroundImg->setAlpha(config.getValue("guialpha", 0.8));
+ mBackgroundImg->setAlpha(config.getFloatValue("guialpha"));
// Setup emote sprites
for (int i = 0; i <= EmoteDB::getLast(); i++)
@@ -72,9 +72,9 @@ EmoteShortcutContainer::~EmoteShortcutContainer()
void EmoteShortcutContainer::draw(gcn::Graphics *graphics)
{
- if (config.getValue("guialpha", 0.8) != mAlpha)
+ if (config.getFloatValue("guialpha") != mAlpha)
{
- mAlpha = config.getValue("guialpha", 0.8);
+ mAlpha = config.getFloatValue("guialpha");
mBackgroundImg->setAlpha(mAlpha);
}
diff --git a/src/gui/widgets/itemshortcutcontainer.cpp b/src/gui/widgets/itemshortcutcontainer.cpp
index b3cefc5f..869264f7 100644
--- a/src/gui/widgets/itemshortcutcontainer.cpp
+++ b/src/gui/widgets/itemshortcutcontainer.cpp
@@ -53,7 +53,7 @@ ItemShortcutContainer::ItemShortcutContainer():
mBackgroundImg = Theme::getImageFromTheme("item_shortcut_bgr.png");
mMaxItems = itemShortcut->getItemCount();
- mBackgroundImg->setAlpha(config.getValue("guialpha", 0.8));
+ mBackgroundImg->setAlpha(config.getFloatValue("guialpha"));
mBoxHeight = mBackgroundImg->getHeight();
mBoxWidth = mBackgroundImg->getWidth();
@@ -67,9 +67,9 @@ ItemShortcutContainer::~ItemShortcutContainer()
void ItemShortcutContainer::draw(gcn::Graphics *graphics)
{
- if (config.getValue("guialpha", 0.8) != mAlpha)
+ if (config.getFloatValue("guialpha") != mAlpha)
{
- mAlpha = config.getValue("guialpha", 0.8);
+ mAlpha = config.getFloatValue("guialpha");
mBackgroundImg->setAlpha(mAlpha);
}
diff --git a/src/gui/widgets/listbox.cpp b/src/gui/widgets/listbox.cpp
index ef591023..2193b888 100644
--- a/src/gui/widgets/listbox.cpp
+++ b/src/gui/widgets/listbox.cpp
@@ -45,8 +45,8 @@ ListBox::~ListBox()
void ListBox::updateAlpha()
{
- float alpha = std::max(config.getValue("guialpha", 0.8),
- (double) Theme::instance()->getMinimumOpacity());
+ float alpha = std::max(config.getFloatValue("guialpha"),
+ Theme::instance()->getMinimumOpacity());
if (mAlpha != alpha)
mAlpha = alpha;
diff --git a/src/gui/widgets/playerbox.cpp b/src/gui/widgets/playerbox.cpp
index 468c77f5..cc9e963e 100644
--- a/src/gui/widgets/playerbox.cpp
+++ b/src/gui/widgets/playerbox.cpp
@@ -57,7 +57,7 @@ PlayerBox::PlayerBox(const Being *being):
bggridx[x], bggridy[y],
bggridx[x + 1] - bggridx[x] + 1,
bggridy[y + 1] - bggridy[y] + 1);
- background.grid[a]->setAlpha(config.getValue("guialpha", 0.8));
+ background.grid[a]->setAlpha(config.getFloatValue("guialpha"));
a++;
}
}
@@ -91,11 +91,11 @@ void PlayerBox::draw(gcn::Graphics *graphics)
mBeing->drawSpriteAt(static_cast<Graphics*>(graphics), x, y);
}
- if (config.getValue("guialpha", 0.8) != mAlpha)
+ if (config.getFloatValue("guialpha") != mAlpha)
{
for (int a = 0; a < 9; a++)
{
- background.grid[a]->setAlpha(config.getValue("guialpha", 0.8));
+ background.grid[a]->setAlpha(config.getFloatValue("guialpha"));
}
}
}
diff --git a/src/gui/widgets/progressbar.cpp b/src/gui/widgets/progressbar.cpp
index 028658ab..60c44fe2 100644
--- a/src/gui/widgets/progressbar.cpp
+++ b/src/gui/widgets/progressbar.cpp
@@ -123,8 +123,8 @@ void ProgressBar::logic()
void ProgressBar::updateAlpha()
{
- float alpha = std::max(config.getValue("guialpha", 0.8),
- (double) Theme::instance()->getMinimumOpacity());
+ float alpha = std::max(config.getFloatValue("guialpha"),
+ Theme::instance()->getMinimumOpacity());
if (mAlpha != alpha)
{
diff --git a/src/gui/widgets/radiobutton.cpp b/src/gui/widgets/radiobutton.cpp
index 96797225..4cbc22e7 100644
--- a/src/gui/widgets/radiobutton.cpp
+++ b/src/gui/widgets/radiobutton.cpp
@@ -78,9 +78,9 @@ RadioButton::~RadioButton()
void RadioButton::drawBox(gcn::Graphics* graphics)
{
- if (config.getValue("guialpha", 0.8) != mAlpha)
+ if (config.getFloatValue("guialpha") != mAlpha)
{
- mAlpha = config.getValue("guialpha", 0.8);
+ mAlpha = config.getFloatValue("guialpha");
radioNormal->setAlpha(mAlpha);
radioChecked->setAlpha(mAlpha);
radioDisabled->setAlpha(mAlpha);
diff --git a/src/gui/widgets/resizegrip.cpp b/src/gui/widgets/resizegrip.cpp
index f0c3691c..496e3727 100644
--- a/src/gui/widgets/resizegrip.cpp
+++ b/src/gui/widgets/resizegrip.cpp
@@ -59,9 +59,9 @@ ResizeGrip::~ResizeGrip()
void ResizeGrip::draw(gcn::Graphics *graphics)
{
- if (config.getValue("guialpha", 0.8) != mAlpha)
+ if (config.getFloatValue("guialpha") != mAlpha)
{
- mAlpha = config.getValue("guialpha", 0.8);
+ mAlpha = config.getFloatValue("guialpha");
gripImage->setAlpha(mAlpha);
}
diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp
index 0c7f4d7d..d8ffe5ab 100644
--- a/src/gui/widgets/scrollarea.cpp
+++ b/src/gui/widgets/scrollarea.cpp
@@ -108,7 +108,7 @@ void ScrollArea::init()
bggridx[x], bggridy[y],
bggridx[x + 1] - bggridx[x] + 1,
bggridy[y + 1] - bggridy[y] + 1);
- background.grid[a]->setAlpha(config.getValue("guialpha", 0.8));
+ background.grid[a]->setAlpha(config.getFloatValue("guialpha"));
a++;
}
}
@@ -135,8 +135,8 @@ void ScrollArea::init()
vsgridx[x], vsgridy[y],
vsgridx[x + 1] - vsgridx[x],
vsgridy[y + 1] - vsgridy[y]);
- vMarker.grid[a]->setAlpha(config.getValue("guialpha", 0.8));
- vMarkerHi.grid[a]->setAlpha(config.getValue("guialpha", 0.8));
+ vMarker.grid[a]->setAlpha(config.getFloatValue("guialpha"));
+ vMarkerHi.grid[a]->setAlpha(config.getFloatValue("guialpha"));
a++;
}
}
@@ -213,8 +213,8 @@ void ScrollArea::logic()
void ScrollArea::updateAlpha()
{
- float alpha = std::max(config.getValue("guialpha", 0.8),
- (double) Theme::instance()->getMinimumOpacity());
+ float alpha = std::max(config.getFloatValue("guialpha"),
+ Theme::instance()->getMinimumOpacity());
if (alpha != mAlpha)
{
diff --git a/src/gui/widgets/shoplistbox.cpp b/src/gui/widgets/shoplistbox.cpp
index 2f5fab34..b92ec6cb 100644
--- a/src/gui/widgets/shoplistbox.cpp
+++ b/src/gui/widgets/shoplistbox.cpp
@@ -71,8 +71,8 @@ void ShopListBox::draw(gcn::Graphics *gcnGraphics)
if (!mListModel)
return;
- if (config.getValue("guialpha", 0.8) != mAlpha)
- mAlpha = config.getValue("guialpha", 0.8);
+ if (config.getFloatValue("guialpha") != mAlpha)
+ mAlpha = config.getFloatValue("guialpha");
int alpha = (int)(mAlpha * 255.0f);
const gcn::Color* highlightColor =
diff --git a/src/gui/widgets/slider.cpp b/src/gui/widgets/slider.cpp
index 6a9a5c7c..00a8e86f 100644
--- a/src/gui/widgets/slider.cpp
+++ b/src/gui/widgets/slider.cpp
@@ -126,8 +126,8 @@ void Slider::init()
void Slider::updateAlpha()
{
- float alpha = std::max(config.getValue("guialpha", 0.8),
- (double) Theme::instance()->getMinimumOpacity());
+ float alpha = std::max(config.getFloatValue("guialpha"),
+ Theme::instance()->getMinimumOpacity());
if (alpha != mAlpha)
{
diff --git a/src/gui/widgets/tab.cpp b/src/gui/widgets/tab.cpp
index 2ab126dd..503a8e55 100644
--- a/src/gui/widgets/tab.cpp
+++ b/src/gui/widgets/tab.cpp
@@ -118,8 +118,8 @@ void Tab::init()
void Tab::updateAlpha()
{
- float alpha = std::max(config.getValue("guialpha", 0.8),
- (double) Theme::instance()->getMinimumOpacity());
+ float alpha = std::max(config.getFloatValue("guialpha"),
+ Theme::instance()->getMinimumOpacity());
// TODO We don't need to do this for every tab on every draw
// Maybe use a config listener to do it as the value changes.
diff --git a/src/gui/widgets/table.cpp b/src/gui/widgets/table.cpp
index f0887ed7..663d6d02 100644
--- a/src/gui/widgets/table.cpp
+++ b/src/gui/widgets/table.cpp
@@ -270,8 +270,8 @@ void GuiTable::draw(gcn::Graphics* graphics)
if (!mModel)
return;
- if (config.getValue("guialpha", 0.8) != mAlpha)
- mAlpha = config.getValue("guialpha", 0.8);
+ if (config.getFloatValue("guialpha") != mAlpha)
+ mAlpha = config.getFloatValue("guialpha");
if (mOpaque)
{
diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp
index 4453f522..f89f6239 100644
--- a/src/gui/widgets/textfield.cpp
+++ b/src/gui/widgets/textfield.cpp
@@ -65,7 +65,7 @@ TextField::TextField(const std::string &text, bool loseFocusOnTab):
gridx[x], gridy[y],
gridx[x + 1] - gridx[x] + 1,
gridy[y + 1] - gridy[y] + 1);
- skin.grid[a]->setAlpha(config.getValue("guialpha", 0.8));
+ skin.grid[a]->setAlpha(config.getFloatValue("guialpha"));
a++;
}
}
@@ -86,8 +86,8 @@ TextField::~TextField()
void TextField::updateAlpha()
{
- float alpha = std::max(config.getValue("guialpha", 0.8),
- (double) Theme::instance()->getMinimumOpacity());
+ float alpha = std::max(config.getFloatValue("guialpha"),
+ Theme::instance()->getMinimumOpacity());
if (alpha != mAlpha)
{
diff --git a/src/gui/widgets/textpreview.cpp b/src/gui/widgets/textpreview.cpp
index 10426d7c..869ebd35 100644
--- a/src/gui/widgets/textpreview.cpp
+++ b/src/gui/widgets/textpreview.cpp
@@ -45,8 +45,8 @@ TextPreview::TextPreview(const std::string &text):
void TextPreview::draw(gcn::Graphics* graphics)
{
- if (config.getValue("guialpha", 0.8) != mAlpha)
- mAlpha = config.getValue("guialpha", 0.8);
+ if (config.getFloatValue("guialpha") != mAlpha)
+ mAlpha = config.getFloatValue("guialpha");
int alpha = (int) (mAlpha * 255.0f);
diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp
index 118ee7c0..dafaaeed 100644
--- a/src/gui/widgets/window.cpp
+++ b/src/gui/widgets/window.cpp
@@ -697,8 +697,8 @@ int Window::getResizeHandles(gcn::MouseEvent &event)
int Window::getGuiAlpha()
{
- float alpha = std::max(config.getValue("guialpha", 0.8),
- (double) Theme::instance()->getMinimumOpacity());
+ float alpha = std::max(config.getFloatValue("guialpha"),
+ Theme::instance()->getMinimumOpacity());
return (int) (alpha * 255.0f);
}
diff --git a/src/item.cpp b/src/item.cpp
index 6e55ad0a..83e12cef 100644
--- a/src/item.cpp
+++ b/src/item.cpp
@@ -59,7 +59,7 @@ void Item::setId(int id)
ResourceManager *resman = ResourceManager::getInstance();
SpriteDisplay display = getInfo().getDisplay();
- std::string imagePath = paths.getValue("itemIcons", "graphics/items/")
+ std::string imagePath = paths.getStringValue("itemIcons")
+ display.image;
mImage = resman->getImage(imagePath);
mDrawImage = resman->getImage(imagePath);
diff --git a/src/joystick.cpp b/src/joystick.cpp
index f440c61f..9864a12b 100644
--- a/src/joystick.cpp
+++ b/src/joystick.cpp
@@ -61,11 +61,11 @@ Joystick::Joystick(int no):
logger->log("Hats: %i", SDL_JoystickNumHats(mJoystick));
logger->log("Buttons: %i", SDL_JoystickNumButtons(mJoystick));
- mEnabled = (int) config.getValue("joystickEnabled", 0) != 0;
- mUpTolerance = (int) config.getValue("upTolerance", 100);
- mDownTolerance = (int) config.getValue("downTolerance", 100);
- mLeftTolerance = (int) config.getValue("leftTolerance", 100);
- mRightTolerance = (int) config.getValue("rightTolerance", 100);
+ mEnabled = config.getBoolValue("joystickEnabled");
+ mUpTolerance = config.getIntValue("upTolerance");
+ mDownTolerance = config.getIntValue("downTolerance");
+ mLeftTolerance = config.getIntValue("leftTolerance");
+ mRightTolerance = config.getIntValue("rightTolerance");
}
Joystick::~Joystick()
diff --git a/src/map.cpp b/src/map.cpp
index 3727efdc..367083b6 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -356,7 +356,7 @@ void Map::draw(Graphics *graphics, int scrollX, int scrollY)
// Draw backgrounds
drawAmbientLayers(graphics, BACKGROUND_LAYERS, scrollX, scrollY,
- (int) config.getValue("OverlayDetail", 2));
+ config.getIntValue("OverlayDetail"));
// draw the game world
Layers::const_iterator layeri = mLayers.begin();
@@ -409,7 +409,7 @@ void Map::draw(Graphics *graphics, int scrollX, int scrollY)
}
drawAmbientLayers(graphics, FOREGROUND_LAYERS, scrollX, scrollY,
- (int) config.getValue("OverlayDetail", 2));
+ config.getIntValue("OverlayDetail"));
}
void Map::drawCollision(Graphics *graphics, int scrollX, int scrollY,
@@ -956,7 +956,7 @@ void Map::initializeParticleEffects(Particle *particleEngine)
{
Particle *p;
- if (config.getValue("particleeffects", 1))
+ if (config.getBoolValue("particleeffects"))
{
for (std::list<ParticleEffectData>::iterator i = particleEffects.begin();
i != particleEffects.end();
diff --git a/src/net/download.cpp b/src/net/download.cpp
index a2cd4910..83ab180f 100644
--- a/src/net/download.cpp
+++ b/src/net/download.cpp
@@ -221,8 +221,8 @@ int Download::downloadThread(void *ptr)
}
curl_easy_setopt(d->mCurl, CURLOPT_USERAGENT,
- strprintf(PACKAGE_EXTENDED_VERSION, branding
- .getValue("appShort", "mana").c_str()).c_str());
+ strprintf(PACKAGE_EXTENDED_VERSION,
+ branding.getStringValue("appShort").c_str()).c_str());
curl_easy_setopt(d->mCurl, CURLOPT_ERRORBUFFER, d->mError);
curl_easy_setopt(d->mCurl, CURLOPT_URL, d->mUrl.c_str());
curl_easy_setopt(d->mCurl, CURLOPT_NOPROGRESS, 0);
diff --git a/src/net/manaserv/playerhandler.cpp b/src/net/manaserv/playerhandler.cpp
index fa823a11..ee67c359 100644
--- a/src/net/manaserv/playerhandler.cpp
+++ b/src/net/manaserv/playerhandler.cpp
@@ -144,8 +144,8 @@ void PlayerHandler::handleMessage(Net::MessageIn &msg)
PlayerInfo::setAttribute(CHAR_POINTS, msg.readInt16());
PlayerInfo::setAttribute(CORR_POINTS, msg.readInt16());
Particle* effect = particleEngine->addEffect(
- paths.getValue("particles", "graphics/particles/")
- + paths.getValue("levelUpEffectFile", "levelup.particle.xml")
+ paths.getStringValue("particles")
+ + paths.getStringValue("levelUpEffectFile")
,0, 0);
player_node->controlParticle(effect);
} break;
diff --git a/src/net/tmwa/generalhandler.cpp b/src/net/tmwa/generalhandler.cpp
index 1cc6cb47..8d69767f 100644
--- a/src/net/tmwa/generalhandler.cpp
+++ b/src/net/tmwa/generalhandler.cpp
@@ -76,7 +76,7 @@ extern Party *taParty;
GeneralHandler::GeneralHandler():
mAdminHandler(new AdminHandler),
- mBeingHandler(new BeingHandler(config.getValue("EnableSync", 0) == 1)),
+ mBeingHandler(new BeingHandler(config.getBoolValue("EnableSync"))),
mBuySellHandler(new BuySellHandler),
mCharHandler(new CharServerHandler),
mChatHandler(new ChatHandler),
diff --git a/src/particle.cpp b/src/particle.cpp
index 6a3fd7da..e3c45a9f 100644
--- a/src/particle.cpp
+++ b/src/particle.cpp
@@ -86,10 +86,10 @@ Particle::~Particle()
void Particle::setupEngine()
{
- Particle::maxCount = (int)config.getValue("particleMaxCount", 3000);
- Particle::fastPhysics = (int)config.getValue("particleFastPhysics", 0);
- Particle::emitterSkip = (int)config.getValue("particleEmitterSkip", 1) + 1;
- Particle::enabled = (bool)config.getValue("particleeffects", true);
+ Particle::maxCount = config.getIntValue("particleMaxCount");
+ Particle::fastPhysics = config.getIntValue("particleFastPhysics");
+ Particle::emitterSkip = config.getIntValue("particleEmitterSkip") + 1;
+ Particle::enabled = config.getBoolValue("particleeffects");
disableAutoDelete();
logger->log("Particle engine set up");
}
diff --git a/src/resources/emotedb.cpp b/src/resources/emotedb.cpp
index c24e760b..bd8a8e38 100644
--- a/src/resources/emotedb.cpp
+++ b/src/resources/emotedb.cpp
@@ -43,7 +43,7 @@ void EmoteDB::load()
EmoteSprite *unknownSprite = new EmoteSprite;
unknownSprite->sprite = AnimatedSprite::load(
- paths.getValue("spriteErrorFile", "error.xml") );
+ paths.getStringValue("spriteErrorFile"));
unknownSprite->name = "unknown";
mUnknown.sprites.push_back(unknownSprite);
@@ -78,8 +78,7 @@ void EmoteDB::load()
if (xmlStrEqual(spriteNode->name, BAD_CAST "sprite"))
{
EmoteSprite *currentSprite = new EmoteSprite;
- std::string file = paths.getValue("sprites",
- "graphics/sprites/")
+ std::string file = paths.getStringValue("sprites")
+ (std::string) (const char*)
spriteNode->xmlChildrenNode->content;
currentSprite->sprite = AnimatedSprite::load(file,
diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp
index 65ce38aa..cbccc4cd 100644
--- a/src/resources/itemdb.cpp
+++ b/src/resources/itemdb.cpp
@@ -117,7 +117,7 @@ void ItemDB::load()
mUnknown = new ItemInfo;
mUnknown->setName(_("Unknown item"));
mUnknown->setDisplay(SpriteDisplay());
- std::string errFile = paths.getValue("spriteErrorFile", "error.xml");
+ std::string errFile = paths.getStringValue("spriteErrorFile");
mUnknown->setSprite(errFile, GENDER_MALE);
mUnknown->setSprite(errFile, GENDER_FEMALE);
diff --git a/src/resources/iteminfo.cpp b/src/resources/iteminfo.cpp
index b7b29ee5..9c275f96 100644
--- a/src/resources/iteminfo.cpp
+++ b/src/resources/iteminfo.cpp
@@ -69,7 +69,7 @@ void ItemInfo::setWeaponType(int type)
void ItemInfo::addSound(EquipmentSoundEvent event, const std::string &filename)
{
- mSounds[event].push_back(paths.getValue("sfx", "sfx/") + filename);
+ mSounds[event].push_back(paths.getStringValue("sfx") + filename);
}
const std::string &ItemInfo::getSound(EquipmentSoundEvent event) const
diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp
index a8582c9b..bb7ffee0 100644
--- a/src/resources/mapreader.cpp
+++ b/src/resources/mapreader.cpp
@@ -323,11 +323,9 @@ Map *MapReader::readMap(xmlNodePtr node, const std::string &path)
if (config.getValue("showWarps", 1))
{
map->addParticleEffect(
- paths.getValue("particles",
- "graphics/particles/")
- + paths.getValue("portalEffectFile",
- "warparea.particle.xml"),
- objX, objY, objW, objH);
+ paths.getStringValue("particles")
+ + paths.getStringValue("portalEffectFile"),
+ objX, objY, objW, objH);
}
}
else
diff --git a/src/resources/spritedef.cpp b/src/resources/spritedef.cpp
index 383e8a27..32fb5757 100644
--- a/src/resources/spritedef.cpp
+++ b/src/resources/spritedef.cpp
@@ -37,8 +37,7 @@
#include <set>
SpriteReference *SpriteReference::Empty = new SpriteReference(
- paths.getValue("spriteErrorFile", "error.xml"),
- 0);
+ paths.getStringValue("spriteErrorFile"), 0);
Action *SpriteDef::getAction(SpriteAction action) const
{
@@ -67,9 +66,8 @@ SpriteDef *SpriteDef::load(const std::string &animationFile, int variant)
{
logger->log("Error, failed to parse %s", animationFile.c_str());
- std::string errorFile = paths.getValue("sprites", "graphics/sprites")
- + paths.getValue("spriteErrorFile",
- "error.xml");
+ std::string errorFile = paths.getStringValue("sprites")
+ + paths.getStringValue("spriteErrorFile");
if (animationFile != errorFile)
{
return load(errorFile, 0);
@@ -287,8 +285,7 @@ void SpriteDef::includeSprite(xmlNodePtr includeNode)
if (filename.empty())
return;
- XML::Document doc(paths.getValue("sprites", "graphics/sprites/")
- + filename);
+ XML::Document doc(paths.getStringValue("sprites") + filename);
xmlNodePtr rootNode = doc.rootNode();
if (!rootNode || !xmlStrEqual(rootNode->name, BAD_CAST "sprite"))
diff --git a/src/resources/wallpaper.cpp b/src/resources/wallpaper.cpp
index 22bbda9c..06675ab1 100644
--- a/src/resources/wallpaper.cpp
+++ b/src/resources/wallpaper.cpp
@@ -53,26 +53,20 @@ static void initDefaultWallpaperPaths()
ResourceManager *resman = ResourceManager::getInstance();
// Init the path
- wallpaperPath = branding.getValue("wallpapersPath", "");
+ wallpaperPath = branding.getStringValue("wallpapersPath");
if (!wallpaperPath.empty() && resman->isDirectory(wallpaperPath))
return;
else
- wallpaperPath = paths.getValue("wallpapers", "");
-
- if (wallpaperPath.empty() || !resman->isDirectory(wallpaperPath))
- wallpaperPath = "graphics/images/";
+ wallpaperPath = paths.getValue("wallpapers", "graphics/images/");
// Init the default file
- wallpaperFile = branding.getValue("wallpaperFile", "");
+ wallpaperFile = branding.getStringValue("wallpaperFile");
- if (!wallpaperFile.empty() && resman->isDirectory(wallpaperFile))
+ if (!wallpaperFile.empty())
return;
else
- wallpaperFile = paths.getValue("wallpaperFile", "");
-
- if (wallpaperFile.empty() || !resman->isDirectory(wallpaperFile))
- wallpaperFile = "login_wallpaper.png";
+ wallpaperFile = paths.getValue("wallpaperFile", "login_wallpaper.png");
}
bool wallpaperCompare(WallpaperData a, WallpaperData b)
@@ -82,7 +76,7 @@ bool wallpaperCompare(WallpaperData a, WallpaperData b)
return (aa > ab || (aa == ab && a.width > b.width));
}
-
+#include <iostream>
void Wallpaper::loadWallpapers()
{
wallpaperData.clear();
diff --git a/src/sound.cpp b/src/sound.cpp
index 241e25e4..a859cb6e 100644
--- a/src/sound.cpp
+++ b/src/sound.cpp
@@ -142,7 +142,7 @@ void Sound::setSfxVolume(int volume)
static Mix_Music *loadMusic(const std::string &filename)
{
ResourceManager *resman = ResourceManager::getInstance();
- std::string path = resman->getPath("music/" + filename);
+ std::string path = resman->getPath(paths.getStringValue("music") + filename);
if (path.find(".zip/") != std::string::npos ||
path.find(".zip\\") != std::string::npos)
@@ -152,7 +152,7 @@ static Mix_Music *loadMusic(const std::string &filename)
logger->log("Loading music \"%s\" from temporary file tempMusic.ogg",
path.c_str());
bool success = resman->copyFile(
- paths.getValue("music", "music/")
+ paths.getStringValue("music")
+ filename, "tempMusic.ogg");
if (success)
path = resman->getPath("tempMusic.ogg");
@@ -240,7 +240,7 @@ void Sound::playSfx(const std::string &path)
ResourceManager *resman = ResourceManager::getInstance();
SoundEffect *sample = resman->getSoundEffect(
- paths.getValue("sfx", "sfx/") + path);
+ paths.getStringValue("sfx") + path);
if (sample)
{
logger->log("Sound::playSfx() Playing: %s", path.c_str());
diff --git a/src/statuseffect.cpp b/src/statuseffect.cpp
index 1f913f4a..ed0edd78 100644
--- a/src/statuseffect.cpp
+++ b/src/statuseffect.cpp
@@ -70,7 +70,7 @@ AnimatedSprite *StatusEffect::getIcon()
else
{
AnimatedSprite *sprite = AnimatedSprite::load(
- paths.getValue("sprites", "graphics/sprites/") + mIcon);
+ paths.getStringValue("sprites") + mIcon);
if (false && sprite)
{
sprite->play(ACTION_DEFAULT);
diff --git a/src/text.cpp b/src/text.cpp
index 9f970872..5e84392e 100644
--- a/src/text.cpp
+++ b/src/text.cpp
@@ -56,7 +56,7 @@ Text::Text(const std::string &text, int x, int y,
{
textManager = new TextManager;
Image *sbImage = Theme::getImageFromTheme("bubble.png|W:#"
- + config.getValue("speechBubblecolor", "000000"));
+ + config.getStringValue("speechBubblecolor"));
mBubble.grid[0] = sbImage->getSubImage(0, 0, 5, 5);
mBubble.grid[1] = sbImage->getSubImage(5, 0, 5, 5);
mBubble.grid[2] = sbImage->getSubImage(10, 0, 5, 5);
@@ -67,7 +67,7 @@ Text::Text(const std::string &text, int x, int y,
mBubble.grid[7] = sbImage->getSubImage(5, 10, 5, 5);
mBubble.grid[8] = sbImage->getSubImage(10, 10, 5, 5);
mBubbleArrow = sbImage->getSubImage(0, 15, 15, 10);
- const float bubbleAlpha = config.getValue("speechBubbleAlpha", 1.0);
+ const float bubbleAlpha = config.getFloatValue("speechBubbleAlpha");
for (int i = 0; i < 9; i++)
{
mBubble.grid[i]->setAlpha(bubbleAlpha);
diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp
index 9fe3de14..3988c769 100644
--- a/src/utils/stringutils.cpp
+++ b/src/utils/stringutils.cpp
@@ -26,7 +26,7 @@
#include <cstdarg>
#include <cstdio>
-const int UTF8_MAX_SIZE = 10;
+static int UTF8_MAX_SIZE = 10;
std::string &trim(std::string &str)
{
@@ -174,4 +174,16 @@ const char* getSafeUtf8String(std::string text)
memcpy(buf, text.c_str(), text.size());
memset(buf + text.size(), 0, UTF8_MAX_SIZE);
return buf;
-} \ No newline at end of file
+}
+
+bool getBoolFromString(const std::string &text)
+{
+ std::string txt = text;
+ toLower(trim(txt));
+ if (txt == "true" || txt == "yes" || txt == "on" || txt == "1")
+ return true;
+ else if (txt == "false" || txt == "no" || txt == "off" || txt == "0")
+ return false;
+ else
+ return (bool) atoi(txt.c_str());
+}
diff --git a/src/utils/stringutils.h b/src/utils/stringutils.h
index ec82e240..7c14b1e5 100644
--- a/src/utils/stringutils.h
+++ b/src/utils/stringutils.h
@@ -125,4 +125,12 @@ const std::string findSameSubstring(const std::string &str1, const std::string &
const char* getSafeUtf8String(std::string text);
+/**
+ * Returns a bool value depending on the given string value.
+ *
+ * @param text the string used to get the bool value
+ * @return a boolean value..
+ */
+bool getBoolFromString(const std::string &text);
+
#endif // UTILS_STRINGUTILS_H
diff --git a/src/variabledata.h b/src/variabledata.h
index c2eca3fb..4f58c1fd 100644
--- a/src/variabledata.h
+++ b/src/variabledata.h
@@ -29,11 +29,13 @@ namespace Mana
class VariableData
{
public:
- enum {
+ enum DataType
+ {
DATA_NONE,
DATA_INT,
DATA_STRING,
- DATA_FLOAT
+ DATA_FLOAT,
+ DATA_BOOL
};
virtual ~VariableData() {};
@@ -70,14 +72,27 @@ private:
class FloatData : public VariableData
{
public:
- FloatData(double value) { mData = value; }
+ FloatData(float value) { mData = value; }
- double getData() const { return mData; }
+ float getData() const { return mData; }
int getType() const { return DATA_FLOAT; }
private:
- double mData;
+ float mData;
+};
+
+class BoolData : public VariableData
+{
+public:
+ BoolData(bool value) { mData = value; }
+
+ bool getData() const { return mData; }
+
+ int getType() const { return DATA_BOOL; }
+
+private:
+ bool mData;
};
} // namespace Mana