From 801da408e5756f19ee50bdc463f2fc6390573b65 Mon Sep 17 00:00:00 2001 From: Jared Adams Date: Wed, 8 Apr 2009 20:34:11 -0600 Subject: Add a more flexible wallpaper system --- src/main.cpp | 60 ++++++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 42 insertions(+), 18 deletions(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index de1ce635..27e61f19 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -93,6 +93,7 @@ #include "resources/monsterdb.h" #include "resources/npcdb.h" #include "resources/resourcemanager.h" +#include "resources/wallpaper.h" #include "utils/gettext.h" #include "utils/stringutils.h" @@ -977,25 +978,14 @@ int main(int argc, char *argv[]) Net::getGeneralHandler()->load(); // Set the most appropriate wallpaper, based on screen width + Wallpaper::loadWallpapers(); + int screenWidth = (int) config.getValue("screenwidth", defaultScreenWidth); -#ifdef EATHENA_SUPPORT int screenHeight = static_cast(config.getValue("screenheight", defaultScreenHeight)); -#endif - std::string wallpaperName; - wallpaperName = "graphics/images/login_wallpaper.png"; - if (screenWidth >= 1024 && screenWidth < 1280) - wallpaperName = "graphics/images/login_wallpaper_1024x768.png"; - else if (screenWidth >= 1280 && screenWidth < 1440) - wallpaperName = "graphics/images/login_wallpaper_1280x960.png"; - else if (screenWidth >= 1440 && screenWidth < 1600) - wallpaperName = "graphics/images/login_wallpaper_1440x1080.png"; - else if (screenWidth >= 1600) - wallpaperName = "graphics/images/login_wallpaper_1600x1200.png"; - - if (!ResourceManager::getInstance()->exists(wallpaperName)) - wallpaperName = "graphics/images/login_wallpaper.png"; + std::string wallpaperName = Wallpaper::getWallpaper(screenWidth, + screenHeight); login_wallpaper = ResourceManager::getInstance()->getImage(wallpaperName); @@ -1206,6 +1196,25 @@ int main(int argc, char *argv[]) EmoteDB::load(); Units::loadUnits(); + Wallpaper::loadWallpapers(); + + { + int screenWidth = (int) config.getValue("screenwidth", + defaultScreenWidth); + int screenHeight = (int) config.getValue("screenheight", + defaultScreenHeight); + + Image *temp = ResourceManager::getInstance() + ->getImage(Wallpaper::getWallpaper(screenWidth, + screenHeight)); + + if (temp) + { + login_wallpaper->decRef(); + login_wallpaper = temp; + } + } + state = STATE_LOGIN; break; @@ -1401,9 +1410,24 @@ int main(int argc, char *argv[]) case STATE_UPDATE: loadUpdates(); // Reload the wallpaper in case that it was updated - login_wallpaper->decRef(); - login_wallpaper = ResourceManager::getInstance()-> - getImage(wallpaperName); + Wallpaper::loadWallpapers(); + + { + int screenWidth = (int) config.getValue("screenwidth", + defaultScreenWidth); + int screenHeight = (int) config.getValue("screenheight", + defaultScreenHeight); + + Image *temp = ResourceManager::getInstance() + ->getImage(Wallpaper::getWallpaper(screenWidth, + screenHeight)); + + if (temp) + { + login_wallpaper->decRef(); + login_wallpaper = temp; + } + } break; // Those states don't cause a network disconnect -- cgit v1.2.3-70-g09d2