diff options
author | Martin Kiewitz | 2010-01-12 20:51:45 +0000 |
---|---|---|
committer | Martin Kiewitz | 2010-01-12 20:51:45 +0000 |
commit | 1ebe047972e2df513449db6aa615f6ab17dd6fb7 (patch) | |
tree | be458571055dbd6be6c0b43c4cb52e7a727bbe42 /engines | |
parent | a62bf2528f1cf8660b87015f135d70c846fb581d (diff) | |
download | scummvm-rg350-1ebe047972e2df513449db6aa615f6ab17dd6fb7.tar.gz scummvm-rg350-1ebe047972e2df513449db6aa615f6ab17dd6fb7.tar.bz2 scummvm-rg350-1ebe047972e2df513449db6aa615f6ab17dd6fb7.zip |
SCI: using _menuRect inside Menu::mouseFindMenuItemSelection for easier code, also fixed stupid oversight that made the code crash in e.g. lsl6
svn-id: r47278
Diffstat (limited to 'engines')
-rw-r--r-- | engines/sci/graphics/menu.cpp | 27 |
1 files changed, 1 insertions, 26 deletions
diff --git a/engines/sci/graphics/menu.cpp b/engines/sci/graphics/menu.cpp index 4466678fd2..6c69586d0c 100644 --- a/engines/sci/graphics/menu.cpp +++ b/engines/sci/graphics/menu.cpp @@ -601,31 +601,16 @@ uint16 Menu::mouseFindMenuSelection(Common::Point mousePosition) { } uint16 Menu::mouseFindMenuItemSelection(Common::Point mousePosition, uint16 menuId) { - GuiMenuEntry *listEntry; - GuiMenuList::iterator listIterator; - GuiMenuList::iterator listEnd = _list.end(); - uint16 curXstart = 8; - uint16 curXend = curXstart; GuiMenuItemEntry *listItemEntry; GuiMenuItemList::iterator listItemIterator; GuiMenuItemList::iterator listItemEnd = _itemList.end(); uint16 curYstart = 10; - int16 maxTextWidth = 0, maxTextRightAlignedWidth = 0; uint16 itemId = 0; if (!menuId) error("No menu active, but mouseFindMenuItemSelection() called"); - listIterator = _list.begin(); - while (listIterator != listEnd) { - listEntry = *listIterator; - if (listEntry->id == menuId) - break; - curXstart += listEntry->textWidth; - listIterator++; - } - - if (mousePosition.x < curXstart) + if ((mousePosition.x < _menuRect.left) || (mousePosition.x >= _menuRect.right)) return 0; listItemIterator = _itemList.begin(); @@ -636,20 +621,10 @@ uint16 Menu::mouseFindMenuItemSelection(Common::Point mousePosition, uint16 menu // Found it if ((!itemId) && (curYstart > mousePosition.y)) itemId = listItemEntry->id; - maxTextWidth = MAX<int16>(maxTextWidth, listItemEntry->textWidth); - maxTextRightAlignedWidth = MAX<int16>(maxTextRightAlignedWidth, listItemEntry->textRightAlignedWidth); } listItemIterator++; } - curXend = curXstart + 16 + 4 + 2; - curXend += maxTextWidth + maxTextRightAlignedWidth; - if (!maxTextRightAlignedWidth) - _menuRect.right -= 5; - - // Verify that horizontal position is correct - if (mousePosition.x >= curXend) - return 0; return itemId; } |