diff options
-rw-r--r-- | engines/xeen/dialogs.cpp | 105 | ||||
-rw-r--r-- | engines/xeen/dialogs.h | 2 | ||||
-rw-r--r-- | engines/xeen/dialogs_options.cpp | 108 | ||||
-rw-r--r-- | engines/xeen/dialogs_options.h | 2 | ||||
-rw-r--r-- | engines/xeen/screen.cpp | 17 | ||||
-rw-r--r-- | engines/xeen/screen.h | 2 |
6 files changed, 117 insertions, 119 deletions
diff --git a/engines/xeen/dialogs.cpp b/engines/xeen/dialogs.cpp index b550cf2f01..cdc6d5ba40 100644 --- a/engines/xeen/dialogs.cpp +++ b/engines/xeen/dialogs.cpp @@ -73,6 +73,111 @@ void Dialog::checkEvents() { } } + +/** +* Draws the scroll in the background +*/ +void Dialog::doScroll(bool drawFlag, bool doFade) { + Screen &screen = *_vm->_screen; + EventsManager &events = *_vm->_events; + + if (_vm->getGameID() != GType_Clouds) { + if (doFade) { + _vm->_screen->fadeIn(2); + } + return; + } + + const int SCROLL_L[8] = { 29, 23, 15, 251, 245, 233, 207, 185 }; + const int SCROLL_R[8] = { 165, 171, 198, 218, 228, 245, 264, 281 }; + + saveButtons(); + clearButtons(); + screen.saveBackground(); + + // Load hand vga files + SpriteResource *hand[16]; + for (int i = 0; i < 16; ++i) { + Common::String name = Common::String::format("hand%02u.vga", i); + hand[i] = new SpriteResource(name); + } + + // Load marb vga files + SpriteResource *marb[5]; + for (int i = 1; i < 5; ++i) { + Common::String name = Common::String::format("marb%02u.vga"); + marb[i] = new SpriteResource(name); + } + + if (drawFlag) { + for (int i = 22; i > 0; --i) { + events.updateGameCounter(); + screen.restoreBackground(); + + if (i > 0 && i <= 14) { + hand[i - 1]->draw(screen, 0); + } + else { + // TODO: Check '800h'.. horizontal reverse maybe? + hand[14]->draw(screen, 0, Common::Point(SCROLL_L[i - 14], 0)); + marb[15]->draw(screen, 0, Common::Point(SCROLL_R[i - 14], 0)); + } + + if (i <= 20) { + marb[i / 5]->draw(screen, i % 5); + } + + while (!_vm->shouldQuit() && _vm->_events->timeElapsed() == 0) + _vm->_events->pollEventsAndWait(); + + screen._windows[0].update(); + if (i == 0 && doFade) + screen.fadeIn(2); + } + } else { + for (int i = 0; i < 22 && !events.isKeyMousePressed(); ++i) { + events.updateGameCounter(); + screen.restoreBackground(); + + if (i < 14) { + hand[i]->draw(screen, 0); + } else { + // TODO: Check '800h'.. horizontal reverse maybe? + hand[14]->draw(screen, 0, Common::Point(SCROLL_L[i - 7], 0)); + marb[15]->draw(screen, 0, Common::Point(SCROLL_R[i - 7], 0)); + } + + if (i < 20) { + marb[i / 5]->draw(screen, i % 5); + } + + while (!_vm->shouldQuit() && _vm->_events->timeElapsed() == 0) + _vm->_events->pollEventsAndWait(); + + screen._windows[0].update(); + if (i == 0 && doFade) + screen.fadeIn(2); + } + } + + if (drawFlag) { + hand[0]->draw(screen, 0); + marb[0]->draw(screen, 0); + } + else { + screen.restoreBackground(); + } + + screen._windows[0].update(); + restoreButtons(); + + // Free resources + for (int i = 1; i < 5; ++i) + delete marb[i]; + for (int i = 0; i < 16; ++i) + delete hand[i]; +} + /*------------------------------------------------------------------------*/ void SettingsBaseDialog::showContents(SpriteResource &title1, bool waitFlag) { diff --git a/engines/xeen/dialogs.h b/engines/xeen/dialogs.h index 9810380081..1f8f2fb624 100644 --- a/engines/xeen/dialogs.h +++ b/engines/xeen/dialogs.h @@ -51,7 +51,7 @@ protected: Common::Array<DialogButton> _buttons; char _key; - virtual void doScroll(bool drawFlag, bool doFade); + void doScroll(bool drawFlag, bool doFade); void checkEvents(); public: diff --git a/engines/xeen/dialogs_options.cpp b/engines/xeen/dialogs_options.cpp index e7f296c9a4..a92fd59715 100644 --- a/engines/xeen/dialogs_options.cpp +++ b/engines/xeen/dialogs_options.cpp @@ -88,13 +88,13 @@ void OptionsMenu::execute() { // Handle keypress char key = toupper(_key); + _key = '\0'; + if (key == 'C' || key == 'V') { // Show credits CreditsScreen::show(_vm); break; } - - _key = '\0'; } } } @@ -172,101 +172,6 @@ void CloudsOptionsMenu::startup(Common::String &title1, Common::String &title2) title2 = "title1a.int"; } -/** -* Draws the scroll in the background -*/ -void Dialog::doScroll(bool drawFlag, bool doFade) { - Screen &screen = *_vm->_screen; - EventsManager &events = *_vm->_events; - const int SCROLL_L[8] = { 29, 23, 15, 251, 245, 233, 207, 185 }; - const int SCROLL_R[8] = { 165, 171, 198, 218, 228, 245, 264, 281 }; - - saveButtons(); - clearButtons(); - screen.saveBackground(); - - // Load hand vga files - SpriteResource *hand[16]; - for (int i = 0; i < 16; ++i) { - Common::String name = Common::String::format("hand%02u.vga", i); - hand[i] = new SpriteResource(name); - } - - // Load marb vga files - SpriteResource *marb[5]; - for (int i = 1; i < 5; ++i) { - Common::String name = Common::String::format("marb%02u.vga"); - marb[i] = new SpriteResource(name); - } - - if (drawFlag) { - for (int i = 22; i > 0; --i) { - events.updateGameCounter(); - screen.restoreBackground(); - - if (i > 0 && i <= 14) { - hand[i - 1]->draw(screen, 0); - } else { - // TODO: Check '800h'.. horizontal reverse maybe? - hand[14]->draw(screen, 0, Common::Point(SCROLL_L[i - 14], 0)); - marb[15]->draw(screen, 0, Common::Point(SCROLL_R[i - 14], 0)); - } - - if (i <= 20) { - marb[i / 5]->draw(screen, i % 5); - } - - while (!_vm->shouldQuit() && _vm->_events->timeElapsed() == 0) - _vm->_events->pollEventsAndWait(); - - screen._windows[0].update(); - if (i == 0 && doFade) - screen.fadeIn(2); - } - } else { - for (int i = 0; i < 22 && !events.isKeyMousePressed(); ++i) { - events.updateGameCounter(); - screen.restoreBackground(); - - if (i < 14) { - hand[i]->draw(screen, 0); - } - else { - // TODO: Check '800h'.. horizontal reverse maybe? - hand[14]->draw(screen, 0, Common::Point(SCROLL_L[i - 7], 0)); - marb[15]->draw(screen, 0, Common::Point(SCROLL_R[i - 7], 0)); - } - - if (i < 20) { - marb[i / 5]->draw(screen, i % 5); - } - - while (!_vm->shouldQuit() && _vm->_events->timeElapsed() == 0) - _vm->_events->pollEventsAndWait(); - - screen._windows[0].update(); - if (i == 0 && doFade) - screen.fadeIn(2); - } - } - - if (drawFlag) { - hand[0]->draw(screen, 0); - marb[0]->draw(screen, 0); - } else { - screen.restoreBackground(); - } - - screen._windows[0].update(); - restoreButtons(); - - // Free resources - for (int i = 1; i < 5; ++i) - delete marb[i]; - for (int i = 0; i < 16; ++i) - delete hand[i]; -} - /*------------------------------------------------------------------------*/ void DarkSideOptionsMenu::startup(Common::String &title1, Common::String &title2) { @@ -274,15 +179,6 @@ void DarkSideOptionsMenu::startup(Common::String &title1, Common::String &title2 title2 = "title2a.int"; } -/** -* Draws the scroll in the background -*/ -void DarkSideOptionsMenu::doScroll(bool drawFlag, bool doFade) { - if (doFade) { - _vm->_screen->fadeIn(2); - } -} - void WorldOptionsMenu::startup(Common::String &title1, Common::String &title2) { title1 = "world.int"; title2 = "start.icn"; diff --git a/engines/xeen/dialogs_options.h b/engines/xeen/dialogs_options.h index 591ab5e043..7a933fdea6 100644 --- a/engines/xeen/dialogs_options.h +++ b/engines/xeen/dialogs_options.h @@ -59,8 +59,6 @@ public: class DarkSideOptionsMenu : public OptionsMenu { protected: virtual void startup(Common::String &title1, Common::String &title2); - - virtual void doScroll(bool drawFlag, bool doFade); public: DarkSideOptionsMenu(XeenEngine *vm) : OptionsMenu(vm) {} }; diff --git a/engines/xeen/screen.cpp b/engines/xeen/screen.cpp index 6d5caae35f..f3cbabcfdd 100644 --- a/engines/xeen/screen.cpp +++ b/engines/xeen/screen.cpp @@ -60,7 +60,7 @@ void Window::open() { } void Window::open2() { - _dirtyRects.push(_bounds); + addDirtyRect(_bounds); frame(); fill(); } @@ -125,7 +125,6 @@ void Window::close() { // Update any remaining pending changes to the screen and free // the window's internal surface storage update(); - free(); // Remove the window from the stack and flag it as now disabled for (uint i = 0; i < _vm->_screen->_windowStack.size(); ++i) { @@ -142,17 +141,18 @@ void Window::close() { } /** - * Pushes any pending changes for the window to the screen + * Update the window */ void Window::update() { - while (!_dirtyRects.empty()) { - Common::Rect r = _dirtyRects.pop(); - blitTo(*_vm->_screen, Common::Point(_bounds.left, _bounds.top)); - } + // Since all window drawing is done on the screen surface anyway, + // there's nothing that needs to be updated here } +/** + * Adds an area that requires redrawing on the next frame update + */ void Window::addDirtyRect(const Common::Rect &r) { - _dirtyRects.push(r); + _vm->_screen->addDirtyRect(r); } /** @@ -319,6 +319,7 @@ void Screen::loadBackground(const Common::String &name) { assert(f.size() == (SCREEN_WIDTH * SCREEN_HEIGHT)); f.read((byte *)getPixels(), SCREEN_WIDTH * SCREEN_HEIGHT); + addDirtyRect(Common::Rect(0, 0, this->w, this->h)); } /** diff --git a/engines/xeen/screen.h b/engines/xeen/screen.h index 41b2821c29..fd8a50968f 100644 --- a/engines/xeen/screen.h +++ b/engines/xeen/screen.h @@ -26,7 +26,6 @@ #include "common/scummsys.h" #include "common/system.h" #include "common/array.h" -#include "common/queue.h" #include "common/rect.h" #include "xeen/font.h" #include "xeen/xsurface.h" @@ -51,7 +50,6 @@ private: int _xLo, _xHi; int _ycL, _ycH; bool _enabled; - Common::Queue<Common::Rect> _dirtyRects; void open2(); public: |