aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBorja Lorente2016-08-10 17:05:05 +0200
committerBorja Lorente2016-08-19 16:29:16 +0200
commit0cd9e876297872269d83f38e93e6525dd4efd8e5 (patch)
tree5b07fe6365209153b2d2be907fc6538a515507a9
parent1d5b7a6e19377c0b279c337ef4ca60749b31f6c9 (diff)
downloadscummvm-rg350-0cd9e876297872269d83f38e93e6525dd4efd8e5.tar.gz
scummvm-rg350-0cd9e876297872269d83f38e93e6525dd4efd8e5.tar.bz2
scummvm-rg350-0cd9e876297872269d83f38e93e6525dd4efd8e5.zip
MACVENTURE: Add 'new game' functionality
-rw-r--r--engines/macventure/macventure.cpp51
-rw-r--r--engines/macventure/macventure.h10
-rw-r--r--engines/macventure/world.cpp5
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();
}