diff options
-rw-r--r-- | gui/newgui.cpp | 58 | ||||
-rw-r--r-- | gui/newgui.h | 13 | ||||
-rw-r--r-- | scumm/gfx.cpp | 12 | ||||
-rw-r--r-- | scumm/scummvm.cpp | 13 |
4 files changed, 55 insertions, 41 deletions
diff --git a/gui/newgui.cpp b/gui/newgui.cpp index d110c474c9..e2c3dfb639 100644 --- a/gui/newgui.cpp +++ b/gui/newgui.cpp @@ -70,7 +70,7 @@ static byte guifont[] = { // Constructor NewGui::NewGui(Scumm *s) : _s(s), _system(s->_system), _screen(0), _use_alpha_blending(true), _need_redraw(false), _prepare_for_gui(true), - _currentKeyDown(0) + _currentKeyDown(0), _cursorAnimateCounter(0) { // Setup some default GUI colors. // TODO - either use nicer values, or maybe make this configurable? @@ -79,6 +79,9 @@ NewGui::NewGui(Scumm *s) : _s(s), _system(s->_system), _screen(0), _shadowcolor = RGB_TO_16(64, 64, 64); _textcolor = RGB_TO_16(32, 160, 32); _textcolorhi = RGB_TO_16(0, 255, 0); + + // Clear the cursor + memset(_cursor, 0xFF, sizeof(_cursor)); } void NewGui::loop() @@ -111,7 +114,7 @@ void NewGui::loop() _need_redraw = false; } - _s->animateCursor(); + animateCursor(); if (_eventList.size() > 0) { @@ -188,19 +191,12 @@ void NewGui::loop() void NewGui::saveState() { + // Pause sound put _old_soundsPaused = _s->_sound->_soundsPaused; _s->_sound->pauseSounds(true); // Backup old cursor - memcpy(_old_grabbedCursor, _s->_grabbedCursor, sizeof(_old_grabbedCursor)); - _old_cursorWidth = _s->_cursorWidth; - _old_cursorHeight = _s->_cursorHeight; - _old_cursorHotspotX = _s->_cursorHotspotX; - _old_cursorHotspotY = _s->_cursorHotspotY; - _old_cursor_mode = _system->show_mouse(true); - - _s->_cursorAnimate++; - _s->gdi._cursorActive = 1; + _oldCursorMode = _system->show_mouse(true); // TODO - add getHeight & getWidth methods to OSystem _system->show_overlay(); @@ -211,18 +207,11 @@ void NewGui::saveState() void NewGui::restoreState() { - _s->_cursorAnimate--; - // Restore old cursor - memcpy(_s->_grabbedCursor, _old_grabbedCursor, sizeof(_old_grabbedCursor)); - _s->_cursorWidth = _old_cursorWidth; - _s->_cursorHeight = _old_cursorHeight; - _s->_cursorHotspotX = _old_cursorHotspotX; - _s->_cursorHotspotY = _old_cursorHotspotY; _s->updateCursor(); + _system->show_mouse(_oldCursorMode); - _system->show_mouse(_old_cursor_mode); - + // Resume sound output _s->_sound->pauseSounds(_old_soundsPaused); _system->hide_overlay(); @@ -439,9 +428,9 @@ void NewGui::drawString(const char *str, int x, int y, int w, int16 color, int a } } -/* - * Draw an 8x8 bitmap at location (x,y) - */ +// +// Draw an 8x8 bitmap at location (x,y) +// void NewGui::drawBitmap(uint32 bitmap[8], int x, int y, int16 color) { int16 *ptr = getBasePtr(x, y); @@ -458,3 +447,26 @@ void NewGui::drawBitmap(uint32 bitmap[8], int x, int y, int16 color) ptr += _screen_pitch; } } + +// +// Draw the mouse cursor (animated). This is mostly ripped from the cursor code in gfx.cpp +// We could plug in a different cursor here if we like to. +// +void NewGui::animateCursor() +{ + if (0 == (_cursorAnimateCounter & 0x3)) { + const byte colors[4] = { 15, 15, 7, 8 }; + const byte color = colors[(_cursorAnimateCounter >> 2) & 3]; + int i; + + for (i = 0; i < 16; i++) { + if ((i < 7) || (i > 9)) { + _cursor[16 * 8 + i] = color; + _cursor[16 * i + 8] = color; + } + } + + _system->set_mouse_cursor(_cursor, 16, 16, 8, 8); + } + _cursorAnimateCounter++; +} diff --git a/gui/newgui.h b/gui/newgui.h index 583a7d6c1c..1f38558097 100644 --- a/gui/newgui.h +++ b/gui/newgui.h @@ -94,11 +94,6 @@ protected: // sound state bool _old_soundsPaused; - - // mouse cursor state - bool _old_cursor_mode; - int _old_cursorHotspotX, _old_cursorHotspotY, _old_cursorWidth, _old_cursorHeight; - byte _old_grabbedCursor[2048]; // position and time of last mouse click (used to detect double clicks) struct { @@ -109,12 +104,20 @@ protected: // List of events to be handled EventList _eventList; + + + // mouse cursor state + bool _oldCursorMode; + int _cursorAnimateCounter; + byte _cursor[2048]; void saveState(); void restoreState(); void openDialog(Dialog *dialog); void closeTopDialog(); + + void animateCursor(); public: // Drawing diff --git a/scumm/gfx.cpp b/scumm/gfx.cpp index 6493d694aa..6939f9cac6 100644 --- a/scumm/gfx.cpp +++ b/scumm/gfx.cpp @@ -3001,6 +3001,18 @@ void Scumm::decompressDefaultCursor(int idx) updateCursor(); } +void Scumm::makeCursorColorTransparent(int a) +{ + int i, size; + + size = _cursorWidth * _cursorHeight; + + for (i = 0; i < size; i++) + if (_grabbedCursor[i] == (byte)a) + _grabbedCursor[i] = 0xFF; + + updateCursor(); +} int Scumm::remapPaletteColor(int r, int g, int b, uint threshold) { diff --git a/scumm/scummvm.cpp b/scumm/scummvm.cpp index 28490fb82c..19287b6164 100644 --- a/scumm/scummvm.cpp +++ b/scumm/scummvm.cpp @@ -1116,19 +1116,6 @@ Actor *Scumm::derefActorSafe(int id, const char *errmsg) return derefActor(id); } -void Scumm::makeCursorColorTransparent(int a) -{ - int i, size; - - size = _cursorWidth * _cursorHeight; - - for (i = 0; i < size; i++) - if (_grabbedCursor[i] == (byte)a) - _grabbedCursor[i] = 0xFF; - - updateCursor(); -} - void Scumm::setStringVars(int slot) { StringTab *st = &string[slot]; |