public virtual void OnItemMouseEnter(GUIMenu menu, int itemIndex) { //if this is the top level menu item we only expand if there is a sibling with an open menu if ((m_MenuSelStack.Count > 0 && m_MenuSelStack[0].m_Menu == menu) || m_MenuSelStack.Count == 0) { bool expand = false; for (int i = 0; i < menu.m_MenuItems.Length; i++) { if (!menu.m_MenuItems[i].m_SubMenu.m_Hidden) { expand = true; break; } } if (!expand) { return; } } //this stack keeps track of selections through the menu system if (itemIndex != -1) { //if the item does not already exist push the item on the stack and make its submenu visible //otherwise just toggle the visibility of the submenu GUIMenuSelection menuSel = new GUIMenuSelection(); menuSel.m_Menu = menu; menuSel.m_SelIndex = itemIndex; if (m_MenuSelStack.Find(x => (x.m_Menu == menuSel.m_Menu && x.m_SelIndex == menuSel.m_SelIndex)) == null) { UnwindMenuSelStack(menuSel); m_MenuSelStack.Add(menuSel); menuSel.GetSelectedMenuItemSubMenu().m_Hidden = false; } else { //toggle visibility bool hidden = menuSel.GetSelectedMenuItemSubMenu().m_Hidden; if (hidden) { menuSel.ShowSel(true); } } } }
//this method will hide all shown menus in the stack based on the selection //if the selection exists in the stack then we toggle the visibility of the selection's submenu public void UnwindMenuSelStack(GUIMenuSelection sel) { //if null is passed in, unwind the stack all the way if (sel == null) { while (m_MenuSelStack.Count > 0) { m_MenuSelStack.Last().ShowSel(false); m_MenuSelStack.RemoveAt(m_MenuSelStack.Count - 1); } } else { //unwind the stack to the selected menu, and hide all submenus in the stack while (m_MenuSelStack.Count > 0 && sel.m_Menu != m_MenuSelStack.Last().GetSelectedMenuItemSubMenu()) { m_MenuSelStack.Last().ShowSel(false); m_MenuSelStack.RemoveAt(m_MenuSelStack.Count - 1); } } }
public virtual void OnItemClick(GUIMenu menu, int itemIndex) { if (itemIndex != -1) { //only the top level menu items handle clicking if (m_MenuSelStack.Count == 0 || m_MenuSelStack[0].m_Menu == menu) { //if the item does not already exist push the item on the stack and make its submenu visible //otherwise just toggle the visibility of the submenu GUIMenuSelection menuSel = new GUIMenuSelection(); menuSel.m_Menu = menu; menuSel.m_SelIndex = itemIndex; if (m_MenuSelStack.Find(x => (x.m_Menu == menuSel.m_Menu && x.m_SelIndex == menuSel.m_SelIndex)) == null) { UnwindMenuSelStack(menuSel); m_MenuSelStack.Add(menuSel); menuSel.GetSelectedMenuItemSubMenu().m_Hidden = false; } else { //toggle visibility bool hidden = menuSel.GetSelectedMenuItemSubMenu().m_Hidden; if (hidden) { menuSel.ShowSel(true); } else { menuSel.GetSelectedMenuItemSubMenu().Show(false); } } } } }
//this method will hide all shown menus in the stack based on the selection //if the selection exists in the stack then we toggle the visibility of the selection's submenu public void UnwindMenuSelStack(GUIMenuSelection sel) { //if null is passed in, unwind the stack all the way if (sel == null) { while (m_MenuSelStack.Count > 0) { m_MenuSelStack.Last().ShowSel(false); m_MenuSelStack.RemoveAt(m_MenuSelStack.Count-1); } } else { //unwind the stack to the selected menu, and hide all submenus in the stack while (m_MenuSelStack.Count > 0 && sel.m_Menu != m_MenuSelStack.Last().GetSelectedMenuItemSubMenu()) { m_MenuSelStack.Last().ShowSel(false); m_MenuSelStack.RemoveAt(m_MenuSelStack.Count-1); } } }
public virtual void OnItemMouseEnter(GUIMenu menu, int itemIndex ) { //if this is the top level menu item we only expand if there is a sibling with an open menu if((m_MenuSelStack.Count > 0 && m_MenuSelStack[0].m_Menu == menu) || m_MenuSelStack.Count == 0) { bool expand = false; for(int i = 0; i < menu.m_MenuItems.Length; i++) { if(!menu.m_MenuItems[i].m_SubMenu.m_Hidden) { expand = true; break; } } if(!expand) return; } //this stack keeps track of selections through the menu system if (itemIndex != -1) { //if the item does not already exist push the item on the stack and make its submenu visible //otherwise just toggle the visibility of the submenu GUIMenuSelection menuSel = new GUIMenuSelection(); menuSel.m_Menu = menu; menuSel.m_SelIndex = itemIndex; if (m_MenuSelStack.Find(x => (x.m_Menu == menuSel.m_Menu && x.m_SelIndex == menuSel.m_SelIndex)) == null) { UnwindMenuSelStack(menuSel); m_MenuSelStack.Add(menuSel); menuSel.GetSelectedMenuItemSubMenu().m_Hidden = false; } else { //toggle visibility bool hidden = menuSel.GetSelectedMenuItemSubMenu().m_Hidden; if (hidden) { menuSel.ShowSel(true); } } } }
public virtual void OnItemClick(GUIMenu menu, int itemIndex ) { if (itemIndex != -1) { //only the top level menu items handle clicking if(m_MenuSelStack.Count == 0 || m_MenuSelStack[0].m_Menu == menu) { //if the item does not already exist push the item on the stack and make its submenu visible //otherwise just toggle the visibility of the submenu GUIMenuSelection menuSel = new GUIMenuSelection(); menuSel.m_Menu = menu; menuSel.m_SelIndex = itemIndex; if (m_MenuSelStack.Find(x => (x.m_Menu == menuSel.m_Menu && x.m_SelIndex == menuSel.m_SelIndex)) == null) { UnwindMenuSelStack(menuSel); m_MenuSelStack.Add(menuSel); menuSel.GetSelectedMenuItemSubMenu().m_Hidden = false; } else { //toggle visibility bool hidden = menuSel.GetSelectedMenuItemSubMenu().m_Hidden; if (hidden) { menuSel.ShowSel(true); } else { menuSel.GetSelectedMenuItemSubMenu().Show(false); } } } } }