added EVENT_SCREEN_CHANGED; small tweak to the way quit is handled in NewGui

svn-id: r10047
This commit is contained in:
Max Horn 2003-09-06 20:21:54 +00:00
parent bbd23e60ce
commit 6ac86b9760
7 changed files with 37 additions and 18 deletions

View File

@ -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) {

View File

@ -160,6 +160,7 @@ protected:
int _mode;
bool _full_screen;
uint32 _mode_flags;
bool _modeChanged;
enum {
NUM_DIRTY_RECT = 100,

View File

@ -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() {

View File

@ -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() {

View File

@ -59,7 +59,8 @@ public:
EVENT_WHEELUP = 8,
EVENT_WHEELDOWN = 9,
EVENT_QUIT = 10
EVENT_QUIT = 10,
EVENT_SCREEN_CHANGED = 11
};
enum {

View File

@ -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;
}
}

View File

@ -113,6 +113,7 @@ protected:
void loop();
void animateCursor();
void updateColors();
public:
// Theme colors