summaryrefslogtreecommitdiff
path: root/src/client.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/client.cpp')
-rw-r--r--src/client.cpp50
1 files changed, 23 insertions, 27 deletions
diff --git a/src/client.cpp b/src/client.cpp
index b64f9a89..2ebdb247 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -219,6 +219,7 @@ Client::Client(const Options &options):
if (!options.brandingPath.empty())
{
branding.init(options.brandingPath);
+ branding.setDefaultValues(getBrandingDefaults());
}
initHomeDir();
@@ -232,7 +233,7 @@ Client::Client(const Options &options):
// Configure logger
logger->setLogFile(mLocalDataDir + std::string("/mana.log"));
- logger->setLogToStandardOut(config.getValue("logToStandardOut", 0));
+ logger->setLogToStandardOut(config.getBoolValue("logToStandardOut"));
// Log the mana version
logger->log("Mana %s", FULL_VERSION);
@@ -336,11 +337,11 @@ Client::Client(const Options &options):
graphics = new Graphics;
#endif
- const int width = (int) config.getValue("screenwidth", defaultScreenWidth);
- const int height = (int) config.getValue("screenheight", defaultScreenHeight);
+ const int width = config.getIntValue("screenwidth");
+ const int height = config.getIntValue("screenheight");
const int bpp = 0;
- const bool fullscreen = ((int) config.getValue("screen", 0) == 1);
- const bool hwaccel = ((int) config.getValue("hwaccel", 0) == 1);
+ const bool fullscreen = config.getBoolValue("screen");
+ const bool hwaccel = config.getBoolValue("hwaccel");
// Try to set the desired video mode
if (!graphics->setVideoMode(width, height, bpp, fullscreen, hwaccel))
@@ -363,13 +364,11 @@ Client::Client(const Options &options):
// Initialize sound engine
try
{
- if (config.getValue("sound", 0) == 1)
+ if (config.getBoolValue("sound"))
sound.init();
- sound.setSfxVolume((int) config.getValue("sfxVolume",
- defaultSfxVolume));
- sound.setMusicVolume((int) config.getValue("musicVolume",
- defaultMusicVolume));
+ sound.setSfxVolume(config.getIntValue("sfxVolume"));
+ sound.setMusicVolume(config.getIntValue("musicVolume"));
}
catch (const char *err)
{
@@ -394,28 +393,25 @@ Client::Client(const Options &options):
mCurrentServer.port = options.serverPort;
loginData.username = options.username;
loginData.password = options.password;
- loginData.remember = config.getValue("remember", 0);
+ loginData.remember = config.getBoolValue("remember");
loginData.registerLogin = false;
if (mCurrentServer.hostname.empty())
- {
- mCurrentServer.hostname = branding.getValue("defaultServer",
- "").c_str();
- }
+ mCurrentServer.hostname = branding.getValue("defaultServer","").c_str();
if (mCurrentServer.port == 0)
{
mCurrentServer.port = (short) branding.getValue("defaultPort",
- DEFAULT_PORT);
+ DEFAULT_PORT);
mCurrentServer.type = ServerInfo::parseType(
- branding.getValue("defaultServerType", "tmwathena"));
+ branding.getValue("defaultServerType", "tmwathena"));
}
if (chatLogger)
chatLogger->setServerName(mCurrentServer.hostname);
if (loginData.username.empty() && loginData.remember)
- loginData.username = config.getValue("username", "");
+ loginData.username = config.getStringValue("username");
if (mState != STATE_ERROR)
mState = STATE_CHOOSE_SERVER;
@@ -577,10 +573,8 @@ int Client::exec()
- 3, 3);
top->add(mSetupButton);
- int screenWidth = (int) config.getValue("screenwidth",
- defaultScreenWidth);
- int screenHeight = (int) config.getValue("screenheight",
- defaultScreenHeight);
+ int screenWidth = config.getIntValue("screenwidth");
+ int screenHeight = config.getIntValue("screenheight");
mDesktop->setSize(screenWidth, screenHeight);
}
@@ -749,6 +743,7 @@ int Client::exec()
// Read default paths file 'data/paths.xml'
paths.init("paths.xml", true);
+ paths.setDefaultValues(getPathsDefaults());
// Load XML databases
ColorDB::load();
@@ -788,7 +783,7 @@ int Client::exec()
mOptions.character, CharSelectDialog::Choose))
{
((CharSelectDialog*) mCurrentDialog)->selectByName(
- config.getValue("lastCharacter", ""),
+ config.getStringValue("lastCharacter"),
mOptions.chooseDefault ?
CharSelectDialog::Choose :
CharSelectDialog::Focus);
@@ -1000,7 +995,7 @@ int Client::exec()
void Client::optionChanged(const std::string &name)
{
- const int fpsLimit = (int) config.getValue("fpslimit", 60);
+ const int fpsLimit = config.getIntValue("fpslimit");
mLimitFps = fpsLimit > 0;
if (mLimitFps)
SDL_setFramerate(&mFpsManager, fpsLimit);
@@ -1151,6 +1146,7 @@ void Client::initConfiguration()
{
fclose(configFile);
config.init(configPath);
+ config.setDefaultValues(getConfigDefaults());
}
}
@@ -1165,7 +1161,7 @@ void Client::initUpdatesDir()
// If updatesHost is currently empty, fill it from config file
if (mUpdateHost.empty())
{
- mUpdateHost = config.getValue("updatehost", "");
+ mUpdateHost = config.getStringValue("updatehost");
}
// Don't go out of range int he next check
@@ -1243,7 +1239,7 @@ void Client::initScreenshotDir()
else
{
std::string configScreenshotDir =
- config.getValue("screenshotDirectory", "");
+ config.getStringValue("screenshotDirectory");
if (!configScreenshotDir.empty())
mScreenshotDir = configScreenshotDir;
else
@@ -1258,7 +1254,7 @@ void Client::initScreenshotDir()
}
config.setValue("screenshotDirectory", mScreenshotDir);
- if (config.getValue("useScreenshotDirectorySuffix", true))
+ if (config.getBoolValue("useScreenshotDirectorySuffix"))
{
std::string configScreenshotSuffix =
config.getValue("screenshotDirectorySuffix",