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

dreammaster dreammaster at scummvm.org
Fri Jul 24 04:57:42 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:
c4736c274e SHERLOCK: RT: Implement Options dialog event handling


Commit: c4736c274e3c2e16791df730d5b82a40b90f882f
    https://github.com/scummvm/scummvm/commit/c4736c274e3c2e16791df730d5b82a40b90f882f
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2015-07-23T22:56:42-04:00

Commit Message:
SHERLOCK: RT: Implement Options dialog event handling

Changed paths:
  A engines/sherlock/tattoo/widget_quit.cpp
  A engines/sherlock/tattoo/widget_quit.h
    engines/sherlock/module.mk
    engines/sherlock/sound.cpp
    engines/sherlock/sound.h
    engines/sherlock/tattoo/tattoo.h
    engines/sherlock/tattoo/tattoo_user_interface.cpp
    engines/sherlock/tattoo/tattoo_user_interface.h
    engines/sherlock/tattoo/widget_options.cpp
    engines/sherlock/tattoo/widget_options.h



diff --git a/engines/sherlock/module.mk b/engines/sherlock/module.mk
index 259c921..3af8986 100644
--- a/engines/sherlock/module.mk
+++ b/engines/sherlock/module.mk
@@ -38,6 +38,7 @@ MODULE_OBJS = \
 	tattoo/widget_inventory.o \
 	tattoo/widget_lab.o \
 	tattoo/widget_options.o \
+	tattoo/widget_quit.o \
 	tattoo/widget_talk.o \
 	tattoo/widget_text.o \
 	tattoo/widget_tooltip.o \
diff --git a/engines/sherlock/sound.cpp b/engines/sherlock/sound.cpp
index 425c321..e63efee 100644
--- a/engines/sherlock/sound.cpp
+++ b/engines/sherlock/sound.cpp
@@ -266,5 +266,9 @@ Audio::SoundHandle Sound::getFreeSoundHandle() {
 	error("getFreeSoundHandle: No sound handle found");
 }
 
+void Sound::setVolume(int volume) {
+	warning("TODO: setVolume - %d", volume);
+}
+
 } // End of namespace Sherlock
 
diff --git a/engines/sherlock/sound.h b/engines/sherlock/sound.h
index 7975478..d757646 100644
--- a/engines/sherlock/sound.h
+++ b/engines/sherlock/sound.h
@@ -99,6 +99,8 @@ public:
 	void freeDigiSound();
 
 	Audio::SoundHandle getFreeSoundHandle();
+
+	void setVolume(int volume);
 };
 
 } // End of namespace Sherlock
diff --git a/engines/sherlock/tattoo/tattoo.h b/engines/sherlock/tattoo/tattoo.h
index 6885f51..923afa3 100644
--- a/engines/sherlock/tattoo/tattoo.h
+++ b/engines/sherlock/tattoo/tattoo.h
@@ -87,7 +87,15 @@ public:
 	TattooEngine(OSystem *syst, const SherlockGameDescription *gameDesc);
 	virtual ~TattooEngine();
 
+	/**
+	 * Shows the hangman puzzle
+	 */
 	void doHangManPuzzle();
+
+	/**
+	 * Save the game configuration
+	 */
+	void saveConfig() {}
 };
 
 } // End of namespace Tattoo
diff --git a/engines/sherlock/tattoo/tattoo_user_interface.cpp b/engines/sherlock/tattoo/tattoo_user_interface.cpp
index 528be5f..ef9e895 100644
--- a/engines/sherlock/tattoo/tattoo_user_interface.cpp
+++ b/engines/sherlock/tattoo/tattoo_user_interface.cpp
@@ -374,15 +374,13 @@ void TattooUserInterface::doStandardControl() {
 	case Common::KEYCODE_F5:
 		// Save game
 		freeMenu();
-		_fileMode = SAVEMODE_SAVE;
-		initFileMenu();
+		saveGame();
 		return;
 
 	case Common::KEYCODE_F7:
 		// Load game
 		freeMenu();
-		_fileMode = SAVEMODE_LOAD;
-		initFileMenu();
+		loadGame();
 		return;
 
 	case Common::KEYCODE_F1:
@@ -882,6 +880,16 @@ void TattooUserInterface::clearWindow() {
 	banishWindow();
 }
 
+void TattooUserInterface::loadGame() {
+	_fileMode = SAVEMODE_LOAD;
+	// TODO
+}
+
+void TattooUserInterface::saveGame() {
+	_fileMode = SAVEMODE_SAVE;
+	// TODO
+}
+
 } // End of namespace Tattoo
 
 } // End of namespace Sherlock
diff --git a/engines/sherlock/tattoo/tattoo_user_interface.h b/engines/sherlock/tattoo/tattoo_user_interface.h
index 5b3c7ea..790c892 100644
--- a/engines/sherlock/tattoo/tattoo_user_interface.h
+++ b/engines/sherlock/tattoo/tattoo_user_interface.h
@@ -204,6 +204,16 @@ public:
 	 * If there is no object being pointed it, clear any previously displayed name
 	 */
 	void displayObjectNames();
+
+	/**
+	 * Show the load game dialog, and allow the user to load a game
+	 */
+	void loadGame();
+
+	/**
+	 * Show the save game dialog, and allow the user to save the game
+	 */
+	void saveGame();
 public:
 	/**
 	 * Resets the user interface
diff --git a/engines/sherlock/tattoo/widget_options.cpp b/engines/sherlock/tattoo/widget_options.cpp
index 16d1d14..a96fcf4 100644
--- a/engines/sherlock/tattoo/widget_options.cpp
+++ b/engines/sherlock/tattoo/widget_options.cpp
@@ -23,13 +23,14 @@
 #include "sherlock/tattoo/widget_options.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 {
 
 namespace Tattoo {
 
-WidgetOptions::WidgetOptions(SherlockEngine *vm) : WidgetBase(vm) {
+WidgetOptions::WidgetOptions(SherlockEngine *vm) : WidgetBase(vm), _quitWidget(vm) {
 	_midiSliderX = _digiSliderX = 0;
 	_selector = _oldSelector = -1;
 }
@@ -56,8 +57,192 @@ void WidgetOptions::load() {
 }
 
 void WidgetOptions::handleEvents() {
+	TattooEngine &vm = *(TattooEngine *)_vm;
 	Events &events = *_vm->_events;
-	// TODO
+	Music &music = *_vm->_music;
+	Screen &screen = *_vm->_screen;
+	Sound &sound = *_vm->_sound;
+	Talk &talk = *_vm->_talk;
+	TattooUserInterface &ui = *(TattooUserInterface *)_vm->_ui;
+	Common::Point mousePos = events.mousePos();
+
+	if (talk._talkToAbort) {
+		sound.stopSound();
+		return;
+	}
+
+	// Flag if they started pressing outside the window
+	if (events._firstPress && !_bounds.contains(mousePos))
+		_outsideMenu = true;
+
+	if (events.kbHit()) {
+		ui._keyState = events.getKey();
+
+		// Emulate a mouse release if Enter or Space Bar is pressed
+		if (ui._keyState.keycode == Common::KEYCODE_RETURN || ui._keyState.keycode == Common::KEYCODE_SPACE) {
+			events._pressed  = events._oldButtons = false;
+			events._released = true;
+		} else if (ui._keyState.keycode == Common::KEYCODE_ESCAPE) {
+			close();
+			return;
+		} else {
+			checkTabbingKeys(11);
+		}
+	}
+
+	// Check highlighting the various controls
+	if (_bounds.contains(mousePos)) {
+		_selector = (mousePos.y - _bounds.top) / (_surface.fontHeight() + 7);
+
+		// If one of the sliders has been selected, & the mouse is not pressed, reset the selector to -1
+		if ((_selector == 3 || _selector == 6) && !events._pressed)
+			_selector = -1;
+	} else {
+		_selector = -1;
+		if (_outsideMenu && (events._released || events._rightReleased)) {
+			close();
+			return;
+		}
+	}
+
+	// If the selected control has changed, redraw the dialog contents
+	if (_selector != _oldSelector)
+		render(OP_CONTENTS);
+	_oldSelector = _selector;
+
+	// Adjust the Volume Sliders (if neccessary) here
+	switch (_selector) {
+	case 3: {
+		// Set Music Volume
+		_midiSliderX = mousePos.x - _bounds.left;
+		if (_midiSliderX < _surface.widestChar())
+			_midiSliderX = _surface.widestChar();
+		else
+			if (_midiSliderX > _bounds.width() - _surface.widestChar())
+				_midiSliderX = _bounds.width() - _surface.widestChar();
+
+		int temp = music._musicVolume;
+		music._musicVolume = (_midiSliderX - _surface.widestChar()) * 127 / (_bounds.width() - _surface.widestChar() * 2);
+		if (music._musicVolume != temp) {
+			music.setMIDIVolume(music._musicVolume);
+			vm.saveConfig();
+		}
+
+		render(OP_NAMES);
+		break;
+	}
+
+	case 6: {
+		// Set Digitized Volume
+		_digiSliderX = mousePos.x - _bounds.left;
+		if (_digiSliderX < _surface.widestChar())
+			_digiSliderX = _surface.widestChar();
+		else if (_digiSliderX > _bounds.width() - _surface.widestChar())
+			_digiSliderX = _bounds.width() - _surface.widestChar();
+
+		int temp = sound._soundVolume;
+		sound._soundVolume = (_digiSliderX - _surface.widestChar()) * 15 / (_bounds.width() - _surface.widestChar() * 2);
+		if (sound._soundVolume != temp) {
+			sound.setVolume(sound._soundVolume);
+			vm.saveConfig();
+		}
+
+		render(OP_NAMES);
+		break;
+	}
+
+	default:
+		break;
+	}
+
+	// Option selected
+	if (events._released || events._rightReleased) {
+		_outsideMenu = false;
+		int temp = _selector;
+		_selector = 255;
+
+		switch (temp) {
+		case 0:
+			// Load Game
+			close();
+			ui.loadGame();
+			break;
+
+		case 1:
+			// Save Game
+			close();
+			ui.saveGame();
+			break;
+
+		case 2:
+			// Toggle Music
+			music._musicOn = !music._musicOn;
+			if (!music._musicOn)
+				music.stopMusic();
+			else
+				music.startSong();
+
+			render(OP_NAMES);
+			vm.saveConfig();
+			break;
+
+		case 4:
+			// Toggle Sound Effects
+			sound.stopSound();
+			sound._digitized = !sound._digitized;
+
+			render(OP_NAMES);
+			vm.saveConfig();
+			break;
+
+		case 5:
+			// Toggle Voices
+			sound._voices = !sound._voices;
+
+			render(OP_NAMES);
+			vm.saveConfig();
+			break;
+			
+		case 7:
+			// Toggle Text Windows
+			vm._textWindowsOn = !vm._textWindowsOn;
+
+			render(OP_NAMES);
+			vm.saveConfig();
+			break;
+
+		case 8: {
+			// New Font Style
+			int fontNumber = screen.fontNumber() + 1;
+			if (fontNumber == 7)
+				fontNumber = 0;
+			screen.setFont(fontNumber);
+
+			render(OP_CONTENTS);
+			vm.saveConfig();
+			break;
+		}
+
+		case 9:
+			// Toggle Transparent Menus
+			vm._transparentMenus = !vm._transparentMenus;
+
+			render(OP_CONTENTS);
+			vm.saveConfig();
+			break;
+
+		case 10:
+			// Quit
+			banishWindow();
+			_quitWidget.show();
+			break;
+
+		default:
+			break;
+		}
+		
+		_oldSelector = -1;
+	}
 }
 
 void WidgetOptions::render(OptionRenderMode mode) {
@@ -192,6 +377,14 @@ 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 b76aed9..213704f 100644
--- a/engines/sherlock/tattoo/widget_options.h
+++ b/engines/sherlock/tattoo/widget_options.h
@@ -25,6 +25,7 @@
 
 #include "common/scummsys.h"
 #include "sherlock/tattoo/widget_base.h"
+#include "sherlock/tattoo/widget_quit.h"
 
 namespace Sherlock {
 
@@ -41,11 +42,17 @@ class WidgetOptions : public WidgetBase {
 private:
 	int _midiSliderX, _digiSliderX;
 	int _selector, _oldSelector;
+	WidgetQuit _quitWidget;
 
 	/**
 	 * 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
new file mode 100644
index 0000000..f1217ff
--- /dev/null
+++ b/engines/sherlock/tattoo/widget_quit.cpp
@@ -0,0 +1,36 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "sherlock/tattoo/widget_quit.h"
+#include "sherlock/tattoo/tattoo.h"
+
+namespace Sherlock {
+
+namespace Tattoo {
+
+void WidgetQuit::show() {
+	// TODO
+}
+
+} // End of namespace Tattoo
+
+} // End of namespace Sherlock
diff --git a/engines/sherlock/tattoo/widget_quit.h b/engines/sherlock/tattoo/widget_quit.h
new file mode 100644
index 0000000..ab3702a
--- /dev/null
+++ b/engines/sherlock/tattoo/widget_quit.h
@@ -0,0 +1,50 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef SHERLOCK_TATTOO_WIDGET_QUIT_H
+#define SHERLOCK_TATTOO_WIDGET_QUIT_H
+
+#include "common/scummsys.h"
+#include "sherlock/tattoo/widget_base.h"
+
+namespace Sherlock {
+
+class SherlockEngine;
+
+namespace Tattoo {
+
+class WidgetQuit: public WidgetBase {
+public:
+	WidgetQuit(SherlockEngine *vm) : WidgetBase(vm) {}
+	virtual ~WidgetQuit() {}
+
+	/**
+	 * Prompt the user whether to quit
+	 */
+	void show();
+};
+
+} // End of namespace Tattoo
+
+} // End of namespace Sherlock
+
+#endif






More information about the Scummvm-git-logs mailing list