Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_MenuToolsLib.c
Go to the documentation of this file.
1 
6 {
7  protected static const int MENU_CLOSE_FALLBACK = 10;
8 
9  protected static MenuManager m_MenuMgr;
10 
11  //------------------------------------------------------------------------------------------------
12  // Invokers
13  //------------------------------------------------------------------------------------------------
14 
15  protected static ref ScriptInvoker<> Event_OnAllMenuClosed;
16 
17  //------------------------------------------------------------------------------------------------
18  protected static void InvokeEventOnAllMenuClosed()
19  {
20  if (Event_OnAllMenuClosed)
21  Event_OnAllMenuClosed.Invoke();
22  }
23 
24  //------------------------------------------------------------------------------------------------
25  static ScriptInvoker GetEventOnAllMenuClosed()
26  {
27  if (!Event_OnAllMenuClosed)
28  Event_OnAllMenuClosed = new ScriptInvoker();
29 
30  return Event_OnAllMenuClosed;
31  }
32 
33  //------------------------------------------------------------------------------------------------
34  // Public
35  //------------------------------------------------------------------------------------------------
36 
37  //------------------------------------------------------------------------------------------------
39  static void CloseAllMenus(array<typename> menus)
40  {
41  if (!m_MenuMgr)
42  m_MenuMgr = GetGame().GetMenuManager();
43 
44  CloseTopMenu(menus, MENU_CLOSE_FALLBACK);
45  }
46 
47  //------------------------------------------------------------------------------------------------
48  // Protected
49  //------------------------------------------------------------------------------------------------
50 
51  //------------------------------------------------------------------------------------------------
52  protected static void CloseTopMenu(array<typename> menus, int calls)
53  {
54  //MainMenuUI mainMenu = MainMenuUI.Cast(GetGame().GetMenuManager().GetTopMenu());
55  //ContentBrowserUI workshopUI = ContentBrowserUI.Cast(GetGame().GetMenuManager().GetTopMenu());
56 
57  bool excluded = false;
58 
59  // Is top menu of excluded type?
60  for (int i = 0, count = menus.Count(); i < count; i++)
61  {
62  typename menuType = m_MenuMgr.GetTopMenu().Type();
63 
64  if (menuType == menus[i])
65  {
66  excluded = true;
67  break;
68  }
69  }
70 
71  // Current excluded = All non-excluded close
72  if (excluded)
73  {
74  GetGame().GetCallqueue().CallLater(AllMenuClosed);
75  //InvokeEventOnAllMenuClosed();
76  return;
77  }
78 
79  m_MenuMgr.GetTopMenu().Close();
80 
81  calls--;
82  GetGame().GetCallqueue().CallLater(CloseTopMenu, 0, false, menus, calls);
83  }
84 
85  //------------------------------------------------------------------------------------------------
86  protected static void AllMenuClosed()
87  {
88  InvokeEventOnAllMenuClosed();
89  }
90 }
SCR_MenuToolsLib
Definition: SCR_MenuToolsLib.c:5
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424