From e15f40978a6904dec7a50cfefbb2a05c454c6c74 Mon Sep 17 00:00:00 2001 From: uruk Date: Fri, 4 Jul 2014 19:07:38 +0200 Subject: CGE2: Implement loading from the Launcher. --- engines/cge2/cge2.cpp | 4 +++- engines/cge2/cge2.h | 1 + engines/cge2/cge2_main.cpp | 18 +++++++++++++----- engines/cge2/detection.cpp | 4 +++- engines/cge2/saveload.cpp | 9 ++++++--- 5 files changed, 26 insertions(+), 10 deletions(-) (limited to 'engines') diff --git a/engines/cge2/cge2.cpp b/engines/cge2/cge2.cpp index e6df241ea9..aa87f99a3b 100644 --- a/engines/cge2/cge2.cpp +++ b/engines/cge2/cge2.cpp @@ -26,7 +26,7 @@ */ #include "engines/util.h" - +#include "common/config-manager.h" #include "cge2/cge2.h" #include "cge2/bitmap.h" #include "cge2/vga13h.h" @@ -123,6 +123,8 @@ void CGE2Engine::init() { _sys = new System(this); _eventManager = new EventManager(this); _map = new Map(this); + + _startGameSlot = ConfMan.hasKey("save_slot") ? ConfMan.getInt("save_slot") : -1; } void CGE2Engine::deinit() { diff --git a/engines/cge2/cge2.h b/engines/cge2/cge2.h index f126da591f..a2cd13107e 100644 --- a/engines/cge2/cge2.h +++ b/engines/cge2/cge2.h @@ -284,6 +284,7 @@ public: int _req; NotifyFunctionType _midiNotify; NotifyFunctionType _spriteNotify; + int _startGameSlot; ResourceManager *_resman; Vga *_vga; diff --git a/engines/cge2/cge2_main.cpp b/engines/cge2/cge2_main.cpp index 77df792e94..b9787b07e1 100644 --- a/engines/cge2/cge2_main.cpp +++ b/engines/cge2/cge2_main.cpp @@ -696,11 +696,13 @@ void CGE2Engine::runGame() { } void CGE2Engine::loadUser() { - warning("STUB: CGE2Engine::loadUser()"); - // Missing loading from file. TODO: Implement it with the saving/loading! - loadScript("CGE.INI"); - loadHeroes(); loadPos(); + if (_startGameSlot != -1) + loadGame(_startGameSlot); + else { + loadScript("CGE.INI"); + loadHeroes(); + } } void CGE2Engine::loadHeroes() { // Original name: loadGame() @@ -847,7 +849,11 @@ void CGE2Engine::cge2_main() { loadTab(); - _mode++; + if (_startGameSlot != -1) { + // Starting up a savegame from the launcher + _mode++; + runGame(); + } if (showTitle("WELCOME")) { #if 0 @@ -900,6 +906,8 @@ int CGE2Engine::newRandom(int range) { bool CGE2Engine::showTitle(const char *name) { if (_quitFlag) return false; + + _mode++; _bitmapPalette = _vga->_sysPal; BitmapPtr LB = new Bitmap[1]; diff --git a/engines/cge2/detection.cpp b/engines/cge2/detection.cpp index 599934b57d..6d4f6339d9 100644 --- a/engines/cge2/detection.cpp +++ b/engines/cge2/detection.cpp @@ -41,7 +41,9 @@ bool CGE2MetaEngine::hasFeature(MetaEngineFeature f) const { (f == kSupportsDeleteSave) || (f == kSavesSupportMetaInfo) || (f == kSavesSupportThumbnail) || - (f == kSavesSupportCreationDate); + (f == kSavesSupportCreationDate) || + (f == kSupportsListSaves) || + (f == kSupportsLoadingDuringStartup); } const ADGameDescription *CGE2MetaEngine::fallbackDetect(const FileMap &allFiles, const Common::FSList &fslist) const { diff --git a/engines/cge2/saveload.cpp b/engines/cge2/saveload.cpp index 0ea957f9e1..3890e74341 100644 --- a/engines/cge2/saveload.cpp +++ b/engines/cge2/saveload.cpp @@ -311,11 +311,8 @@ void CGE2Engine::syncHeader(Common::Serializer &s) { Common::Error CGE2Engine::loadGameState(int slot) { sceneDown(); - resetGame(); if (!loadGame(slot)) return Common::kReadingFailed; - initToolbar(); - loadHeroes(); sceneUp(_now); return Common::kNoError; } @@ -365,10 +362,16 @@ bool CGE2Engine::loadGame(int slotNumber) { delete saveHeader.thumbnail; } + resetGame(); + // Get in the savegame syncGame(readStream, nullptr); delete readStream; + + initToolbar(); + loadHeroes(); + return true; } -- cgit v1.2.3