From 0cd9e876297872269d83f38e93e6525dd4efd8e5 Mon Sep 17 00:00:00 2001 From: Borja Lorente Date: Wed, 10 Aug 2016 17:05:05 +0200 Subject: MACVENTURE: Add 'new game' functionality --- engines/macventure/macventure.cpp | 51 +++++++++++++++++++++++++-------------- engines/macventure/macventure.h | 10 +++++--- engines/macventure/world.cpp | 5 ++-- 3 files changed, 41 insertions(+), 25 deletions(-) diff --git a/engines/macventure/macventure.cpp b/engines/macventure/macventure.cpp index 37e1472338..0a27babb26 100644 --- a/engines/macventure/macventure.cpp +++ b/engines/macventure/macventure.cpp @@ -153,15 +153,7 @@ Common::Error MacVentureEngine::run() { _soundManager = new SoundManager(this, _mixer); - _paused = false; - _halted = false; - _cmdReady = false; - _haltedAtEnd = false; - _haltedInSelection = false; - _clickToContinue = true; - _gameState = kGameStateInit; - _destObject = 0; - _prepared = true; + setInitialFlags(); int directSaveSlotLoading = ConfMan.getInt("save_slot"); if (directSaveSlotLoading >= 0) { @@ -169,10 +161,7 @@ Common::Error MacVentureEngine::run() { error("Could not load game from slot '%d'", directSaveSlotLoading); } } else { - _cmdReady = true; - ObjID playerParent = _world->getObjAttr(1, kAttrParentObject); - _currentSelection.push_back(playerParent);// Push the parent of the player - _world->setObjAttr(playerParent, kAttrContainerOpen, 1); + setNewGameState(); } _selectedControl = kStartOrResume; @@ -208,17 +197,42 @@ Common::Error MacVentureEngine::run() { } } } - _gui->draw(); - - g_system->updateScreen(); - g_system->delayMillis(50); + refreshScreen(); } return Common::kNoError; } +void MacVentureEngine::refreshScreen() { + _gui->draw(); + g_system->updateScreen(); + g_system->delayMillis(50); +} + void MacVentureEngine::newGame() { - warning("New Game not implemented!"); + _world->startNewGame(); + reset(); + setInitialFlags(); + setNewGameState(); +} + +void MacVentureEngine::setInitialFlags() { + _paused = false; + _halted = false; + _cmdReady = false; + _haltedAtEnd = false; + _haltedInSelection = false; + _clickToContinue = true; + _gameState = kGameStateInit; + _destObject = 0; + _prepared = true; +} + +void MacVentureEngine::setNewGameState() { + _cmdReady = true; + ObjID playerParent = _world->getObjAttr(1, kAttrParentObject); + _currentSelection.push_back(playerParent);// Push the parent of the player + _world->setObjAttr(playerParent, kAttrContainerOpen, 1); } void MacVentureEngine::reset() { @@ -241,6 +255,7 @@ void MacVentureEngine::resetGui() { _gui->updateWindowInfo(kInventoryStart, 1, _world->getChildren(1, true)); updateControls(); updateExits(); + refreshScreen(); } void MacVentureEngine::requestQuit() { diff --git a/engines/macventure/macventure.h b/engines/macventure/macventure.h index 576fd9b323..3f0ce0cc7b 100644 --- a/engines/macventure/macventure.h +++ b/engines/macventure/macventure.h @@ -185,17 +185,19 @@ public: virtual Common::Error loadGameState(int slot); virtual Common::Error saveGameState(int slot, const Common::String &desc); void newGame(); + void setInitialFlags(); + void setNewGameState(); void initDebugChannels(); + void reset(); + void resetInternals(); + void resetGui(); + void refreshScreen(); // datafiles.cpp void loadDataBundle(); Common::SeekableReadStream *getBorderFile(MVWindowType windowType, bool isActive); - void reset(); - void resetInternals(); - void resetGui(); - void requestQuit(); void requestUnpause(); void selectControl(ControlAction action); diff --git a/engines/macventure/world.cpp b/engines/macventure/world.cpp index 2c9b55c6ab..82a8952f02 100644 --- a/engines/macventure/world.cpp +++ b/engines/macventure/world.cpp @@ -10,11 +10,8 @@ World::World(MacVentureEngine *engine, Common::MacResManager *resMan) { _engine = engine; _saveGame = NULL; - startNewGame(); - //_-------------------- - _objectConstants = new Container(_engine->getFilePath(kObjectPathID)); calculateObjectRelations(); @@ -47,6 +44,8 @@ void World::startNewGame() { _saveGame = new SaveGame(_engine, saveGameRes); + calculateObjectRelations(); + delete saveGameRes; saveGameFile.close(); } -- cgit v1.2.3