[Scummvm-cvs-logs] SF.net SVN: scummvm:[47260] scummvm/trunk/engines/sci/graphics/menu.cpp
thebluegr at users.sourceforge.net
thebluegr at users.sourceforge.net
Tue Jan 12 01:18:40 CET 2010
Revision: 47260
http://scummvm.svn.sourceforge.net/scummvm/?rev=47260&view=rev
Author: thebluegr
Date: 2010-01-12 00:18:40 +0000 (Tue, 12 Jan 2010)
Log Message:
-----------
Added mouse click handling for top menus (mouse clicks on menu items of each menu are not handled yet)
Modified Paths:
--------------
scummvm/trunk/engines/sci/graphics/menu.cpp
Modified: scummvm/trunk/engines/sci/graphics/menu.cpp
===================================================================
--- scummvm/trunk/engines/sci/graphics/menu.cpp 2010-01-11 21:45:48 UTC (rev 47259)
+++ scummvm/trunk/engines/sci/graphics/menu.cpp 2010-01-12 00:18:40 UTC (rev 47260)
@@ -571,6 +571,7 @@
uint16 newItemId = _curItemId;
GuiMenuItemEntry *curItemEntry = findItem(_curMenuId, _curItemId);
GuiMenuItemEntry *newItemEntry = curItemEntry;
+ uint16 cursorX, curX = 0;
// We don't 100% follow sierra here: we select last item instead of selecting first item of first menu everytime
@@ -587,6 +588,9 @@
_gfx->BitsShow(_gfx->_menuBarRect);
_gfx->BitsShow(_menuRect);
+ // Show mouse cursor when the menu appears
+ ((SciEngine *)g_engine)->getEngineState()->_gui->showCursor();
+
while (true) {
curEvent = _event->get(SCI_EVENT_ANY);
@@ -645,6 +649,38 @@
}
break;
+ case SCI_EVENT_MOUSE_PRESS:
+ if (_cursor->getPosition().y < 10) {
+ cursorX = _cursor->getPosition().x;
+ curX = 0;
+
+ for (GuiMenuList::iterator menuIterator = _list.begin(); menuIterator != _list.end(); menuIterator++) {
+ if (cursorX >= curX && cursorX <= curX + (*menuIterator)->textWidth) {
+ newMenuId = (*menuIterator)->id; newItemId = 1;
+ newItemEntry = interactiveGetItem(newMenuId, newItemId, newMenuId != curItemEntry->menuId);
+ break;
+ }
+
+ curX += (*menuIterator)->textWidth;
+ }
+
+ if ((newMenuId != curItemEntry->menuId) || (newItemId != curItemEntry->id)) {
+ // paint old and new
+ if (newMenuId != curItemEntry->menuId) {
+ // Menu changed, remove cur menu and paint new menu
+ drawMenu(curItemEntry->menuId, newMenuId);
+ } else {
+ invertMenuSelection(curItemEntry->id);
+ }
+ invertMenuSelection(newItemId);
+
+ curItemEntry = newItemEntry;
+ }
+ }
+
+ // TODO: Handle mouse clicks for the menu items of each menu (i.e. when y >= 10)
+
+ break;
case SCI_EVENT_NONE:
kernel_sleep(_event, 2500 / 1000);
break;
@@ -655,8 +691,18 @@
GuiMenuItemEntry *Menu::interactiveWithMouse() {
calculateTextWidth();
- // TODO
+ int16 cursorX = _cursor->getPosition().x;
+ int16 curX = 0;
+ for (GuiMenuList::iterator menuIterator = _list.begin(); menuIterator != _list.end(); menuIterator++) {
+ if (cursorX >= curX && cursorX <= curX + (*menuIterator)->textWidth) {
+ _curMenuId = (*menuIterator)->id;
+ return interactiveWithKeyboard();
+ }
+
+ curX += (*menuIterator)->textWidth;
+ }
+
return NULL;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list