From 6be958da64e96f0b0d7ae043182b3f124eadfd4e Mon Sep 17 00:00:00 2001 From: Lloyd Bryant Date: Tue, 19 Aug 2008 02:17:09 +0000 Subject: Added handling for different resolution wallpapers, reduced CPU usage during login sequence --- src/main.cpp | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index 89bc8e6b..7efbca4f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -697,6 +697,27 @@ int main(int argc, char *argv[]) SDLNet_Init(); Network *network = new Network(); + + // Set the most appropriate wallpaper, based on screen width + int screenWidth = (int) config.getValue("screenwidth", defaultScreenWidth); + std::string wallpaperName; + + if (screenWidth <= 800) + wallpaperName = "graphics/images/login_wallpaper.png"; + else if (screenWidth <= 1024) + wallpaperName = "graphics/images/login_wallpaper_1024x768.png"; + else if (screenWidth <= 1280) + wallpaperName = "graphics/images/login_wallpaper_1280x960.png"; + else if (screenWidth <= 1440) + wallpaperName = "graphics/images/login_wallpaper_1440x1080.png"; + else + wallpaperName = "graphics/images/login_wallpaper_1600x1200.png"; + + login_wallpaper = ResourceManager::getInstance()-> getImage(wallpaperName); + + if (!login_wallpaper) + logger->log("Couldn't load %s as wallpaper", wallpaperName.c_str()); + while (state != EXIT_STATE) { // Handle SDL events @@ -732,16 +753,6 @@ int main(int argc, char *argv[]) } } - if (!login_wallpaper) - { - login_wallpaper = ResourceManager::getInstance()-> - getImage("graphics/images/login_wallpaper.png"); - if (!login_wallpaper) - { - logger->error("Couldn't load login_wallpaper.png"); - } - } - if (progressBar->isVisible()) { progressBar->setProgress(progressBar->getProgress() + 0.005f); @@ -933,6 +944,12 @@ int main(int argc, char *argv[]) break; } } + /* + * This loop can really stress the CPU, for no reason since it's + * just constantly redrawing the wallpaper. Added the following + * usleep to limit it to 20 FPS during the login sequence + */ + usleep(50000); } #ifdef PACKAGE_VERSION -- cgit v1.2.3-70-g09d2