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->selectControl((ControlReference)data.getData().refcon);
|
||||||
_engine->activateCommand((ControlReference)data.getData().refcon);
|
_engine->activateCommand((ControlReference)data.getData().refcon);
|
||||||
|
_engine->refreshReady();
|
||||||
// Run main
|
_engine->preparedToRun();
|
||||||
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,28 +94,34 @@ Common::Error MacVentureEngine::run() {
|
||||||
_cmdReady = false;
|
_cmdReady = false;
|
||||||
_haltedAtEnd = false;
|
_haltedAtEnd = false;
|
||||||
_haltedInSelection = false;
|
_haltedInSelection = false;
|
||||||
|
_prepared = true;
|
||||||
while (!(_gameState == kGameStateQuitting)) {
|
while (!(_gameState == kGameStateQuitting)) {
|
||||||
processEvents();
|
processEvents();
|
||||||
|
|
||||||
if (!_halted) {
|
if (_prepared) {
|
||||||
_gui->draw();
|
_prepared = false;
|
||||||
}
|
|
||||||
|
|
||||||
if (_cmdReady || _halted) {
|
if (!_halted) {
|
||||||
_halted = false;
|
_gui->draw();
|
||||||
if (runScriptEngine()) {
|
}
|
||||||
_halted = true;
|
|
||||||
_paused = true;
|
if (_cmdReady || _halted) {
|
||||||
} else {
|
_halted = false;
|
||||||
_paused = false;
|
if (runScriptEngine()) {
|
||||||
if (!updateState()) {
|
_halted = true;
|
||||||
updateControls();
|
_paused = true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
_paused = false;
|
||||||
|
if (!updateState()) {
|
||||||
|
updateControls();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (_gameState == kGameStateWinnig || _gameState == kGameStateLosing) {
|
if (_gameState == kGameStateWinnig || _gameState == kGameStateLosing) {
|
||||||
endGame();
|
endGame();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
g_system->updateScreen();
|
g_system->updateScreen();
|
||||||
|
@ -144,13 +150,32 @@ void MacVentureEngine::selectControl(ControlReference id) {
|
||||||
void MacVentureEngine::activateCommand(ControlReference id) {
|
void MacVentureEngine::activateCommand(ControlReference id) {
|
||||||
ControlAction action = referenceToAction(id);
|
ControlAction action = referenceToAction(id);
|
||||||
if (action != _activeControl) {
|
if (action != _activeControl) {
|
||||||
if (_activeControl)
|
if (_activeControl)
|
||||||
_activeControl = kNoCommand;
|
_activeControl = kNoCommand;
|
||||||
_activeControl = action;
|
_activeControl = action;
|
||||||
}
|
}
|
||||||
debug(7, "Activating Command %x... Command %x is active", action, _activeControl);
|
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) {
|
void MacVentureEngine::enqueueObject(ObjID id) {
|
||||||
QueuedObject obj;
|
QueuedObject obj;
|
||||||
obj.parent = _world->getObjAttr(id, kAttrParentObject);
|
obj.parent = _world->getObjAttr(id, kAttrParentObject);
|
||||||
|
@ -287,6 +312,10 @@ ControlAction MacVenture::MacVentureEngine::referenceToAction(ControlReference i
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint MacVentureEngine::objectsToApplyCommand() {
|
||||||
|
return uint();
|
||||||
|
}
|
||||||
|
|
||||||
// Data retrieval
|
// Data retrieval
|
||||||
|
|
||||||
bool MacVentureEngine::isPaused() {
|
bool MacVentureEngine::isPaused() {
|
||||||
|
|
|
@ -148,6 +148,8 @@ public:
|
||||||
void requestUnpause();
|
void requestUnpause();
|
||||||
void selectControl(ControlReference id);
|
void selectControl(ControlReference id);
|
||||||
void activateCommand(ControlReference id);
|
void activateCommand(ControlReference id);
|
||||||
|
void refreshReady();
|
||||||
|
void preparedToRun();
|
||||||
|
|
||||||
void enqueueObject(ObjID id);
|
void enqueueObject(ObjID id);
|
||||||
|
|
||||||
|
@ -173,6 +175,7 @@ private:
|
||||||
|
|
||||||
// Utils
|
// Utils
|
||||||
ControlAction referenceToAction(ControlReference id);
|
ControlAction referenceToAction(ControlReference id);
|
||||||
|
uint objectsToApplyCommand();
|
||||||
|
|
||||||
private: // Attributes
|
private: // Attributes
|
||||||
|
|
||||||
|
@ -192,7 +195,7 @@ private: // Attributes
|
||||||
StringTable *_filenames;
|
StringTable *_filenames;
|
||||||
Common::Huffman *_textHuffman;
|
Common::Huffman *_textHuffman;
|
||||||
bool _oldTextEncoding;
|
bool _oldTextEncoding;
|
||||||
bool _paused, _halted, _cmdReady;
|
bool _paused, _halted, _cmdReady, _prepared;
|
||||||
bool _haltedAtEnd, _haltedInSelection;
|
bool _haltedAtEnd, _haltedInSelection;
|
||||||
bool _gameChanged;
|
bool _gameChanged;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue