Commit 2b1c0dcf269d617de1f6c203df547166661f089e

  • avatar
  • Yohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>
  • Wed Jul 28 19:57:31 CEST 2010
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.
mana.cbp
(2 / 0)
  
125125 <Unit filename="src\configlistener.h" />
126126 <Unit filename="src\configuration.cpp" />
127127 <Unit filename="src\configuration.h" />
128 <Unit filename="src\defaults.cpp" />
129 <Unit filename="src\defaults.h" />
128130 <Unit filename="src\effectmanager.cpp" />
129131 <Unit filename="src\effectmanager.h" />
130132 <Unit filename="src\emoteshortcut.cpp" />
  
434434 configlistener.h
435435 configuration.cpp
436436 configuration.h
437 defaults.cpp
438 defaults.h
437439 effectmanager.cpp
438440 effectmanager.h
439441 emoteshortcut.cpp
  
333333 configlistener.h \
334334 configuration.cpp \
335335 configuration.h \
336 defaults.cpp \
337 defaults.h \
336338 effectmanager.cpp \
337339 effectmanager.h \
338340 emoteshortcut.cpp \
  
112112 mWalkSpeed = Net::getPlayerHandler()->getDefaultWalkSpeed();
113113
114114 if (getType() == PLAYER)
115 mShowName = config.getValue("visiblenames", 1);
115 mShowName = config.getBoolValue("visiblenames");
116116
117117 config.addListener("visiblenames", this);
118118
298298 if (!mSpeech.empty())
299299 mSpeechTime = time <= SPEECH_MAX_TIME ? time : SPEECH_MAX_TIME;
300300
301 const int speech = (int) config.getValue("speech", TEXT_OVERHEAD);
301 const int speech = config.getIntValue("speech");
302302 if (speech == TEXT_OVERHEAD)
303303 {
304304 if (mText)
887887{
888888 const int px = getPixelX() - offsetX;
889889 const int py = getPixelY() - offsetY;
890 const int speech = (int) config.getValue("speech", TEXT_OVERHEAD);
890 const int speech = config.getIntValue("speech");
891891
892892 // Draw speech above this being
893893 if (mSpeechTime == 0)
994994{
995995 if (getType() == PLAYER && value == "visiblenames")
996996 {
997 setShowName(config.getValue("visiblenames", 1));
997 setShowName(config.getBoolValue("visiblenames"));
998998 }
999999}
10001000
10101010 mDispName = 0;
10111011 std::string mDisplayName(mName);
10121012
1013 if (config.getValue("showgender", false))
1013 if (config.getBoolValue("showgender"))
10141014 {
10151015 if (getGender() == GENDER_FEMALE)
10161016 mDisplayName += " \u2640";
10201020
10211021 if (getType() == MONSTER)
10221022 {
1023 if (config.getValue("showMonstersTakedDamage", false))
1023 if (config.getBoolValue("showMonstersTakedDamage"))
10241024 {
10251025 mDisplayName += ", " + toString(getDamageTaken());
10261026 }
11131113 if (!color.empty())
11141114 filename += "|" + color;
11151115
1116 equipmentSprite = AnimatedSprite::load("graphics/sprites/" +
1117 filename);
1116 equipmentSprite = AnimatedSprite::load(
1117 paths.getStringValue("sprites") + filename);
11181118 }
11191119
11201120 if (equipmentSprite)
11541154 int hairstyles = 1;
11551155
11561156 while (ItemDB::get(-hairstyles).getSprite(GENDER_MALE) !=
1157 paths.getValue("spriteErrorFile", "error.xml"))
1157 paths.getStringValue("spriteErrorFile"))
11581158 hairstyles++;
11591159
11601160 mNumberOfHairstyles = hairstyles;
  
150150{
151151 mServerName = serverName;
152152 if (mServerName == "")
153 mServerName = config.getValue("MostUsedServerName0",
154 "server.themanaworld.org");
153 mServerName = config.getStringValue("MostUsedServerName0");
155154
156155 if (mLogFile.is_open())
157156 mLogFile.close();
  
219219 if (!options.brandingPath.empty())
220220 {
221221 branding.init(options.brandingPath);
222 branding.setDefaultValues(getBrandingDefaults());
222223 }
223224
224225 initHomeDir();
233233
234234 // Configure logger
235235 logger->setLogFile(mLocalDataDir + std::string("/mana.log"));
236 logger->setLogToStandardOut(config.getValue("logToStandardOut", 0));
236 logger->setLogToStandardOut(config.getBoolValue("logToStandardOut"));
237237
238238 // Log the mana version
239239 logger->log("Mana %s", FULL_VERSION);
337337 graphics = new Graphics;
338338#endif
339339
340 const int width = (int) config.getValue("screenwidth", defaultScreenWidth);
341 const int height = (int) config.getValue("screenheight", defaultScreenHeight);
340 const int width = config.getIntValue("screenwidth");
341 const int height = config.getIntValue("screenheight");
342342 const int bpp = 0;
343 const bool fullscreen = ((int) config.getValue("screen", 0) == 1);
344 const bool hwaccel = ((int) config.getValue("hwaccel", 0) == 1);
343 const bool fullscreen = config.getBoolValue("screen");
344 const bool hwaccel = config.getBoolValue("hwaccel");
345345
346346 // Try to set the desired video mode
347347 if (!graphics->setVideoMode(width, height, bpp, fullscreen, hwaccel))
364364 // Initialize sound engine
365365 try
366366 {
367 if (config.getValue("sound", 0) == 1)
367 if (config.getBoolValue("sound"))
368368 sound.init();
369369
370 sound.setSfxVolume((int) config.getValue("sfxVolume",
371 defaultSfxVolume));
372 sound.setMusicVolume((int) config.getValue("musicVolume",
373 defaultMusicVolume));
370 sound.setSfxVolume(config.getIntValue("sfxVolume"));
371 sound.setMusicVolume(config.getIntValue("musicVolume"));
374372 }
375373 catch (const char *err)
376374 {
393393 mCurrentServer.port = options.serverPort;
394394 loginData.username = options.username;
395395 loginData.password = options.password;
396 loginData.remember = config.getValue("remember", 0);
396 loginData.remember = config.getBoolValue("remember");
397397 loginData.registerLogin = false;
398398
399399 if (mCurrentServer.hostname.empty())
400 {
401 mCurrentServer.hostname = branding.getValue("defaultServer",
402 "").c_str();
403 }
400 mCurrentServer.hostname = branding.getValue("defaultServer","").c_str();
404401
405402 if (mCurrentServer.port == 0)
406403 {
407404 mCurrentServer.port = (short) branding.getValue("defaultPort",
408 DEFAULT_PORT);
405 DEFAULT_PORT);
409406 mCurrentServer.type = ServerInfo::parseType(
410 branding.getValue("defaultServerType", "tmwathena"));
407 branding.getValue("defaultServerType", "tmwathena"));
411408 }
412409
413410 if (chatLogger)
414411 chatLogger->setServerName(mCurrentServer.hostname);
415412
416413 if (loginData.username.empty() && loginData.remember)
417 loginData.username = config.getValue("username", "");
414 loginData.username = config.getStringValue("username");
418415
419416 if (mState != STATE_ERROR)
420417 mState = STATE_CHOOSE_SERVER;
573573 - 3, 3);
574574 top->add(mSetupButton);
575575
576 int screenWidth = (int) config.getValue("screenwidth",
577 defaultScreenWidth);
578 int screenHeight = (int) config.getValue("screenheight",
579 defaultScreenHeight);
576 int screenWidth = config.getIntValue("screenwidth");
577 int screenHeight = config.getIntValue("screenheight");
580578
581579 mDesktop->setSize(screenWidth, screenHeight);
582580 }
743743
744744 // Read default paths file 'data/paths.xml'
745745 paths.init("paths.xml", true);
746 paths.setDefaultValues(getPathsDefaults());
746747
747748 // Load XML databases
748749 ColorDB::load();
783783 mOptions.character, CharSelectDialog::Choose))
784784 {
785785 ((CharSelectDialog*) mCurrentDialog)->selectByName(
786 config.getValue("lastCharacter", ""),
786 config.getStringValue("lastCharacter"),
787787 mOptions.chooseDefault ?
788788 CharSelectDialog::Choose :
789789 CharSelectDialog::Focus);
995995
996996void Client::optionChanged(const std::string &name)
997997{
998 const int fpsLimit = (int) config.getValue("fpslimit", 60);
998 const int fpsLimit = config.getIntValue("fpslimit");
999999 mLimitFps = fpsLimit > 0;
10001000 if (mLimitFps)
10011001 SDL_setFramerate(&mFpsManager, fpsLimit);
11461146 {
11471147 fclose(configFile);
11481148 config.init(configPath);
1149 config.setDefaultValues(getConfigDefaults());
11491150 }
11501151}
11511152
11611161 // If updatesHost is currently empty, fill it from config file
11621162 if (mUpdateHost.empty())
11631163 {
1164 mUpdateHost = config.getValue("updatehost", "");
1164 mUpdateHost = config.getStringValue("updatehost");
11651165 }
11661166
11671167 // Don't go out of range int he next check
12391239 else
12401240 {
12411241 std::string configScreenshotDir =
1242 config.getValue("screenshotDirectory", "");
1242 config.getStringValue("screenshotDirectory");
12431243 if (!configScreenshotDir.empty())
12441244 mScreenshotDir = configScreenshotDir;
12451245 else
12541254 }
12551255 config.setValue("screenshotDirectory", mScreenshotDir);
12561256
1257 if (config.getValue("useScreenshotDirectorySuffix", true))
1257 if (config.getBoolValue("useScreenshotDirectorySuffix"))
12581258 {
12591259 std::string configScreenshotSuffix =
12601260 config.getValue("screenshotDirectorySuffix",
  
9898 clear();
9999}
100100
101void Configuration::cleanDefaults()
102{
103 if (mDefaultsData)
104 {
105 for (DefaultsData::const_iterator iter = mDefaultsData->begin();
106 iter != mDefaultsData->end(); iter++)
107 {
108 if (iter->second)
109 delete(iter->second);
110 }
111 mDefaultsData->clear();
112 delete mDefaultsData;
113 mDefaultsData = 0;
114 }
115}
116
117Configuration::~Configuration()
118{
119 cleanDefaults();
120}
121
122void Configuration::setDefaultValues(DefaultsData *defaultsData)
123{
124 cleanDefaults();
125 mDefaultsData = defaultsData;
126}
127
128int Configuration::getIntValue(const std::string &key) const
129{
130 int defaultValue = 0;
131 if (mDefaultsData)
132 {
133 DefaultsData::const_iterator itdef = mDefaultsData->find(key);
134
135 if (itdef != mDefaultsData->end() && itdef->second
136 && itdef->second->getType() == Mana::VariableData::DATA_INT)
137 {
138 defaultValue = ((Mana::IntData*)itdef->second)->getData();
139 }
140 else
141 {
142 logger->log("%s: No integer value in registry for key %s",
143 mConfigPath.c_str(), key.c_str());
144 }
145 }
146 Options::const_iterator iter = mOptions.find(key);
147 return (iter != mOptions.end()) ? atoi(iter->second.c_str()) : defaultValue;
148}
149
150std::string Configuration::getStringValue(const std::string &key) const
151{
152 std::string defaultValue = "";
153 if (mDefaultsData)
154 {
155 DefaultsData::const_iterator itdef = mDefaultsData->find(key);
156
157 if (itdef != mDefaultsData->end() && itdef->second
158 && itdef->second->getType() == Mana::VariableData::DATA_STRING)
159 {
160 defaultValue = ((Mana::StringData*)itdef->second)->getData();
161 }
162 else
163 {
164 logger->log("%s: No string value in registry for key %s",
165 mConfigPath.c_str(), key.c_str());
166 }
167 }
168 Options::const_iterator iter = mOptions.find(key);
169 return (iter != mOptions.end()) ? iter->second : defaultValue;
170}
171
172
173float Configuration::getFloatValue(const std::string &key) const
174{
175 float defaultValue = 0.0f;
176 if (mDefaultsData)
177 {
178 DefaultsData::const_iterator itdef = mDefaultsData->find(key);
179
180 if (itdef != mDefaultsData->end() && itdef->second
181 && itdef->second->getType() == Mana::VariableData::DATA_FLOAT)
182 {
183 defaultValue = ((Mana::FloatData*)itdef->second)->getData();
184 }
185 else
186 {
187 logger->log("%s: No float value in registry for key %s",
188 mConfigPath.c_str(), key.c_str());
189 }
190 }
191 Options::const_iterator iter = mOptions.find(key);
192 return (iter != mOptions.end()) ? atof(iter->second.c_str()) : defaultValue;
193}
194
195bool Configuration::getBoolValue(const std::string &key) const
196{
197 bool defaultValue = false;
198 if (mDefaultsData)
199 {
200 DefaultsData::const_iterator itdef = mDefaultsData->find(key);
201
202 if (itdef != mDefaultsData->end() && itdef->second
203 && itdef->second->getType() == Mana::VariableData::DATA_BOOL)
204 {
205 defaultValue = ((Mana::BoolData*)itdef->second)->getData();
206 }
207 else
208 {
209 logger->log("%s: No boolean value in registry for key %s",
210 mConfigPath.c_str(), key.c_str());
211 }
212 }
213
214 Options::const_iterator iter = mOptions.find(key);
215 if (iter != mOptions.end())
216 return getBoolFromString(iter->second);
217 else
218 return defaultValue;
219}
220
101221void ConfigurationObject::initFromXML(xmlNodePtr parent_node)
102222{
103223 clear();
  
2323#define CONFIGURATION_H
2424
2525#include "utils/stringutils.h"
26#include "defaults.h"
2627
2728#include <libxml/xmlwriter.h>
2829
193193class Configuration : public ConfigurationObject
194194{
195195 public:
196 virtual ~Configuration() {}
196 ~Configuration();
197197
198198 /**
199199 * Reads config file and parse all options into memory.
204204 void init(const std::string &filename, bool useResManager = false);
205205
206206 /**
207 * Set the default values for each keys.
208 *
209 * @param defaultsData data used as defaults.
210 */
211 void setDefaultValues(DefaultsData *defaultsData);
212
213 /**
207214 * Writes the current settings back to the config file.
208215 */
209216 void write();
246246 inline void setValue(const std::string &key, bool value)
247247 { setValue(key, value ? "1" : "0"); }
248248
249 /**
250 * returns a value corresponding to the given key.
251 * The default value returned in based on fallbacks registry.
252 * @see defaults.h
253 */
254 int getIntValue(const std::string &key) const;
255 float getFloatValue(const std::string &key) const;
256 std::string getStringValue(const std::string &key) const;
257 bool getBoolValue(const std::string &key) const;
258
249259 private:
260 /**
261 * Clean up the default values member.
262 */
263 void cleanDefaults();
264
250265 typedef std::list<ConfigListener*> Listeners;
251266 typedef Listeners::iterator ListenerIterator;
252267 typedef std::map<std::string, Listeners> ListenerMap;
253268 typedef ListenerMap::iterator ListenerMapIterator;
254269 ListenerMap mListenerMap;
255270
256 std::string mConfigPath; /**< Location of config file */
271 std::string mConfigPath; /**< Location of config file */
272 DefaultsData *mDefaultsData; /**< Defaults of value for a given key */
257273};
258274
259275extern Configuration branding;
  
1/*
2 * The Mana Client
3 * Copyright (C) 2010 The Mana Developers
4 *
5 * This file is part of The Mana Client.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#include "defaults.h"
22
23#include "utils/stringutils.h"
24
25#include "being.h"
26#include "graphics.h"
27#include "client.h"
28
29#include <stdlib.h>
30
31using namespace Mana;
32
33VariableData* createData(int defData)
34{
35 return new IntData(defData);
36}
37
38VariableData* createData(float defData)
39{
40 return new FloatData(defData);
41}
42
43VariableData* createData(const std::string &defData)
44{
45 return new StringData(defData);
46}
47
48VariableData* createData(const char* defData)
49{
50 return new StringData(defData);
51}
52
53VariableData* createData(bool defData)
54{
55 return new BoolData(defData);
56}
57
58#define AddDEF(defaultsData, key, value) \
59 defaultsData->insert(std::pair<std::string, VariableData*> \
60 (key, createData(value)));
61
62
63DefaultsData* getConfigDefaults()
64{
65 DefaultsData* configData = new DefaultsData;
66 // Init main config defaults
67 AddDEF(configData, "OverlayDetail", 2);
68 AddDEF(configData, "speechBubblecolor", "000000");
69 AddDEF(configData, "speechBubbleAlpha", 1.0f);
70 AddDEF(configData, "MostUsedServerName0", "server.themanaworld.org");
71 AddDEF(configData, "visiblenames", true);
72 AddDEF(configData, "speech", Being::TEXT_OVERHEAD);
73 AddDEF(configData, "showgender", false);
74 AddDEF(configData, "showMonstersTakedDamage", false);
75 AddDEF(configData, "particleMaxCount", 3000);
76 AddDEF(configData, "particleFastPhysics", 0);
77 AddDEF(configData, "particleEmitterSkip", 1);
78 AddDEF(configData, "particleeffects", true);
79 AddDEF(configData, "logToStandardOut", false);
80 AddDEF(configData, "opengl", false);
81 AddDEF(configData, "screenwidth", defaultScreenWidth);
82 AddDEF(configData, "screenheight", defaultScreenHeight);
83 AddDEF(configData, "screen", false);
84 AddDEF(configData, "hwaccel", false);
85 AddDEF(configData, "sound", false);
86 AddDEF(configData, "sfxVolume", 100);
87 AddDEF(configData, "musicVolume", 60);
88 AddDEF(configData, "remember", false);
89 AddDEF(configData, "username", "");
90 AddDEF(configData, "lastCharacter", "");
91 AddDEF(configData, "fpslimit", 60);
92 AddDEF(configData, "updatehost", "");
93 AddDEF(configData, "screenshotDirectory", "");
94 AddDEF(configData, "useScreenshotDirectorySuffix", true);
95 AddDEF(configData, "screenshotDirectorySuffix", "");
96 AddDEF(configData, "EnableSync", false);
97 AddDEF(configData, "joystickEnabled", false);
98 AddDEF(configData, "upTolerance", 100);
99 AddDEF(configData, "downTolerance", 100);
100 AddDEF(configData, "leftTolerance", 100);
101 AddDEF(configData, "rightTolerance", 100);
102 AddDEF(configData, "logNpcInGui", true);
103 AddDEF(configData, "download-music", false);
104 AddDEF(configData, "guialpha", 0.8f);
105 AddDEF(configData, "ChatLogLength", 0);
106 AddDEF(configData, "enableChatLog", false);
107 AddDEF(configData, "whispertab", false);
108 AddDEF(configData, "customcursor", true);
109 AddDEF(configData, "showownname", false);
110 AddDEF(configData, "showpickupparticle", false);
111 AddDEF(configData, "showpickupchat", true);
112 AddDEF(configData, "fontSize", 11);
113 AddDEF(configData, "ReturnToggles", false);
114 AddDEF(configData, "ScrollLaziness", 16);
115 AddDEF(configData, "ScrollRadius", 0);
116 AddDEF(configData, "ScrollCenterOffsetX", 0);
117 AddDEF(configData, "ScrollCenterOffsetY", 0);
118 AddDEF(configData, "onlineServerList", "");
119 AddDEF(configData, "theme", "");
120
121 return configData;
122}
123
124DefaultsData* getBrandingDefaults()
125{
126 DefaultsData* brandingData = new DefaultsData;
127 // Init config defaults
128 AddDEF(brandingData, "wallpapersPath", "");
129 AddDEF(brandingData, "wallpapersFile", "");
130 AddDEF(brandingData, "appName", "Mana");
131 AddDEF(brandingData, "appIcon", "icons/mana.png");
132 AddDEF(brandingData, "loginMusic", "Magick - Real.ogg");
133 AddDEF(brandingData, "defaultServer", "");
134 AddDEF(brandingData, "defaultPort", DEFAULT_PORT);
135 AddDEF(brandingData, "defaultServerType", "tmwathena");
136 AddDEF(brandingData, "onlineServerList", "a");
137 AddDEF(brandingData, "appShort", "mana");
138 AddDEF(brandingData, "defaultUpdateHost", "");
139 AddDEF(brandingData, "helpPath", "");
140 AddDEF(brandingData, "onlineServerList", "");
141 AddDEF(brandingData, "guiThemePath", "");
142 AddDEF(brandingData, "theme", "");
143 AddDEF(brandingData, "font", "fonts/dejavusans.ttf");
144 AddDEF(brandingData, "boldFont", "fonts/dejavusans-bold.ttf");
145
146 return brandingData;
147}
148
149DefaultsData* getPathsDefaults()
150{
151 DefaultsData *pathsData = new DefaultsData;
152 // Init paths.xml defaults
153 AddDEF(pathsData, "itemIcons", "graphics/items/");
154 AddDEF(pathsData, "unknownItemFile", "unknown-item.png");
155 AddDEF(pathsData, "sprites", "graphics/sprites/");
156 AddDEF(pathsData, "spriteErrorFile", "error.xml");
157
158 AddDEF(pathsData, "particles", "graphics/particles/");
159 AddDEF(pathsData, "levelUpEffectFile", "levelup.particle.xml");
160 AddDEF(pathsData, "portalEffectFile", "warparea.particle.xml");
161
162 AddDEF(pathsData, "minimaps", "graphics/minimaps/");
163 AddDEF(pathsData, "maps", "maps/");
164
165 AddDEF(pathsData, "sfx", "sfx/");
166 AddDEF(pathsData, "attackSfxFile", "fist-swish.ogg");
167 AddDEF(pathsData, "music", "music/");
168
169 AddDEF(pathsData, "wallpapers", "graphics/images/");
170 AddDEF(pathsData, "wallpaperFile", "login_wallpaper.png");
171
172 AddDEF(pathsData, "help", "help/");
173
174 return pathsData;
175}
176
177#undef AddDEF
  
1/*
2 * The Mana Client
3 * Copyright (C) 2010 The Mana Developers
4 *
5 * This file is part of The Mana Client.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#ifndef DEFAULTS_H
22#define DEFAULTS_H
23
24#include <map>
25#include <string>
26#include "variabledata.h"
27
28typedef std::map<std::string, Mana::VariableData*> DefaultsData;
29
30DefaultsData* getConfigDefaults();
31DefaultsData* getBrandingDefaults();
32DefaultsData* getPathsDefaults();
33
34#endif
  
110110 mChatInput->addKeyListener(this);
111111 mCurHist = mHistory.end();
112112
113 mReturnToggles = config.getValue("ReturnToggles", "0") == "1";
113 mReturnToggles = config.getBoolValue("ReturnToggles");
114114
115115 mRecorder = new Recorder(this);
116116}
478478
479479 if (i != mWhispers.end())
480480 tab = i->second;
481 else if (config.getValue("whispertab", true))
481 else if (config.getBoolValue("whispertab"))
482482 tab = addWhisperTab(nick);
483483
484484 if (tab)
  
6161 if (!mSelectionImage)
6262 logger->error("Unable to load selection.png");
6363
64 mSelectionImage->setAlpha(config.getValue("guialpha", 0.8));
64 mSelectionImage->setAlpha(config.getFloatValue("guialpha"));
6565
6666 addMouseListener(this);
6767 recalculateSize();
  
6161 {
6262 if (name == "customcursor")
6363 {
64 bool bCustomCursor = config.getValue("customcursor", 1) == 1;
64 bool bCustomCursor = config.getBoolValue("customcursor");
6565 mGui->setUseCustomCursor(bCustomCursor);
6666 }
6767 }
104104 ResourceManager *resman = ResourceManager::getInstance();
105105
106106 // Set global font
107 const int fontSize = (int) config.getValue("fontSize", 11);
107 const int fontSize = config.getValue("fontSize", 11);
108108 std::string fontFile = branding.getValue("font", "fonts/dejavusans.ttf");
109109 std::string path = resman->getPath(fontFile);
110110
135135 gcn::Widget::setGlobalFont(mGuiFont);
136136
137137 // Initialize mouse cursor and listen for changes to the option
138 setUseCustomCursor(config.getValue("customcursor", 1) == 1);
138 setUseCustomCursor(config.getBoolValue("customcursor"));
139139 mConfigListener = new GuiConfigListener(this);
140140 config.addListener("customcursor", mConfigListener);
141141}
  
9494void HelpWindow::loadFile(const std::string &file)
9595{
9696 ResourceManager *resman = ResourceManager::getInstance();
97 std::string helpPath = branding.getValue("helpPath", "");
97 std::string helpPath = branding.getStringValue("helpPath");
9898 if (helpPath.empty())
99 helpPath = paths.getValue("help", "help/");
99 helpPath = paths.getStringValue("help");
100100 std::vector<std::string> lines =
101101 resman->loadTextFile(helpPath + file + ".txt");
102102
  
103103 {
104104 ResourceManager *resman = ResourceManager::getInstance();
105105 Image *image = resman->getImage(
106 paths.getValue("itemIcons", "graphics/items/")
106 paths.getStringValue("itemIcons")
107107 + item.getDisplay().image);
108108
109109 mIcon->setImage(image);
  
5151NpcDialog::NpcDialog(int npcId)
5252 : Window(_("NPC")),
5353 mNpcId(npcId),
54 mLogInteraction(config.getValue("logNpcInGui", true)),
54 mLogInteraction(config.getBoolValue("logNpcInGui")),
5555 mDefaultInt(0),
5656 mInputState(NPC_INPUT_NONE),
5757 mActionState(NPC_ACTION_WAIT)
369369{
370370 if (name == "logNpcInGui")
371371 {
372 mLogInteraction = config.getValue("logNpcInGui", true);
372 mLogInteraction = config.getBoolValue("logNpcInGui");
373373 }
374374}
375375
  
485485void ServerDialog::downloadServerList()
486486{
487487 // Try to load the configuration value for the onlineServerList
488 std::string listFile = branding.getValue("onlineServerList", std::string());
488 std::string listFile = branding.getStringValue("onlineServerList");
489489
490490 if (listFile.empty())
491 listFile = config.getValue("onlineServerList", std::string());
491 listFile = config.getStringValue("onlineServerList");
492492
493493 // Fall back to manasource.org when neither branding nor config set it
494494 if (listFile.empty())
  
3535#include "utils/gettext.h"
3636
3737Setup_Audio::Setup_Audio():
38 mMusicVolume((int)config.getValue("musicVolume", 60)),
39 mSfxVolume((int)config.getValue("sfxVolume", 100)),
40 mSoundEnabled(config.getValue("sound", 0)),
41 mDownloadEnabled(config.getValue("download-music", false)),
38 mMusicVolume(config.getIntValue("musicVolume")),
39 mSfxVolume(config.getIntValue("sfxVolume")),
40 mSoundEnabled(config.getBoolValue("sound")),
41 mDownloadEnabled(config.getBoolValue("download-music")),
4242 mSoundCheckBox(new CheckBox(_("Sound"), mSoundEnabled)),
4343 mDownloadMusicCheckBox(new CheckBox(_("Download music"), mDownloadEnabled)),
4444 mSfxSlider(new Slider(0, sound.getMaxVolume())),
8282{
8383 mSoundEnabled = mSoundCheckBox->isSelected();
8484 mDownloadEnabled = mDownloadMusicCheckBox->isSelected();
85 mSfxVolume = (int) config.getValue("sfxVolume", 100);
86 mMusicVolume = (int) config.getValue("musicVolume", 60);
85 mSfxVolume = config.getIntValue("sfxVolume");
86 mMusicVolume = config.getIntValue("musicVolume");
8787
8888 config.setValue("sound", mSoundEnabled);
8989
9090 // Display a message if user has selected to download music,
9191 // And if downloadmusic is not already enabled
92 if (mDownloadEnabled && !config.getValue("download-music", false))
92 if (mDownloadEnabled && !config.getBoolValue("download-music"))
9393 {
9494 new OkDialog(_("Notice"),_("You may have to restart your client if you want to download new music"));
9595 }
  
4040{
4141 setName(_("Joystick"));
4242
43 mOriginalJoystickEnabled = !config.getValue("joystickEnabled", false);
43 mOriginalJoystickEnabled = !config.getBoolValue("joystickEnabled");
4444 mJoystickEnabled->setSelected(mOriginalJoystickEnabled);
4545
4646 mJoystickEnabled->addActionListener(this);
  
227227 mDefaultWhisper(new CheckBox(_("Allow whispers"),
228228 player_relations.getDefault() & PlayerRelation::WHISPER)),
229229 mDeleteButton(new Button(_("Delete"), ACTION_DELETE, this)),
230 mWhisperTab(config.getValue("whispertab", false)),
230 mWhisperTab(config.getBoolValue("whispertab")),
231231 mWhisperTabCheckBox(new CheckBox(_("Put all whispers in tabs"), mWhisperTab)),
232 mShowGender(config.getValue("showgender", false)),
232 mShowGender(config.getBoolValue("showgender")),
233233 mShowGenderCheckBox(new CheckBox(_("Show gender"), mShowGender)),
234 mEnableChatLog(config.getValue("enableChatLog", false)),
234 mEnableChatLog(config.getBoolValue("enableChatLog")),
235235 mEnableChatLogCheckBox(new CheckBox(_("Enable Chat log"), mEnableChatLog))
236236{
237237 setName(_("Players"));
348348 PlayerRelation::WHISPER : 0));
349349 config.setValue("whispertab", mWhisperTab);
350350
351 bool showGender = config.getValue("showgender", false);
351 bool showGender = config.getBoolValue("showgender");
352352
353353 config.setValue("showgender", mShowGender);
354354
360360
361361void Setup_Players::cancel()
362362{
363 mWhisperTab = config.getValue("whispertab", false);
363 mWhisperTab = config.getBoolValue("whispertab");
364364 mWhisperTabCheckBox->setSelected(mWhisperTab);
365 mShowGender = config.getValue("showgender", false);
365 mShowGender = config.getBoolValue("showgender");
366366 mShowGenderCheckBox->setSelected(mShowGender);
367 mEnableChatLog = config.getValue("enableChatLog", false);
367 mEnableChatLog = config.getBoolValue("enableChatLog");
368368 mEnableChatLogCheckBox->setSelected(mEnableChatLog);
369369}
370370
  
171171const char *Setup_Video::overlayDetailToString(int detail)
172172{
173173 if (detail == -1)
174 detail = config.getValue("OverlayDetail", -1);
174 detail = config.getIntValue("OverlayDetail");
175175
176176 switch (detail)
177177 {
185185const char *Setup_Video::particleDetailToString(int detail)
186186{
187187 if (detail == -1)
188 detail = 3 - config.getValue("particleEmitterSkip", -1);
188 detail = 3 - config.getIntValue("particleEmitterSkip");
189189
190190 switch (detail)
191191 {
198198}
199199
200200Setup_Video::Setup_Video():
201 mFullScreenEnabled(config.getValue("screen", false)),
202 mOpenGLEnabled(config.getValue("opengl", false)),
203 mCustomCursorEnabled(config.getValue("customcursor", true)),
204 mShowMonsterDamageEnabled(config.getValue("showMonstersTakedDamage",
205 false)),
206 mVisibleNamesEnabled(config.getValue("visiblenames", true)),
207 mParticleEffectsEnabled(config.getValue("particleeffects", true)),
208 mNameEnabled(config.getValue("showownname", false)),
209 mNPCLogEnabled(config.getValue("logNpcInGui", true)),
210 mPickupChatEnabled(config.getValue("showpickupchat", true)),
211 mPickupParticleEnabled(config.getValue("showpickupparticle", false)),
212 mOpacity(config.getValue("guialpha", 0.8)),
213 mFps((int) config.getValue("fpslimit", 60)),
214 mSpeechMode(static_cast<Being::Speech>(
215 config.getValue("speech", Being::TEXT_OVERHEAD))),
201 mFullScreenEnabled(config.getBoolValue("screen")),
202 mOpenGLEnabled(config.getBoolValue("opengl")),
203 mCustomCursorEnabled(config.getBoolValue("customcursor")),
204 mShowMonsterDamageEnabled(config.getBoolValue("showMonstersTakedDamage")),
205 mVisibleNamesEnabled(config.getBoolValue("visiblenames")),
206 mParticleEffectsEnabled(config.getBoolValue("particleeffects")),
207 mNameEnabled(config.getBoolValue("showownname")),
208 mNPCLogEnabled(config.getBoolValue("logNpcInGui")),
209 mPickupChatEnabled(config.getBoolValue("showpickupchat")),
210 mPickupParticleEnabled(config.getBoolValue("showpickupparticle")),
211 mOpacity(config.getFloatValue("guialpha")),
212 mFps(config.getIntValue("fpslimit")),
213 mSpeechMode(static_cast<Being::Speech>(config.getIntValue("speech"))),
216214 mModeListModel(new ModeListModel),
217215 mModeList(new ListBox(mModeListModel)),
218216 mFsCheckBox(new CheckBox(_("Full screen"), mFullScreenEnabled)),
235235 mFpsCheckBox(new CheckBox(_("FPS limit:"))),
236236 mFpsSlider(new Slider(10, 120)),
237237 mFpsLabel(new Label),
238 mOverlayDetail((int) config.getValue("OverlayDetail", 2)),
238 mOverlayDetail(config.getIntValue("OverlayDetail")),
239239 mOverlayDetailSlider(new Slider(0, 2)),
240240 mOverlayDetailField(new Label),
241 mParticleDetail(3 - (int) config.getValue("particleEmitterSkip", 1)),
241 mParticleDetail(3 - config.getIntValue("particleEmitterSkip")),
242242 mParticleDetailSlider(new Slider(0, 3)),
243243 mParticleDetailField(new Label),
244 mFontSize((int) config.getValue("fontSize", 11))
244 mFontSize(config.getIntValue("fontSize"))
245245{
246246 setName(_("Video"));
247247
386386{
387387 // Full screen changes
388388 bool fullscreen = mFsCheckBox->isSelected();
389 if (fullscreen != (config.getValue("screen", false) == 1))
389 if (fullscreen != config.getBoolValue("screen"))
390390 {
391391 /* The OpenGL test is only necessary on Windows, since switching
392392 * to/from full screen works fine on Linux. On Windows we'd have to
397397
398398#if defined(WIN32) || defined(__APPLE__)
399399 // checks for opengl usage
400 if (!(config.getValue("opengl", false) == 1))
400 if (!config.getBoolValue("opengl"))
401401 {
402402#endif
403403 if (!graphics->setFullscreen(fullscreen))
450450 config.setValue("fontSize", mFontSizeDropDown->getSelected() + 10);
451451
452452 // We sync old and new values at apply time
453 mFullScreenEnabled = config.getValue("screen", false);
454 mCustomCursorEnabled = config.getValue("customcursor", true);
455 mShowMonsterDamageEnabled = config.getValue("showMonstersTakedDamage", false);
456 mVisibleNamesEnabled = config.getValue("visiblenames", true);
457 mParticleEffectsEnabled = config.getValue("particleeffects", true);
458 mNameEnabled = config.getValue("showownname", false);
459 mNPCLogEnabled = config.getValue("logNpcInGui", true);
453 mFullScreenEnabled = config.getBoolValue("screen");
454 mCustomCursorEnabled = config.getBoolValue("customcursor");
455 mShowMonsterDamageEnabled = config.getBoolValue("showMonstersTakedDamage");
456 mVisibleNamesEnabled = config.getBoolValue("visiblenames");
457 mParticleEffectsEnabled = config.getBoolValue("particleeffects");
458 mNameEnabled = config.getBoolValue("showownname");
459 mNPCLogEnabled = config.getBoolValue("logNpcInGui");
460460 mSpeechMode = static_cast<Being::Speech>(
461 config.getValue("speech", Being::TEXT_OVERHEAD));
462 mOpacity = config.getValue("guialpha", 0.8);
463 mOverlayDetail = (int) config.getValue("OverlayDetail", 2);
464 mOpenGLEnabled = config.getValue("opengl", false);
465 mPickupChatEnabled = config.getValue("showpickupchat", true);
466 mPickupParticleEnabled = config.getValue("showpickupparticle", false);
461 config.getIntValue("speech"));
462 mOpacity = config.getFloatValue("guialpha");
463 mOverlayDetail = config.getIntValue("OverlayDetail");
464 mOpenGLEnabled = config.getBoolValue("opengl");
465 mPickupChatEnabled = config.getBoolValue("showpickupchat");
466 mPickupParticleEnabled = config.getBoolValue("showpickupparticle");
467467}
468468
469469void Setup_Video::cancel()
  
4848static void initDefaultThemePath()
4949{
5050 ResourceManager *resman = ResourceManager::getInstance();
51 defaultThemePath = branding.getValue("guiThemePath", "");
51 defaultThemePath = branding.getStringValue("guiThemePath");
5252
5353 if (!defaultThemePath.empty() && resman->isDirectory(defaultThemePath))
5454 return;
8181
8282void Skin::updateAlpha(float minimumOpacityAllowed)
8383{
84 const float alpha = std::max((double)minimumOpacityAllowed,
85 config.getValue("guialpha", 0.8f));
84 const float alpha = std::max(minimumOpacityAllowed,
85 config.getFloatValue("guialpha"));
8686
8787 for_each(mBorder.grid, mBorder.grid + 9,
8888 std::bind2nd(std::mem_fun(&Image::setAlpha), alpha));
339339void Theme::prepareThemePath()
340340{
341341 // Try theme from settings
342 if (!tryThemePath(config.getValue("theme", "")))
342 if (!tryThemePath(config.getStringValue("theme")))
343343 // Try theme from branding
344 if (!tryThemePath(branding.getValue("theme", "")))
344 if (!tryThemePath(branding.getStringValue("theme")))
345345 // Use default
346346 mThemePath = defaultThemePath;
347347
  
476476 // This statement checks to see if the file type is music, and if download-music is true
477477 // If it fails, this statement returns true, and results in not downloading the file
478478 // Else it will ignore the break, and download the file.
479 if ( !(thisFile.type == "music" && config.getValue("download-music", false)) )
479 if ( !(thisFile.type == "music" && config.getBoolValue("download-music")) )
480480 {
481481 mUpdateIndex++;
482482 break;
  
5858 setOpaque(false);
5959 addMouseListener(this);
6060
61 mScrollLaziness = (int) config.getValue("ScrollLaziness", 16);
62 mScrollRadius = (int) config.getValue("ScrollRadius", 0);
63 mScrollCenterOffsetX = (int) config.getValue("ScrollCenterOffsetX", 0);
64 mScrollCenterOffsetY = (int) config.getValue("ScrollCenterOffsetY", 0);
61 mScrollLaziness = config.getIntValue("ScrollLaziness");
62 mScrollRadius = config.getIntValue("ScrollRadius");
63 mScrollCenterOffsetX = config.getIntValue("ScrollCenterOffsetX");
64 mScrollCenterOffsetY = config.getIntValue("ScrollCenterOffsetY");
6565
6666 config.addListener("ScrollLaziness", this);
6767 config.addListener("ScrollRadius", this);
481481
482482void Viewport::optionChanged(const std::string &name)
483483{
484 mScrollLaziness = (int) config.getValue("ScrollLaziness", 32);
485 mScrollRadius = (int) config.getValue("ScrollRadius", 32);
484 mScrollLaziness = config.getIntValue("ScrollLaziness");
485 mScrollRadius = config.getIntValue("ScrollRadius");
486486}
487487
488488void Viewport::mouseMoved(gcn::MouseEvent &event)
  
125125
126126void Button::updateAlpha()
127127{
128 float alpha = std::max(config.getValue("guialpha", 0.8f),
129 (double) Theme::instance()->getMinimumOpacity());
128 float alpha = std::max(config.getFloatValue("guialpha"),
129 Theme::instance()->getMinimumOpacity());
130130
131131 if (mAlpha != alpha)
132132 {
  
5151
5252 mTextOutput = new BrowserBox(BrowserBox::AUTO_WRAP);
5353 mTextOutput->setOpaque(false);
54 mTextOutput->setMaxRow((int) config.getValue("ChatLogLength", 0));
54 mTextOutput->setMaxRow((int) config.getIntValue("ChatLogLength"));
5555 mTextOutput->setLinkHandler(chatWindow->mItemLinkHandler);
5656
5757 mScrollArea = new ScrollArea(mTextOutput);
181181
182182 line = lineColor + timeStr.str() + tmp.nick + tmp.text;
183183
184 if (config.getValue("enableChatLog", false))
184 if (config.getBoolValue("enableChatLog"))
185185 saveToLogFile(line);
186186
187187 // We look if the Vertical Scroll Bar is set at the max before
  
9292
9393void CheckBox::updateAlpha()
9494{
95 float alpha = std::max(config.getValue("guialpha", 0.8f),
96 (double) Theme::instance()->getMinimumOpacity());
95 float alpha = std::max(config.getFloatValue("guialpha"),
96 Theme::instance()->getMinimumOpacity());
9797
9898 if (mAlpha != alpha)
9999 {
  
110110
111111void DropDown::updateAlpha()
112112{
113 float alpha = std::max(config.getValue("guialpha", 0.8f),
114 (double) Theme::instance()->getMinimumOpacity());
113 float alpha = std::max(config.getFloatValue("guialpha"),
114 Theme::instance()->getMinimumOpacity());
115115
116116 if (mAlpha != alpha)
117117 {
  
5151
5252 mBackgroundImg = Theme::getImageFromTheme("item_shortcut_bgr.png");
5353
54 mBackgroundImg->setAlpha(config.getValue("guialpha", 0.8));
54 mBackgroundImg->setAlpha(config.getFloatValue("guialpha"));
5555
5656 // Setup emote sprites
5757 for (int i = 0; i <= EmoteDB::getLast(); i++)
7272
7373void EmoteShortcutContainer::draw(gcn::Graphics *graphics)
7474{
75 if (config.getValue("guialpha", 0.8) != mAlpha)
75 if (config.getFloatValue("guialpha") != mAlpha)
7676 {
77 mAlpha = config.getValue("guialpha", 0.8);
77 mAlpha = config.getFloatValue("guialpha");
7878 mBackgroundImg->setAlpha(mAlpha);
7979 }
8080
  
5353 mBackgroundImg = Theme::getImageFromTheme("item_shortcut_bgr.png");
5454 mMaxItems = itemShortcut->getItemCount();
5555
56 mBackgroundImg->setAlpha(config.getValue("guialpha", 0.8));
56 mBackgroundImg->setAlpha(config.getFloatValue("guialpha"));
5757
5858 mBoxHeight = mBackgroundImg->getHeight();
5959 mBoxWidth = mBackgroundImg->getWidth();
6767
6868void ItemShortcutContainer::draw(gcn::Graphics *graphics)
6969{
70 if (config.getValue("guialpha", 0.8) != mAlpha)
70 if (config.getFloatValue("guialpha") != mAlpha)
7171 {
72 mAlpha = config.getValue("guialpha", 0.8);
72 mAlpha = config.getFloatValue("guialpha");
7373 mBackgroundImg->setAlpha(mAlpha);
7474 }
7575
  
4545
4646void ListBox::updateAlpha()
4747{
48 float alpha = std::max(config.getValue("guialpha", 0.8),
49 (double) Theme::instance()->getMinimumOpacity());
48 float alpha = std::max(config.getFloatValue("guialpha"),
49 Theme::instance()->getMinimumOpacity());
5050
5151 if (mAlpha != alpha)
5252 mAlpha = alpha;
  
5757 bggridx[x], bggridy[y],
5858 bggridx[x + 1] - bggridx[x] + 1,
5959 bggridy[y + 1] - bggridy[y] + 1);
60 background.grid[a]->setAlpha(config.getValue("guialpha", 0.8));
60 background.grid[a]->setAlpha(config.getFloatValue("guialpha"));
6161 a++;
6262 }
6363 }
9191 mBeing->drawSpriteAt(static_cast<Graphics*>(graphics), x, y);
9292 }
9393
94 if (config.getValue("guialpha", 0.8) != mAlpha)
94 if (config.getFloatValue("guialpha") != mAlpha)
9595 {
9696 for (int a = 0; a < 9; a++)
9797 {
98 background.grid[a]->setAlpha(config.getValue("guialpha", 0.8));
98 background.grid[a]->setAlpha(config.getFloatValue("guialpha"));
9999 }
100100 }
101101}
  
123123
124124void ProgressBar::updateAlpha()
125125{
126 float alpha = std::max(config.getValue("guialpha", 0.8),
127 (double) Theme::instance()->getMinimumOpacity());
126 float alpha = std::max(config.getFloatValue("guialpha"),
127 Theme::instance()->getMinimumOpacity());
128128
129129 if (mAlpha != alpha)
130130 {
  
7878
7979void RadioButton::drawBox(gcn::Graphics* graphics)
8080{
81 if (config.getValue("guialpha", 0.8) != mAlpha)
81 if (config.getFloatValue("guialpha") != mAlpha)
8282 {
83 mAlpha = config.getValue("guialpha", 0.8);
83 mAlpha = config.getFloatValue("guialpha");
8484 radioNormal->setAlpha(mAlpha);
8585 radioChecked->setAlpha(mAlpha);
8686 radioDisabled->setAlpha(mAlpha);
  
5959
6060void ResizeGrip::draw(gcn::Graphics *graphics)
6161{
62 if (config.getValue("guialpha", 0.8) != mAlpha)
62 if (config.getFloatValue("guialpha") != mAlpha)
6363 {
64 mAlpha = config.getValue("guialpha", 0.8);
64 mAlpha = config.getFloatValue("guialpha");
6565 gripImage->setAlpha(mAlpha);
6666 }
6767
  
108108 bggridx[x], bggridy[y],
109109 bggridx[x + 1] - bggridx[x] + 1,
110110 bggridy[y + 1] - bggridy[y] + 1);
111 background.grid[a]->setAlpha(config.getValue("guialpha", 0.8));
111 background.grid[a]->setAlpha(config.getFloatValue("guialpha"));
112112 a++;
113113 }
114114 }
135135 vsgridx[x], vsgridy[y],
136136 vsgridx[x + 1] - vsgridx[x],
137137 vsgridy[y + 1] - vsgridy[y]);
138 vMarker.grid[a]->setAlpha(config.getValue("guialpha", 0.8));
139 vMarkerHi.grid[a]->setAlpha(config.getValue("guialpha", 0.8));
138 vMarker.grid[a]->setAlpha(config.getFloatValue("guialpha"));
139 vMarkerHi.grid[a]->setAlpha(config.getFloatValue("guialpha"));
140140 a++;
141141 }
142142 }
213213
214214void ScrollArea::updateAlpha()
215215{
216 float alpha = std::max(config.getValue("guialpha", 0.8),
217 (double) Theme::instance()->getMinimumOpacity());
216 float alpha = std::max(config.getFloatValue("guialpha"),
217 Theme::instance()->getMinimumOpacity());
218218
219219 if (alpha != mAlpha)
220220 {
  
7171 if (!mListModel)
7272 return;
7373
74 if (config.getValue("guialpha", 0.8) != mAlpha)
75 mAlpha = config.getValue("guialpha", 0.8);
74 if (config.getFloatValue("guialpha") != mAlpha)
75 mAlpha = config.getFloatValue("guialpha");
7676
7777 int alpha = (int)(mAlpha * 255.0f);
7878 const gcn::Color* highlightColor =
  
126126
127127void Slider::updateAlpha()
128128{
129 float alpha = std::max(config.getValue("guialpha", 0.8),
130 (double) Theme::instance()->getMinimumOpacity());
129 float alpha = std::max(config.getFloatValue("guialpha"),
130 Theme::instance()->getMinimumOpacity());
131131
132132 if (alpha != mAlpha)
133133 {
  
118118
119119void Tab::updateAlpha()
120120{
121 float alpha = std::max(config.getValue("guialpha", 0.8),
122 (double) Theme::instance()->getMinimumOpacity());
121 float alpha = std::max(config.getFloatValue("guialpha"),
122 Theme::instance()->getMinimumOpacity());
123123
124124 // TODO We don't need to do this for every tab on every draw
125125 // Maybe use a config listener to do it as the value changes.
  
270270 if (!mModel)
271271 return;
272272
273 if (config.getValue("guialpha", 0.8) != mAlpha)
274 mAlpha = config.getValue("guialpha", 0.8);
273 if (config.getFloatValue("guialpha") != mAlpha)
274 mAlpha = config.getFloatValue("guialpha");
275275
276276 if (mOpaque)
277277 {
  
6565 gridx[x], gridy[y],
6666 gridx[x + 1] - gridx[x] + 1,
6767 gridy[y + 1] - gridy[y] + 1);
68 skin.grid[a]->setAlpha(config.getValue("guialpha", 0.8));
68 skin.grid[a]->setAlpha(config.getFloatValue("guialpha"));
6969 a++;
7070 }
7171 }
8686
8787void TextField::updateAlpha()
8888{
89 float alpha = std::max(config.getValue("guialpha", 0.8),
90 (double) Theme::instance()->getMinimumOpacity());
89 float alpha = std::max(config.getFloatValue("guialpha"),
90 Theme::instance()->getMinimumOpacity());
9191
9292 if (alpha != mAlpha)
9393 {
  
4545
4646void TextPreview::draw(gcn::Graphics* graphics)
4747{
48 if (config.getValue("guialpha", 0.8) != mAlpha)
49 mAlpha = config.getValue("guialpha", 0.8);
48 if (config.getFloatValue("guialpha") != mAlpha)
49 mAlpha = config.getFloatValue("guialpha");
5050
5151 int alpha = (int) (mAlpha * 255.0f);
5252
  
697697
698698int Window::getGuiAlpha()
699699{
700 float alpha = std::max(config.getValue("guialpha", 0.8),
701 (double) Theme::instance()->getMinimumOpacity());
700 float alpha = std::max(config.getFloatValue("guialpha"),
701 Theme::instance()->getMinimumOpacity());
702702 return (int) (alpha * 255.0f);
703703}
704704
  
5959
6060 ResourceManager *resman = ResourceManager::getInstance();
6161 SpriteDisplay display = getInfo().getDisplay();
62 std::string imagePath = paths.getValue("itemIcons", "graphics/items/")
62 std::string imagePath = paths.getStringValue("itemIcons")
6363 + display.image;
6464 mImage = resman->getImage(imagePath);
6565 mDrawImage = resman->getImage(imagePath);
  
6161 logger->log("Hats: %i", SDL_JoystickNumHats(mJoystick));
6262 logger->log("Buttons: %i", SDL_JoystickNumButtons(mJoystick));
6363
64 mEnabled = (int) config.getValue("joystickEnabled", 0) != 0;
65 mUpTolerance = (int) config.getValue("upTolerance", 100);
66 mDownTolerance = (int) config.getValue("downTolerance", 100);
67 mLeftTolerance = (int) config.getValue("leftTolerance", 100);
68 mRightTolerance = (int) config.getValue("rightTolerance", 100);
64 mEnabled = config.getBoolValue("joystickEnabled");
65 mUpTolerance = config.getIntValue("upTolerance");
66 mDownTolerance = config.getIntValue("downTolerance");
67 mLeftTolerance = config.getIntValue("leftTolerance");
68 mRightTolerance = config.getIntValue("rightTolerance");
6969}
7070
7171Joystick::~Joystick()
  
356356
357357 // Draw backgrounds
358358 drawAmbientLayers(graphics, BACKGROUND_LAYERS, scrollX, scrollY,
359 (int) config.getValue("OverlayDetail", 2));
359 config.getIntValue("OverlayDetail"));
360360
361361 // draw the game world
362362 Layers::const_iterator layeri = mLayers.begin();
409409 }
410410
411411 drawAmbientLayers(graphics, FOREGROUND_LAYERS, scrollX, scrollY,
412 (int) config.getValue("OverlayDetail", 2));
412 config.getIntValue("OverlayDetail"));
413413}
414414
415415void Map::drawCollision(Graphics *graphics, int scrollX, int scrollY,
956956{
957957 Particle *p;
958958
959 if (config.getValue("particleeffects", 1))
959 if (config.getBoolValue("particleeffects"))
960960 {
961961 for (std::list<ParticleEffectData>::iterator i = particleEffects.begin();
962962 i != particleEffects.end();
  
221221 }
222222
223223 curl_easy_setopt(d->mCurl, CURLOPT_USERAGENT,
224 strprintf(PACKAGE_EXTENDED_VERSION, branding
225 .getValue("appShort", "mana").c_str()).c_str());
224 strprintf(PACKAGE_EXTENDED_VERSION,
225 branding.getStringValue("appShort").c_str()).c_str());
226226 curl_easy_setopt(d->mCurl, CURLOPT_ERRORBUFFER, d->mError);
227227 curl_easy_setopt(d->mCurl, CURLOPT_URL, d->mUrl.c_str());
228228 curl_easy_setopt(d->mCurl, CURLOPT_NOPROGRESS, 0);
  
144144 PlayerInfo::setAttribute(CHAR_POINTS, msg.readInt16());
145145 PlayerInfo::setAttribute(CORR_POINTS, msg.readInt16());
146146 Particle* effect = particleEngine->addEffect(
147 paths.getValue("particles", "graphics/particles/")
148 + paths.getValue("levelUpEffectFile", "levelup.particle.xml")
147 paths.getStringValue("particles")
148 + paths.getStringValue("levelUpEffectFile")
149149 ,0, 0);
150150 player_node->controlParticle(effect);
151151 } break;
  
7676
7777GeneralHandler::GeneralHandler():
7878 mAdminHandler(new AdminHandler),
79 mBeingHandler(new BeingHandler(config.getValue("EnableSync", 0) == 1)),
79 mBeingHandler(new BeingHandler(config.getBoolValue("EnableSync"))),
8080 mBuySellHandler(new BuySellHandler),
8181 mCharHandler(new CharServerHandler),
8282 mChatHandler(new ChatHandler),
  
8686
8787void Particle::setupEngine()
8888{
89 Particle::maxCount = (int)config.getValue("particleMaxCount", 3000);
90 Particle::fastPhysics = (int)config.getValue("particleFastPhysics", 0);
91 Particle::emitterSkip = (int)config.getValue("particleEmitterSkip", 1) + 1;
92 Particle::enabled = (bool)config.getValue("particleeffects", true);
89 Particle::maxCount = config.getIntValue("particleMaxCount");
90 Particle::fastPhysics = config.getIntValue("particleFastPhysics");
91 Particle::emitterSkip = config.getIntValue("particleEmitterSkip") + 1;
92 Particle::enabled = config.getBoolValue("particleeffects");
9393 disableAutoDelete();
9494 logger->log("Particle engine set up");
9595}
  
4343
4444 EmoteSprite *unknownSprite = new EmoteSprite;
4545 unknownSprite->sprite = AnimatedSprite::load(
46 paths.getValue("spriteErrorFile", "error.xml") );
46 paths.getStringValue("spriteErrorFile"));
4747 unknownSprite->name = "unknown";
4848 mUnknown.sprites.push_back(unknownSprite);
4949
7878 if (xmlStrEqual(spriteNode->name, BAD_CAST "sprite"))
7979 {
8080 EmoteSprite *currentSprite = new EmoteSprite;
81 std::string file = paths.getValue("sprites",
82 "graphics/sprites/")
81 std::string file = paths.getStringValue("sprites")
8382 + (std::string) (const char*)
8483 spriteNode->xmlChildrenNode->content;
8584 currentSprite->sprite = AnimatedSprite::load(file,
  
117117 mUnknown = new ItemInfo;
118118 mUnknown->setName(_("Unknown item"));
119119 mUnknown->setDisplay(SpriteDisplay());
120 std::string errFile = paths.getValue("spriteErrorFile", "error.xml");
120 std::string errFile = paths.getStringValue("spriteErrorFile");
121121 mUnknown->setSprite(errFile, GENDER_MALE);
122122 mUnknown->setSprite(errFile, GENDER_FEMALE);
123123
  
6969
7070void ItemInfo::addSound(EquipmentSoundEvent event, const std::string &filename)
7171{
72 mSounds[event].push_back(paths.getValue("sfx", "sfx/") + filename);
72 mSounds[event].push_back(paths.getStringValue("sfx") + filename);
7373}
7474
7575const std::string &ItemInfo::getSound(EquipmentSoundEvent event) const
  
323323 if (config.getValue("showWarps", 1))
324324 {
325325 map->addParticleEffect(
326 paths.getValue("particles",
327 "graphics/particles/")
328 + paths.getValue("portalEffectFile",
329 "warparea.particle.xml"),
330 objX, objY, objW, objH);
326 paths.getStringValue("particles")
327 + paths.getStringValue("portalEffectFile"),
328 objX, objY, objW, objH);
331329 }
332330 }
333331 else
  
3737#include <set>
3838
3939SpriteReference *SpriteReference::Empty = new SpriteReference(
40 paths.getValue("spriteErrorFile", "error.xml"),
41 0);
40 paths.getStringValue("spriteErrorFile"), 0);
4241
4342Action *SpriteDef::getAction(SpriteAction action) const
4443{
6666 {
6767 logger->log("Error, failed to parse %s", animationFile.c_str());
6868
69 std::string errorFile = paths.getValue("sprites", "graphics/sprites")
70 + paths.getValue("spriteErrorFile",
71 "error.xml");
69 std::string errorFile = paths.getStringValue("sprites")
70 + paths.getStringValue("spriteErrorFile");
7271 if (animationFile != errorFile)
7372 {
7473 return load(errorFile, 0);
285285 if (filename.empty())
286286 return;
287287
288 XML::Document doc(paths.getValue("sprites", "graphics/sprites/")
289 + filename);
288 XML::Document doc(paths.getStringValue("sprites") + filename);
290289 xmlNodePtr rootNode = doc.rootNode();
291290
292291 if (!rootNode || !xmlStrEqual(rootNode->name, BAD_CAST "sprite"))
  
5353 ResourceManager *resman = ResourceManager::getInstance();
5454
5555 // Init the path
56 wallpaperPath = branding.getValue("wallpapersPath", "");
56 wallpaperPath = branding.getStringValue("wallpapersPath");
5757
5858 if (!wallpaperPath.empty() && resman->isDirectory(wallpaperPath))
5959 return;
6060 else
61 wallpaperPath = paths.getValue("wallpapers", "");
61 wallpaperPath = paths.getValue("wallpapers", "graphics/images/");
6262
63 if (wallpaperPath.empty() || !resman->isDirectory(wallpaperPath))
64 wallpaperPath = "graphics/images/";
65
6663 // Init the default file
67 wallpaperFile = branding.getValue("wallpaperFile", "");
64 wallpaperFile = branding.getStringValue("wallpaperFile");
6865
69 if (!wallpaperFile.empty() && resman->isDirectory(wallpaperFile))
66 if (!wallpaperFile.empty())
7067 return;
7168 else
72 wallpaperFile = paths.getValue("wallpaperFile", "");
73
74 if (wallpaperFile.empty() || !resman->isDirectory(wallpaperFile))
75 wallpaperFile = "login_wallpaper.png";
69 wallpaperFile = paths.getValue("wallpaperFile", "login_wallpaper.png");
7670}
7771
7872bool wallpaperCompare(WallpaperData a, WallpaperData b)
7676
7777 return (aa > ab || (aa == ab && a.width > b.width));
7878}
79
79#include <iostream>
8080void Wallpaper::loadWallpapers()
8181{
8282 wallpaperData.clear();
  
142142static Mix_Music *loadMusic(const std::string &filename)
143143{
144144 ResourceManager *resman = ResourceManager::getInstance();
145 std::string path = resman->getPath("music/" + filename);
145 std::string path = resman->getPath(paths.getStringValue("music") + filename);
146146
147147 if (path.find(".zip/") != std::string::npos ||
148148 path.find(".zip\\") != std::string::npos)
152152 logger->log("Loading music \"%s\" from temporary file tempMusic.ogg",
153153 path.c_str());
154154 bool success = resman->copyFile(
155 paths.getValue("music", "music/")
155 paths.getStringValue("music")
156156 + filename, "tempMusic.ogg");
157157 if (success)
158158 path = resman->getPath("tempMusic.ogg");
240240
241241 ResourceManager *resman = ResourceManager::getInstance();
242242 SoundEffect *sample = resman->getSoundEffect(
243 paths.getValue("sfx", "sfx/") + path);
243 paths.getStringValue("sfx") + path);
244244 if (sample)
245245 {
246246 logger->log("Sound::playSfx() Playing: %s", path.c_str());
  
7070 else
7171 {
7272 AnimatedSprite *sprite = AnimatedSprite::load(
73 paths.getValue("sprites", "graphics/sprites/") + mIcon);
73 paths.getStringValue("sprites") + mIcon);
7474 if (false && sprite)
7575 {
7676 sprite->play(ACTION_DEFAULT);
  
5656 {
5757 textManager = new TextManager;
5858 Image *sbImage = Theme::getImageFromTheme("bubble.png|W:#"
59 + config.getValue("speechBubblecolor", "000000"));
59 + config.getStringValue("speechBubblecolor"));
6060 mBubble.grid[0] = sbImage->getSubImage(0, 0, 5, 5);
6161 mBubble.grid[1] = sbImage->getSubImage(5, 0, 5, 5);
6262 mBubble.grid[2] = sbImage->getSubImage(10, 0, 5, 5);
6767 mBubble.grid[7] = sbImage->getSubImage(5, 10, 5, 5);
6868 mBubble.grid[8] = sbImage->getSubImage(10, 10, 5, 5);
6969 mBubbleArrow = sbImage->getSubImage(0, 15, 15, 10);
70 const float bubbleAlpha = config.getValue("speechBubbleAlpha", 1.0);
70 const float bubbleAlpha = config.getFloatValue("speechBubbleAlpha");
7171 for (int i = 0; i < 9; i++)
7272 {
7373 mBubble.grid[i]->setAlpha(bubbleAlpha);
  
2626#include <cstdarg>
2727#include <cstdio>
2828
29const int UTF8_MAX_SIZE = 10;
29static int UTF8_MAX_SIZE = 10;
3030
3131std::string &trim(std::string &str)
3232{
174174 memcpy(buf, text.c_str(), text.size());
175175 memset(buf + text.size(), 0, UTF8_MAX_SIZE);
176176 return buf;
177}
178
179bool getBoolFromString(const std::string &text)
180{
181 std::string txt = text;
182 toLower(trim(txt));
183 if (txt == "true" || txt == "yes" || txt == "on" || txt == "1")
184 return true;
185 else if (txt == "false" || txt == "no" || txt == "off" || txt == "0")
186 return false;
187 else
188 return (bool) atoi(txt.c_str());
177189}
  
125125
126126const char* getSafeUtf8String(std::string text);
127127
128/**
129 * Returns a bool value depending on the given string value.
130 *
131 * @param text the string used to get the bool value
132 * @return a boolean value..
133 */
134bool getBoolFromString(const std::string &text);
135
128136#endif // UTILS_STRINGUTILS_H
  
2929class VariableData
3030{
3131 public:
32 enum {
32 enum DataType
33 {
3334 DATA_NONE,
3435 DATA_INT,
3536 DATA_STRING,
36 DATA_FLOAT
37 DATA_FLOAT,
38 DATA_BOOL
3739 };
3840
3941 virtual ~VariableData() {};
7272class FloatData : public VariableData
7373{
7474public:
75 FloatData(double value) { mData = value; }
75 FloatData(float value) { mData = value; }
7676
77 double getData() const { return mData; }
77 float getData() const { return mData; }
7878
7979 int getType() const { return DATA_FLOAT; }
8080
8181private:
82 double mData;
82 float mData;
83};
84
85class BoolData : public VariableData
86{
87public:
88 BoolData(bool value) { mData = value; }
89
90 bool getData() const { return mData; }
91
92 int getType() const { return DATA_BOOL; }
93
94private:
95 bool mData;
8396};
8497
8598} // namespace Mana