Browse Source

Added function to guiMenuBar to find a menu by name.

Areloch 7 years ago
parent
commit
cfe977584d
2 changed files with 23 additions and 1 deletions
  1. 22 1
      Engine/source/gui/editor/guiMenuBar.cpp
  2. 1 0
      Engine/source/gui/editor/guiMenuBar.h

+ 22 - 1
Engine/source/gui/editor/guiMenuBar.cpp

@@ -1472,6 +1472,17 @@ PopupMenu* GuiMenuBar::getMenu(U32 index)
    return mMenuList[index].popupMenu;
    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
 // 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")
 DefineConsoleMethod(GuiMenuBar, insert, void, (SimObject* pObject, S32 pos), (nullAsType<SimObject*>(), -1), "(object, pos) insert object at position")
 {
 {
    object->insert(pObject, pos);
    object->insert(pObject, pos);
-}
+}
+
+DefineConsoleMethod(GuiMenuBar, findMenu, S32, (StringTableEntry barTitle), (""), "(barTitle)")
+{
+   PopupMenu* menu = object->findMenu(barTitle);
+
+   if (menu)
+      return menu->getId();
+   else
+      return 0;
+}

+ 1 - 0
Engine/source/gui/editor/guiMenuBar.h

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