MACVENTURE: Test and complete main loop
This commit is contained in:
parent
79496ea5c0
commit
ec768fbec1
3 changed files with 51 additions and 20 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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 (_cmdReady || _halted) {
|
||||
_halted = false;
|
||||
if (runScriptEngine()) {
|
||||
_halted = true;
|
||||
_paused = true;
|
||||
} else {
|
||||
_paused = false;
|
||||
if (!updateState()) {
|
||||
updateControls();
|
||||
if (!_halted) {
|
||||
_gui->draw();
|
||||
}
|
||||
|
||||
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() {
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue