From 783fd028937d1b5c16d945db4dbed3ba8ca307b2 Mon Sep 17 00:00:00 2001 From: Eric Fry Date: Wed, 18 Apr 2018 07:04:47 +1000 Subject: Work on save support --- engines/illusions/duckman/illusions_duckman.cpp | 5 ++--- engines/illusions/duckman/menusystem_duckman.cpp | 15 +++++++++++++-- engines/illusions/duckman/menusystem_duckman.h | 4 +++- engines/illusions/menusystem.cpp | 24 ++++++++++++++++++++++++ engines/illusions/menusystem.h | 8 ++++++++ 5 files changed, 50 insertions(+), 6 deletions(-) diff --git a/engines/illusions/duckman/illusions_duckman.cpp b/engines/illusions/duckman/illusions_duckman.cpp index 2cd338b1db..199bae7eb3 100644 --- a/engines/illusions/duckman/illusions_duckman.cpp +++ b/engines/illusions/duckman/illusions_duckman.cpp @@ -1179,9 +1179,8 @@ bool IllusionsEngine_Duckman::loadSavegameFromScript(int16 slotNum, uint32 calli } bool IllusionsEngine_Duckman::saveSavegameFromScript(int16 slotNum, uint32 callingThreadId) { - // TODO - // const char *fileName = getSavegameFilename(slotNum); - bool success = false;//savegame(fileName, _savegameDescription.c_str()); + const char *fileName = getSavegameFilename(_savegameSlotNum); + bool success = savegame(fileName, "");//_savegameDescription.c_str()); //TODO return success; } diff --git a/engines/illusions/duckman/menusystem_duckman.cpp b/engines/illusions/duckman/menusystem_duckman.cpp index 7b1191612f..a1e500b1ff 100644 --- a/engines/illusions/duckman/menusystem_duckman.cpp +++ b/engines/illusions/duckman/menusystem_duckman.cpp @@ -79,6 +79,8 @@ BaseMenu *DuckmanMenuSystem::createMenuById(int menuId) { return createQueryRestartMenu(); case kDuckmanQueryQuitMenu: return createQueryQuitMenu(); + case kDuckmanSaveCompleteMenu: + return createSaveCompleteMenu(); default: error("DuckmanMenuSystem::createMenuById() Invalid menu id %d", menuId); } @@ -107,7 +109,7 @@ BaseMenu *DuckmanMenuSystem::createPauseMenu() { menu->addText("-------------------"); menu->addMenuItem(new MenuItem("Resume", new MenuActionReturnChoice(this, 21))); menu->addMenuItem(new MenuItem("Load Game", new MenuActionLoadGame(this, 1))); - // TODO menu->addMenuItem(new MenuItem("Save Game", new MenuActionSaveGame(this, 11))); + menu->addMenuItem(new MenuItem("Save Game", new MenuActionSaveGame(this, 11))); // TODO menu->addMenuItem(new MenuItem("Restart Game", new MenuActionEnterQueryMenu(this, kDuckmanQueryRestartMenu, 2))); // TODO menu->addMenuItem(new MenuItem("Options", new MenuActionEnterMenu(this, kDuckmanOptionsMenu))); menu->addMenuItem(new MenuItem("Quit Game", new MenuActionEnterQueryMenu(this, kDuckmanQueryQuitMenu, 23))); @@ -127,14 +129,23 @@ BaseMenu *DuckmanMenuSystem::createQueryQuitMenu() { return menu; } +BaseMenu *DuckmanMenuSystem::createSaveCompleteMenu() { + BaseMenu *menu = new BaseMenu(this, 0x00120003, 12, 17, 11, 27, 1); + menu->addText("Game Saved"); + menu->addText("-------------"); + menu->addMenuItem(new MenuItem("Continue", new MenuActionLeaveMenu(this))); + return menu; +} + int DuckmanMenuSystem::convertRootMenuId(uint32 menuId) { switch (menuId) { case 0x180001: return kDuckmanMainMenu; case 0x180002: return kDuckmanPauseMenu; - /* Debug menus, not implemented case 0x180005: + return kDuckmanSaveCompleteMenu; + /* Debug menus, not implemented case 0x180006: case 0x180007: */ diff --git a/engines/illusions/duckman/menusystem_duckman.h b/engines/illusions/duckman/menusystem_duckman.h index bb43619acd..10a8a6eb0b 100644 --- a/engines/illusions/duckman/menusystem_duckman.h +++ b/engines/illusions/duckman/menusystem_duckman.h @@ -34,6 +34,7 @@ enum { kDuckmanPauseMenu, kDuckmanQueryQuitMenu, kDuckmanQueryRestartMenu, + kDuckmanSaveCompleteMenu, kDuckmanLastMenuIndex }; @@ -56,8 +57,9 @@ public://protected: BaseMenu *createLoadGameMenu(); BaseMenu *createOptionsMenu(); BaseMenu *createPauseMenu(); - BaseMenu *createQueryRestartMenu(); + BaseMenu *createQueryRestartMenu(); BaseMenu *createQueryQuitMenu(); + BaseMenu *createSaveCompleteMenu(); int convertRootMenuId(uint32 menuId); virtual bool initMenuCursor(); virtual int getGameState(); diff --git a/engines/illusions/menusystem.cpp b/engines/illusions/menusystem.cpp index 829756cf2f..4fb0f18834 100644 --- a/engines/illusions/menusystem.cpp +++ b/engines/illusions/menusystem.cpp @@ -621,4 +621,28 @@ void MenuActionLoadGame::execute() { } +// MenuActionSaveGame + + MenuActionSaveGame::MenuActionSaveGame(BaseMenuSystem *menuSystem, uint choiceIndex) + : BaseMenuAction(menuSystem), _choiceIndex(choiceIndex) { + } + + void MenuActionSaveGame::execute() { + const Plugin *plugin = NULL; + EngineMan.findGame(ConfMan.get("gameid"), &plugin); + GUI::SaveLoadChooser *dialog; + Common::String desc; + int slot; + + dialog = new GUI::SaveLoadChooser(_("Save game:"), _("Save"), true); + slot = dialog->runModalWithPluginAndTarget(plugin, ConfMan.getActiveDomainName()); + + delete dialog; + + if (slot >= 0) { + _menuSystem->setSavegameSlotNum(slot); + _menuSystem->selectMenuChoiceIndex(_choiceIndex); + } + _menuSystem->closeMenu(); + } } // End of namespace Illusions diff --git a/engines/illusions/menusystem.h b/engines/illusions/menusystem.h index 26a5931d18..26324c6786 100644 --- a/engines/illusions/menusystem.h +++ b/engines/illusions/menusystem.h @@ -239,6 +239,14 @@ protected: uint _choiceIndex; }; +class MenuActionSaveGame : public BaseMenuAction { +public: + MenuActionSaveGame(BaseMenuSystem *menuSystem, uint choiceIndex); + virtual void execute(); +protected: + uint _choiceIndex; +}; + } // End of namespace Illusions #endif // ILLUSIONS_MENUSYSTEM_H -- cgit v1.2.3