Added function to guiMenuBar to find a menu by name.

This commit is contained in:
Areloch 2018-01-28 15:14:16 -06:00
parent 727592d63a
commit cfe977584d
2 changed files with 23 additions and 1 deletions

View file

@ -1472,6 +1472,17 @@ PopupMenu* GuiMenuBar::getMenu(U32 index)
return mMenuList[index].popupMenu;
}
PopupMenu* GuiMenuBar::findMenu(StringTableEntry barTitle)
{
for (U32 i = 0; i < mMenuList.size(); i++)
{
if (mMenuList[i].text == barTitle)
return mMenuList[i].popupMenu;
}
return nullptr;
}
//-----------------------------------------------------------------------------
// Console Methods
//-----------------------------------------------------------------------------
@ -1506,4 +1517,14 @@ DefineConsoleMethod(GuiMenuBar, getMenu, S32, (S32 index), (0), "(Index)")
DefineConsoleMethod(GuiMenuBar, insert, void, (SimObject* pObject, S32 pos), (nullAsType<SimObject*>(), -1), "(object, pos) insert object at position")
{
object->insert(pObject, pos);
}
}
DefineConsoleMethod(GuiMenuBar, findMenu, S32, (StringTableEntry barTitle), (""), "(barTitle)")
{
PopupMenu* menu = object->findMenu(barTitle);
if (menu)
return menu->getId();
else
return 0;
}

View file

@ -116,6 +116,7 @@ public:
U32 getMenuListCount() { return mMenuList.size(); }
PopupMenu* getMenu(U32 index);
PopupMenu* findMenu(StringTableEntry barTitle);
DECLARE_CONOBJECT(GuiMenuBar);
DECLARE_CALLBACK( void, onMouseInMenu, ( bool hasLeftMenu ));