diff options
-rw-r--r-- | backends/sdl/sdl-common.cpp | 9 | ||||
-rw-r--r-- | backends/sdl/sdl-common.h | 1 | ||||
-rw-r--r-- | backends/sdl/sdl.cpp | 5 | ||||
-rw-r--r-- | backends/sdl/sdl_gl.cpp | 5 | ||||
-rw-r--r-- | common/system.h | 3 | ||||
-rw-r--r-- | gui/newgui.cpp | 31 | ||||
-rw-r--r-- | gui/newgui.h | 1 |
7 files changed, 37 insertions, 18 deletions
diff --git a/backends/sdl/sdl-common.cpp b/backends/sdl/sdl-common.cpp index a6b1a785aa..1a453bb697 100644 --- a/backends/sdl/sdl-common.cpp +++ b/backends/sdl/sdl-common.cpp @@ -91,7 +91,7 @@ void OSystem_SDL_Common::set_timer(int timer, int (*callback)(int)) { OSystem_SDL_Common::OSystem_SDL_Common() : _screen(0), _screenWidth(0), _screenHeight(0), _tmpscreen(0), _tmpScreenWidth(0), _overlayVisible(false), - _cdrom(0), _dirty_checksums(0), + _cdrom(0), _modeChanged(false), _dirty_checksums(0), _mouseVisible(false), _mouseDrawn(false), _mouseData(0), _mouseHotspotX(0), _mouseHotspotY(0), _currentShakePos(0), _newShakePos(0), @@ -536,6 +536,13 @@ bool OSystem_SDL_Common::poll_event(Event *event) { byte b = 0; kbd_mouse(); + + // If the screen mode changed, send an EVENT_SCREEN_CHANGED + if (_modeChanged) { + _modeChanged = false; + event->event_code = EVENT_SCREEN_CHANGED; + return true; + } while(SDL_PollEvent(&ev)) { switch(ev.type) { diff --git a/backends/sdl/sdl-common.h b/backends/sdl/sdl-common.h index 9b378e8bb1..90586225d3 100644 --- a/backends/sdl/sdl-common.h +++ b/backends/sdl/sdl-common.h @@ -160,6 +160,7 @@ protected: int _mode; bool _full_screen; uint32 _mode_flags; + bool _modeChanged; enum { NUM_DIRTY_RECT = 100, diff --git a/backends/sdl/sdl.cpp b/backends/sdl/sdl.cpp index af2d30ad5a..b888bcf253 100644 --- a/backends/sdl/sdl.cpp +++ b/backends/sdl/sdl.cpp @@ -204,8 +204,11 @@ void OSystem_SDL::hotswap_gfx_mode() { free(old_tmpscreen->pixels); SDL_FreeSurface(old_tmpscreen); - // Finally, blit everything to the screen + // Blit everything to the screen update_screen(); + + // Make sure that an EVENT_SCREEN_CHANGED gets sent later + _modeChanged = true; } void OSystem_SDL::update_screen() { diff --git a/backends/sdl/sdl_gl.cpp b/backends/sdl/sdl_gl.cpp index 15e45c875c..5df8440713 100644 --- a/backends/sdl/sdl_gl.cpp +++ b/backends/sdl/sdl_gl.cpp @@ -343,8 +343,11 @@ void OSystem_SDL_OpenGL::hotswap_gfx_mode() { free(old_tmpscreen->pixels); SDL_FreeSurface(old_tmpscreen); - // Finally, blit everything to the screen + // Blit everything to the screen update_screen(); + + // Make sure that an EVENT_SCREEN_CHANGED gets sent later + _modeChanged = true; } void OSystem_SDL_OpenGL::update_screen() { diff --git a/common/system.h b/common/system.h index 51fca24f66..623d5a7e40 100644 --- a/common/system.h +++ b/common/system.h @@ -59,7 +59,8 @@ public: EVENT_WHEELUP = 8, EVENT_WHEELDOWN = 9, - EVENT_QUIT = 10 + EVENT_QUIT = 10, + EVENT_SCREEN_CHANGED = 11 }; enum { diff --git a/gui/newgui.cpp b/gui/newgui.cpp index 886e118263..ef75e9a575 100644 --- a/gui/newgui.cpp +++ b/gui/newgui.cpp @@ -91,6 +91,15 @@ NewGui::NewGui(OSystem *system) : _system(system), _screen(0), _needRedraw(false _currentKeyDown.keycode = 0; } +void NewGui::updateColors() { + // Setup some default GUI colors. + _bgcolor = _system->RGBToColor(0, 0, 0); + _color = _system->RGBToColor(96, 96, 96); + _shadowcolor = _system->RGBToColor(64, 64, 64); + _textcolor = _system->RGBToColor(32, 160, 32); + _textcolorhi = _system->RGBToColor(0, 255, 0); +} + void NewGui::runLoop() { Dialog *activeDialog = _dialogStack.top(); bool didSaveState = false; @@ -98,20 +107,11 @@ void NewGui::runLoop() { if (activeDialog == 0) return; - // Setup some default GUI colors. This has to be done here to ensure the - // overlay has been created already. Even then, one can get wrong colors, namely - // if the GUI is up and then the user toggles to full screen mode - on some system - // different color modes (555 vs 565) might be used depending on the resolution - // (e.g. that's the case on my system), so we still end up with wrong colors in those - // sitauations. At least now the user can fix it by closing and reopening the GUI. - - // TODO: Let's add a new even type which is sent whenever the backend GFX device - // changes (e.g. resized, full screen toggle, etc.). - _bgcolor = _system->RGBToColor(0, 0, 0); - _color = _system->RGBToColor(96, 96, 96); - _shadowcolor = _system->RGBToColor(64, 64, 64); - _textcolor = _system->RGBToColor(32, 160, 32); - _textcolorhi = _system->RGBToColor(0, 255, 0); + // Setup some default GUI colors. Normally this will be done whenever an + // EVENT_SCREEN_CHANGED is received. However, not all backends support + // that even at this time, so we also do it "manually" whenever a run loop + // is entered. + updateColors(); if (!_stateIsSaved) { saveState(); @@ -197,6 +197,9 @@ void NewGui::runLoop() { break; case OSystem::EVENT_QUIT: _system->quit(); + return; + case OSystem::EVENT_SCREEN_CHANGED: + updateColors(); break; } } diff --git a/gui/newgui.h b/gui/newgui.h index b7969a3900..69c5af4075 100644 --- a/gui/newgui.h +++ b/gui/newgui.h @@ -113,6 +113,7 @@ protected: void loop(); void animateCursor(); + void updateColors(); public: // Theme colors |