diff options
author | Lloyd Bryant <lloyd_bryant@netzero.net> | 2008-08-19 02:17:09 +0000 |
---|---|---|
committer | Lloyd Bryant <lloyd_bryant@netzero.net> | 2008-08-19 02:17:09 +0000 |
commit | 6be958da64e96f0b0d7ae043182b3f124eadfd4e (patch) | |
tree | 9e915b5b9126167c867d8824c54350b460141282 /src | |
parent | 7ac798f289e58348fdd1c08bd422fb435399f5d4 (diff) | |
download | mana-6be958da64e96f0b0d7ae043182b3f124eadfd4e.tar.gz mana-6be958da64e96f0b0d7ae043182b3f124eadfd4e.tar.bz2 mana-6be958da64e96f0b0d7ae043182b3f124eadfd4e.tar.xz mana-6be958da64e96f0b0d7ae043182b3f124eadfd4e.zip |
Added handling for different resolution wallpapers, reduced CPU usage during login sequence
Diffstat (limited to 'src')
-rw-r--r-- | src/main.cpp | 37 |
1 files changed, 27 insertions, 10 deletions
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 |