From e52cf3e7aae1adde1c4674a6f5686d9f633bd2f8 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 28 Dec 2015 00:31:50 +0200 Subject: CINE: Add support for ScummVM save/load menus --- engines/cine/cine.cpp | 3 +++ engines/cine/cine.h | 1 + engines/cine/detection.cpp | 15 +++++++++++ engines/cine/various.cpp | 67 +++++++++++++++++++++++++++++++++++++++++++++- 4 files changed, 85 insertions(+), 1 deletion(-) (limited to 'engines/cine') diff --git a/engines/cine/cine.cpp b/engines/cine/cine.cpp index d2f088dcd8..0d3f99b49f 100644 --- a/engines/cine/cine.cpp +++ b/engines/cine/cine.cpp @@ -52,6 +52,9 @@ CineEngine::CineEngine(OSystem *syst, const CINEGameDescription *gameDesc) // Setup mixer syncSoundSettings(); + // Assign default values to the config manager, in case settings are missing + ConfMan.registerDefault("originalsaveload", "false"); + DebugMan.addDebugChannel(kCineDebugScript, "Script", "Script debug level"); DebugMan.addDebugChannel(kCineDebugPart, "Part", "Part debug level"); DebugMan.addDebugChannel(kCineDebugSound, "Sound", "Sound debug level"); diff --git a/engines/cine/cine.h b/engines/cine/cine.h index 71a0c242b6..1618899af3 100644 --- a/engines/cine/cine.h +++ b/engines/cine/cine.h @@ -123,6 +123,7 @@ public: bool loadSaveDirectory(); void makeSystemMenu(); + int scummVMSaveLoadDialog(bool isSave); int modifyGameSpeed(int speedChange); int getTimerDelay() const; Common::Error loadGameState(int slot); diff --git a/engines/cine/detection.cpp b/engines/cine/detection.cpp index 4202bdc942..5b839b8043 100644 --- a/engines/cine/detection.cpp +++ b/engines/cine/detection.cpp @@ -24,8 +24,10 @@ #include "engines/advancedDetector.h" #include "engines/obsolete.h" + #include "common/system.h" #include "common/textconsole.h" +#include "common/translation.h" #include "cine/cine.h" #include "cine/various.h" @@ -61,6 +63,13 @@ static const Engines::ObsoleteGameID obsoleteGameIDsTable[] = { #include "cine/detection_tables.h" +static const ExtraGuiOption cineExtraGuiOption = { + _s("Use original save/load screens"), + _s("Use the original save/load screens, instead of the ScummVM ones"), + "originalsaveload", + false +}; + class CineMetaEngine : public AdvancedMetaEngine { public: CineMetaEngine() : AdvancedMetaEngine(Cine::gameDescriptions, sizeof(Cine::CINEGameDescription), cineGames) { @@ -86,6 +95,12 @@ public: } virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const; + const ExtraGuiOptions CineMetaEngine::getExtraGuiOptions(const Common::String &target) const { + ExtraGuiOptions options; + options.push_back(cineExtraGuiOption); + return options; + } + virtual bool hasFeature(MetaEngineFeature f) const; virtual SaveStateList listSaves(const char *target) const; virtual int getMaximumSaveSlot() const; diff --git a/engines/cine/various.cpp b/engines/cine/various.cpp index 8687699a44..fa05369f8d 100644 --- a/engines/cine/various.cpp +++ b/engines/cine/various.cpp @@ -21,12 +21,16 @@ */ +#include "common/config-manager.h" #include "common/endian.h" #include "common/events.h" #include "common/textconsole.h" +#include "common/translation.h" #include "graphics/cursorman.h" +#include "gui/saveload.h" + #include "cine/cine.h" #include "cine/main_loop.h" #include "cine/object.h" @@ -335,6 +339,56 @@ void CineEngine::resetEngine() { } } +int CineEngine::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); + } + } + else { + dialog = new GUI::SaveLoadChooser(_("Restore game:"), _("Restore"), false); + slot = dialog->runModalWithCurrentTarget(); + } + + delete dialog; + + if (slot < 0) + return true; + + char saveFileName[256]; + sprintf(saveFileName, "%s.%1d", _targetName.c_str(), slot); + + if (isSave) { + Common::String tmp = Common::String::format("%s.dir", _targetName.c_str()); + + Common::OutSaveFile *fHandle = _saveFileMan->openForSaving(tmp); + if (!fHandle) { + warning("Unable to open file %s for saving", tmp.c_str()); + return false; + } + + Common::strlcpy(currentSaveName[slot], desc.c_str(), 20); + + fHandle->write(currentSaveName, 200); + delete fHandle; + + makeSave(saveFileName); + return true; + } else { + return makeLoad(saveFileName); + } +} + void CineEngine::makeSystemMenu() { int16 numEntry, systemCommand; int16 mouseX, mouseY, mouseButton; @@ -381,7 +435,11 @@ void CineEngine::makeSystemMenu() { } case 4: { // load game if (loadSaveDirectory()) { -// int16 selectedSave; + if (!ConfMan.getBool("originalsaveload")) { + scummVMSaveLoadDialog(false); + inMenu = false; + return; + } getMouseData(mouseUpdateStatus, (uint16 *)&mouseButton, (uint16 *)&mouseX, (uint16 *)&mouseY); selectedSave = makeMenuChoice(currentSaveName, 10, mouseX, mouseY + 8, 180); @@ -417,6 +475,13 @@ void CineEngine::makeSystemMenu() { } case 5: { // Save game loadSaveDirectory(); + + if (!ConfMan.getBool("originalsaveload")) { + scummVMSaveLoadDialog(true); + inMenu = false; + return; + } + selectedSave = makeMenuChoice(currentSaveName, 10, mouseX, mouseY + 8, 180); if (selectedSave >= 0) { -- cgit v1.2.3 From 1688a1b239294b6cd9fe21ca4d2f5bd929c450dd Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 28 Dec 2015 00:39:47 +0200 Subject: CINE: Fix compilation --- engines/cine/detection.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/cine') diff --git a/engines/cine/detection.cpp b/engines/cine/detection.cpp index 5b839b8043..027ed91fe0 100644 --- a/engines/cine/detection.cpp +++ b/engines/cine/detection.cpp @@ -95,7 +95,7 @@ public: } virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const; - const ExtraGuiOptions CineMetaEngine::getExtraGuiOptions(const Common::String &target) const { + const ExtraGuiOptions getExtraGuiOptions(const Common::String &target) const { ExtraGuiOptions options; options.push_back(cineExtraGuiOption); return options; -- cgit v1.2.3 From 796ea1468f7871892acc84a5aff69fc99a64cca4 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 27 Dec 2015 23:54:19 +0100 Subject: CINE: Remove superflous default value registration for extra GUI options. --- engines/cine/cine.cpp | 3 --- 1 file changed, 3 deletions(-) (limited to 'engines/cine') diff --git a/engines/cine/cine.cpp b/engines/cine/cine.cpp index 0d3f99b49f..d2f088dcd8 100644 --- a/engines/cine/cine.cpp +++ b/engines/cine/cine.cpp @@ -52,9 +52,6 @@ CineEngine::CineEngine(OSystem *syst, const CINEGameDescription *gameDesc) // Setup mixer syncSoundSettings(); - // Assign default values to the config manager, in case settings are missing - ConfMan.registerDefault("originalsaveload", "false"); - DebugMan.addDebugChannel(kCineDebugScript, "Script", "Script debug level"); DebugMan.addDebugChannel(kCineDebugPart, "Part", "Part debug level"); DebugMan.addDebugChannel(kCineDebugSound, "Sound", "Sound debug level"); -- cgit v1.2.3 From 8c1fc40d3d358ee7e315aa5de067d0c435105273 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Mon, 28 Dec 2015 00:04:13 +0100 Subject: CINE: Implement extra GUI options using AD's features. --- engines/cine/detection.cpp | 27 ++++++++++++++------------- engines/cine/detection_tables.h | 2 ++ 2 files changed, 16 insertions(+), 13 deletions(-) (limited to 'engines/cine') diff --git a/engines/cine/detection.cpp b/engines/cine/detection.cpp index 027ed91fe0..40e79f96ac 100644 --- a/engines/cine/detection.cpp +++ b/engines/cine/detection.cpp @@ -63,18 +63,25 @@ static const Engines::ObsoleteGameID obsoleteGameIDsTable[] = { #include "cine/detection_tables.h" -static const ExtraGuiOption cineExtraGuiOption = { - _s("Use original save/load screens"), - _s("Use the original save/load screens, instead of the ScummVM ones"), - "originalsaveload", - false +static const ADExtraGuiOptionsMap optionsList[] = { + { + GAMEOPTION_ORIGINAL_SAVELOAD, + { + _s("Use original save/load screens"), + _s("Use the original save/load screens, instead of the ScummVM ones"), + "originalsaveload", + false + } + }, + + AD_EXTRA_GUI_OPTIONS_TERMINATOR }; class CineMetaEngine : public AdvancedMetaEngine { public: - CineMetaEngine() : AdvancedMetaEngine(Cine::gameDescriptions, sizeof(Cine::CINEGameDescription), cineGames) { + CineMetaEngine() : AdvancedMetaEngine(Cine::gameDescriptions, sizeof(Cine::CINEGameDescription), cineGames, optionsList) { _singleid = "cine"; - _guioptions = GUIO1(GUIO_NOSPEECH); + _guioptions = GUIO2(GUIO_NOSPEECH, GAMEOPTION_ORIGINAL_SAVELOAD); } virtual GameDescriptor findGame(const char *gameid) const { @@ -95,12 +102,6 @@ public: } virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const; - const ExtraGuiOptions getExtraGuiOptions(const Common::String &target) const { - ExtraGuiOptions options; - options.push_back(cineExtraGuiOption); - return options; - } - virtual bool hasFeature(MetaEngineFeature f) const; virtual SaveStateList listSaves(const char *target) const; virtual int getMaximumSaveSlot() const; diff --git a/engines/cine/detection_tables.h b/engines/cine/detection_tables.h index 1188deb1a6..ca6a8a9168 100644 --- a/engines/cine/detection_tables.h +++ b/engines/cine/detection_tables.h @@ -22,6 +22,8 @@ namespace Cine { +#define GAMEOPTION_ORIGINAL_SAVELOAD GUIO_GAMEOPTIONS1 + static const CINEGameDescription gameDescriptions[] = { { { -- cgit v1.2.3 From de0b5b62ab9171fc9839b7804a0f2b56fe0da9a9 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Mon, 28 Dec 2015 00:35:43 +0100 Subject: CINE: Let makeLoad take a Common::String as parameter. --- engines/cine/cine.h | 2 +- engines/cine/saveload.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/cine') diff --git a/engines/cine/cine.h b/engines/cine/cine.h index 1618899af3..7c0191b4d9 100644 --- a/engines/cine/cine.h +++ b/engines/cine/cine.h @@ -153,7 +153,7 @@ private: bool makeLoad(const Common::String &saveName); void makeSaveFW(Common::OutSaveFile &out); void makeSaveOS(Common::OutSaveFile &out); - void makeSave(char *saveFileName); + void makeSave(const Common::String &saveFileName); void mainLoop(int bootScriptIdx); void readVolCnf(); diff --git a/engines/cine/saveload.cpp b/engines/cine/saveload.cpp index 907086a9a1..1f4f286694 100644 --- a/engines/cine/saveload.cpp +++ b/engines/cine/saveload.cpp @@ -969,7 +969,7 @@ void CineEngine::makeSaveOS(Common::OutSaveFile &out) { saveBgIncrustList(out); } -void CineEngine::makeSave(char *saveFileName) { +void CineEngine::makeSave(const Common::String &saveFileName) { Common::SharedPtr fHandle(_saveFileMan->openForSaving(saveFileName)); setMouseCursor(MOUSE_CURSOR_DISK); -- cgit v1.2.3 From c9bda09bc0900aac6d1cd96cd3f69b6a1761df70 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Mon, 28 Dec 2015 00:36:24 +0100 Subject: CINE: Prevent buffer overruns in scummVMSaveLoadDialog. --- engines/cine/various.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'engines/cine') diff --git a/engines/cine/various.cpp b/engines/cine/various.cpp index fa05369f8d..cd877a3295 100644 --- a/engines/cine/various.cpp +++ b/engines/cine/various.cpp @@ -365,8 +365,7 @@ int CineEngine::scummVMSaveLoadDialog(bool isSave) { if (slot < 0) return true; - char saveFileName[256]; - sprintf(saveFileName, "%s.%1d", _targetName.c_str(), slot); + Common::String saveFileName(Common::String::format("%s.%1d", _targetName.c_str(), slot)); if (isSave) { Common::String tmp = Common::String::format("%s.dir", _targetName.c_str()); -- cgit v1.2.3 From f4022c0ab8ca2393055ad6430293c833bdacd6a8 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Mon, 28 Dec 2015 05:27:04 +0100 Subject: CINE: Add POTFILES file. e52cf3e7aae1adde1c4674a6f5686d9f633bd2f8 added translatable strings to Cine's detection.cpp. Thus, there should be a POTFILE to allow checking the file when building our translation base file. --- engines/cine/POTFILES | 1 + 1 file changed, 1 insertion(+) create mode 100644 engines/cine/POTFILES (limited to 'engines/cine') diff --git a/engines/cine/POTFILES b/engines/cine/POTFILES new file mode 100644 index 0000000000..76f76832c3 --- /dev/null +++ b/engines/cine/POTFILES @@ -0,0 +1 @@ +engines/cine/detection.cpp -- cgit v1.2.3