[Scummvm-cvs-logs] CVS: scummvm/kyra gui.cpp,1.7,1.8 kyra.cpp,1.132,1.133 kyra.h,1.73,1.74

Oystein Eftevaag vinterstum at users.sourceforge.net
Sun Jan 22 14:08:04 CET 2006


Update of /cvsroot/scummvm/scummvm/kyra
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17616

Modified Files:
	gui.cpp kyra.cpp kyra.h 
Log Message:
Added highlighting to the menu buttons on mouseover.


Index: gui.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/kyra/gui.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- gui.cpp	22 Jan 2006 09:34:12 -0000	1.7
+++ gui.cpp	22 Jan 2006 22:06:33 -0000	1.8
@@ -413,6 +413,7 @@
 
 	_menuRestoreScreen = true;
 	while (_displayMenu) {
+		gui_processHighlights(_menu[0]);
 		processButtonList(_menuButtonList);
 		gui_getInput();
 	}
@@ -458,8 +459,8 @@
 		x1 = menu.x + menu.item[i].x;
 		y1 = menu.y + menu.item[i].y;
 
-		x2 = menu.x + menu.item[i].x + menu.item[i].width - 1;
-		y2 = menu.y + menu.item[i].y + menu.item[i].height - 1;
+		x2 = x1 + menu.item[i].width - 1;
+		y2 = y1 + menu.item[i].height - 1;
 
 		if (i < 6) {
 			_menuButtonData[i].nextButton = 0;
@@ -488,7 +489,7 @@
 		textY = y1 + 2;
 		_text->printText(menu.item[i].itemString, textX - 1, textY + 1,  12, 0, 0);
 
-		if (i == menu.field_14)
+		if (i == menu.highlightedItem)
 			_text->printText(menu.item[i].itemString, textX, textY, menu.item[i].highlightColor, 0, 0);
 		else
 			_text->printText(menu.item[i].itemString, textX, textY, menu.item[i].textColor, 0, 0);
@@ -602,13 +603,14 @@
 	_savegameOffset = 0;
 	setupSavegames(_menu[2], 5);
 	initMenu(_menu[2]);
+	processAllMenuButtons();
 
 	_displayLoadGameMenu = true;
 	_cancelLoadGameMenu = false;
 
 	while (_displayLoadGameMenu) {
 		gui_getInput();
-		//processHighlights();
+		gui_processHighlights(_menu[2]);
 		processButtonList(_menuButtonList);
 	}
 
@@ -672,7 +674,7 @@
 
 	while (_displayQuitConfirmDialog) {
 		gui_getInput();
-		//processHighlights();
+		gui_processHighlights(_menu[1]);
 		processButtonList(_menuButtonList);
 	}
 
@@ -723,5 +725,69 @@
 	return 0;
 }
 
+void KyraEngine::gui_processHighlights(Menu &menu) {
+	int x1, y1, x2, y2;
+
+	for (int i = 0; i < menu.nrOfItems; i++) {
+		if (!menu.item[i].enabled)
+			continue;
+
+		x1 = menu.x + menu.item[i].x;
+		y1 = menu.y + menu.item[i].y;
+
+		x2 = x1 + menu.item[i].width;
+		y2 = y1 + menu.item[i].height;
+
+		if (_mouseX > x1 && _mouseX < x2 &&
+			_mouseY > y1 && _mouseY < y2) {
+			
+			if (menu.highlightedItem != i) {
+				gui_redrawText(menu);
+				menu.highlightedItem = i;
+				gui_redrawHighlight(menu);
+				_screen->updateScreen();
+			}
+		}
+	}
+}
+
+void KyraEngine::gui_redrawText(Menu menu) {
+	int textX;
+	int i = menu.highlightedItem;
+
+	int x1 = menu.x + menu.item[i].x;
+	int y1 = menu.y + menu.item[i].y;
+
+	int x2 = x1 + menu.item[i].width - 1;
+
+	if (menu.item[i].field_12 != -1)
+		textX = x1 + menu.item[i].field_12 + 3;
+	else
+		textX = _text->getCenterStringX(menu.item[i].itemString, x1, x2);
+
+	int textY = y1 + 2;
+	_text->printText(menu.item[i].itemString, textX - 1, textY + 1,  12, 0, 0);
+	_text->printText(menu.item[i].itemString, textX, textY, menu.item[i].textColor, 0, 0);
+}
+
+void KyraEngine::gui_redrawHighlight(Menu menu) {
+	int textX;
+	int i = menu.highlightedItem;
+
+	int x1 = menu.x + menu.item[i].x;
+	int y1 = menu.y + menu.item[i].y;
+
+	int x2 = x1 + menu.item[i].width - 1;
+
+	if (menu.item[i].field_12 != -1)
+		textX = x1 + menu.item[i].field_12 + 3;
+	else
+		textX = _text->getCenterStringX(menu.item[i].itemString, x1, x2);
+
+	int textY = y1 + 2;
+	_text->printText(menu.item[i].itemString, textX - 1, textY + 1,  12, 0, 0);
+	_text->printText(menu.item[i].itemString, textX, textY, menu.item[i].highlightColor, 0, 0);
+}
+
 } // end of namespace Kyra
  

Index: kyra.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/kyra/kyra.cpp,v
retrieving revision 1.132
retrieving revision 1.133
diff -u -d -r1.132 -r1.133
--- kyra.cpp	22 Jan 2006 09:34:12 -0000	1.132
+++ kyra.cpp	22 Jan 2006 22:06:33 -0000	1.133
@@ -730,7 +730,7 @@
 }
 
 void KyraEngine::quitGame() {
-	res_unloadResources();
+	res_unloadResources(RES_ALL);
 
 	for (int i = 0; i < ARRAYSIZE(_movieObjects); ++i) {
 		_movieObjects[i]->close();

Index: kyra.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/kyra/kyra.h,v
retrieving revision 1.73
retrieving revision 1.74
diff -u -d -r1.73 -r1.74
--- kyra.h	22 Jan 2006 16:48:13 -0000	1.73
+++ kyra.h	22 Jan 2006 22:06:34 -0000	1.74
@@ -205,7 +205,7 @@
 	uint8 textColor;
 	int16 field_10;
 	uint16 field_12;
-	uint16 field_14;
+	uint16 highlightedItem;
 	uint8 nrOfItems;
 	int16 scrollUpBtnX;
 	int16 scrollUpBtnY;
@@ -672,6 +672,9 @@
 
 	bool gui_quitConfirm(const char *str);
 	void gui_getInput();
+	void gui_redrawText(Menu menu);
+	void gui_redrawHighlight(Menu menu);
+	void gui_processHighlights(Menu &menu);
 
 	uint8 _game;
 	bool _fastMode;





More information about the Scummvm-git-logs mailing list