From aaaab9ec34bdb52d40b33295293fdbeab4568a93 Mon Sep 17 00:00:00 2001 From: Martin Kiewitz Date: Sun, 25 Apr 2010 09:35:34 +0000 Subject: SCI: fix regression of r48659 - now calculating menu width and splitting text on kernelDrawMenuBar() as well - fixes menu not displaying all the time in hoyle 1&2 svn-id: r48791 --- engines/sci/graphics/menu.cpp | 22 +++++++++++++++------- engines/sci/graphics/menu.h | 3 ++- 2 files changed, 17 insertions(+), 8 deletions(-) (limited to 'engines/sci') diff --git a/engines/sci/graphics/menu.cpp b/engines/sci/graphics/menu.cpp index 46df316932..0241721aa1 100644 --- a/engines/sci/graphics/menu.cpp +++ b/engines/sci/graphics/menu.cpp @@ -339,14 +339,11 @@ void GfxMenu::drawBar() { } } -// This helper calculates all text widths for all menus/items -void GfxMenu::calculateTextWidth() { +// This helper calculates all text widths for all menus (only) +void GfxMenu::calculateMenuWidth() { GuiMenuList::iterator menuIterator; GuiMenuList::iterator menuEnd = _list.end(); GuiMenuEntry *menuEntry; - GuiMenuItemList::iterator itemIterator; - GuiMenuItemList::iterator itemEnd = _itemList.end(); - GuiMenuItemEntry *itemEntry; int16 dummyHeight; menuIterator = _list.begin(); @@ -357,6 +354,16 @@ void GfxMenu::calculateTextWidth() { menuIterator++; } +} + +// This helper calculates all text widths for all menus/items +void GfxMenu::calculateMenuAndItemWidth() { + GuiMenuItemList::iterator itemIterator; + GuiMenuItemList::iterator itemEnd = _itemList.end(); + GuiMenuItemEntry *itemEntry; + int16 dummyHeight; + + calculateMenuWidth(); itemIterator = _itemList.begin(); while (itemIterator != itemEnd) { @@ -680,7 +687,7 @@ GuiMenuItemEntry *GfxMenu::interactiveWithKeyboard() { // We don't 100% follow sierra here: we select last item instead of selecting first item of first menu everytime // Also sierra sci didnt allow mouse interaction, when menu was activated via keyboard - calculateTextWidth(); + calculateMenuAndItemWidth(); _oldPort = _ports->setPort(_ports->_menuPort); _barSaveHandle = _paint16->bitsSave(_ports->_menuRect, SCI_SCREEN_MASK_VISUAL); @@ -801,7 +808,7 @@ GuiMenuItemEntry *GfxMenu::interactiveWithMouse() { bool firstMenuChange = true; GuiMenuItemEntry *curItemEntry = NULL; - calculateTextWidth(); + calculateMenuAndItemWidth(); _oldPort = _ports->setPort(_ports->_menuPort); _barSaveHandle = _paint16->bitsSave(_ports->_menuRect, SCI_SCREEN_MASK_VISUAL); @@ -874,6 +881,7 @@ void GfxMenu::kernelDrawStatus(const char *text, int16 colorPen, int16 colorBack void GfxMenu::kernelDrawMenuBar(bool clear) { if (!clear) { Port *oldPort = _ports->setPort(_ports->_menuPort); + calculateMenuWidth(); drawBar(); _paint16->bitsShow(_ports->_menuBarRect); _ports->setPort(oldPort); diff --git a/engines/sci/graphics/menu.h b/engines/sci/graphics/menu.h index 3730cb49ae..8f23b46ff8 100644 --- a/engines/sci/graphics/menu.h +++ b/engines/sci/graphics/menu.h @@ -99,7 +99,8 @@ public: private: GuiMenuItemEntry *findItem(uint16 menuId, uint16 itemId); - void calculateTextWidth(); + void calculateMenuWidth(); + void calculateMenuAndItemWidth(); void drawMenu(uint16 oldMenuId, uint16 newMenuId); void invertMenuSelection(uint16 itemId); void interactiveShowMouse(); -- cgit v1.2.3