diff options
author | Filippos Karapetis | 2010-01-12 00:18:40 +0000 |
---|---|---|
committer | Filippos Karapetis | 2010-01-12 00:18:40 +0000 |
commit | dc45c729a99714c27f5ce9d35cdf67e5fbcd8159 (patch) | |
tree | 644277327301b544eba540acdd6e735116d4001e /engines | |
parent | 65f11afe896bb9408b1a70343bb9bd9fb276f397 (diff) | |
download | scummvm-rg350-dc45c729a99714c27f5ce9d35cdf67e5fbcd8159.tar.gz scummvm-rg350-dc45c729a99714c27f5ce9d35cdf67e5fbcd8159.tar.bz2 scummvm-rg350-dc45c729a99714c27f5ce9d35cdf67e5fbcd8159.zip |
Added mouse click handling for top menus (mouse clicks on menu items of each menu are not handled yet)
svn-id: r47260
Diffstat (limited to 'engines')
-rw-r--r-- | engines/sci/graphics/menu.cpp | 48 |
1 files changed, 47 insertions, 1 deletions
diff --git a/engines/sci/graphics/menu.cpp b/engines/sci/graphics/menu.cpp index 162b245119..80409c03d5 100644 --- a/engines/sci/graphics/menu.cpp +++ b/engines/sci/graphics/menu.cpp @@ -571,6 +571,7 @@ GuiMenuItemEntry *Menu::interactiveWithKeyboard() { 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 @@ GuiMenuItemEntry *Menu::interactiveWithKeyboard() { _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 @@ GuiMenuItemEntry *Menu::interactiveWithKeyboard() { } 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,7 +691,17 @@ GuiMenuItemEntry *Menu::interactiveWithKeyboard() { 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; } |