Commit 2b1c0dcf269d617de1f6c203df547166661f089e
- Diff rendering mode:
- inline
- side by side
mana.cbp
(2 / 0)
|   | |||
| 125 | 125 | <Unit filename="src\configlistener.h" /> | |
| 126 | 126 | <Unit filename="src\configuration.cpp" /> | |
| 127 | 127 | <Unit filename="src\configuration.h" /> | |
| 128 | <Unit filename="src\defaults.cpp" /> | ||
| 129 | <Unit filename="src\defaults.h" /> | ||
| 128 | 130 | <Unit filename="src\effectmanager.cpp" /> | |
| 129 | 131 | <Unit filename="src\effectmanager.h" /> | |
| 130 | 132 | <Unit filename="src\emoteshortcut.cpp" /> |
src/CMakeLists.txt
(2 / 0)
|   | |||
| 434 | 434 | configlistener.h | |
| 435 | 435 | configuration.cpp | |
| 436 | 436 | configuration.h | |
| 437 | defaults.cpp | ||
| 438 | defaults.h | ||
| 437 | 439 | effectmanager.cpp | |
| 438 | 440 | effectmanager.h | |
| 439 | 441 | emoteshortcut.cpp |
src/Makefile.am
(2 / 0)
|   | |||
| 333 | 333 | configlistener.h \ | |
| 334 | 334 | configuration.cpp \ | |
| 335 | 335 | configuration.h \ | |
| 336 | defaults.cpp \ | ||
| 337 | defaults.h \ | ||
| 336 | 338 | effectmanager.cpp \ | |
| 337 | 339 | effectmanager.h \ | |
| 338 | 340 | emoteshortcut.cpp \ |
src/being.cpp
(9 / 9)
|   | |||
| 112 | 112 | mWalkSpeed = Net::getPlayerHandler()->getDefaultWalkSpeed(); | |
| 113 | 113 | ||
| 114 | 114 | if (getType() == PLAYER) | |
| 115 | mShowName = config.getValue("visiblenames", 1); | ||
| 115 | mShowName = config.getBoolValue("visiblenames"); | ||
| 116 | 116 | ||
| 117 | 117 | config.addListener("visiblenames", this); | |
| 118 | 118 | ||
| … | … | ||
| 298 | 298 | if (!mSpeech.empty()) | |
| 299 | 299 | mSpeechTime = time <= SPEECH_MAX_TIME ? time : SPEECH_MAX_TIME; | |
| 300 | 300 | ||
| 301 | const int speech = (int) config.getValue("speech", TEXT_OVERHEAD); | ||
| 301 | const int speech = config.getIntValue("speech"); | ||
| 302 | 302 | if (speech == TEXT_OVERHEAD) | |
| 303 | 303 | { | |
| 304 | 304 | if (mText) | |
| … | … | ||
| 887 | 887 | { | |
| 888 | 888 | const int px = getPixelX() - offsetX; | |
| 889 | 889 | const int py = getPixelY() - offsetY; | |
| 890 | const int speech = (int) config.getValue("speech", TEXT_OVERHEAD); | ||
| 890 | const int speech = config.getIntValue("speech"); | ||
| 891 | 891 | ||
| 892 | 892 | // Draw speech above this being | |
| 893 | 893 | if (mSpeechTime == 0) | |
| … | … | ||
| 994 | 994 | { | |
| 995 | 995 | if (getType() == PLAYER && value == "visiblenames") | |
| 996 | 996 | { | |
| 997 | setShowName(config.getValue("visiblenames", 1)); | ||
| 997 | setShowName(config.getBoolValue("visiblenames")); | ||
| 998 | 998 | } | |
| 999 | 999 | } | |
| 1000 | 1000 | ||
| … | … | ||
| 1010 | 1010 | mDispName = 0; | |
| 1011 | 1011 | std::string mDisplayName(mName); | |
| 1012 | 1012 | ||
| 1013 | if (config.getValue("showgender", false)) | ||
| 1013 | if (config.getBoolValue("showgender")) | ||
| 1014 | 1014 | { | |
| 1015 | 1015 | if (getGender() == GENDER_FEMALE) | |
| 1016 | 1016 | mDisplayName += " \u2640"; | |
| … | … | ||
| 1020 | 1020 | ||
| 1021 | 1021 | if (getType() == MONSTER) | |
| 1022 | 1022 | { | |
| 1023 | if (config.getValue("showMonstersTakedDamage", false)) | ||
| 1023 | if (config.getBoolValue("showMonstersTakedDamage")) | ||
| 1024 | 1024 | { | |
| 1025 | 1025 | mDisplayName += ", " + toString(getDamageTaken()); | |
| 1026 | 1026 | } | |
| … | … | ||
| 1113 | 1113 | if (!color.empty()) | |
| 1114 | 1114 | filename += "|" + color; | |
| 1115 | 1115 | ||
| 1116 | equipmentSprite = AnimatedSprite::load("graphics/sprites/" + | ||
| 1117 | filename); | ||
| 1116 | equipmentSprite = AnimatedSprite::load( | ||
| 1117 | paths.getStringValue("sprites") + filename); | ||
| 1118 | 1118 | } | |
| 1119 | 1119 | ||
| 1120 | 1120 | if (equipmentSprite) | |
| … | … | ||
| 1154 | 1154 | int hairstyles = 1; | |
| 1155 | 1155 | ||
| 1156 | 1156 | while (ItemDB::get(-hairstyles).getSprite(GENDER_MALE) != | |
| 1157 | paths.getValue("spriteErrorFile", "error.xml")) | ||
| 1157 | paths.getStringValue("spriteErrorFile")) | ||
| 1158 | 1158 | hairstyles++; | |
| 1159 | 1159 | ||
| 1160 | 1160 | mNumberOfHairstyles = hairstyles; |
src/chatlog.cpp
(1 / 2)
|   | |||
| 150 | 150 | { | |
| 151 | 151 | mServerName = serverName; | |
| 152 | 152 | if (mServerName == "") | |
| 153 | mServerName = config.getValue("MostUsedServerName0", | ||
| 154 | "server.themanaworld.org"); | ||
| 153 | mServerName = config.getStringValue("MostUsedServerName0"); | ||
| 155 | 154 | ||
| 156 | 155 | if (mLogFile.is_open()) | |
| 157 | 156 | mLogFile.close(); |
src/client.cpp
(23 / 27)
|   | |||
| 219 | 219 | if (!options.brandingPath.empty()) | |
| 220 | 220 | { | |
| 221 | 221 | branding.init(options.brandingPath); | |
| 222 | branding.setDefaultValues(getBrandingDefaults()); | ||
| 222 | 223 | } | |
| 223 | 224 | ||
| 224 | 225 | initHomeDir(); | |
| … | … | ||
| 233 | 233 | ||
| 234 | 234 | // Configure logger | |
| 235 | 235 | logger->setLogFile(mLocalDataDir + std::string("/mana.log")); | |
| 236 | logger->setLogToStandardOut(config.getValue("logToStandardOut", 0)); | ||
| 236 | logger->setLogToStandardOut(config.getBoolValue("logToStandardOut")); | ||
| 237 | 237 | ||
| 238 | 238 | // Log the mana version | |
| 239 | 239 | logger->log("Mana %s", FULL_VERSION); | |
| … | … | ||
| 337 | 337 | graphics = new Graphics; | |
| 338 | 338 | #endif | |
| 339 | 339 | ||
| 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"); | ||
| 342 | 342 | 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"); | ||
| 345 | 345 | ||
| 346 | 346 | // Try to set the desired video mode | |
| 347 | 347 | if (!graphics->setVideoMode(width, height, bpp, fullscreen, hwaccel)) | |
| … | … | ||
| 364 | 364 | // Initialize sound engine | |
| 365 | 365 | try | |
| 366 | 366 | { | |
| 367 | if (config.getValue("sound", 0) == 1) | ||
| 367 | if (config.getBoolValue("sound")) | ||
| 368 | 368 | sound.init(); | |
| 369 | 369 | ||
| 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")); | ||
| 374 | 372 | } | |
| 375 | 373 | catch (const char *err) | |
| 376 | 374 | { | |
| … | … | ||
| 393 | 393 | mCurrentServer.port = options.serverPort; | |
| 394 | 394 | loginData.username = options.username; | |
| 395 | 395 | loginData.password = options.password; | |
| 396 | loginData.remember = config.getValue("remember", 0); | ||
| 396 | loginData.remember = config.getBoolValue("remember"); | ||
| 397 | 397 | loginData.registerLogin = false; | |
| 398 | 398 | ||
| 399 | 399 | if (mCurrentServer.hostname.empty()) | |
| 400 | { | ||
| 401 | mCurrentServer.hostname = branding.getValue("defaultServer", | ||
| 402 | "").c_str(); | ||
| 403 | } | ||
| 400 | mCurrentServer.hostname = branding.getValue("defaultServer","").c_str(); | ||
| 404 | 401 | ||
| 405 | 402 | if (mCurrentServer.port == 0) | |
| 406 | 403 | { | |
| 407 | 404 | mCurrentServer.port = (short) branding.getValue("defaultPort", | |
| 408 | DEFAULT_PORT); | ||
| 405 | DEFAULT_PORT); | ||
| 409 | 406 | mCurrentServer.type = ServerInfo::parseType( | |
| 410 | branding.getValue("defaultServerType", "tmwathena")); | ||
| 407 | branding.getValue("defaultServerType", "tmwathena")); | ||
| 411 | 408 | } | |
| 412 | 409 | ||
| 413 | 410 | if (chatLogger) | |
| 414 | 411 | chatLogger->setServerName(mCurrentServer.hostname); | |
| 415 | 412 | ||
| 416 | 413 | if (loginData.username.empty() && loginData.remember) | |
| 417 | loginData.username = config.getValue("username", ""); | ||
| 414 | loginData.username = config.getStringValue("username"); | ||
| 418 | 415 | ||
| 419 | 416 | if (mState != STATE_ERROR) | |
| 420 | 417 | mState = STATE_CHOOSE_SERVER; | |
| … | … | ||
| 573 | 573 | - 3, 3); | |
| 574 | 574 | top->add(mSetupButton); | |
| 575 | 575 | ||
| 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"); | ||
| 580 | 578 | ||
| 581 | 579 | mDesktop->setSize(screenWidth, screenHeight); | |
| 582 | 580 | } | |
| … | … | ||
| 743 | 743 | ||
| 744 | 744 | // Read default paths file 'data/paths.xml' | |
| 745 | 745 | paths.init("paths.xml", true); | |
| 746 | paths.setDefaultValues(getPathsDefaults()); | ||
| 746 | 747 | ||
| 747 | 748 | // Load XML databases | |
| 748 | 749 | ColorDB::load(); | |
| … | … | ||
| 783 | 783 | mOptions.character, CharSelectDialog::Choose)) | |
| 784 | 784 | { | |
| 785 | 785 | ((CharSelectDialog*) mCurrentDialog)->selectByName( | |
| 786 | config.getValue("lastCharacter", ""), | ||
| 786 | config.getStringValue("lastCharacter"), | ||
| 787 | 787 | mOptions.chooseDefault ? | |
| 788 | 788 | CharSelectDialog::Choose : | |
| 789 | 789 | CharSelectDialog::Focus); | |
| … | … | ||
| 995 | 995 | ||
| 996 | 996 | void Client::optionChanged(const std::string &name) | |
| 997 | 997 | { | |
| 998 | const int fpsLimit = (int) config.getValue("fpslimit", 60); | ||
| 998 | const int fpsLimit = config.getIntValue("fpslimit"); | ||
| 999 | 999 | mLimitFps = fpsLimit > 0; | |
| 1000 | 1000 | if (mLimitFps) | |
| 1001 | 1001 | SDL_setFramerate(&mFpsManager, fpsLimit); | |
| … | … | ||
| 1146 | 1146 | { | |
| 1147 | 1147 | fclose(configFile); | |
| 1148 | 1148 | config.init(configPath); | |
| 1149 | config.setDefaultValues(getConfigDefaults()); | ||
| 1149 | 1150 | } | |
| 1150 | 1151 | } | |
| 1151 | 1152 | ||
| … | … | ||
| 1161 | 1161 | // If updatesHost is currently empty, fill it from config file | |
| 1162 | 1162 | if (mUpdateHost.empty()) | |
| 1163 | 1163 | { | |
| 1164 | mUpdateHost = config.getValue("updatehost", ""); | ||
| 1164 | mUpdateHost = config.getStringValue("updatehost"); | ||
| 1165 | 1165 | } | |
| 1166 | 1166 | ||
| 1167 | 1167 | // Don't go out of range int he next check | |
| … | … | ||
| 1239 | 1239 | else | |
| 1240 | 1240 | { | |
| 1241 | 1241 | std::string configScreenshotDir = | |
| 1242 | config.getValue("screenshotDirectory", ""); | ||
| 1242 | config.getStringValue("screenshotDirectory"); | ||
| 1243 | 1243 | if (!configScreenshotDir.empty()) | |
| 1244 | 1244 | mScreenshotDir = configScreenshotDir; | |
| 1245 | 1245 | else | |
| … | … | ||
| 1254 | 1254 | } | |
| 1255 | 1255 | config.setValue("screenshotDirectory", mScreenshotDir); | |
| 1256 | 1256 | ||
| 1257 | if (config.getValue("useScreenshotDirectorySuffix", true)) | ||
| 1257 | if (config.getBoolValue("useScreenshotDirectorySuffix")) | ||
| 1258 | 1258 | { | |
| 1259 | 1259 | std::string configScreenshotSuffix = | |
| 1260 | 1260 | config.getValue("screenshotDirectorySuffix", |
src/configuration.cpp
(120 / 0)
|   | |||
| 98 | 98 | clear(); | |
| 99 | 99 | } | |
| 100 | 100 | ||
| 101 | void 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 | |||
| 117 | Configuration::~Configuration() | ||
| 118 | { | ||
| 119 | cleanDefaults(); | ||
| 120 | } | ||
| 121 | |||
| 122 | void Configuration::setDefaultValues(DefaultsData *defaultsData) | ||
| 123 | { | ||
| 124 | cleanDefaults(); | ||
| 125 | mDefaultsData = defaultsData; | ||
| 126 | } | ||
| 127 | |||
| 128 | int 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 | |||
| 150 | std::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 | |||
| 173 | float 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 | |||
| 195 | bool 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 | |||
| 101 | 221 | void ConfigurationObject::initFromXML(xmlNodePtr parent_node) | |
| 102 | 222 | { | |
| 103 | 223 | clear(); |
src/configuration.h
(26 / 2)
|   | |||
| 23 | 23 | #define CONFIGURATION_H | |
| 24 | 24 | ||
| 25 | 25 | #include "utils/stringutils.h" | |
| 26 | #include "defaults.h" | ||
| 26 | 27 | ||
| 27 | 28 | #include <libxml/xmlwriter.h> | |
| 28 | 29 | ||
| … | … | ||
| 193 | 193 | class Configuration : public ConfigurationObject | |
| 194 | 194 | { | |
| 195 | 195 | public: | |
| 196 | virtual ~Configuration() {} | ||
| 196 | ~Configuration(); | ||
| 197 | 197 | ||
| 198 | 198 | /** | |
| 199 | 199 | * Reads config file and parse all options into memory. | |
| … | … | ||
| 204 | 204 | void init(const std::string &filename, bool useResManager = false); | |
| 205 | 205 | ||
| 206 | 206 | /** | |
| 207 | * Set the default values for each keys. | ||
| 208 | * | ||
| 209 | * @param defaultsData data used as defaults. | ||
| 210 | */ | ||
| 211 | void setDefaultValues(DefaultsData *defaultsData); | ||
| 212 | |||
| 213 | /** | ||
| 207 | 214 | * Writes the current settings back to the config file. | |
| 208 | 215 | */ | |
| 209 | 216 | void write(); | |
| … | … | ||
| 246 | 246 | inline void setValue(const std::string &key, bool value) | |
| 247 | 247 | { setValue(key, value ? "1" : "0"); } | |
| 248 | 248 | ||
| 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 | |||
| 249 | 259 | private: | |
| 260 | /** | ||
| 261 | * Clean up the default values member. | ||
| 262 | */ | ||
| 263 | void cleanDefaults(); | ||
| 264 | |||
| 250 | 265 | typedef std::list<ConfigListener*> Listeners; | |
| 251 | 266 | typedef Listeners::iterator ListenerIterator; | |
| 252 | 267 | typedef std::map<std::string, Listeners> ListenerMap; | |
| 253 | 268 | typedef ListenerMap::iterator ListenerMapIterator; | |
| 254 | 269 | ListenerMap mListenerMap; | |
| 255 | 270 | ||
| 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 */ | ||
| 257 | 273 | }; | |
| 258 | 274 | ||
| 259 | 275 | extern Configuration branding; |
src/defaults.cpp
(177 / 0)
|   | |||
| 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 | |||
| 31 | using namespace Mana; | ||
| 32 | |||
| 33 | VariableData* createData(int defData) | ||
| 34 | { | ||
| 35 | return new IntData(defData); | ||
| 36 | } | ||
| 37 | |||
| 38 | VariableData* createData(float defData) | ||
| 39 | { | ||
| 40 | return new FloatData(defData); | ||
| 41 | } | ||
| 42 | |||
| 43 | VariableData* createData(const std::string &defData) | ||
| 44 | { | ||
| 45 | return new StringData(defData); | ||
| 46 | } | ||
| 47 | |||
| 48 | VariableData* createData(const char* defData) | ||
| 49 | { | ||
| 50 | return new StringData(defData); | ||
| 51 | } | ||
| 52 | |||
| 53 | VariableData* 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 | |||
| 63 | DefaultsData* 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 | |||
| 124 | DefaultsData* 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 | |||
| 149 | DefaultsData* 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 |
src/defaults.h
(34 / 0)
|   | |||
| 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 | |||
| 28 | typedef std::map<std::string, Mana::VariableData*> DefaultsData; | ||
| 29 | |||
| 30 | DefaultsData* getConfigDefaults(); | ||
| 31 | DefaultsData* getBrandingDefaults(); | ||
| 32 | DefaultsData* getPathsDefaults(); | ||
| 33 | |||
| 34 | #endif |
src/gui/chat.cpp
(2 / 2)
|   | |||
| 110 | 110 | mChatInput->addKeyListener(this); | |
| 111 | 111 | mCurHist = mHistory.end(); | |
| 112 | 112 | ||
| 113 | mReturnToggles = config.getValue("ReturnToggles", "0") == "1"; | ||
| 113 | mReturnToggles = config.getBoolValue("ReturnToggles"); | ||
| 114 | 114 | ||
| 115 | 115 | mRecorder = new Recorder(this); | |
| 116 | 116 | } | |
| … | … | ||
| 478 | 478 | ||
| 479 | 479 | if (i != mWhispers.end()) | |
| 480 | 480 | tab = i->second; | |
| 481 | else if (config.getValue("whispertab", true)) | ||
| 481 | else if (config.getBoolValue("whispertab")) | ||
| 482 | 482 | tab = addWhisperTab(nick); | |
| 483 | 483 | ||
| 484 | 484 | if (tab) |
src/gui/emotepopup.cpp
(1 / 1)
|   | |||
| 61 | 61 | if (!mSelectionImage) | |
| 62 | 62 | logger->error("Unable to load selection.png"); | |
| 63 | 63 | ||
| 64 | mSelectionImage->setAlpha(config.getValue("guialpha", 0.8)); | ||
| 64 | mSelectionImage->setAlpha(config.getFloatValue("guialpha")); | ||
| 65 | 65 | ||
| 66 | 66 | addMouseListener(this); | |
| 67 | 67 | recalculateSize(); |
src/gui/gui.cpp
(3 / 3)
|   | |||
| 61 | 61 | { | |
| 62 | 62 | if (name == "customcursor") | |
| 63 | 63 | { | |
| 64 | bool bCustomCursor = config.getValue("customcursor", 1) == 1; | ||
| 64 | bool bCustomCursor = config.getBoolValue("customcursor"); | ||
| 65 | 65 | mGui->setUseCustomCursor(bCustomCursor); | |
| 66 | 66 | } | |
| 67 | 67 | } | |
| … | … | ||
| 104 | 104 | ResourceManager *resman = ResourceManager::getInstance(); | |
| 105 | 105 | ||
| 106 | 106 | // Set global font | |
| 107 | const int fontSize = (int) config.getValue("fontSize", 11); | ||
| 107 | const int fontSize = config.getValue("fontSize", 11); | ||
| 108 | 108 | std::string fontFile = branding.getValue("font", "fonts/dejavusans.ttf"); | |
| 109 | 109 | std::string path = resman->getPath(fontFile); | |
| 110 | 110 | ||
| … | … | ||
| 135 | 135 | gcn::Widget::setGlobalFont(mGuiFont); | |
| 136 | 136 | ||
| 137 | 137 | // Initialize mouse cursor and listen for changes to the option | |
| 138 | setUseCustomCursor(config.getValue("customcursor", 1) == 1); | ||
| 138 | setUseCustomCursor(config.getBoolValue("customcursor")); | ||
| 139 | 139 | mConfigListener = new GuiConfigListener(this); | |
| 140 | 140 | config.addListener("customcursor", mConfigListener); | |
| 141 | 141 | } |
src/gui/help.cpp
(2 / 2)
|   | |||
| 94 | 94 | void HelpWindow::loadFile(const std::string &file) | |
| 95 | 95 | { | |
| 96 | 96 | ResourceManager *resman = ResourceManager::getInstance(); | |
| 97 | std::string helpPath = branding.getValue("helpPath", ""); | ||
| 97 | std::string helpPath = branding.getStringValue("helpPath"); | ||
| 98 | 98 | if (helpPath.empty()) | |
| 99 | helpPath = paths.getValue("help", "help/"); | ||
| 99 | helpPath = paths.getStringValue("help"); | ||
| 100 | 100 | std::vector<std::string> lines = | |
| 101 | 101 | resman->loadTextFile(helpPath + file + ".txt"); | |
| 102 | 102 |
src/gui/itempopup.cpp
(1 / 1)
|   | |||
| 103 | 103 | { | |
| 104 | 104 | ResourceManager *resman = ResourceManager::getInstance(); | |
| 105 | 105 | Image *image = resman->getImage( | |
| 106 | paths.getValue("itemIcons", "graphics/items/") | ||
| 106 | paths.getStringValue("itemIcons") | ||
| 107 | 107 | + item.getDisplay().image); | |
| 108 | 108 | ||
| 109 | 109 | mIcon->setImage(image); |
src/gui/npcdialog.cpp
(2 / 2)
|   | |||
| 51 | 51 | NpcDialog::NpcDialog(int npcId) | |
| 52 | 52 | : Window(_("NPC")), | |
| 53 | 53 | mNpcId(npcId), | |
| 54 | mLogInteraction(config.getValue("logNpcInGui", true)), | ||
| 54 | mLogInteraction(config.getBoolValue("logNpcInGui")), | ||
| 55 | 55 | mDefaultInt(0), | |
| 56 | 56 | mInputState(NPC_INPUT_NONE), | |
| 57 | 57 | mActionState(NPC_ACTION_WAIT) | |
| … | … | ||
| 369 | 369 | { | |
| 370 | 370 | if (name == "logNpcInGui") | |
| 371 | 371 | { | |
| 372 | mLogInteraction = config.getValue("logNpcInGui", true); | ||
| 372 | mLogInteraction = config.getBoolValue("logNpcInGui"); | ||
| 373 | 373 | } | |
| 374 | 374 | } | |
| 375 | 375 |
src/gui/serverdialog.cpp
(2 / 2)
|   | |||
| 485 | 485 | void ServerDialog::downloadServerList() | |
| 486 | 486 | { | |
| 487 | 487 | // 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"); | ||
| 489 | 489 | ||
| 490 | 490 | if (listFile.empty()) | |
| 491 | listFile = config.getValue("onlineServerList", std::string()); | ||
| 491 | listFile = config.getStringValue("onlineServerList"); | ||
| 492 | 492 | ||
| 493 | 493 | // Fall back to manasource.org when neither branding nor config set it | |
| 494 | 494 | if (listFile.empty()) |
src/gui/setup_audio.cpp
(7 / 7)
|   | |||
| 35 | 35 | #include "utils/gettext.h" | |
| 36 | 36 | ||
| 37 | 37 | Setup_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")), | ||
| 42 | 42 | mSoundCheckBox(new CheckBox(_("Sound"), mSoundEnabled)), | |
| 43 | 43 | mDownloadMusicCheckBox(new CheckBox(_("Download music"), mDownloadEnabled)), | |
| 44 | 44 | mSfxSlider(new Slider(0, sound.getMaxVolume())), | |
| … | … | ||
| 82 | 82 | { | |
| 83 | 83 | mSoundEnabled = mSoundCheckBox->isSelected(); | |
| 84 | 84 | 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"); | ||
| 87 | 87 | ||
| 88 | 88 | config.setValue("sound", mSoundEnabled); | |
| 89 | 89 | ||
| 90 | 90 | // Display a message if user has selected to download music, | |
| 91 | 91 | // And if downloadmusic is not already enabled | |
| 92 | if (mDownloadEnabled && !config.getValue("download-music", false)) | ||
| 92 | if (mDownloadEnabled && !config.getBoolValue("download-music")) | ||
| 93 | 93 | { | |
| 94 | 94 | new OkDialog(_("Notice"),_("You may have to restart your client if you want to download new music")); | |
| 95 | 95 | } |
src/gui/setup_joystick.cpp
(1 / 1)
|   | |||
| 40 | 40 | { | |
| 41 | 41 | setName(_("Joystick")); | |
| 42 | 42 | ||
| 43 | mOriginalJoystickEnabled = !config.getValue("joystickEnabled", false); | ||
| 43 | mOriginalJoystickEnabled = !config.getBoolValue("joystickEnabled"); | ||
| 44 | 44 | mJoystickEnabled->setSelected(mOriginalJoystickEnabled); | |
| 45 | 45 | ||
| 46 | 46 | mJoystickEnabled->addActionListener(this); |
src/gui/setup_players.cpp
(7 / 7)
|   | |||
| 227 | 227 | mDefaultWhisper(new CheckBox(_("Allow whispers"), | |
| 228 | 228 | player_relations.getDefault() & PlayerRelation::WHISPER)), | |
| 229 | 229 | mDeleteButton(new Button(_("Delete"), ACTION_DELETE, this)), | |
| 230 | mWhisperTab(config.getValue("whispertab", false)), | ||
| 230 | mWhisperTab(config.getBoolValue("whispertab")), | ||
| 231 | 231 | mWhisperTabCheckBox(new CheckBox(_("Put all whispers in tabs"), mWhisperTab)), | |
| 232 | mShowGender(config.getValue("showgender", false)), | ||
| 232 | mShowGender(config.getBoolValue("showgender")), | ||
| 233 | 233 | mShowGenderCheckBox(new CheckBox(_("Show gender"), mShowGender)), | |
| 234 | mEnableChatLog(config.getValue("enableChatLog", false)), | ||
| 234 | mEnableChatLog(config.getBoolValue("enableChatLog")), | ||
| 235 | 235 | mEnableChatLogCheckBox(new CheckBox(_("Enable Chat log"), mEnableChatLog)) | |
| 236 | 236 | { | |
| 237 | 237 | setName(_("Players")); | |
| … | … | ||
| 348 | 348 | PlayerRelation::WHISPER : 0)); | |
| 349 | 349 | config.setValue("whispertab", mWhisperTab); | |
| 350 | 350 | ||
| 351 | bool showGender = config.getValue("showgender", false); | ||
| 351 | bool showGender = config.getBoolValue("showgender"); | ||
| 352 | 352 | ||
| 353 | 353 | config.setValue("showgender", mShowGender); | |
| 354 | 354 | ||
| … | … | ||
| 360 | 360 | ||
| 361 | 361 | void Setup_Players::cancel() | |
| 362 | 362 | { | |
| 363 | mWhisperTab = config.getValue("whispertab", false); | ||
| 363 | mWhisperTab = config.getBoolValue("whispertab"); | ||
| 364 | 364 | mWhisperTabCheckBox->setSelected(mWhisperTab); | |
| 365 | mShowGender = config.getValue("showgender", false); | ||
| 365 | mShowGender = config.getBoolValue("showgender"); | ||
| 366 | 366 | mShowGenderCheckBox->setSelected(mShowGender); | |
| 367 | mEnableChatLog = config.getValue("enableChatLog", false); | ||
| 367 | mEnableChatLog = config.getBoolValue("enableChatLog"); | ||
| 368 | 368 | mEnableChatLogCheckBox->setSelected(mEnableChatLog); | |
| 369 | 369 | } | |
| 370 | 370 |
src/gui/setup_video.cpp
(33 / 35)
|   | |||
| 171 | 171 | const char *Setup_Video::overlayDetailToString(int detail) | |
| 172 | 172 | { | |
| 173 | 173 | if (detail == -1) | |
| 174 | detail = config.getValue("OverlayDetail", -1); | ||
| 174 | detail = config.getIntValue("OverlayDetail"); | ||
| 175 | 175 | ||
| 176 | 176 | switch (detail) | |
| 177 | 177 | { | |
| … | … | ||
| 185 | 185 | const char *Setup_Video::particleDetailToString(int detail) | |
| 186 | 186 | { | |
| 187 | 187 | if (detail == -1) | |
| 188 | detail = 3 - config.getValue("particleEmitterSkip", -1); | ||
| 188 | detail = 3 - config.getIntValue("particleEmitterSkip"); | ||
| 189 | 189 | ||
| 190 | 190 | switch (detail) | |
| 191 | 191 | { | |
| … | … | ||
| 198 | 198 | } | |
| 199 | 199 | ||
| 200 | 200 | Setup_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"))), | ||
| 216 | 214 | mModeListModel(new ModeListModel), | |
| 217 | 215 | mModeList(new ListBox(mModeListModel)), | |
| 218 | 216 | mFsCheckBox(new CheckBox(_("Full screen"), mFullScreenEnabled)), | |
| … | … | ||
| 235 | 235 | mFpsCheckBox(new CheckBox(_("FPS limit:"))), | |
| 236 | 236 | mFpsSlider(new Slider(10, 120)), | |
| 237 | 237 | mFpsLabel(new Label), | |
| 238 | mOverlayDetail((int) config.getValue("OverlayDetail", 2)), | ||
| 238 | mOverlayDetail(config.getIntValue("OverlayDetail")), | ||
| 239 | 239 | mOverlayDetailSlider(new Slider(0, 2)), | |
| 240 | 240 | mOverlayDetailField(new Label), | |
| 241 | mParticleDetail(3 - (int) config.getValue("particleEmitterSkip", 1)), | ||
| 241 | mParticleDetail(3 - config.getIntValue("particleEmitterSkip")), | ||
| 242 | 242 | mParticleDetailSlider(new Slider(0, 3)), | |
| 243 | 243 | mParticleDetailField(new Label), | |
| 244 | mFontSize((int) config.getValue("fontSize", 11)) | ||
| 244 | mFontSize(config.getIntValue("fontSize")) | ||
| 245 | 245 | { | |
| 246 | 246 | setName(_("Video")); | |
| 247 | 247 | ||
| … | … | ||
| 386 | 386 | { | |
| 387 | 387 | // Full screen changes | |
| 388 | 388 | bool fullscreen = mFsCheckBox->isSelected(); | |
| 389 | if (fullscreen != (config.getValue("screen", false) == 1)) | ||
| 389 | if (fullscreen != config.getBoolValue("screen")) | ||
| 390 | 390 | { | |
| 391 | 391 | /* The OpenGL test is only necessary on Windows, since switching | |
| 392 | 392 | * to/from full screen works fine on Linux. On Windows we'd have to | |
| … | … | ||
| 397 | 397 | ||
| 398 | 398 | #if defined(WIN32) || defined(__APPLE__) | |
| 399 | 399 | // checks for opengl usage | |
| 400 | if (!(config.getValue("opengl", false) == 1)) | ||
| 400 | if (!config.getBoolValue("opengl")) | ||
| 401 | 401 | { | |
| 402 | 402 | #endif | |
| 403 | 403 | if (!graphics->setFullscreen(fullscreen)) | |
| … | … | ||
| 450 | 450 | config.setValue("fontSize", mFontSizeDropDown->getSelected() + 10); | |
| 451 | 451 | ||
| 452 | 452 | // 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"); | ||
| 460 | 460 | 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"); | ||
| 467 | 467 | } | |
| 468 | 468 | ||
| 469 | 469 | void Setup_Video::cancel() |
src/gui/theme.cpp
(5 / 5)
|   | |||
| 48 | 48 | static void initDefaultThemePath() | |
| 49 | 49 | { | |
| 50 | 50 | ResourceManager *resman = ResourceManager::getInstance(); | |
| 51 | defaultThemePath = branding.getValue("guiThemePath", ""); | ||
| 51 | defaultThemePath = branding.getStringValue("guiThemePath"); | ||
| 52 | 52 | ||
| 53 | 53 | if (!defaultThemePath.empty() && resman->isDirectory(defaultThemePath)) | |
| 54 | 54 | return; | |
| … | … | ||
| 81 | 81 | ||
| 82 | 82 | void Skin::updateAlpha(float minimumOpacityAllowed) | |
| 83 | 83 | { | |
| 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")); | ||
| 86 | 86 | ||
| 87 | 87 | for_each(mBorder.grid, mBorder.grid + 9, | |
| 88 | 88 | std::bind2nd(std::mem_fun(&Image::setAlpha), alpha)); | |
| … | … | ||
| 339 | 339 | void Theme::prepareThemePath() | |
| 340 | 340 | { | |
| 341 | 341 | // Try theme from settings | |
| 342 | if (!tryThemePath(config.getValue("theme", ""))) | ||
| 342 | if (!tryThemePath(config.getStringValue("theme"))) | ||
| 343 | 343 | // Try theme from branding | |
| 344 | if (!tryThemePath(branding.getValue("theme", ""))) | ||
| 344 | if (!tryThemePath(branding.getStringValue("theme"))) | ||
| 345 | 345 | // Use default | |
| 346 | 346 | mThemePath = defaultThemePath; | |
| 347 | 347 |
src/gui/updatewindow.cpp
(1 / 1)
|   | |||
| 476 | 476 | // This statement checks to see if the file type is music, and if download-music is true | |
| 477 | 477 | // If it fails, this statement returns true, and results in not downloading the file | |
| 478 | 478 | // 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")) ) | ||
| 480 | 480 | { | |
| 481 | 481 | mUpdateIndex++; | |
| 482 | 482 | break; |
src/gui/viewport.cpp
(6 / 6)
|   | |||
| 58 | 58 | setOpaque(false); | |
| 59 | 59 | addMouseListener(this); | |
| 60 | 60 | ||
| 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"); | ||
| 65 | 65 | ||
| 66 | 66 | config.addListener("ScrollLaziness", this); | |
| 67 | 67 | config.addListener("ScrollRadius", this); | |
| … | … | ||
| 481 | 481 | ||
| 482 | 482 | void Viewport::optionChanged(const std::string &name) | |
| 483 | 483 | { | |
| 484 | mScrollLaziness = (int) config.getValue("ScrollLaziness", 32); | ||
| 485 | mScrollRadius = (int) config.getValue("ScrollRadius", 32); | ||
| 484 | mScrollLaziness = config.getIntValue("ScrollLaziness"); | ||
| 485 | mScrollRadius = config.getIntValue("ScrollRadius"); | ||
| 486 | 486 | } | |
| 487 | 487 | ||
| 488 | 488 | void Viewport::mouseMoved(gcn::MouseEvent &event) |
src/gui/widgets/button.cpp
(2 / 2)
|   | |||
| 125 | 125 | ||
| 126 | 126 | void Button::updateAlpha() | |
| 127 | 127 | { | |
| 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()); | ||
| 130 | 130 | ||
| 131 | 131 | if (mAlpha != alpha) | |
| 132 | 132 | { |
src/gui/widgets/chattab.cpp
(2 / 2)
|   | |||
| 51 | 51 | ||
| 52 | 52 | mTextOutput = new BrowserBox(BrowserBox::AUTO_WRAP); | |
| 53 | 53 | mTextOutput->setOpaque(false); | |
| 54 | mTextOutput->setMaxRow((int) config.getValue("ChatLogLength", 0)); | ||
| 54 | mTextOutput->setMaxRow((int) config.getIntValue("ChatLogLength")); | ||
| 55 | 55 | mTextOutput->setLinkHandler(chatWindow->mItemLinkHandler); | |
| 56 | 56 | ||
| 57 | 57 | mScrollArea = new ScrollArea(mTextOutput); | |
| … | … | ||
| 181 | 181 | ||
| 182 | 182 | line = lineColor + timeStr.str() + tmp.nick + tmp.text; | |
| 183 | 183 | ||
| 184 | if (config.getValue("enableChatLog", false)) | ||
| 184 | if (config.getBoolValue("enableChatLog")) | ||
| 185 | 185 | saveToLogFile(line); | |
| 186 | 186 | ||
| 187 | 187 | // We look if the Vertical Scroll Bar is set at the max before |
src/gui/widgets/checkbox.cpp
(2 / 2)
|   | |||
| 92 | 92 | ||
| 93 | 93 | void CheckBox::updateAlpha() | |
| 94 | 94 | { | |
| 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()); | ||
| 97 | 97 | ||
| 98 | 98 | if (mAlpha != alpha) | |
| 99 | 99 | { |
src/gui/widgets/dropdown.cpp
(2 / 2)
|   | |||
| 110 | 110 | ||
| 111 | 111 | void DropDown::updateAlpha() | |
| 112 | 112 | { | |
| 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()); | ||
| 115 | 115 | ||
| 116 | 116 | if (mAlpha != alpha) | |
| 117 | 117 | { |
|   | |||
| 51 | 51 | ||
| 52 | 52 | mBackgroundImg = Theme::getImageFromTheme("item_shortcut_bgr.png"); | |
| 53 | 53 | ||
| 54 | mBackgroundImg->setAlpha(config.getValue("guialpha", 0.8)); | ||
| 54 | mBackgroundImg->setAlpha(config.getFloatValue("guialpha")); | ||
| 55 | 55 | ||
| 56 | 56 | // Setup emote sprites | |
| 57 | 57 | for (int i = 0; i <= EmoteDB::getLast(); i++) | |
| … | … | ||
| 72 | 72 | ||
| 73 | 73 | void EmoteShortcutContainer::draw(gcn::Graphics *graphics) | |
| 74 | 74 | { | |
| 75 | if (config.getValue("guialpha", 0.8) != mAlpha) | ||
| 75 | if (config.getFloatValue("guialpha") != mAlpha) | ||
| 76 | 76 | { | |
| 77 | mAlpha = config.getValue("guialpha", 0.8); | ||
| 77 | mAlpha = config.getFloatValue("guialpha"); | ||
| 78 | 78 | mBackgroundImg->setAlpha(mAlpha); | |
| 79 | 79 | } | |
| 80 | 80 |
|   | |||
| 53 | 53 | mBackgroundImg = Theme::getImageFromTheme("item_shortcut_bgr.png"); | |
| 54 | 54 | mMaxItems = itemShortcut->getItemCount(); | |
| 55 | 55 | ||
| 56 | mBackgroundImg->setAlpha(config.getValue("guialpha", 0.8)); | ||
| 56 | mBackgroundImg->setAlpha(config.getFloatValue("guialpha")); | ||
| 57 | 57 | ||
| 58 | 58 | mBoxHeight = mBackgroundImg->getHeight(); | |
| 59 | 59 | mBoxWidth = mBackgroundImg->getWidth(); | |
| … | … | ||
| 67 | 67 | ||
| 68 | 68 | void ItemShortcutContainer::draw(gcn::Graphics *graphics) | |
| 69 | 69 | { | |
| 70 | if (config.getValue("guialpha", 0.8) != mAlpha) | ||
| 70 | if (config.getFloatValue("guialpha") != mAlpha) | ||
| 71 | 71 | { | |
| 72 | mAlpha = config.getValue("guialpha", 0.8); | ||
| 72 | mAlpha = config.getFloatValue("guialpha"); | ||
| 73 | 73 | mBackgroundImg->setAlpha(mAlpha); | |
| 74 | 74 | } | |
| 75 | 75 |
src/gui/widgets/listbox.cpp
(2 / 2)
|   | |||
| 45 | 45 | ||
| 46 | 46 | void ListBox::updateAlpha() | |
| 47 | 47 | { | |
| 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()); | ||
| 50 | 50 | ||
| 51 | 51 | if (mAlpha != alpha) | |
| 52 | 52 | mAlpha = alpha; |
|   | |||
| 57 | 57 | bggridx[x], bggridy[y], | |
| 58 | 58 | bggridx[x + 1] - bggridx[x] + 1, | |
| 59 | 59 | bggridy[y + 1] - bggridy[y] + 1); | |
| 60 | background.grid[a]->setAlpha(config.getValue("guialpha", 0.8)); | ||
| 60 | background.grid[a]->setAlpha(config.getFloatValue("guialpha")); | ||
| 61 | 61 | a++; | |
| 62 | 62 | } | |
| 63 | 63 | } | |
| … | … | ||
| 91 | 91 | mBeing->drawSpriteAt(static_cast<Graphics*>(graphics), x, y); | |
| 92 | 92 | } | |
| 93 | 93 | ||
| 94 | if (config.getValue("guialpha", 0.8) != mAlpha) | ||
| 94 | if (config.getFloatValue("guialpha") != mAlpha) | ||
| 95 | 95 | { | |
| 96 | 96 | for (int a = 0; a < 9; a++) | |
| 97 | 97 | { | |
| 98 | background.grid[a]->setAlpha(config.getValue("guialpha", 0.8)); | ||
| 98 | background.grid[a]->setAlpha(config.getFloatValue("guialpha")); | ||
| 99 | 99 | } | |
| 100 | 100 | } | |
| 101 | 101 | } |
|   | |||
| 123 | 123 | ||
| 124 | 124 | void ProgressBar::updateAlpha() | |
| 125 | 125 | { | |
| 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()); | ||
| 128 | 128 | ||
| 129 | 129 | if (mAlpha != alpha) | |
| 130 | 130 | { |
|   | |||
| 78 | 78 | ||
| 79 | 79 | void RadioButton::drawBox(gcn::Graphics* graphics) | |
| 80 | 80 | { | |
| 81 | if (config.getValue("guialpha", 0.8) != mAlpha) | ||
| 81 | if (config.getFloatValue("guialpha") != mAlpha) | ||
| 82 | 82 | { | |
| 83 | mAlpha = config.getValue("guialpha", 0.8); | ||
| 83 | mAlpha = config.getFloatValue("guialpha"); | ||
| 84 | 84 | radioNormal->setAlpha(mAlpha); | |
| 85 | 85 | radioChecked->setAlpha(mAlpha); | |
| 86 | 86 | radioDisabled->setAlpha(mAlpha); |
|   | |||
| 59 | 59 | ||
| 60 | 60 | void ResizeGrip::draw(gcn::Graphics *graphics) | |
| 61 | 61 | { | |
| 62 | if (config.getValue("guialpha", 0.8) != mAlpha) | ||
| 62 | if (config.getFloatValue("guialpha") != mAlpha) | ||
| 63 | 63 | { | |
| 64 | mAlpha = config.getValue("guialpha", 0.8); | ||
| 64 | mAlpha = config.getFloatValue("guialpha"); | ||
| 65 | 65 | gripImage->setAlpha(mAlpha); | |
| 66 | 66 | } | |
| 67 | 67 |
|   | |||
| 108 | 108 | bggridx[x], bggridy[y], | |
| 109 | 109 | bggridx[x + 1] - bggridx[x] + 1, | |
| 110 | 110 | bggridy[y + 1] - bggridy[y] + 1); | |
| 111 | background.grid[a]->setAlpha(config.getValue("guialpha", 0.8)); | ||
| 111 | background.grid[a]->setAlpha(config.getFloatValue("guialpha")); | ||
| 112 | 112 | a++; | |
| 113 | 113 | } | |
| 114 | 114 | } | |
| … | … | ||
| 135 | 135 | vsgridx[x], vsgridy[y], | |
| 136 | 136 | vsgridx[x + 1] - vsgridx[x], | |
| 137 | 137 | 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")); | ||
| 140 | 140 | a++; | |
| 141 | 141 | } | |
| 142 | 142 | } | |
| … | … | ||
| 213 | 213 | ||
| 214 | 214 | void ScrollArea::updateAlpha() | |
| 215 | 215 | { | |
| 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()); | ||
| 218 | 218 | ||
| 219 | 219 | if (alpha != mAlpha) | |
| 220 | 220 | { |
|   | |||
| 71 | 71 | if (!mListModel) | |
| 72 | 72 | return; | |
| 73 | 73 | ||
| 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"); | ||
| 76 | 76 | ||
| 77 | 77 | int alpha = (int)(mAlpha * 255.0f); | |
| 78 | 78 | const gcn::Color* highlightColor = |
src/gui/widgets/slider.cpp
(2 / 2)
|   | |||
| 126 | 126 | ||
| 127 | 127 | void Slider::updateAlpha() | |
| 128 | 128 | { | |
| 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()); | ||
| 131 | 131 | ||
| 132 | 132 | if (alpha != mAlpha) | |
| 133 | 133 | { |
src/gui/widgets/tab.cpp
(2 / 2)
|   | |||
| 118 | 118 | ||
| 119 | 119 | void Tab::updateAlpha() | |
| 120 | 120 | { | |
| 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()); | ||
| 123 | 123 | ||
| 124 | 124 | // TODO We don't need to do this for every tab on every draw | |
| 125 | 125 | // Maybe use a config listener to do it as the value changes. |
src/gui/widgets/table.cpp
(2 / 2)
|   | |||
| 270 | 270 | if (!mModel) | |
| 271 | 271 | return; | |
| 272 | 272 | ||
| 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"); | ||
| 275 | 275 | ||
| 276 | 276 | if (mOpaque) | |
| 277 | 277 | { |
|   | |||
| 65 | 65 | gridx[x], gridy[y], | |
| 66 | 66 | gridx[x + 1] - gridx[x] + 1, | |
| 67 | 67 | gridy[y + 1] - gridy[y] + 1); | |
| 68 | skin.grid[a]->setAlpha(config.getValue("guialpha", 0.8)); | ||
| 68 | skin.grid[a]->setAlpha(config.getFloatValue("guialpha")); | ||
| 69 | 69 | a++; | |
| 70 | 70 | } | |
| 71 | 71 | } | |
| … | … | ||
| 86 | 86 | ||
| 87 | 87 | void TextField::updateAlpha() | |
| 88 | 88 | { | |
| 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()); | ||
| 91 | 91 | ||
| 92 | 92 | if (alpha != mAlpha) | |
| 93 | 93 | { |
|   | |||
| 45 | 45 | ||
| 46 | 46 | void TextPreview::draw(gcn::Graphics* graphics) | |
| 47 | 47 | { | |
| 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"); | ||
| 50 | 50 | ||
| 51 | 51 | int alpha = (int) (mAlpha * 255.0f); | |
| 52 | 52 |
src/gui/widgets/window.cpp
(2 / 2)
|   | |||
| 697 | 697 | ||
| 698 | 698 | int Window::getGuiAlpha() | |
| 699 | 699 | { | |
| 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()); | ||
| 702 | 702 | return (int) (alpha * 255.0f); | |
| 703 | 703 | } | |
| 704 | 704 |
src/item.cpp
(1 / 1)
|   | |||
| 59 | 59 | ||
| 60 | 60 | ResourceManager *resman = ResourceManager::getInstance(); | |
| 61 | 61 | SpriteDisplay display = getInfo().getDisplay(); | |
| 62 | std::string imagePath = paths.getValue("itemIcons", "graphics/items/") | ||
| 62 | std::string imagePath = paths.getStringValue("itemIcons") | ||
| 63 | 63 | + display.image; | |
| 64 | 64 | mImage = resman->getImage(imagePath); | |
| 65 | 65 | mDrawImage = resman->getImage(imagePath); |
src/joystick.cpp
(5 / 5)
|   | |||
| 61 | 61 | logger->log("Hats: %i", SDL_JoystickNumHats(mJoystick)); | |
| 62 | 62 | logger->log("Buttons: %i", SDL_JoystickNumButtons(mJoystick)); | |
| 63 | 63 | ||
| 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"); | ||
| 69 | 69 | } | |
| 70 | 70 | ||
| 71 | 71 | Joystick::~Joystick() |
src/map.cpp
(3 / 3)
|   | |||
| 356 | 356 | ||
| 357 | 357 | // Draw backgrounds | |
| 358 | 358 | drawAmbientLayers(graphics, BACKGROUND_LAYERS, scrollX, scrollY, | |
| 359 | (int) config.getValue("OverlayDetail", 2)); | ||
| 359 | config.getIntValue("OverlayDetail")); | ||
| 360 | 360 | ||
| 361 | 361 | // draw the game world | |
| 362 | 362 | Layers::const_iterator layeri = mLayers.begin(); | |
| … | … | ||
| 409 | 409 | } | |
| 410 | 410 | ||
| 411 | 411 | drawAmbientLayers(graphics, FOREGROUND_LAYERS, scrollX, scrollY, | |
| 412 | (int) config.getValue("OverlayDetail", 2)); | ||
| 412 | config.getIntValue("OverlayDetail")); | ||
| 413 | 413 | } | |
| 414 | 414 | ||
| 415 | 415 | void Map::drawCollision(Graphics *graphics, int scrollX, int scrollY, | |
| … | … | ||
| 956 | 956 | { | |
| 957 | 957 | Particle *p; | |
| 958 | 958 | ||
| 959 | if (config.getValue("particleeffects", 1)) | ||
| 959 | if (config.getBoolValue("particleeffects")) | ||
| 960 | 960 | { | |
| 961 | 961 | for (std::list<ParticleEffectData>::iterator i = particleEffects.begin(); | |
| 962 | 962 | i != particleEffects.end(); |
src/net/download.cpp
(2 / 2)
|   | |||
| 221 | 221 | } | |
| 222 | 222 | ||
| 223 | 223 | 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()); | ||
| 226 | 226 | curl_easy_setopt(d->mCurl, CURLOPT_ERRORBUFFER, d->mError); | |
| 227 | 227 | curl_easy_setopt(d->mCurl, CURLOPT_URL, d->mUrl.c_str()); | |
| 228 | 228 | curl_easy_setopt(d->mCurl, CURLOPT_NOPROGRESS, 0); |
|   | |||
| 144 | 144 | PlayerInfo::setAttribute(CHAR_POINTS, msg.readInt16()); | |
| 145 | 145 | PlayerInfo::setAttribute(CORR_POINTS, msg.readInt16()); | |
| 146 | 146 | 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") | ||
| 149 | 149 | ,0, 0); | |
| 150 | 150 | player_node->controlParticle(effect); | |
| 151 | 151 | } break; |
|   | |||
| 76 | 76 | ||
| 77 | 77 | GeneralHandler::GeneralHandler(): | |
| 78 | 78 | mAdminHandler(new AdminHandler), | |
| 79 | mBeingHandler(new BeingHandler(config.getValue("EnableSync", 0) == 1)), | ||
| 79 | mBeingHandler(new BeingHandler(config.getBoolValue("EnableSync"))), | ||
| 80 | 80 | mBuySellHandler(new BuySellHandler), | |
| 81 | 81 | mCharHandler(new CharServerHandler), | |
| 82 | 82 | mChatHandler(new ChatHandler), |
src/particle.cpp
(4 / 4)
|   | |||
| 86 | 86 | ||
| 87 | 87 | void Particle::setupEngine() | |
| 88 | 88 | { | |
| 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"); | ||
| 93 | 93 | disableAutoDelete(); | |
| 94 | 94 | logger->log("Particle engine set up"); | |
| 95 | 95 | } |
src/resources/emotedb.cpp
(2 / 3)
|   | |||
| 43 | 43 | ||
| 44 | 44 | EmoteSprite *unknownSprite = new EmoteSprite; | |
| 45 | 45 | unknownSprite->sprite = AnimatedSprite::load( | |
| 46 | paths.getValue("spriteErrorFile", "error.xml") ); | ||
| 46 | paths.getStringValue("spriteErrorFile")); | ||
| 47 | 47 | unknownSprite->name = "unknown"; | |
| 48 | 48 | mUnknown.sprites.push_back(unknownSprite); | |
| 49 | 49 | ||
| … | … | ||
| 78 | 78 | if (xmlStrEqual(spriteNode->name, BAD_CAST "sprite")) | |
| 79 | 79 | { | |
| 80 | 80 | EmoteSprite *currentSprite = new EmoteSprite; | |
| 81 | std::string file = paths.getValue("sprites", | ||
| 82 | "graphics/sprites/") | ||
| 81 | std::string file = paths.getStringValue("sprites") | ||
| 83 | 82 | + (std::string) (const char*) | |
| 84 | 83 | spriteNode->xmlChildrenNode->content; | |
| 85 | 84 | currentSprite->sprite = AnimatedSprite::load(file, |
src/resources/itemdb.cpp
(1 / 1)
|   | |||
| 117 | 117 | mUnknown = new ItemInfo; | |
| 118 | 118 | mUnknown->setName(_("Unknown item")); | |
| 119 | 119 | mUnknown->setDisplay(SpriteDisplay()); | |
| 120 | std::string errFile = paths.getValue("spriteErrorFile", "error.xml"); | ||
| 120 | std::string errFile = paths.getStringValue("spriteErrorFile"); | ||
| 121 | 121 | mUnknown->setSprite(errFile, GENDER_MALE); | |
| 122 | 122 | mUnknown->setSprite(errFile, GENDER_FEMALE); | |
| 123 | 123 |
src/resources/iteminfo.cpp
(1 / 1)
|   | |||
| 69 | 69 | ||
| 70 | 70 | void ItemInfo::addSound(EquipmentSoundEvent event, const std::string &filename) | |
| 71 | 71 | { | |
| 72 | mSounds[event].push_back(paths.getValue("sfx", "sfx/") + filename); | ||
| 72 | mSounds[event].push_back(paths.getStringValue("sfx") + filename); | ||
| 73 | 73 | } | |
| 74 | 74 | ||
| 75 | 75 | const std::string &ItemInfo::getSound(EquipmentSoundEvent event) const |
src/resources/mapreader.cpp
(3 / 5)
|   | |||
| 323 | 323 | if (config.getValue("showWarps", 1)) | |
| 324 | 324 | { | |
| 325 | 325 | 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); | ||
| 331 | 329 | } | |
| 332 | 330 | } | |
| 333 | 331 | else |
src/resources/spritedef.cpp
(4 / 7)
|   | |||
| 37 | 37 | #include <set> | |
| 38 | 38 | ||
| 39 | 39 | SpriteReference *SpriteReference::Empty = new SpriteReference( | |
| 40 | paths.getValue("spriteErrorFile", "error.xml"), | ||
| 41 | 0); | ||
| 40 | paths.getStringValue("spriteErrorFile"), 0); | ||
| 42 | 41 | ||
| 43 | 42 | Action *SpriteDef::getAction(SpriteAction action) const | |
| 44 | 43 | { | |
| … | … | ||
| 66 | 66 | { | |
| 67 | 67 | logger->log("Error, failed to parse %s", animationFile.c_str()); | |
| 68 | 68 | ||
| 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"); | ||
| 72 | 71 | if (animationFile != errorFile) | |
| 73 | 72 | { | |
| 74 | 73 | return load(errorFile, 0); | |
| … | … | ||
| 285 | 285 | if (filename.empty()) | |
| 286 | 286 | return; | |
| 287 | 287 | ||
| 288 | XML::Document doc(paths.getValue("sprites", "graphics/sprites/") | ||
| 289 | + filename); | ||
| 288 | XML::Document doc(paths.getStringValue("sprites") + filename); | ||
| 290 | 289 | xmlNodePtr rootNode = doc.rootNode(); | |
| 291 | 290 | ||
| 292 | 291 | if (!rootNode || !xmlStrEqual(rootNode->name, BAD_CAST "sprite")) |
src/resources/wallpaper.cpp
(6 / 12)
|   | |||
| 53 | 53 | ResourceManager *resman = ResourceManager::getInstance(); | |
| 54 | 54 | ||
| 55 | 55 | // Init the path | |
| 56 | wallpaperPath = branding.getValue("wallpapersPath", ""); | ||
| 56 | wallpaperPath = branding.getStringValue("wallpapersPath"); | ||
| 57 | 57 | ||
| 58 | 58 | if (!wallpaperPath.empty() && resman->isDirectory(wallpaperPath)) | |
| 59 | 59 | return; | |
| 60 | 60 | else | |
| 61 | wallpaperPath = paths.getValue("wallpapers", ""); | ||
| 61 | wallpaperPath = paths.getValue("wallpapers", "graphics/images/"); | ||
| 62 | 62 | ||
| 63 | if (wallpaperPath.empty() || !resman->isDirectory(wallpaperPath)) | ||
| 64 | wallpaperPath = "graphics/images/"; | ||
| 65 | |||
| 66 | 63 | // Init the default file | |
| 67 | wallpaperFile = branding.getValue("wallpaperFile", ""); | ||
| 64 | wallpaperFile = branding.getStringValue("wallpaperFile"); | ||
| 68 | 65 | ||
| 69 | if (!wallpaperFile.empty() && resman->isDirectory(wallpaperFile)) | ||
| 66 | if (!wallpaperFile.empty()) | ||
| 70 | 67 | return; | |
| 71 | 68 | 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"); | ||
| 76 | 70 | } | |
| 77 | 71 | ||
| 78 | 72 | bool wallpaperCompare(WallpaperData a, WallpaperData b) | |
| … | … | ||
| 76 | 76 | ||
| 77 | 77 | return (aa > ab || (aa == ab && a.width > b.width)); | |
| 78 | 78 | } | |
| 79 | |||
| 79 | #include <iostream> | ||
| 80 | 80 | void Wallpaper::loadWallpapers() | |
| 81 | 81 | { | |
| 82 | 82 | wallpaperData.clear(); |
src/sound.cpp
(3 / 3)
|   | |||
| 142 | 142 | static Mix_Music *loadMusic(const std::string &filename) | |
| 143 | 143 | { | |
| 144 | 144 | ResourceManager *resman = ResourceManager::getInstance(); | |
| 145 | std::string path = resman->getPath("music/" + filename); | ||
| 145 | std::string path = resman->getPath(paths.getStringValue("music") + filename); | ||
| 146 | 146 | ||
| 147 | 147 | if (path.find(".zip/") != std::string::npos || | |
| 148 | 148 | path.find(".zip\\") != std::string::npos) | |
| … | … | ||
| 152 | 152 | logger->log("Loading music \"%s\" from temporary file tempMusic.ogg", | |
| 153 | 153 | path.c_str()); | |
| 154 | 154 | bool success = resman->copyFile( | |
| 155 | paths.getValue("music", "music/") | ||
| 155 | paths.getStringValue("music") | ||
| 156 | 156 | + filename, "tempMusic.ogg"); | |
| 157 | 157 | if (success) | |
| 158 | 158 | path = resman->getPath("tempMusic.ogg"); | |
| … | … | ||
| 240 | 240 | ||
| 241 | 241 | ResourceManager *resman = ResourceManager::getInstance(); | |
| 242 | 242 | SoundEffect *sample = resman->getSoundEffect( | |
| 243 | paths.getValue("sfx", "sfx/") + path); | ||
| 243 | paths.getStringValue("sfx") + path); | ||
| 244 | 244 | if (sample) | |
| 245 | 245 | { | |
| 246 | 246 | logger->log("Sound::playSfx() Playing: %s", path.c_str()); |
src/statuseffect.cpp
(1 / 1)
|   | |||
| 70 | 70 | else | |
| 71 | 71 | { | |
| 72 | 72 | AnimatedSprite *sprite = AnimatedSprite::load( | |
| 73 | paths.getValue("sprites", "graphics/sprites/") + mIcon); | ||
| 73 | paths.getStringValue("sprites") + mIcon); | ||
| 74 | 74 | if (false && sprite) | |
| 75 | 75 | { | |
| 76 | 76 | sprite->play(ACTION_DEFAULT); |
src/text.cpp
(2 / 2)
|   | |||
| 56 | 56 | { | |
| 57 | 57 | textManager = new TextManager; | |
| 58 | 58 | Image *sbImage = Theme::getImageFromTheme("bubble.png|W:#" | |
| 59 | + config.getValue("speechBubblecolor", "000000")); | ||
| 59 | + config.getStringValue("speechBubblecolor")); | ||
| 60 | 60 | mBubble.grid[0] = sbImage->getSubImage(0, 0, 5, 5); | |
| 61 | 61 | mBubble.grid[1] = sbImage->getSubImage(5, 0, 5, 5); | |
| 62 | 62 | mBubble.grid[2] = sbImage->getSubImage(10, 0, 5, 5); | |
| … | … | ||
| 67 | 67 | mBubble.grid[7] = sbImage->getSubImage(5, 10, 5, 5); | |
| 68 | 68 | mBubble.grid[8] = sbImage->getSubImage(10, 10, 5, 5); | |
| 69 | 69 | mBubbleArrow = sbImage->getSubImage(0, 15, 15, 10); | |
| 70 | const float bubbleAlpha = config.getValue("speechBubbleAlpha", 1.0); | ||
| 70 | const float bubbleAlpha = config.getFloatValue("speechBubbleAlpha"); | ||
| 71 | 71 | for (int i = 0; i < 9; i++) | |
| 72 | 72 | { | |
| 73 | 73 | mBubble.grid[i]->setAlpha(bubbleAlpha); |
src/utils/stringutils.cpp
(13 / 1)
|   | |||
| 26 | 26 | #include <cstdarg> | |
| 27 | 27 | #include <cstdio> | |
| 28 | 28 | ||
| 29 | const int UTF8_MAX_SIZE = 10; | ||
| 29 | static int UTF8_MAX_SIZE = 10; | ||
| 30 | 30 | ||
| 31 | 31 | std::string &trim(std::string &str) | |
| 32 | 32 | { | |
| … | … | ||
| 174 | 174 | memcpy(buf, text.c_str(), text.size()); | |
| 175 | 175 | memset(buf + text.size(), 0, UTF8_MAX_SIZE); | |
| 176 | 176 | return buf; | |
| 177 | } | ||
| 178 | |||
| 179 | bool 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()); | ||
| 177 | 189 | } |
src/utils/stringutils.h
(8 / 0)
|   | |||
| 125 | 125 | ||
| 126 | 126 | const char* getSafeUtf8String(std::string text); | |
| 127 | 127 | ||
| 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 | */ | ||
| 134 | bool getBoolFromString(const std::string &text); | ||
| 135 | |||
| 128 | 136 | #endif // UTILS_STRINGUTILS_H |
src/variabledata.h
(20 / 5)
|   | |||
| 29 | 29 | class VariableData | |
| 30 | 30 | { | |
| 31 | 31 | public: | |
| 32 | enum { | ||
| 32 | enum DataType | ||
| 33 | { | ||
| 33 | 34 | DATA_NONE, | |
| 34 | 35 | DATA_INT, | |
| 35 | 36 | DATA_STRING, | |
| 36 | DATA_FLOAT | ||
| 37 | DATA_FLOAT, | ||
| 38 | DATA_BOOL | ||
| 37 | 39 | }; | |
| 38 | 40 | ||
| 39 | 41 | virtual ~VariableData() {}; | |
| … | … | ||
| 72 | 72 | class FloatData : public VariableData | |
| 73 | 73 | { | |
| 74 | 74 | public: | |
| 75 | FloatData(double value) { mData = value; } | ||
| 75 | FloatData(float value) { mData = value; } | ||
| 76 | 76 | ||
| 77 | double getData() const { return mData; } | ||
| 77 | float getData() const { return mData; } | ||
| 78 | 78 | ||
| 79 | 79 | int getType() const { return DATA_FLOAT; } | |
| 80 | 80 | ||
| 81 | 81 | private: | |
| 82 | double mData; | ||
| 82 | float mData; | ||
| 83 | }; | ||
| 84 | |||
| 85 | class BoolData : public VariableData | ||
| 86 | { | ||
| 87 | public: | ||
| 88 | BoolData(bool value) { mData = value; } | ||
| 89 | |||
| 90 | bool getData() const { return mData; } | ||
| 91 | |||
| 92 | int getType() const { return DATA_BOOL; } | ||
| 93 | |||
| 94 | private: | ||
| 95 | bool mData; | ||
| 83 | 96 | }; | |
| 84 | 97 | ||
| 85 | 98 | } // namespace Mana |

