From ec1fdeb25ad6b2d9aae69a544f45eb7fc5e189b8 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 8 Dec 2014 01:08:27 +0200 Subject: ZVISION: Implement several advanced engine features and ScummVM dialogs The functionality to return to launcher, list saves, delete saves, load games from the launcher and load and save games during runtime has been implemented. Also, ScummVM save/load dialogs have been implemented. Saved games now have three numbers in their file extension, bumping the possible save game slots up to 999 --- engines/zvision/core/save_manager.cpp | 40 ++++++++++++++++++++++++++++++++++- engines/zvision/core/save_manager.h | 1 + 2 files changed, 40 insertions(+), 1 deletion(-) (limited to 'engines/zvision/core') diff --git a/engines/zvision/core/save_manager.cpp b/engines/zvision/core/save_manager.cpp index 11d3dd391a..20bd39fde5 100644 --- a/engines/zvision/core/save_manager.cpp +++ b/engines/zvision/core/save_manager.cpp @@ -23,22 +23,60 @@ #include "common/scummsys.h" #include "zvision/core/save_manager.h" - #include "zvision/zvision.h" #include "zvision/scripting/script_manager.h" #include "zvision/graphics/render_manager.h" #include "common/system.h" +#include "common/translation.h" #include "graphics/surface.h" #include "graphics/thumbnail.h" #include "gui/message.h" +#include "gui/saveload.h" namespace ZVision { const uint32 SaveManager::SAVEGAME_ID = MKTAG('Z', 'E', 'N', 'G'); +bool SaveManager::scummVMSaveLoadDialog(bool isSave) { + GUI::SaveLoadChooser *dialog; + Common::String desc; + int slot; + + if (isSave) { + dialog = new GUI::SaveLoadChooser(_("Save game:"), _("Save"), true); + + slot = dialog->runModalWithCurrentTarget(); + desc = dialog->getResultString(); + + if (desc.empty()) { + // create our own description for the saved game, the user didnt enter it + desc = dialog->createDefaultSaveDescription(slot); + } + + if (desc.size() > 28) + desc = Common::String(desc.c_str(), 28); + } else { + dialog = new GUI::SaveLoadChooser(_("Restore game:"), _("Restore"), false); + slot = dialog->runModalWithCurrentTarget(); + } + + delete dialog; + + if (slot < 0) + return false; + + if (isSave) { + saveGame(slot, desc); + return true; + } else { + Common::ErrorCode result = loadGame(slot).getCode(); + return (result == Common::kNoError); + } +} + void SaveManager::saveGame(uint slot, const Common::String &saveName) { // The games only support 20 slots //assert(slot <= 1 && slot <= 20); diff --git a/engines/zvision/core/save_manager.h b/engines/zvision/core/save_manager.h index 5cd61c7aa9..75841331e7 100644 --- a/engines/zvision/core/save_manager.h +++ b/engines/zvision/core/save_manager.h @@ -96,6 +96,7 @@ public: void prepareSaveBuffer(); void flushSaveBuffer(); + bool scummVMSaveLoadDialog(bool isSave); private: void writeSaveGameHeader(Common::OutSaveFile *file, const Common::String &saveName); }; -- cgit v1.2.3