[Scummvm-cvs-logs] scummvm master -> e77f9f1779adc885f85299840b4ab58a8dcb6c13

dreammaster dreammaster at scummvm.org
Sat Jul 25 16:28:45 CEST 2015


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
e77f9f1779 SHERLOCK: RT: Hook up ScummVM save/load dialogs in-game


Commit: e77f9f1779adc885f85299840b4ab58a8dcb6c13
    https://github.com/scummvm/scummvm/commit/e77f9f1779adc885f85299840b4ab58a8dcb6c13
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2015-07-25T10:27:49-04:00

Commit Message:
SHERLOCK: RT: Hook up ScummVM save/load dialogs in-game

Changed paths:
    engines/sherlock/saveload.cpp
    engines/sherlock/tattoo/tattoo_user_interface.cpp
    engines/sherlock/tattoo/tattoo_user_interface.h
    engines/sherlock/tattoo/widget_base.cpp
    engines/sherlock/tattoo/widget_base.h
    engines/sherlock/tattoo/widget_files.cpp
    engines/sherlock/tattoo/widget_files.h
    engines/sherlock/tattoo/widget_options.cpp
    engines/sherlock/tattoo/widget_options.h
    engines/sherlock/tattoo/widget_quit.cpp
    engines/sherlock/tattoo/widget_quit.h



diff --git a/engines/sherlock/saveload.cpp b/engines/sherlock/saveload.cpp
index 1151655..0ae437f 100644
--- a/engines/sherlock/saveload.cpp
+++ b/engines/sherlock/saveload.cpp
@@ -24,6 +24,7 @@
 #include "sherlock/surface.h"
 #include "sherlock/sherlock.h"
 #include "sherlock/scalpel/scalpel_saveload.h"
+#include "sherlock/tattoo/widget_files.h"
 #include "common/system.h"
 #include "graphics/scaler.h"
 #include "graphics/thumbnail.h"
@@ -40,7 +41,7 @@ SaveManager *SaveManager::init(SherlockEngine *vm, const Common::String &target)
 	if (vm->getGameID() == GType_SerratedScalpel)
 		return new Scalpel::ScalpelSaveManager(vm, target);
 	else
-		return new SaveManager(vm, target);
+		return new Tattoo::WidgetFiles(vm, target);
 }
 
 SaveManager::SaveManager(SherlockEngine *vm, const Common::String &target) :
diff --git a/engines/sherlock/tattoo/tattoo_user_interface.cpp b/engines/sherlock/tattoo/tattoo_user_interface.cpp
index 01f927b..bbe93b5 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 652e5b1..a5a678f 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 4f58125..3a4e331 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<WidgetBase *>::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 149f80e..401dba6 100644
--- a/engines/sherlock/tattoo/widget_base.h
+++ b/engines/sherlock/tattoo/widget_base.h
@@ -80,6 +80,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
 	 */
 	virtual void drawBackground();
diff --git a/engines/sherlock/tattoo/widget_files.cpp b/engines/sherlock/tattoo/widget_files.cpp
index 37842bb..0666e17 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 6ef5aab..495a95c 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 eb18a8b..5c09a01 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 b50a557..9be0105 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 dc80a3d..f853e7f 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 e7da685..b8b640f 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() {}






More information about the Scummvm-git-logs mailing list