[Scummvm-cvs-logs] CVS: scummvm/sword1 menu.cpp,1.18,1.19 mouse.cpp,1.20,1.21 screen.cpp,1.32,1.33 screen.h,1.12,1.13

Torbj?rn Andersson eriktorbjorn at users.sourceforge.net
Wed Jan 7 11:04:02 CET 2004


Update of /cvsroot/scummvm/scummvm/sword1
In directory sc8-pr-cvs1:/tmp/cvs-serv21426

Modified Files:
	menu.cpp mouse.cpp screen.cpp screen.h 
Log Message:
Tried to make the menus behave a bit more like the original. Perhaps most
noticeably:

* It no longer matters where you release the mouse button when talking to
  someone. It uses whatever topic you selected on mouse-down.

* The inventory menu doesn't vanish if you're holding an object, even if
  you move the pointer away from it.

* When using an object on a character (to talk to him about it), the top
  menu fades away, rather than vanishing instantly.

Ok, that last change is rather non-obvious, but it does obsolete the
clearMenu() function, which has therefore been removed.


Index: menu.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword1/menu.cpp,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- menu.cpp	6 Jan 2004 12:45:34 -0000	1.18
+++ menu.cpp	7 Jan 2004 19:03:29 -0000	1.19
@@ -128,47 +128,66 @@
 		return 0;
 	uint16 x, y;
 	_mouse->giveCoords(&x, &y);
-	if (menuType == MENU_BOT) {
-		for (uint8 cnt = 0; cnt < SwordLogic::_scriptVars[IN_SUBJECT]; cnt++) {
-			if (_subjects[cnt]->wasClicked(x, y)) {
-				if (mouseEvent & BS1L_BUTTON_DOWN) {
-					SwordLogic::_scriptVars[OBJECT_HELD] = _subjectBar[cnt];
-					refreshMenus();
-				} else if (mouseEvent & BS1L_BUTTON_UP) {
-					if (SwordLogic::_scriptVars[OBJECT_HELD] == _subjectBar[cnt])
+	if (_subjectBarStatus == MENU_OPEN) {
+		// Conversation mode. Icons are highlighted on mouse-down, but
+		// the actual response is made on mouse-up.
+		if (menuType == MENU_BOT) {
+			if (SwordLogic::_scriptVars[OBJECT_HELD] && (mouseEvent & BS1L_BUTTON_UP)) {
+				for (uint8 cnt = 0; cnt < SwordLogic::_scriptVars[IN_SUBJECT]; cnt++) {
+					if (_subjectBar[cnt] == SwordLogic::_scriptVars[OBJECT_HELD])
 						return cnt + 1;
-					else {
-						SwordLogic::_scriptVars[OBJECT_HELD] = 0;
+				}
+			} else if (mouseEvent & BS1L_BUTTON_DOWN) {
+				for (uint8 cnt = 0; cnt < SwordLogic::_scriptVars[IN_SUBJECT]; cnt++) {
+					if (_subjects[cnt]->wasClicked(x, y)) {
+						SwordLogic::_scriptVars[OBJECT_HELD] = _subjectBar[cnt];
 						refreshMenus();
+						break;
+					}
+				}
+			}
+		} else {
+			if (SwordLogic::_scriptVars[OBJECT_HELD] && (mouseEvent & BS1L_BUTTON_UP)) {
+				for (uint8 cnt = 0; cnt < _inMenu; cnt++) {
+					if (_menuList[cnt] == SwordLogic::_scriptVars[OBJECT_HELD])
+						return cnt + 1;
+				}
+			} else if (mouseEvent & BS1L_BUTTON_DOWN) {
+				for (uint8 cnt = 0; cnt < _inMenu; cnt++) {
+					if (_objects[cnt]->wasClicked(x, y)) {
+						SwordLogic::_scriptVars[OBJECT_HELD] = _menuList[cnt];
+						refreshMenus();
+						break;
 					}
 				}
 			}
 		}
 	} else {
-		for (uint8 cnt = 0; cnt < _inMenu; cnt++) {
-			if (_objects[cnt]->wasClicked(x, y)) {
-				if (mouseEvent & BS1R_BUTTON_DOWN) { // looking at item
-					SwordLogic::_scriptVars[OBJECT_HELD] = _menuList[cnt];
-					SwordLogic::_scriptVars[MENU_LOOKING] = 1;
-					SwordLogic::_scriptVars[DEFAULT_ICON_TEXT] = _objectDefs[_menuList[cnt]].textDesc;
-					refreshMenus();
-				} else if (mouseEvent & BS1L_BUTTON_DOWN) {
-					if (SwordLogic::_scriptVars[OBJECT_HELD]) {
-						if (SwordLogic::_scriptVars[OBJECT_HELD] == _menuList[cnt]) {
-							_mouse->setLuggage(0, 0);
-							SwordLogic::_scriptVars[OBJECT_HELD] = 0; // reselected => deselect it
-						} else { // the player is clicking another item on this one.
-							   // run its use-script, if there is one
-							SwordLogic::_scriptVars[SECOND_ITEM] = _menuList[cnt];
-							_mouse->setLuggage(0, 0);
-						}
-					} else {
+		// Normal use, i.e. inventory. Things happen on mouse-down.
+		if (menuType == MENU_TOP) {
+			for (uint8 cnt = 0; cnt < _inMenu; cnt++) {
+				if (_objects[cnt]->wasClicked(x, y)) {
+					if (mouseEvent & BS1R_BUTTON_DOWN) { // looking at item
 						SwordLogic::_scriptVars[OBJECT_HELD] = _menuList[cnt];
-						_mouse->setLuggage(_objectDefs[_menuList[cnt]].luggageIconRes, 0);
-						refreshMenus();
-						return cnt + 1;
+						SwordLogic::_scriptVars[MENU_LOOKING] = 1;
+						SwordLogic::_scriptVars[DEFAULT_ICON_TEXT] = _objectDefs[_menuList[cnt]].textDesc;
+					} else if (mouseEvent & BS1L_BUTTON_DOWN) {
+						if (SwordLogic::_scriptVars[OBJECT_HELD]) {
+							if (SwordLogic::_scriptVars[OBJECT_HELD] == _menuList[cnt]) {
+								_mouse->setLuggage(0, 0);
+								SwordLogic::_scriptVars[OBJECT_HELD] = 0; // reselected => deselect it
+							} else { // the player is clicking another item on this one.
+								   // run its use-script, if there is one
+								SwordLogic::_scriptVars[SECOND_ITEM] = _menuList[cnt];
+								_mouse->setLuggage(0, 0);
+							}
+						} else {
+							SwordLogic::_scriptVars[OBJECT_HELD] = _menuList[cnt];
+							_mouse->setLuggage(_objectDefs[_menuList[cnt]].luggageIconRes, 0);
+						}
 					}
 					refreshMenus();
+					break;
 				}
 			}
 		}
@@ -352,5 +371,5 @@
 }
 
 void SwordMenu::cfnReleaseMenu(void) {
-	_screen->clearMenu(MENU_TOP);
+	_objectBarStatus = MENU_CLOSING;
 }

Index: mouse.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword1/mouse.cpp,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- mouse.cpp	6 Jan 2004 12:45:34 -0000	1.20
+++ mouse.cpp	7 Jan 2004 19:03:29 -0000	1.21
@@ -104,13 +104,15 @@
 	if (!SwordLogic::_scriptVars[TOP_MENU_DISABLED]) {
 		if (y < 40) { // okay, we are in the top menu.
 			if (!_inTopMenu) { // are we just entering it?
-				_menu->fnStartMenu();
+				if (!SwordLogic::_scriptVars[OBJECT_HELD])
+					_menu->fnStartMenu();
 				setPointer(MSE_POINTER, 0);
 			}
 			_menu->checkTopMenu();
 			_inTopMenu = true;
 		} else if (_inTopMenu) { // we're not in the menu. did we just leave it?
-			_menu->fnEndMenu();
+			if (!SwordLogic::_scriptVars[OBJECT_HELD])
+				_menu->fnEndMenu();
 			_inTopMenu = false;
 		}
 	} else if (_inTopMenu) {
@@ -144,7 +146,7 @@
 				_getOff = 0;
 			}
 			if (touchedId) { // there's something new selected, now.
-				if	(_objList[clicked].compact->o_mouse_on)	//run its get on
+				if (_objList[clicked].compact->o_mouse_on)	//run its get on
 					_logic->runMouseScript(_objList[clicked].compact, _objList[clicked].compact->o_mouse_on);
 
 				_getOff = _objList[clicked].compact->o_mouse_off; //setup get-off for later

Index: screen.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword1/screen.cpp,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -d -r1.32 -r1.33
--- screen.cpp	6 Jan 2004 12:45:34 -0000	1.32
+++ screen.cpp	7 Jan 2004 19:03:29 -0000	1.33
@@ -763,17 +763,6 @@
 	_system->copy_rect(frame, 40, x, y, 40, 40);
 }
 
-void SwordScreen::clearMenu(uint8 menuType) {
-	// isn't there a better way to do this?
-	uint8 *tmp = (uint8*)malloc(640 * 40);
-	memset(tmp, 0, 640 * 40);
-	if (menuType == MENU_BOT)
-		_system->copy_rect(tmp, 640, 0, 440, 640, 40);
-	else
-		_system->copy_rect(tmp, 640, 0, 0, 640, 40);
-	free(tmp);
-}
-
 // ------------------- router debugging code --------------------------------
 
 void SwordScreen::vline(uint16 x, uint16 y1, uint16 y2) {

Index: screen.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword1/screen.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- screen.h	6 Jan 2004 12:45:34 -0000	1.12
+++ screen.h	7 Jan 2004 19:03:30 -0000	1.13
@@ -82,7 +82,6 @@
 
 	void updateScreen(void);
 	void showFrame(uint16 x, uint16 y, uint32 resId, uint32 frameNo, const byte *fadeMask = NULL, int8 fadeStatus = 0);
-	void clearMenu(uint8 menuType);
 
 	void fnSetParallax(uint32 screen, uint32 resId);
 	void fnFlash(uint8 color);





More information about the Scummvm-git-logs mailing list