Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_MapRadialUI.c
Go to the documentation of this file.
1//------------------------------------------------------------------------------------------------
4typedef ScriptInvokerBase<ScriptInvokerEntrySelectedMethod> ScriptInvokerMenuEntrySelected;
5
6//------------------------------------------------------------------------------------------------
9typedef ScriptInvokerBase<ScriptInvokerEntryPerformedMethod> ScriptInvokerMenuEntryPerformed;
10
11//------------------------------------------------------------------------------------------------
14{
15 [Attribute()]
17
18 [Attribute()]
20
21 protected SCR_MapCursorModule m_CursorModule;
23
24 protected bool m_bRefresh;
25 protected bool m_bEntriesUpdate = false; // entries updated instead of entry selected
26
28
29 protected ref ScriptInvokerVoid m_OnMenuInit = new ScriptInvokerVoid(); // used to fill in entries after map open;
32
33 //------------------------------------------------------------------------------------------------
39
40 //------------------------------------------------------------------------------------------------
46
47 //------------------------------------------------------------------------------------------------
53
54 //------------------------------------------------------------------------------------------------
60
61 //------------------------------------------------------------------------------------------------
67
68 //------------------------------------------------------------------------------------------------
71 {
73 if (!mapEntity)
74 return null;
75
77 }
78
79 //------------------------------------------------------------------------------------------------
82 {
83 m_vMenuWorldPos[1] = GetGame().GetWorld().GetSurfaceY(m_vMenuWorldPos[0], m_vMenuWorldPos[2]);
84
85 return m_vMenuWorldPos;
86 }
87
88 //------------------------------------------------------------------------------------------------
92 protected void OnInputMenuOpen(float value, EActionTrigger reason)
93 {
94 if (m_CursorModule.GetCursorState() & EMapCursorState.CS_PAN) // dont open + pan at the same time
95 return;
96
97 if (m_RadialMenu && m_RadialMenu.IsOpened())
98 return;
99
100 m_RadialController.OnInputOpen();
101 }
102
103 //------------------------------------------------------------------------------------------------
106 protected void InputOpenMenu(SCR_RadialMenuController controller, bool hasControl)
107 {
108 if (!hasControl)
109 {
111
114 m_RadialMenu.SetMenuDisplay(m_Display);
115
116 float w, h;
117 GetGame().GetWorkspace().GetScreenSize(w, h);
118 m_RadialMenu.SetMenuCenterPos(Vector(w, h, 0) * 0.5);
119 }
120 else if (m_RadialMenu.IsOpened()) // TODO proper close here
121 return;
122
123 if (!m_CursorModule.HandleContextualMenu()) // map side conditions to open
124 m_RadialController.SetEnableControl(false);
125 else
126 m_RadialController.SetEnableControl(true);
127 }
128
129 //------------------------------------------------------------------------------------------------
133 {
134 m_RadialMenu = m_RadialController.GetRadialMenu();
135 m_RadialMenu.GetOnSelect().Insert(OnEntrySelected);
136 m_RadialMenu.GetOnPerform().Insert(OnEntryPerformed);
137 m_RadialMenu.GetOnOpen().Insert(OpenMenu);
138 m_RadialMenu.GetOnClose().Insert(CloseMenu);
139
140 m_RadialMenu.ClearEntries();
141
142 m_OnMenuInit.Invoke(); // fill menu entries
143 }
144
145 //------------------------------------------------------------------------------------------------
148 protected void OnControllerChanged(SCR_RadialMenuController controller, bool hasControl)
149 {
150 m_RadialMenu = m_RadialController.GetRadialMenu();
151 m_RadialMenu.GetOnSelect().Remove(OnEntrySelected);
152 m_RadialMenu.GetOnPerform().Remove(OnEntryPerformed);
153 m_RadialMenu.GetOnOpen().Remove(OpenMenu);
154 m_RadialMenu.GetOnClose().Remove(CloseMenu);
155 }
156
157 //------------------------------------------------------------------------------------------------
160 bool OpenMenu()
161 {
162 SCR_VONController controllerVON = SCR_VONController.Cast(GetGame().GetPlayerController().FindComponent(SCR_VONController));
163 if (controllerVON)
164 {
165 SCR_VONMenu menuVON = controllerVON.GetVONMenu();
166 if (menuVON)
167 menuVON.SetMenuDisabled(true);
168 }
169
170 float wX, wY, sX, sY;
171 m_MapEntity.GetMapCursorWorldPosition(wX, wY);
172 m_MapEntity.WorldToScreen(wX, wY, sX, sY);
173 m_MapEntity.PanSmooth(sX, sY);
174
175 m_vMenuWorldPos[0] = wX;
176 m_vMenuWorldPos[2] = wY;
177
178 m_CursorModule.ForceCenterCursor();
179
180 return true;
181 }
182
183 //------------------------------------------------------------------------------------------------
186 {
187 SCR_VONController controllerVON = SCR_VONController.Cast(GetGame().GetPlayerController().FindComponent(SCR_VONController));
188 if (controllerVON)
189 {
190 SCR_VONMenu menuVON = controllerVON.GetVONMenu();
191 if (menuVON)
192 menuVON.SetMenuDisabled(false);
193 }
194
195 m_CursorModule.HandleContextualMenu(true);
196 }
197
198 //------------------------------------------------------------------------------------------------
204 {
205 m_OnEntrySelected.Invoke(entry, entryID);
206 }
207
208 //------------------------------------------------------------------------------------------------
213 {
214 float wX, wY;
215 float worldPos[2];
216 m_MapEntity.GetMapCenterWorldPosition(wX, wY);
217 worldPos[0] = wX;
218 worldPos[1] = wY;
219
220 m_OnEntryPerformed.Invoke(entry, worldPos);
221 }
222
223 //------------------------------------------------------------------------------------------------
228 {
229 if (category)
230 category.AddEntry(entry);
231 else
232 m_RadialMenu.AddEntry(entry);
233 }
234
235 //------------------------------------------------------------------------------------------------
240 {
241 if (parent)
242 parent.AddEntry(entry);
243 else
244 m_RadialMenu.AddCategoryEntry(entry);
245 }
246
247 //------------------------------------------------------------------------------------------------
253 {
255 entry.SetName(name);
256
257 if (category)
258 category.AddEntry(entry);
259 else
260 m_RadialMenu.AddEntry(entry);
261
262 return entry;
263 }
264
265 //------------------------------------------------------------------------------------------------
271 {
273 entry.SetName(name);
274
275 if (parent)
276 parent.AddEntry(entry);
277 else
278 m_RadialMenu.AddCategoryEntry(entry);
279
280 return entry;
281 }
282
283 //------------------------------------------------------------------------------------------------
287 {
288 m_RadialMenu.RemoveEntry(entry);
289 }
290
291 //------------------------------------------------------------------------------------------------
292 // OVERRIDES
293 //------------------------------------------------------------------------------------------------
294
295 //------------------------------------------------------------------------------------------------
296 override void Update(float timeSlice)
297 {
298 if (m_RadialMenu)
299 m_RadialMenu.Update(timeSlice);
300 }
301
302 //------------------------------------------------------------------------------------------------
303 override void OnMapOpen(MapConfiguration config)
304 {
305 super.OnMapOpen(config);
306
307 m_CursorModule = SCR_MapCursorModule.Cast(m_MapEntity.GetMapModule(SCR_MapCursorModule));
308
309 m_RadialController.GetOnInputOpen().Insert(InputOpenMenu);
310 m_RadialController.GetOnTakeControl().Insert(OnControllerTakeControl);
311 m_RadialController.GetOnControllerChanged().Insert(OnControllerChanged);
312
313 GetGame().GetInputManager().AddActionListener("MapContextualMenu", EActionTrigger.UP, OnInputMenuOpen);
314 }
315
316 //------------------------------------------------------------------------------------------------
317 override void OnMapClose(MapConfiguration config)
318 {
319 GetGame().GetInputManager().RemoveActionListener("MapContextualMenu", EActionTrigger.UP, OnInputMenuOpen);
320
321 m_RadialController.GetOnInputOpen().Remove(InputOpenMenu);
322 m_RadialController.GetOnTakeControl().Remove(OnControllerTakeControl);
323 m_RadialController.GetOnControllerChanged().Remove(OnControllerChanged);
324
325 if (m_RadialController.HasControl())
326 {
327 if (m_RadialMenu.IsOpened()) // close event is unregistered below so close manually here
328 CloseMenu();
329
330 OnControllerChanged(null, false);
331 m_RadialController.StopControl(true);
332 }
333
334 super.OnMapClose(config);
335 }
336
337 //------------------------------------------------------------------------------------------------
338 // constructor
340 {
341 m_bHookToRoot = true;
342 }
343}
ArmaReforgerScripted GetGame()
Definition game.c:1398
EMapCursorState
Map cursor state.
func ScriptInvokerEntrySelectedMethod
ScriptInvokerBase< ScriptInvokerEntryPerformedMethod > ScriptInvokerMenuEntryPerformed
func ScriptInvokerEntryPerformedMethod
ScriptInvokerBase< ScriptInvokerEntrySelectedMethod > ScriptInvokerMenuEntrySelected
ScriptInvokerBase< ScriptInvokerVoidMethod > ScriptInvokerVoid
SCR_InfoDisplay FindInfoDisplay(typename type)
Return hud component of given type.
static SCR_HUDManagerComponent GetHUDManager()
SCR_MapUIBaseComponent GetMapUIComponent(typename componentType)
static SCR_MapEntity GetMapInstance()
Get map entity instance.
Info display within hud manager of player controller.
override void Update(float timeSlice)
void OnControllerTakeControl(SCR_RadialMenuController controller)
ScriptInvokerMenuEntrySelected GetOnEntrySelectedInvoker()
ref ScriptInvokerMenuEntryPerformed m_OnEntryPerformed
ScriptInvokerVoid GetOnMenuInitInvoker()
ref SCR_RadialMenuController m_RadialController
SCR_MapRadialDisplay GetRadialDisplay()
SCR_MapCursorModule m_CursorModule
void RemoveRadialEntry(SCR_SelectionMenuEntry entry)
ref ScriptInvokerMenuEntrySelected m_OnEntrySelected
void CloseMenu()
SCR_RadialMenu event.
override void OnMapClose(MapConfiguration config)
void OnEntrySelected(SCR_SelectionMenu menu, SCR_SelectionMenuEntry entry, int entryID)
void InsertCustomRadialCategory(SCR_SelectionMenuCategoryEntry entry, SCR_SelectionMenuCategoryEntry parent=null)
SCR_SelectionMenuEntry AddRadialEntry(string name, SCR_SelectionMenuCategoryEntry category=null)
vector GetMenuWorldPosition()
ScriptInvokerMenuEntryPerformed GetOnEntryPerformedInvoker()
SCR_SelectionMenuCategoryEntry AddRadialCategory(string name, SCR_SelectionMenuCategoryEntry parent=null)
static SCR_MapRadialUI GetInstance()
ref ScriptInvokerVoid m_OnMenuInit
SCR_RadialMenuController GetRadialController()
override void OnMapOpen(MapConfiguration config)
void OnInputMenuOpen(float value, EActionTrigger reason)
void OnControllerChanged(SCR_RadialMenuController controller, bool hasControl)
void OnEntryPerformed(SCR_SelectionMenu menu, SCR_SelectionMenuEntry entry)
void InsertCustomRadialEntry(SCR_SelectionMenuEntry entry, SCR_SelectionMenuCategoryEntry category=null)
void InputOpenMenu(SCR_RadialMenuController controller, bool hasControl)
ref SCR_RadialMenu m_RadialMenu
SCR_MapRadialDisplay m_Display
void AddEntry(SCR_SelectionMenuEntry entry=null)
void SetName(string name)
void SetMenuDisabled(bool state)
Definition SCR_VONMenu.c:30
SCR_FieldOfViewSettings Attribute
proto external PlayerController GetPlayerController()
EActionTrigger
proto native vector Vector(float x, float y, float z)