diff options
author | Borja Lorente | 2016-06-17 12:53:32 +0200 |
---|---|---|
committer | Borja Lorente | 2016-08-14 18:28:06 +0200 |
commit | ec768fbec167321914326a54a7efc2032e03c3e3 (patch) | |
tree | 203c575c1321c3fc50dccb47f4f3c16c950d9360 /engines/macventure | |
parent | 79496ea5c07cf3da9fef845e53b6df2c36a6a8e7 (diff) | |
download | scummvm-rg350-ec768fbec167321914326a54a7efc2032e03c3e3.tar.gz scummvm-rg350-ec768fbec167321914326a54a7efc2032e03c3e3.tar.bz2 scummvm-rg350-ec768fbec167321914326a54a7efc2032e03c3e3.zip |
MACVENTURE: Test and complete main loop
Diffstat (limited to 'engines/macventure')
-rw-r--r-- | engines/macventure/gui.cpp | 5 | ||||
-rw-r--r-- | engines/macventure/macventure.cpp | 61 | ||||
-rw-r--r-- | engines/macventure/macventure.h | 5 |
3 files changed, 51 insertions, 20 deletions
diff --git a/engines/macventure/gui.cpp b/engines/macventure/gui.cpp index aeca8df1c9..4ca3de70b3 100644 --- a/engines/macventure/gui.cpp +++ b/engines/macventure/gui.cpp @@ -582,9 +582,8 @@ bool Gui::processCommandEvents(WindowClick click, Common::Event &event) { _engine->selectControl((ControlReference)data.getData().refcon); _engine->activateCommand((ControlReference)data.getData().refcon); - - // Run main - + _engine->refreshReady(); + _engine->preparedToRun(); } return false; } 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() { diff --git a/engines/macventure/macventure.h b/engines/macventure/macventure.h index 8fe5792e7c..16d4d8de63 100644 --- a/engines/macventure/macventure.h +++ b/engines/macventure/macventure.h @@ -148,6 +148,8 @@ public: void requestUnpause(); void selectControl(ControlReference id); void activateCommand(ControlReference id); + void refreshReady(); + void preparedToRun(); void enqueueObject(ObjID id); @@ -173,6 +175,7 @@ private: // Utils ControlAction referenceToAction(ControlReference id); + uint objectsToApplyCommand(); private: // Attributes @@ -192,7 +195,7 @@ private: // Attributes StringTable *_filenames; Common::Huffman *_textHuffman; bool _oldTextEncoding; - bool _paused, _halted, _cmdReady; + bool _paused, _halted, _cmdReady, _prepared; bool _haltedAtEnd, _haltedInSelection; bool _gameChanged; |