[Scummvm-cvs-logs] scummvm master -> 8ccc6331adadee6cb5c4d6582ce3af614be0850d

dreammaster dreammaster at scummvm.org
Fri Jul 24 18:07:11 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:
8ccc6331ad SHERLOCK: RT: Implement Quit dialog


Commit: 8ccc6331adadee6cb5c4d6582ce3af614be0850d
    https://github.com/scummvm/scummvm/commit/8ccc6331adadee6cb5c4d6582ce3af614be0850d
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2015-07-24T12:06:07-04:00

Commit Message:
SHERLOCK: RT: Implement Quit dialog

Changed paths:
    engines/sherlock/tattoo/tattoo_fixed_text.cpp
    engines/sherlock/tattoo/tattoo_fixed_text.h
    engines/sherlock/tattoo/widget_quit.cpp
    engines/sherlock/tattoo/widget_quit.h
    engines/sherlock/user_interface.h



diff --git a/engines/sherlock/tattoo/tattoo_fixed_text.cpp b/engines/sherlock/tattoo/tattoo_fixed_text.cpp
index a4c38c8..5d8df2f 100644
--- a/engines/sherlock/tattoo/tattoo_fixed_text.cpp
+++ b/engines/sherlock/tattoo/tattoo_fixed_text.cpp
@@ -97,7 +97,12 @@ static const char *const FIXED_TEXT_ENGLISH[] = {
 	"Transparent Menus",
 	"Change Font Style",
 	"Off",
-	"On"
+	"On",
+	"Quit",
+	"Are you sure you",
+	"wish to Quit ?",
+	"Yes",
+	"No"
 };
 
 TattooFixedText::TattooFixedText(SherlockEngine *vm) : FixedText(vm) {
diff --git a/engines/sherlock/tattoo/tattoo_fixed_text.h b/engines/sherlock/tattoo/tattoo_fixed_text.h
index e8fea93..e07d63f 100644
--- a/engines/sherlock/tattoo/tattoo_fixed_text.h
+++ b/engines/sherlock/tattoo/tattoo_fixed_text.h
@@ -98,7 +98,11 @@ enum FixedTextId {
 	kFixedText_ChangeFont,
 	kFixedText_Off,
 	kFixedText_On,
-	kFixedText_Quit
+	kFixedText_Quit,
+	kFixedText_AreYouSureYou,
+	kFixedText_WishToQuit,
+	kFixedText_Yes,
+	kFixedText_No
 };
 
 class TattooFixedText: public FixedText {
diff --git a/engines/sherlock/tattoo/widget_quit.cpp b/engines/sherlock/tattoo/widget_quit.cpp
index f1217ff..c44a488 100644
--- a/engines/sherlock/tattoo/widget_quit.cpp
+++ b/engines/sherlock/tattoo/widget_quit.cpp
@@ -22,13 +22,151 @@
 
 #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 {
 
 namespace Tattoo {
 
+WidgetQuit::WidgetQuit(SherlockEngine *vm) : WidgetBase(vm) {
+	_select = _oldSelect = -1;
+}
+
 void WidgetQuit::show() {
-	// TODO
+	Screen &screen = *_vm->_screen;
+	TattooUserInterface &ui = *(TattooUserInterface *)_vm->_ui;
+	ImageFile &images = *ui._interfaceImages;
+	const char *YES = FIXED(Yes);
+	const char *NO = FIXED(No);
+
+	// Set up the display area
+	_bounds = Common::Rect(_surface.stringWidth(FIXED(AreYouSureYou)) + _surface.widestChar() * 2,
+		(_surface.fontHeight() + 7) * 4);
+	_bounds.moveTo((SHERLOCK_SCREEN_WIDTH - _bounds.width()) / 2 + screen._currentScroll.x,
+		SHERLOCK_SCREEN_HEIGHT - _bounds.height() - 100);
+	
+	// Create the surface
+	_surface.create(_bounds.width(), _bounds.height());
+	_surface.fill(TRANSPARENCY);
+	makeInfoArea();
+
+	// Draw the message text
+	_surface.writeString(FIXED(AreYouSureYou), Common::Point((_surface.w() - _surface.stringWidth(FIXED(AreYouSureYou))) / 2, 5), INFO_TOP);
+	_surface.writeString(FIXED(WishToQuit), Common::Point((_surface.w() - _surface.stringWidth(FIXED(WishToQuit))) / 2,
+		_surface.fontHeight() + 9), INFO_TOP);
+
+	// Draw the horizontal bars seperating the commands and the message
+	int yp = (_surface.fontHeight() + 4) * 2 + 3;
+	for (int idx = 0; idx < 2; ++idx) {
+		_surface.transBlitFrom(images[4], Common::Point(0, yp - 1));
+		_surface.transBlitFrom(images[5], Common::Point(_surface.w() - images[5]._width, yp - 1));
+		_surface.hLine(3, yp, _surface.w() - 4, INFO_TOP);
+		_surface.hLine(3, yp + 1, _surface.w() - 4, INFO_MIDDLE);
+		_surface.hLine(3, yp + 2, _surface.w() - 4, INFO_BOTTOM);
+
+		const char *btn = (idx == 0) ? YES : NO;
+		_surface.writeString(btn, Common::Point((_bounds.width() - _surface.stringWidth(btn)) / 2, yp + 5), INFO_TOP);
+		yp += _surface.fontHeight() + 7;
+	}
+
+	ui._menuMode = QUIT_MODE;
+}
+
+void WidgetQuit::handleEvents() {
+	Events &events = *_vm->_events;
+	Talk &talk = *_vm->_talk;
+	Common::Point mousePos = events.mousePos();
+	Common::Rect btn1Rect(_bounds.left, _bounds.top + (_surface.fontHeight() + 4) * 2 + 3, _bounds.right,
+		_bounds.top + (_surface.fontHeight() + 4) * 2 + 3 + _surface.fontHeight() + 7);
+	Common::Rect btn2Rect(_bounds.left, _bounds.top + (_surface.fontHeight() + 4) * 2 + _surface.fontHeight() + 10,
+		_bounds.right, _bounds.top + (_surface.fontHeight() + 4) * 2 + 3 + _surface.fontHeight() + 7);
+
+	if (talk._talkToAbort)
+		return;
+
+	if (events.kbHit()) {
+		Common::KeyState keyState = events.getKey();
+
+		switch (keyState.keycode) {
+		case Common::KEYCODE_TAB:
+			_select = -1;
+
+			if (btn1Rect.contains(mousePos))
+				_select = 1;
+			else if (btn2Rect.contains(mousePos))
+				_select = 0;
+
+			// If the mouse is not over any of the options, move the mouse so that it points to the first option
+			if (_select == -1)
+				events.warpMouse(Common::Point(_bounds.right - 10, _bounds.top + (_surface.fontHeight() + 4) * 2
+					+ 3 + _surface.fontHeight() + 1));
+			else if (_select == 1)
+				events.warpMouse(Common::Point(mousePos.x, _bounds.top + (_surface.fontHeight() + 4) * 2
+					+ 3 + _surface.fontHeight() * 2 + 11));
+			else
+				events.warpMouse(Common::Point(mousePos.x, _bounds.top + (_surface.fontHeight() + 4) * 2
+					+ 3 + _surface.fontHeight() + 1));
+			break;
+
+		case Common::KEYCODE_ESCAPE:
+		case Common::KEYCODE_n:
+			close();
+			return;
+
+		case Common::KEYCODE_y:
+			close();
+			_vm->quitGame();
+			break;
+
+		default:
+			break;
+		}
+	}
+
+	// Check for highlight
+	_select = -1;
+	if (btn1Rect.contains(mousePos))
+		_select = 0;
+	else if (btn2Rect.contains(mousePos))
+		_select = 1;
+
+	if (_select != _oldSelect) {
+		// Highlight changed, 
+		byte color = (_select == 1) ? COMMAND_HIGHLIGHTED : INFO_TOP;
+		int yp = (_surface.fontHeight() + 4) * 2 + 8;
+		_surface.writeString(FIXED(Yes), Common::Point((_surface.w() - _surface.stringWidth(FIXED(Yes))) / 2, yp), color);
+		
+		color = (_select == 0) ? COMMAND_HIGHLIGHTED : INFO_TOP;
+		yp += (_surface.fontHeight() + 7);
+		_surface.writeString(FIXED(No), Common::Point((_surface.w() - _surface.stringWidth(FIXED(No))) / 2, yp), color);
+	}
+	_oldSelect = _select;
+
+	// Flag is they started pressing outside of the menu
+	if (events._firstPress && !_bounds.contains(mousePos))
+		_outsideMenu = true;
+
+	if (events._released || events._rightReleased) {
+		_select = -1;
+		_outsideMenu = false;
+
+		if (btn2Rect.contains(mousePos)) {
+			close();
+		} else if (btn1Rect.contains(mousePos)) {
+			close();
+			_vm->quitGame();
+		}
+	}
+}
+
+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
diff --git a/engines/sherlock/tattoo/widget_quit.h b/engines/sherlock/tattoo/widget_quit.h
index ab3702a..e7da685 100644
--- a/engines/sherlock/tattoo/widget_quit.h
+++ b/engines/sherlock/tattoo/widget_quit.h
@@ -33,14 +33,26 @@ class SherlockEngine;
 namespace Tattoo {
 
 class WidgetQuit: public WidgetBase {
+private:
+	int _select, _oldSelect;
+
+	/**
+	 * Close the dialog
+	 */
+	void close();
 public:
-	WidgetQuit(SherlockEngine *vm) : WidgetBase(vm) {}
+	WidgetQuit(SherlockEngine *vm);
 	virtual ~WidgetQuit() {}
 
 	/**
 	 * Prompt the user whether to quit
 	 */
 	void show();
+
+	/**
+	 * Handle event processing
+	 */
+	virtual void handleEvents();
 };
 
 } // End of namespace Tattoo
diff --git a/engines/sherlock/user_interface.h b/engines/sherlock/user_interface.h
index 75e005c..b6734fb 100644
--- a/engines/sherlock/user_interface.h
+++ b/engines/sherlock/user_interface.h
@@ -54,7 +54,8 @@ enum MenuMode {
 	LAB_MODE		= 20,
 	MESSAGE_MODE	= 21,
 	VERB_MODE		= 22,
-	OPTION_MODE		= 23
+	OPTION_MODE		= 23,
+	QUIT_MODE		= 24
 };
 
 class UserInterface {






More information about the Scummvm-git-logs mailing list