diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2005-05-20 21:28:20 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2005-05-20 21:28:20 +0000 |
commit | 77436e727119ae4d762d426efcd1d84748f9edea (patch) | |
tree | 534751bd903493faec75946e11bebdd563d00c92 | |
parent | 04da189810d74df40d6f92694bd8e0285c6d07ad (diff) | |
download | mana-client-77436e727119ae4d762d426efcd1d84748f9edea.tar.gz mana-client-77436e727119ae4d762d426efcd1d84748f9edea.tar.bz2 mana-client-77436e727119ae4d762d426efcd1d84748f9edea.tar.xz mana-client-77436e727119ae4d762d426efcd1d84748f9edea.zip |
Stop drawing frames when application isn't active (ie. minimized)
-rw-r--r-- | ChangeLog | 1 | ||||
-rw-r--r-- | src/game.cpp | 18 |
2 files changed, 14 insertions, 5 deletions
@@ -8,6 +8,7 @@ - Dialogs are now modal when appropriate - Fixed a crash in OpenGL mode - Fixed rendering of minimap, progress bars and player sprite in OpenGL mode +- Fixed 100% CPU usage when minimized 0.0.12 (1 May 2005) - Added new map (a cave), tiles, monsters and items diff --git a/src/game.cpp b/src/game.cpp index 6bac6458..717567d1 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -131,14 +131,22 @@ void game() { do_input(); engine->logic(); + gui->logic(); gameTime++; } + gameTime = tick_time; - // Draw next frame - gui->logic(); - engine->draw(); - graphics->updateScreen(); + // Update the screen when application is active, delay otherwise + if (SDL_GetAppState() & SDL_APPACTIVE) + { + engine->draw(); + graphics->updateScreen(); + } + else + { + SDL_Delay(10); + } // Handle network stuff and flush it do_parse(); @@ -296,7 +304,7 @@ void do_input() buddyWindow->setVisible(!buddyWindow->isVisible()); used = true; } - else if (keysym.sym == SDLK_m) { + else if (keysym.sym == SDLK_m) { menu->setVisible(!menu->isVisible()); used = true; } |