diff options
author | Philipp Sehmisch <tmw@crushnet.org> | 2008-11-11 13:41:26 +0000 |
---|---|---|
committer | Philipp Sehmisch <tmw@crushnet.org> | 2008-11-11 13:41:26 +0000 |
commit | d2bf248c7623324dc6a133b1e5eb0e71235d883a (patch) | |
tree | 37c4afeca8f57a74ab392b728509e6c32405f4dc /src | |
parent | 2e7a4d66bd9ce5077b7a0062aff856d669e05b97 (diff) | |
download | mana-client-d2bf248c7623324dc6a133b1e5eb0e71235d883a.tar.gz mana-client-d2bf248c7623324dc6a133b1e5eb0e71235d883a.tar.bz2 mana-client-d2bf248c7623324dc6a133b1e5eb0e71235d883a.tar.xz mana-client-d2bf248c7623324dc6a133b1e5eb0e71235d883a.zip |
Moved some hardcoded strings and filenames to an external configuration file.
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/serverdialog.cpp | 2 | ||||
-rw-r--r-- | src/main.cpp | 54 | ||||
-rw-r--r-- | src/main.h | 3 |
3 files changed, 36 insertions, 23 deletions
diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp index 00490d31..a6d1d1f0 100644 --- a/src/gui/serverdialog.cpp +++ b/src/gui/serverdialog.cpp @@ -74,7 +74,7 @@ void ServersListModel::addElement(Server server) } ServerDialog::ServerDialog(LoginData *loginData): - Window(_("Choose your Mana World Server")), mLoginData(loginData) + Window(_("Choose your server")), mLoginData(loginData) { gcn::Label *serverLabel = new gcn::Label(_("Server:")); gcn::Label *portLabel = new gcn::Label(_("Port:")); diff --git a/src/main.cpp b/src/main.cpp index 59d21ef7..67eeccd6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -107,6 +107,7 @@ Sound sound; Music *bgm; Configuration config; /**< XML file configuration reader */ +Configuration branding; /**< XML branding information reader */ Logger *logger; /**< Log object */ KeyboardConfig keyboard; @@ -167,14 +168,17 @@ struct Options */ void initHomeDir() { - homeDir = std::string(PHYSFS_getUserDir()) + "/.tmw"; + homeDir = std::string(PHYSFS_getUserDir()) + + "/." + + branding.getValue("appShort", "tmw"); #if defined WIN32 if (!CreateDirectory(homeDir.c_str(), 0) && GetLastError() != ERROR_ALREADY_EXISTS) #elif defined __APPLE__ // Use Application Directory instead of .tmw - homeDir = std::string(PHYSFS_getUserDir()) + - "/Library/Application Support/The Mana World"; + homeDir = std::string(PHYSFS_getUserDir()) + + "/Library/Application Support/" + + branding.getValue("appName", "The Mana World"); if ((mkdir(homeDir.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) != 0) && (errno != EEXIST)) #else @@ -197,8 +201,11 @@ void initConfiguration(const Options &options) { // Fill configuration with defaults logger->log("Initializing configuration..."); - config.setValue("host", "server.themanaworld.org"); - config.setValue("port", 9601); + std::string defaultHost = branding.getValue("defaultServer", + "server.themanaworld.org"); + config.setValue("host", defaultHost); + int defaultPort = (int)branding.getValue("defaultPort", 9601); + config.setValue("port", defaultPort); config.setValue("hwaccel", 0); #if (defined __APPLE__ || defined WIN32) && defined USE_OPENGL config.setValue("opengl", 1); @@ -212,7 +219,9 @@ void initConfiguration(const Options &options) config.setValue("sfxVolume", 100); config.setValue("musicVolume", 60); config.setValue("fpslimit", 0); - config.setValue("updatehost", "http://updates.themanaworld.org"); + std::string defaultUpdateHost = branding.getValue("defaultUpdateHost", + "http://updates.themanaworld.org"); + config.setValue("updatehost", defaultUpdateHost); config.setValue("customcursor", 1); config.setValue("ChatLogLength", 128); @@ -257,7 +266,7 @@ void initEngine(const Options &options) SDL_EnableUNICODE(1); SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); - SDL_WM_SetCaption("The Mana World", NULL); + SDL_WM_SetCaption(branding.getValue("appName", "The Mana World").c_str(), NULL); #ifdef WIN32 static SDL_SysWMinfo pInfo; SDL_GetWMInfo(&pInfo); @@ -267,7 +276,7 @@ void initEngine(const Options &options) SetClassLong(pInfo.window, GCL_HICON, (LONG) icon); } #else - SDL_Surface *icon = IMG_Load(TMW_DATADIR "data/icons/tmw.png"); + SDL_Surface *icon = IMG_Load(TMW_DATADIR branding.getValue("appIcon", "data/icons/tmw.png")); if (icon) { SDL_SetAlpha(icon, SDL_SRCALPHA, SDL_ALPHA_OPAQUE); @@ -741,7 +750,6 @@ void xmlNullLogger(void *ctx, const char *msg, ...) // compiled version and the shared library actually used. void initXML() { - logger->log("Initializing libxml2..."); xmlInitParser(); LIBXML_TEST_VERSION; @@ -783,6 +791,11 @@ int main(int argc, char *argv[]) // Initialize PhysicsFS PHYSFS_init(argv[0]); + initXML(); + + // load branding information + branding.init("data/branding.xml"); + initHomeDir(); // Configure logger logger = new Logger(); @@ -796,8 +809,8 @@ int main(int argc, char *argv[]) logger->log("The Mana World - version not defined"); #endif - initXML(); initConfiguration(options); + initEngine(options); Game *game = NULL; @@ -811,19 +824,19 @@ int main(int argc, char *argv[]) top->add(versionLabel, 25, 2); #endif - sound.playMusic("Magick - Real.ogg"); + sound.playMusic(branding.getValue("loginMusic", "")); // Server choice if (options.serverName.empty()) { loginData.hostname = config.getValue("MostUsedServerName0", - defaultAccountServerName.c_str()); + branding.getValue("defaultServer", "server.themanaworld.org").c_str()); } else { loginData.hostname = options.serverName; } if (options.serverPort == 0) { loginData.port = (short)config.getValue("MostUsedServerPort0", - defaultAccountServerPort); + branding.getValue("defaultPort", 9601)); } else { loginData.port = options.serverPort; } @@ -852,9 +865,9 @@ int main(int argc, char *argv[]) while (state != STATE_FORCE_QUIT) { // Handle SDL events - while (SDL_PollEvent(&event)) + while (SDL_PollEvent(&event)) { - switch (event.type) + switch (event.type) { case SDL_QUIT: state = STATE_FORCE_QUIT; @@ -883,11 +896,13 @@ int main(int argc, char *argv[]) if (!login_wallpaper) { + std::string wallpaperFile = branding.getValue( + "loginWallpaper", "graphics/images/login_wallpaper.png"); login_wallpaper = ResourceManager::getInstance()-> - getImage("graphics/images/login_wallpaper.png"); + getImage(wallpaperFile); if (!login_wallpaper) { - logger->error("Couldn't load login_wallpaper.png"); + logger->error(wallpaperFile); } } @@ -929,8 +944,9 @@ int main(int argc, char *argv[]) //loadUpdates(); // Reload the wallpaper in case that it was updated login_wallpaper->decRef(); - login_wallpaper = ResourceManager::getInstance()-> - getImage("graphics/images/login_wallpaper.png"); + login_wallpaper = ResourceManager::getInstance()->getImage( + branding.getValue("loginWallpaper", + "graphics/images/login_wallpaper.png")); } oldstate = state; @@ -118,9 +118,6 @@ const short defaultScreenHeight = 600; // Sound const short defaultSfxVolume = 100; const short defaultMusicVolume = 60; -// Account Server Name and port -const std::string defaultAccountServerName = "testing.themanaworld.org"; -const short defaultAccountServerPort = 9601; // Defines the number of usable player slots const short maxSlot = 2; |