From d09b482bcb976ab36a5a4aa670b7258b1e12a65c Mon Sep 17 00:00:00 2001 From: uruk Date: Thu, 6 Mar 2014 23:01:53 +0100 Subject: AVALANCHE: Implement MainMenu::wait(). Rework other pieces of the engine to fit to it's mechanism. --- engines/avalanche/avalot.cpp | 8 +++++--- engines/avalanche/graphics.cpp | 12 +++++++++++- engines/avalanche/graphics.h | 4 +++- engines/avalanche/mainmenu.cpp | 33 +++++++++++++++++++++++++++++++-- 4 files changed, 50 insertions(+), 7 deletions(-) (limited to 'engines/avalanche') diff --git a/engines/avalanche/avalot.cpp b/engines/avalanche/avalot.cpp index fefbbedd34..ae96ac4c74 100644 --- a/engines/avalanche/avalot.cpp +++ b/engines/avalanche/avalot.cpp @@ -211,7 +211,9 @@ void AvalancheEngine::setup() { loadGame(loadSlot); } else { _mainmenu->run(); - + if (_letMeOut) + return; + newGame(); thinkAbout(kObjectMoney, kThing); @@ -223,7 +225,7 @@ void AvalancheEngine::setup() { void AvalancheEngine::runAvalot() { setup(); - do { + while (!_letMeOut && !shouldQuit()) { uint32 beginLoop = _system->getMillis(); updateEvents(); // The event handler. @@ -241,7 +243,7 @@ void AvalancheEngine::runAvalot() { uint32 delay = _system->getMillis() - beginLoop; if (delay <= 55) _system->delayMillis(55 - delay); // Replaces slowdown(); 55 comes from 18.2 Hz (B Flight). - } while (!_letMeOut && !shouldQuit()); + }; warning("STUB: run()"); diff --git a/engines/avalanche/graphics.cpp b/engines/avalanche/graphics.cpp index 553556f8e0..ae53f3e034 100644 --- a/engines/avalanche/graphics.cpp +++ b/engines/avalanche/graphics.cpp @@ -801,8 +801,11 @@ void GraphicManager::menuInitialize() { _menu.create(kScreenWidth, kMenuScreenHeight, Graphics::PixelFormat::createFormatCLUT8()); } -void GraphicManager::menuClear() { +void GraphicManager::menuFree() { _menu.free(); +} + +void GraphicManager::menuRestoreScreen() { initGraphics(kScreenWidth, 2 * kScreenHeight, true); } @@ -867,6 +870,13 @@ void GraphicManager::menuDrawBigText(FontType font, uint16 x, uint16 y, Common:: drawBigText(_menu, text, font, 14, x, y, color); } +void GraphicManager::menuDrawIndicator(int x) { // TODO: Implement striped pattern for the indicator. + if (x > 0) + _menu.fillRect(Common::Rect(x - 1, 330, x, 337), kColorBlack); + _menu.fillRect(Common::Rect(x, 330, x + 1, 337), kColorWhite); + menuRefreshScreen(); +} + /** * This function is for skipping the difference between a stored 'size' value associated with a picture * and the actual size of the pictures when reading them from files for Ghostroom and Shoot em' up. diff --git a/engines/avalanche/graphics.h b/engines/avalanche/graphics.h index 270e04da85..7e0ed64b5f 100644 --- a/engines/avalanche/graphics.h +++ b/engines/avalanche/graphics.h @@ -122,9 +122,11 @@ public: // so it needs it's own graphic functions on that matter. void menuRefreshScreen(); void menuInitialize(); - void menuClear(); + void menuFree(); + void menuRestoreScreen(); void menuLoadPictures(); void menuDrawBigText(FontType font, uint16 x, uint16 y, Common::String text, Color color); + void menuDrawIndicator(int x); void clearAlso(); void clearTextBar(); diff --git a/engines/avalanche/mainmenu.cpp b/engines/avalanche/mainmenu.cpp index 0f64527305..543684556c 100644 --- a/engines/avalanche/mainmenu.cpp +++ b/engines/avalanche/mainmenu.cpp @@ -37,6 +37,7 @@ MainMenu::MainMenu(AvalancheEngine *vm) { } void MainMenu::run() { + CursorMan.showMouse(false); _vm->_graphics->menuInitialize(); _vm->_graphics->menuLoadPictures(); loadRegiInfo(); @@ -54,7 +55,6 @@ void MainMenu::run() { _vm->_graphics->menuRefreshScreen(); wait(); - _vm->_graphics->menuClear(); } void MainMenu::loadFont() { @@ -81,7 +81,36 @@ void MainMenu::centre(int16 y, Common::String text) { } void MainMenu::wait() { - warning("STUB: MainMenu::wait()"); + int x = 0; + while (!_vm->shouldQuit()) { + _vm->_graphics->menuDrawIndicator(x); + _vm->_system->delayMillis(40); + x++; + if (x == 641) + x = 0; + Common::Event event; + _vm->getEvent(event); + if (event.type == Common::EVENT_KEYDOWN) { + switch (event.kbd.keycode) { + case Common::KEYCODE_SPACE: + case Common::KEYCODE_RETURN: + case Common::KEYCODE_1: // Falltroughs are inteded. + // Play the game + _vm->_graphics->menuFree(); + _vm->_graphics->menuRestoreScreen(); + CursorMan.showMouse(true); + return; + case Common::KEYCODE_ESCAPE: + case Common::KEYCODE_6: // Falltroughs are inteded. + // Exit back to DOS + _vm->_letMeOut = true; + _vm->_graphics->menuFree(); + return; + default: + break; + } + } + } } } // End of namespace Avalanche -- cgit v1.2.3