From e77f9f1779adc885f85299840b4ab58a8dcb6c13 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 25 Jul 2015 10:27:49 -0400 Subject: SHERLOCK: RT: Hook up ScummVM save/load dialogs in-game --- engines/sherlock/tattoo/tattoo_user_interface.cpp | 8 +-- engines/sherlock/tattoo/tattoo_user_interface.h | 1 - engines/sherlock/tattoo/widget_base.cpp | 9 ++++ engines/sherlock/tattoo/widget_base.h | 5 ++ engines/sherlock/tattoo/widget_files.cpp | 60 ++++++++++++++++++++--- engines/sherlock/tattoo/widget_files.h | 20 +++++++- engines/sherlock/tattoo/widget_options.cpp | 8 --- engines/sherlock/tattoo/widget_options.h | 5 -- engines/sherlock/tattoo/widget_quit.cpp | 9 ---- engines/sherlock/tattoo/widget_quit.h | 5 -- 10 files changed, 91 insertions(+), 39 deletions(-) (limited to 'engines/sherlock/tattoo') diff --git a/engines/sherlock/tattoo/tattoo_user_interface.cpp b/engines/sherlock/tattoo/tattoo_user_interface.cpp index 01f927b8c3..bbe93b50f1 100644 --- a/engines/sherlock/tattoo/tattoo_user_interface.cpp +++ b/engines/sherlock/tattoo/tattoo_user_interface.cpp @@ -31,7 +31,7 @@ namespace Tattoo { TattooUserInterface::TattooUserInterface(SherlockEngine *vm): UserInterface(vm), _inventoryWidget(vm), _messageWidget(vm), _textWidget(vm), _tooltipWidget(vm), _verbsWidget(vm), - _labWidget(vm), _creditsWidget(vm), _optionsWidget(vm), _quitWidget(vm), _filesWidget(vm) { + _labWidget(vm), _creditsWidget(vm), _optionsWidget(vm), _quitWidget(vm) { Common::fill(&_lookupTable[0], &_lookupTable[PALETTE_COUNT], 0); Common::fill(&_lookupTable1[0], &_lookupTable1[PALETTE_COUNT], 0); _scrollSize = 0; @@ -881,11 +881,13 @@ void TattooUserInterface::clearWindow() { } void TattooUserInterface::loadGame() { - _filesWidget.show(SAVEMODE_LOAD); + WidgetFiles &files = *(WidgetFiles *)_vm->_saves; + files.show(SAVEMODE_LOAD); } void TattooUserInterface::saveGame() { - _filesWidget.show(SAVEMODE_SAVE); + WidgetFiles &files = *(WidgetFiles *)_vm->_saves; + files.show(SAVEMODE_SAVE); } } // End of namespace Tattoo diff --git a/engines/sherlock/tattoo/tattoo_user_interface.h b/engines/sherlock/tattoo/tattoo_user_interface.h index 652e5b1da2..a5a678fa21 100644 --- a/engines/sherlock/tattoo/tattoo_user_interface.h +++ b/engines/sherlock/tattoo/tattoo_user_interface.h @@ -54,7 +54,6 @@ private: int _lockoutTimer; int _scriptZone; int _cAnimFramePause; - WidgetFiles _filesWidget; WidgetInventory _inventoryWidget; WidgetMessage _messageWidget; WidgetQuit _quitWidget; diff --git a/engines/sherlock/tattoo/widget_base.cpp b/engines/sherlock/tattoo/widget_base.cpp index 4f58125bb9..3a4e331f2d 100644 --- a/engines/sherlock/tattoo/widget_base.cpp +++ b/engines/sherlock/tattoo/widget_base.cpp @@ -22,6 +22,7 @@ #include "sherlock/tattoo/widget_base.h" #include "sherlock/tattoo/tattoo.h" +#include "sherlock/tattoo/tattoo_scene.h" #include "sherlock/tattoo/tattoo_talk.h" #include "sherlock/tattoo/tattoo_user_interface.h" @@ -57,6 +58,14 @@ void WidgetBase::banishWindow() { ui._widgets.remove(this); } +void WidgetBase::close() { + TattooScene &scene = *(TattooScene *)_vm->_scene; + TattooUserInterface &ui = *(TattooUserInterface *)_vm->_ui; + + banishWindow(); + ui._menuMode = scene._labTableScene ? LAB_MODE : STD_MODE; +} + bool WidgetBase::active() const { TattooUserInterface &ui = *(TattooUserInterface *)_vm->_ui; for (Common::List::iterator i = ui._widgets.begin(); i != ui._widgets.end(); ++i) { diff --git a/engines/sherlock/tattoo/widget_base.h b/engines/sherlock/tattoo/widget_base.h index 149f80e770..401dba6aed 100644 --- a/engines/sherlock/tattoo/widget_base.h +++ b/engines/sherlock/tattoo/widget_base.h @@ -79,6 +79,11 @@ protected: */ void handleScrollbarEvents(int index, int pageSize, int count); + /** + * Close the dialog + */ + void close(); + /** * Handle drawing the background on the area the widget is going to cover */ diff --git a/engines/sherlock/tattoo/widget_files.cpp b/engines/sherlock/tattoo/widget_files.cpp index 37842bb98f..0666e173aa 100644 --- a/engines/sherlock/tattoo/widget_files.cpp +++ b/engines/sherlock/tattoo/widget_files.cpp @@ -20,6 +20,8 @@ * */ +#include "common/translation.h" +#include "gui/saveload.h" #include "sherlock/tattoo/widget_files.h" #include "sherlock/tattoo/tattoo.h" #include "sherlock/tattoo/tattoo_fixed_text.h" @@ -30,7 +32,9 @@ namespace Sherlock { namespace Tattoo { -WidgetFiles::WidgetFiles(SherlockEngine *vm) : WidgetBase(vm) { +WidgetFiles::WidgetFiles(SherlockEngine *vm, const Common::String &target) : + SaveManager(vm, target), WidgetBase(vm), _vm(vm) { + _fileMode = SAVEMODE_NONE; } void WidgetFiles::show(SaveMode mode) { @@ -38,7 +42,55 @@ void WidgetFiles::show(SaveMode mode) { TattooUserInterface &ui = *(TattooUserInterface *)_vm->_ui; Common::Point mousePos = events.mousePos(); - _fileMode = mode; + if (_vm->_showOriginalSavesDialog) { + // Render and display the file dialog + _fileMode = mode; + render(); + + summonWindow(); + ui._menuMode = FILES_MODE; + } else if (mode == SAVEMODE_LOAD) { + showScummVMRestoreDialog(); + } else { + showScummVMSaveDialog(); + } +} + +void WidgetFiles::showScummVMSaveDialog() { + GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser(_("Save game:"), _("Save"), true); + + int slot = dialog->runModalWithCurrentTarget(); + if (slot >= 0) { + Common::String desc = dialog->getResultString(); + + if (desc.empty()) { + // create our own description for the saved game, the user didn't enter it + desc = dialog->createDefaultSaveDescription(slot); + } + + _vm->saveGameState(slot, desc); + } + + close(); + delete dialog; +} + +void WidgetFiles::showScummVMRestoreDialog() { + GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser(_("Restore game:"), _("Restore"), false); + int slot = dialog->runModalWithCurrentTarget(); + close(); + delete dialog; + + if (slot >= 0) { + _vm->loadGameState(slot); + } +} + +void WidgetFiles::render() { + Events &events = *_vm->_events; + Common::Point mousePos = events.mousePos(); + + createSavegameList(); // Set up the display area _bounds = Common::Rect(_surface.stringWidth(FIXED(AreYouSureYou)) + _surface.widestChar() * 2, @@ -49,10 +101,6 @@ void WidgetFiles::show(SaveMode mode) { _surface.create(_bounds.width(), _bounds.height()); _surface.fill(TRANSPARENCY); makeInfoArea(); - - - ui._menuMode = FILES_MODE; - summonWindow(); } void WidgetFiles::handleEvents() { diff --git a/engines/sherlock/tattoo/widget_files.h b/engines/sherlock/tattoo/widget_files.h index 6ef5aab836..495a95c003 100644 --- a/engines/sherlock/tattoo/widget_files.h +++ b/engines/sherlock/tattoo/widget_files.h @@ -33,16 +33,32 @@ class SherlockEngine; namespace Tattoo { -class WidgetFiles: public WidgetBase { +class WidgetFiles: public WidgetBase, public SaveManager { private: + SherlockEngine *_vm; SaveMode _fileMode; + /** + * Render the dialog + */ + void render(); + /** * Close the dialog */ void close(); + + /** + * Show the ScummVM Save Game dialog + */ + void showScummVMSaveDialog(); + + /** + * Show the ScummVM Load Game dialog + */ + void showScummVMRestoreDialog(); public: - WidgetFiles(SherlockEngine *vm); + WidgetFiles(SherlockEngine *vm, const Common::String &target); virtual ~WidgetFiles() {} /** diff --git a/engines/sherlock/tattoo/widget_options.cpp b/engines/sherlock/tattoo/widget_options.cpp index eb18a8b03a..5c09a016b9 100644 --- a/engines/sherlock/tattoo/widget_options.cpp +++ b/engines/sherlock/tattoo/widget_options.cpp @@ -386,14 +386,6 @@ void WidgetOptions::render(OptionRenderMode mode) { } } -void WidgetOptions::close() { - TattooScene &scene = *(TattooScene *)_vm->_scene; - TattooUserInterface &ui = *(TattooUserInterface *)_vm->_ui; - - banishWindow(); - ui._menuMode = scene._labTableScene ? LAB_MODE : STD_MODE; -} - } // End of namespace Tattoo } // End of namespace Sherlock diff --git a/engines/sherlock/tattoo/widget_options.h b/engines/sherlock/tattoo/widget_options.h index b50a557f14..9be0105ab4 100644 --- a/engines/sherlock/tattoo/widget_options.h +++ b/engines/sherlock/tattoo/widget_options.h @@ -47,11 +47,6 @@ private: * Render the contents of the dialog onto the widget's surface */ void render(OptionRenderMode mode = OP_ALL); - - /** - * Close the dialog - */ - void close(); public: WidgetOptions(SherlockEngine *vm); virtual ~WidgetOptions() {} diff --git a/engines/sherlock/tattoo/widget_quit.cpp b/engines/sherlock/tattoo/widget_quit.cpp index dc80a3dc47..f853e7f47f 100644 --- a/engines/sherlock/tattoo/widget_quit.cpp +++ b/engines/sherlock/tattoo/widget_quit.cpp @@ -23,7 +23,6 @@ #include "sherlock/tattoo/widget_quit.h" #include "sherlock/tattoo/tattoo.h" #include "sherlock/tattoo/tattoo_fixed_text.h" -#include "sherlock/tattoo/tattoo_scene.h" #include "sherlock/tattoo/tattoo_user_interface.h" namespace Sherlock { @@ -151,14 +150,6 @@ void WidgetQuit::handleEvents() { } } -void WidgetQuit::close() { - TattooScene &scene = *(TattooScene *)_vm->_scene; - TattooUserInterface &ui = *(TattooUserInterface *)_vm->_ui; - - banishWindow(); - ui._menuMode = scene._labTableScene ? LAB_MODE : STD_MODE; -} - } // End of namespace Tattoo } // End of namespace Sherlock diff --git a/engines/sherlock/tattoo/widget_quit.h b/engines/sherlock/tattoo/widget_quit.h index e7da685b72..b8b640f2d2 100644 --- a/engines/sherlock/tattoo/widget_quit.h +++ b/engines/sherlock/tattoo/widget_quit.h @@ -35,11 +35,6 @@ namespace Tattoo { class WidgetQuit: public WidgetBase { private: int _select, _oldSelect; - - /** - * Close the dialog - */ - void close(); public: WidgetQuit(SherlockEngine *vm); virtual ~WidgetQuit() {} -- cgit v1.2.3