[Scummvm-cvs-logs] scummvm master -> 5dbe676011ec9d24030fd10ff3e213045798df12

urukgit urukgit at users.noreply.github.com
Fri Feb 14 04:56:13 CET 2014


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:
5dbe676011 AVALANCHE: Implement mouse control in Help.


Commit: 5dbe676011ec9d24030fd10ff3e213045798df12
    https://github.com/scummvm/scummvm/commit/5dbe676011ec9d24030fd10ff3e213045798df12
Author: uruk (koppirnyo at gmail.com)
Date: 2014-02-13T19:55:36-08:00

Commit Message:
AVALANCHE: Implement mouse control in Help.

Changed paths:
    engines/avalanche/graphics.cpp
    engines/avalanche/graphics.h
    engines/avalanche/help.cpp
    engines/avalanche/help.h



diff --git a/engines/avalanche/graphics.cpp b/engines/avalanche/graphics.cpp
index ec1446d..e1d9223 100644
--- a/engines/avalanche/graphics.cpp
+++ b/engines/avalanche/graphics.cpp
@@ -687,6 +687,17 @@ void GraphicManager::helpDrawButton(int y, byte which) {
 }
 
 /**
+ * @remarks	Originally called 'light'
+ */
+void GraphicManager::helpDrawHighlight(byte which, Color color) {
+	if (which == 177) // Dummy value for "no button at all".
+		return;
+
+	which &= 31;
+	drawRectangle(Common::Rect(466, 38 + which * 27, 555, 63 + which * 27), color);
+}
+
+/**
  * This function mimics Pascal's getimage().
  */
 Graphics::Surface GraphicManager::loadPictureGraphic(Common::File &file) {
diff --git a/engines/avalanche/graphics.h b/engines/avalanche/graphics.h
index 8e74b18..de7a07f 100644
--- a/engines/avalanche/graphics.h
+++ b/engines/avalanche/graphics.h
@@ -105,6 +105,7 @@ public:
 
 	// Help's function:
 	void helpDrawButton(int y, byte which);
+	void helpDrawHighlight(byte which, Color color);
 
 	void clearAlso();
 	void clearTextBar();
diff --git a/engines/avalanche/help.cpp b/engines/avalanche/help.cpp
index 9985e9e..5b8158e 100644
--- a/engines/avalanche/help.cpp
+++ b/engines/avalanche/help.cpp
@@ -36,8 +36,13 @@ namespace Avalanche {
 Help::Help(AvalancheEngine *vm) {
 	_vm = vm;
 
+	for (int i = 0; i < 10; i++) {
+		_buttons[i]._trigger = 0;
+		_buttons[i]._whither = 0;
+	}
 	_highlightWas = 0;
 	_buttonNum = 0;
+	_holdLeft = false;
 }
 
 /**
@@ -139,9 +144,59 @@ Common::String Help::getLine(Common::File &file) {
 	return line;
 }
 
-byte Help::checkMouse() {
-	warning("STUB: Help::checkMouse()");
-	return 0;
+bool Help::handleMouse(const Common::Event &event) {
+	Common::Point mousePos;
+	mousePos.x = event.mouse.x;
+	mousePos.y = event.mouse.y / 2;
+
+	int index = -1;
+
+	if (event.type == Common::EVENT_LBUTTONUP) { // Clicked *somewhere*...
+		_holdLeft = false;
+
+		if ((mousePos.x < 470) || (mousePos.x > 550) || (((mousePos.y - 13) % 27) > 20))
+			index = -1;
+		else // Clicked on a button. 
+			index = ((mousePos.y - 13) / 27) - 1;
+	} else { // LBUTTONDOWN or MOUSEMOVE
+		int highlightIs = 0;
+
+		if ((mousePos.x > 470) && (mousePos.x <= 550) && (((mousePos.y - 13) % 27) <= 20)) { // No click, so highlight.
+			highlightIs = (mousePos.y - 13) / 27 - 1;
+			if ((highlightIs < 0) || (5 < highlightIs))
+				highlightIs = 177; // In case of silly values.
+		} else
+			highlightIs = 177;
+
+		if (((highlightIs != 177) && (event.type == Common::EVENT_LBUTTONDOWN)) || _holdLeft) {
+			_holdLeft = true;
+			highlightIs += 32;
+		}
+
+		if (_highlightWas != highlightIs) {
+			_vm->_graphics->helpDrawHighlight(_highlightWas, kColorBlue);
+			_highlightWas = highlightIs;
+			if (_buttons[highlightIs & 31]._trigger != 0) {
+				if (highlightIs > 31)
+					_vm->_graphics->helpDrawHighlight(highlightIs, kColorLightcyan);
+				else
+					_vm->_graphics->helpDrawHighlight(highlightIs, kColorLightblue);
+			}
+		}
+	}
+
+	if ((index >= 0) && (_buttons[index]._trigger != 0)) {
+		if (_buttons[index]._trigger == 254)
+			return true;
+		else {
+			_vm->fadeOut();
+			switchPage(_buttons[index]._whither);
+			_vm->fadeIn();
+			return false;
+		}
+	}
+
+	return false;
 }
 
 bool Help::handleKeyboard(const Common::Event &event) {
@@ -164,18 +219,17 @@ bool Help::handleKeyboard(const Common::Event &event) {
 }
 
 void Help::continueHelp() {
-	warning("STUB: Help::continueHelp()");
-
 	bool close = false;
-	Common::Event event;
 	while (!_vm->shouldQuit() && !close) {
-		_vm->_graphics->refreshScreen();
+		Common::Event event;
 		_vm->getEvent(event);
-		if (event.type == Common::EVENT_KEYDOWN) {
+		if (event.type == Common::EVENT_KEYDOWN)
 			close = handleKeyboard(event);
-		}		
+		else if ((event.type == Common::EVENT_LBUTTONDOWN) || (event.type == Common::EVENT_LBUTTONUP) || (event.type == Common::EVENT_MOUSEMOVE))
+			close = handleMouse(event);
+
+		_vm->_graphics->refreshScreen();
 	}
-	
 }
 
 /**
diff --git a/engines/avalanche/help.h b/engines/avalanche/help.h
index 8ac552d..c63bacd 100644
--- a/engines/avalanche/help.h
+++ b/engines/avalanche/help.h
@@ -48,12 +48,16 @@ private:
 
 	Button _buttons[10];
 	byte _highlightWas;
-	byte _buttonNum; // How many buttons do we have on the screen at the moment.
+	byte _buttonNum; // How many buttons do we have on the screen at the moment?
+	bool _holdLeft; // Is the left mouse button is still being held?
 
 	void switchPage(byte which);
 	Common::String getLine(Common::File &file); // It was a nested function in getMe().
-	byte checkMouse(); // Returns clicked-on button, or 0 if none.
+
+	// These two return true if we have to leave the Help:
+	bool handleMouse(const Common::Event &event);
 	bool handleKeyboard(const Common::Event &event);
+
 	void continueHelp();
 };
 






More information about the Scummvm-git-logs mailing list