From 483bca3d96b7012774d13875e78cfd8b649657f7 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 17 Aug 2014 20:17:38 -0400 Subject: ACCESS: Fixes for drawing bubble box backgrounds --- engines/access/bubble_box.cpp | 21 +++++++++++++-------- engines/access/events.cpp | 29 +++++++++++++++++++---------- engines/access/events.h | 4 ++-- engines/access/scripts.cpp | 2 +- 4 files changed, 35 insertions(+), 21 deletions(-) (limited to 'engines/access') diff --git a/engines/access/bubble_box.cpp b/engines/access/bubble_box.cpp index f910028fc5..b896e5ef1a 100644 --- a/engines/access/bubble_box.cpp +++ b/engines/access/bubble_box.cpp @@ -94,7 +94,7 @@ void BubbleBox::calcBubble(const Common::String &msg) { bool lastLine; do { lastLine = _vm->_fonts._font2.getLine(s, _maxChars * 6, line, width); - width = MAX(width, _vm->_fonts._printMaxX); + _vm->_fonts._printMaxX = MAX(width, _vm->_fonts._printMaxX); _vm->_fonts._printOrg.y += 6; _vm->_fonts._printOrg.x = _vm->_fonts._printStart.x; @@ -150,10 +150,10 @@ void BubbleBox::printBubble(const Common::String &msg) { int xp = _vm->_fonts._printOrg.x; if (_type == TYPE_4) xp = (_bounds.width() - width) / 2 + _bounds.left - 4; - + // Draw the text font2.drawString(_vm->_screen, line, Common::Point(xp, _vm->_fonts._printOrg.y)); - + // Move print position _vm->_fonts._printOrg.y += 6; _vm->_fonts._printOrg.x = _vm->_fonts._printStart.x; @@ -221,7 +221,7 @@ void BubbleBox::doBox(int item, int box) { screen.plotImage(icons, 21, Common::Point(xp, screen._orgY1)); // Draw images to form the bottom border - yp = screen._orgY2 - (_type == TYPE_4) ? 18 : 12; + yp = screen._orgY2 - (_type == TYPE_4 ? 18 : 12); screen.plotImage(icons, (_type == TYPE_4) ? 72 : 22, Common::Point(screen._orgX1, yp)); xp = screen._orgX1 + 12; @@ -232,16 +232,21 @@ void BubbleBox::doBox(int item, int box) { Common::Point(xp, yp)); } - yp -= (_type == TYPE_4) ? 18 : 12; - screen.plotImage(icons, (_type == TYPE_4) ? 73 : 23, - Common::Point(screen._orgX1, yp)); + yp = screen._orgY2 - (_type == TYPE_4 ? 18 : 12); + screen.plotImage(icons, (_type == TYPE_4) ? 73 : 23, Common::Point(xp, yp)); if (_type == TYPE_4) { // Further stuff - warning("YSIZE not yet used %d", ySize); error("TODO: Box type 4"); } + // Draw images to form the sides + yp = screen._orgY1 + 12; + for (int y = 0; y < ySize; ++y) { + screen.plotImage(icons, 44 + y, Common::Point(screen._orgX1, yp)); + screen.plotImage(icons, 53 + y, Common::Point(screen._orgX2 - 4, yp)); + } + // Handle drawing title int titleWidth = _vm->_fonts._font2.stringWidth(_bubblePtr); Font &font2 = _vm->_fonts._font2; diff --git a/engines/access/events.cpp b/engines/access/events.cpp index 521e8895c8..71ed5f433e 100644 --- a/engines/access/events.cpp +++ b/engines/access/events.cpp @@ -112,9 +112,10 @@ bool EventsManager::isCursorVisible() { return CursorMan.isVisible(); } -void EventsManager::pollEvents(bool suppressFrames) { - if (!suppressFrames) - checkForNextFrameCounter(); +void EventsManager::pollEvents() { + if (checkForNextFrameCounter()) { + nextFrame(); + } Common::Event event; while (g_system->getEventManager()->pollEvent(event)) { @@ -158,24 +159,26 @@ void EventsManager::pollEvents(bool suppressFrames) { } } -void EventsManager::checkForNextFrameCounter() { +bool EventsManager::checkForNextFrameCounter() { // Check for next game frame uint32 milli = g_system->getMillis(); if ((milli - _priorFrameTime) >= GAME_FRAME_TIME) { ++_frameCounter; _priorFrameTime = milli; - nextFrame(); + return true; } + + return false; } void EventsManager::nextFrame() { - // Give time to the debugger - _vm->_debugger->onFrame(); - // Update timers _vm->_animation->updateTimers(); + // Give time to the debugger + _vm->_debugger->onFrame(); + // TODO: Refactor for dirty rects _vm->_screen->updateScreen(); } @@ -199,13 +202,19 @@ bool EventsManager::getKey(Common::KeyState &key) { void EventsManager::debounceLeft() { while (_leftButton && !_vm->shouldQuit()) { - pollEvents(true); + pollEvents(); g_system->delayMillis(10); } } void EventsManager::waitKeyMouse() { - error("TODO: waitKeyPress"); + while (!_vm->shouldQuit() && !_leftButton && _keypresses.size() == 0) { + pollEvents(); + g_system->delayMillis(10); + } + + zeroKeys(); + debounceLeft(); } } // End of namespace Access diff --git a/engines/access/events.h b/engines/access/events.h index dc89829312..c6702ec7af 100644 --- a/engines/access/events.h +++ b/engines/access/events.h @@ -46,7 +46,7 @@ private: uint32 _frameCounter; uint32 _priorFrameTime; - void checkForNextFrameCounter(); + bool checkForNextFrameCounter(); void nextFrame(); public: @@ -95,7 +95,7 @@ public: */ bool isCursorVisible(); - void pollEvents(bool suppressFrames = false); + void pollEvents(); void zeroKeys(); diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index 0d232cc779..2e4e2adca6 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -193,7 +193,7 @@ void Scripts::cmdPrint() { _vm->_events->waitKeyMouse(); // Wait until the bubble display is expired - while (_vm->_timers[PRINT_TIMER]._flag) { + while (!_vm->shouldQuit() && _vm->_timers[PRINT_TIMER]._flag) { _vm->_events->pollEvents(); } -- cgit v1.2.3