From ec768fbec167321914326a54a7efc2032e03c3e3 Mon Sep 17 00:00:00 2001 From: Borja Lorente Date: Fri, 17 Jun 2016 12:53:32 +0200 Subject: MACVENTURE: Test and complete main loop --- engines/macventure/macventure.cpp | 61 +++++++++++++++++++++++++++++---------- 1 file changed, 45 insertions(+), 16 deletions(-) (limited to 'engines/macventure/macventure.cpp') diff --git a/engines/macventure/macventure.cpp b/engines/macventure/macventure.cpp index 27a2aad1fc..3b453563a6 100644 --- a/engines/macventure/macventure.cpp +++ b/engines/macventure/macventure.cpp @@ -94,28 +94,34 @@ Common::Error MacVentureEngine::run() { _cmdReady = false; _haltedAtEnd = false; _haltedInSelection = false; + _prepared = true; while (!(_gameState == kGameStateQuitting)) { processEvents(); - if (!_halted) { - _gui->draw(); - } + if (_prepared) { + _prepared = false; + + if (!_halted) { + _gui->draw(); + } - if (_cmdReady || _halted) { - _halted = false; - if (runScriptEngine()) { - _halted = true; - _paused = true; - } else { - _paused = false; - if (!updateState()) { - updateControls(); + if (_cmdReady || _halted) { + _halted = false; + if (runScriptEngine()) { + _halted = true; + _paused = true; + } + else { + _paused = false; + if (!updateState()) { + updateControls(); + } } } - } - if (_gameState == kGameStateWinnig || _gameState == kGameStateLosing) { - endGame(); + if (_gameState == kGameStateWinnig || _gameState == kGameStateLosing) { + endGame(); + } } g_system->updateScreen(); @@ -144,13 +150,32 @@ void MacVentureEngine::selectControl(ControlReference id) { void MacVentureEngine::activateCommand(ControlReference id) { ControlAction action = referenceToAction(id); if (action != _activeControl) { - if (_activeControl) + if (_activeControl) _activeControl = kNoCommand; _activeControl = action; } debug(7, "Activating Command %x... Command %x is active", action, _activeControl); } +void MacVentureEngine::refreshReady() { + switch (objectsToApplyCommand()) { + case 0: // No selected object + _cmdReady = true; + break; + case 1: // We have some selected object + _cmdReady = _currentSelection.size() != 0; + break; + case 2: + if (_destObject > 0) // We have a destination seleted + _cmdReady = true; + break; + } +} + +void MacVentureEngine::preparedToRun() { + _prepared = true; +} + void MacVentureEngine::enqueueObject(ObjID id) { QueuedObject obj; obj.parent = _world->getObjAttr(id, kAttrParentObject); @@ -287,6 +312,10 @@ ControlAction MacVenture::MacVentureEngine::referenceToAction(ControlReference i } } +uint MacVentureEngine::objectsToApplyCommand() { + return uint(); +} + // Data retrieval bool MacVentureEngine::isPaused() { -- cgit v1.2.3