Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
MenuRootBase.c
Go to the documentation of this file.
1 
7 {
8  protected MenuRootComponent m_MenuRootComponent;
9 
10  protected ref ScriptInvoker m_EventOnMenuFocusGained;
11  protected ref ScriptInvoker m_EventOnMenuFocusLost;
12  protected ref ScriptInvoker m_EventOnMenuShow;
13  protected ref ScriptInvoker m_EventOnMenuHide;
14  protected ref ScriptInvoker m_EventOnMenuItem;
15  protected ref ScriptInvoker m_EventOnMenuUpdate;
16  protected ref ScriptInvoker m_EventOnMenuOpen;
17  protected ref ScriptInvoker m_EventOnMenuInit;
18  protected ref ScriptInvoker m_EventOnMenuClose;
19 
20  protected SCR_ChatPanel m_ChatPanel;
21  protected SCR_DynamicFooterComponent m_DynamicFooter;
22 
23  //------------------------------------------------------------------------------------------------
24  ScriptInvoker GetOnMenuFocusGained()
25  {
26  if (!m_EventOnMenuFocusGained)
27  m_EventOnMenuFocusGained = new ScriptInvoker();
28  return m_EventOnMenuFocusGained;
29  }
30  ScriptInvoker GetOnMenuFocusLost()
31  {
32  if (!m_EventOnMenuFocusLost)
33  m_EventOnMenuFocusLost = new ScriptInvoker();
34  return m_EventOnMenuFocusLost;
35  }
36  ScriptInvoker GetOnMenuShow()
37  {
38  if (!m_EventOnMenuShow)
39  m_EventOnMenuShow = new ScriptInvoker();
40  return m_EventOnMenuShow;
41  }
42  ScriptInvoker GetOnMenuHide()
43  {
44  if (!m_EventOnMenuHide)
45  m_EventOnMenuHide = new ScriptInvoker();
46  return m_EventOnMenuHide;
47  }
48  ScriptInvoker GetOnMenuItem()
49  {
50  if (!m_EventOnMenuItem)
51  m_EventOnMenuItem = new ScriptInvoker();
52  return m_EventOnMenuItem;
53  }
54  ScriptInvoker GetOnMenuUpdate()
55  {
56  if (!m_EventOnMenuUpdate)
57  m_EventOnMenuUpdate = new ScriptInvoker();
58  return m_EventOnMenuUpdate;
59  }
60  ScriptInvoker GetOnMenuOpen()
61  {
62  if (!m_EventOnMenuOpen)
63  m_EventOnMenuOpen = new ScriptInvoker();
64  return m_EventOnMenuOpen;
65  }
66  ScriptInvoker GetOnMenuInit()
67  {
68  if (!m_EventOnMenuInit)
69  m_EventOnMenuInit = new ScriptInvoker();
70  return m_EventOnMenuInit;
71  }
72 
73  //------------------------------------------------------------------------------------------------
74  ScriptInvoker GetOnMenuClose()
75  {
76  if (!m_EventOnMenuClose)
77  m_EventOnMenuClose = new ScriptInvoker();
78  return m_EventOnMenuClose;
79  }
80 
81  //------------------------------------------------------------------------------------------------
82  void OnMenuClosed()
83  {
84  SCR_ChatPanelManager chatManager = SCR_ChatPanelManager.GetInstance();
85  if (chatManager)
86  GetGame().GetCallqueue().CallLater(chatManager.OnMenuClosed, 1);
87  }
88 
89  //------------------------------------------------------------------------------------------------
90  void InitChat()
91  {
92  // Check if this menu has chat
93  Widget chatPanelWidget = GetRootWidget().FindAnyWidget("ChatPanel");
94  if (!chatPanelWidget)
95  return;
96 
97  m_ChatPanel = SCR_ChatPanel.Cast(chatPanelWidget.FindHandler(SCR_ChatPanel));
98  }
99 
100  //------------------------------------------------------------------------------------------------
101  // Chat related methods are here, as we assume any menu can have it's chat panel and therefore needs to implement these.
102  void ShowChat()
103  {
104  SCR_ChatPanelManager chatManager = SCR_ChatPanelManager.GetInstance();
105  if (!chatManager)
106  return;
107 
108  // Check if this menu has chat
109  Widget chatPanelWidget = GetRootWidget().FindAnyWidget("ChatPanel");
110  if (!chatPanelWidget)
111  return;
112 
113  SCR_ChatPanel chatPanel = SCR_ChatPanel.Cast(chatPanelWidget.FindHandler(SCR_ChatPanel));
114  chatManager.HideAllChatPanels();
115  chatManager.ShowChatPanel(chatPanel);
116  }
117 
118  //------------------------------------------------------------------------------------------------
119  MenuRootComponent GetRootComponent()
120  {
121  return m_MenuRootComponent;
122  }
123 
124  //------------------------------------------------------------------------------------------------
125  SCR_DynamicFooterComponent GetFooterComponent()
126  {
127  return m_DynamicFooter;
128  }
129 
130  //------------------------------------------------------------------------------------------------
131  override void OnMenuFocusGained()
132  {
133  super.OnMenuFocusGained();
134  ShowChat(); // If chat is part of this menu, it will be shown
135  if (m_EventOnMenuFocusGained)
136  m_EventOnMenuFocusGained.Invoke();
137  }
138 
139  //------------------------------------------------------------------------------------------------
140  override void OnMenuFocusLost()
141  {
142  super.OnMenuFocusLost();
143  if (m_EventOnMenuFocusLost)
144  m_EventOnMenuFocusLost.Invoke();
145  }
146 
147  //------------------------------------------------------------------------------------------------
148  override void OnMenuShow()
149  {
150  super.OnMenuShow();
151  if (m_EventOnMenuShow)
152  m_EventOnMenuShow.Invoke();
153  }
154 
155  //------------------------------------------------------------------------------------------------
156  override void OnMenuHide()
157  {
158  super.OnMenuHide();
159  if (m_EventOnMenuHide)
160  m_EventOnMenuHide.Invoke();
161  }
162 
163  //------------------------------------------------------------------------------------------------
164  override void OnMenuItem(string menuItemName, bool changed, bool finished)
165  {
166  super.OnMenuItem(menuItemName, changed, finished);
167  if (m_EventOnMenuItem)
168  m_EventOnMenuItem.Invoke(menuItemName, changed, finished);
169  }
170 
171  //------------------------------------------------------------------------------------------------
172  override void OnMenuUpdate(float tDelta)
173  {
174  super.OnMenuUpdate(tDelta);
175 
176  if (m_ChatPanel)
177  m_ChatPanel.OnUpdateChat(tDelta);
178 
179  if (IsFocused() && m_EventOnMenuUpdate)
180  m_EventOnMenuUpdate.Invoke(tDelta);
181  }
182 
183  //------------------------------------------------------------------------------------------------
184  override void OnMenuOpen()
185  {
186  super.OnMenuOpen();
187  InitChat();
188  ShowChat(); // If chat is part of this menu, it will be shown
189  if (m_EventOnMenuOpen)
190  m_EventOnMenuOpen.Invoke();
191  }
192 
193  //------------------------------------------------------------------------------------------------
194  override void OnMenuInit()
195  {
196  super.OnMenuInit();
197  m_MenuRootComponent = MenuRootComponent.GetRootOf(this);
198  m_DynamicFooter = SCR_DynamicFooterComponent.FindComponentInHierarchy(GetRootWidget());
199  if (m_MenuRootComponent)
200  m_MenuRootComponent.Init(this);
201  if (m_EventOnMenuInit)
202  m_EventOnMenuInit.Invoke();
203  }
204 
205  //------------------------------------------------------------------------------------------------
206  override void OnMenuClose()
207  {
208  super.OnMenuClose();
209  OnMenuClosed();
210  if (m_EventOnMenuClose)
211  m_EventOnMenuClose.Invoke();
212  }
213 };
ChimeraMenuBase
Constant variables used in various menus.
Definition: ChimeraMenuBase.c:70
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SCR_ChatPanelManager
Definition: SCR_ChatPanelManager.c:12
GetRootWidget
Widget GetRootWidget()
Definition: SCR_UITaskManagerComponent.c:160
SCR_ChatPanel
Definition: SCR_ChatPanel.c:6
MenuRootBase
Definition: MenuRootBase.c:6
MenuRootComponent
Definition: MenuRootComponent.c:6