Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_RadialMenu.c
Go to the documentation of this file.
2{
5}
6
9typedef ScriptInvokerBase<ScriptInvokerSelectionMenuEntryMethod> ScriptInvokerSelectionMenuEntry;
10
11//------------------------------------------------------------------------------------------------
17[BaseContainerProps(configRoot: true)]
19{
21 protected static SCR_RadialMenu m_OpenedRadialMenu; // reference to any currently open radial menu inheriting from this class
22
23 const float SIZE_LARGE = 580;
24 protected const float SIZE_SMALL = 400;
25
27
28 protected float m_fEntriesAngleDistance;
29 protected float m_fEntryAngleOffset;
30
31 protected float m_fPointingAngle;
32 protected bool m_bIsPointingToCenter;
34
35 protected bool m_bActivateContext;
37
40
41 protected string m_sActionHint;
42
43 // Events
46
48
50
51 //------------------------------------------------------------------------------------------------
59
60 //------------------------------------------------------------------------------------------------
61 protected void InvokeOnDisplaySizeChange(float size)
62 {
64 m_OnDisplaySizeChange.Invoke(this, size);
65 }
66
67 //------------------------------------------------------------------------------------------------
75
76 //------------------------------------------------------------------------------------------------
77 protected void InvokeOnSetActionHint(string action)
78 {
80 m_OnSetActionHint.Invoke(this, action);
81 }
82
83 //------------------------------------------------------------------------------------------------
91
92 //------------------------------------------------------------------------------------------------
93 // Getting global menu
94 //------------------------------------------------------------------------------------------------
95
96
97 //------------------------------------------------------------------------------------------------
100 {
102 {
103 PlayerController controller = GetGame().GetPlayerController();
104 if (!controller)
105 return null;
106
107 SCR_RadialMenuGameModeComponent rm = SCR_RadialMenuGameModeComponent.Cast(controller.FindComponent(SCR_RadialMenuGameModeComponent));
108
109 if (!rm)
110 {
111 #ifdef RADMENU_DEBUG
112 Print("[SCR_RadialMenuController] - Can't setup radial menu due to missing RM game mode!");
113 #endif
114 return null;
115 }
116
117 m_GlobalRadialMenu = rm.GetMenu();
118 }
119
120 return m_GlobalRadialMenu;
121 }
122
123 //------------------------------------------------------------------------------------------------
126 {
127 return m_OpenedRadialMenu;
128 }
129
130 //------------------------------------------------------------------------------------------------
131 protected void OnMenuOpened(ChimeraMenuBase menu)
132 {
134 m_OpenedRadialMenu.Close();
135 }
136
137 //------------------------------------------------------------------------------------------------
138 // Override
139 //------------------------------------------------------------------------------------------------
140
141 //------------------------------------------------------------------------------------------------
142 protected override event void OnOpen()
143 {
144 super.OnOpen(owner);
145
147 m_OpenedRadialMenu.Close();
148
149 // Setup controls
150 m_Inputs.Init();
152
153 GetGame().GetCallqueue().Remove(ReleaseContext);
154 m_bActivateContext = true;
155
156 m_OpenedRadialMenu = this;
157
159 }
160
161 //------------------------------------------------------------------------------------------------
162 protected override event void OnClose()
163 {
164 super.OnClose(owner);
166
167 m_OpenedRadialMenu = null;
168
169 // Allow to stop using context after split of a second to prevent unwanted input
170 if (m_RadialInputs)
171 GetGame().GetCallqueue().CallLater(ReleaseContext, m_RadialInputs.m_iContextDeactivationTime);
172 }
173
174 //------------------------------------------------------------------------------------------------
175 protected void ReleaseContext()
176 {
177 m_bActivateContext = false;
178 }
179
180 //------------------------------------------------------------------------------------------------
181 override void Update(float timeSlice)
182 {
183 if (System.IsConsoleApp())
184 return;
185
186 // Context
188 GetGame().GetInputManager().ActivateContext(m_Inputs.m_sContext);
189
190 // Controller inputs
192 GetGame().GetInputManager().ActivateContext(m_ControllerInputs.m_sControllerContext);
193
194 OnUpdate(timeSlice);
195 }
196
197 //------------------------------------------------------------------------------------------------
199 override protected void OnUpdate(float timeSlice)
200 {
201 if (!m_bOpened)
202 return;
203
205 SelectEntry();
206 }
207
208 //------------------------------------------------------------------------------------------------
210 override void SetMenuDisplay(SCR_SelectionMenuDisplay display = null)
211 {
212 // By default find radial menu display from HUD manager
213 if (!display)
214 {
216
217 if (hud)
218 {
220 }
221 }
222
223 super.SetMenuDisplay(display);
224
225 // Setup cofiguration
228 }
229
230 //------------------------------------------------------------------------------------------------
232 override protected void SelectEntry()
233 {
235 int id = -1;
236
237 entry = HandleSelection(id);
238
239 if (!GetGame().GetInputManager().IsUsingMouseAndKeyboard())
240 {
241 if (m_bIsPointingToCenter && m_RadialControllerInputs.m_bDeselectInCenter)
242 {
243 // Call deselection after split of a second to prevent deselection happening during closing
245 GetGame().GetCallqueue().CallLater(DeselectEntry, m_RadialInputs.m_iGamepadDeselectionDelay);
246
247 return;
248 }
249 }
250
251 GetGame().GetCallqueue().Remove(DeselectEntry);
252
253 // Update selection
254 if (m_SelectedEntry != entry)
255 {
256 m_SelectedEntry = entry;
257 InvokeOnSelect(entry, id);
258
260
261 // Setup input action
262 if (entry && !entry.GetInputAction().IsEmpty())
264 else
266 }
267 }
268
269 //------------------------------------------------------------------------------------------------
270 override protected void InvokeOnUpdateEntries(array<ref SCR_SelectionMenuEntry> entries)
271 {
272 if (!m_aEntries.IsEmpty())
273 m_fEntriesAngleDistance = 360 / m_aEntries.Count();
274
275 super.InvokeOnUpdateEntries(entries);
276 }
277
278 //------------------------------------------------------------------------------------------------
280 {
281 super.SetController(owner, controls);
282
285
287 m_RadialInputs.SetUseRightStick(m_RadialControllerInputs.m_bUseRightStick);
288
289 #ifdef RADMENU_DEBUG
290 // Set controller configuration from diag menu
291 DebugSetupControllerInputs(m_RadialControllerInputs);
292 DebugFillWithEntries();
293 #endif
294
296 }
297
298 //------------------------------------------------------------------------------------------------
299 override protected void OnPerformInput()
300 {
301 super.OnPerformInput();
302
303 if (!m_SelectedEntry)
304 {
305 if (m_ControllerInputs.m_bCloseOnPerform)
306 Close();
307 }
308
311 }
312
313 //------------------------------------------------------------------------------------------------
315 override protected void AddActionListeners()
316 {
317 super.AddActionListeners();
318
320
321 // Quick actions 1-9
322 if (!m_RadialControllerInputs.m_bUseQuickActions)
323 return;
324
325 GetGame().GetInputManager().AddActionListener("InventoryQuickSlot1", EActionTrigger.DOWN, OnQuickAction1);
326 GetGame().GetInputManager().AddActionListener("InventoryQuickSlot2", EActionTrigger.DOWN, OnQuickAction2);
327 GetGame().GetInputManager().AddActionListener("InventoryQuickSlot3", EActionTrigger.DOWN, OnQuickAction3);
328 GetGame().GetInputManager().AddActionListener("InventoryQuickSlot4", EActionTrigger.DOWN, OnQuickAction4);
329 GetGame().GetInputManager().AddActionListener("InventoryQuickSlot5", EActionTrigger.DOWN, OnQuickAction5);
330 GetGame().GetInputManager().AddActionListener("InventoryQuickSlot6", EActionTrigger.DOWN, OnQuickAction6);
331 GetGame().GetInputManager().AddActionListener("InventoryQuickSlot7", EActionTrigger.DOWN, OnQuickAction7);
332 GetGame().GetInputManager().AddActionListener("InventoryQuickSlot8", EActionTrigger.DOWN, OnQuickAction8);
333 GetGame().GetInputManager().AddActionListener("InventoryQuickSlot9", EActionTrigger.DOWN, OnQuickAction9);
334 }
335
336 //------------------------------------------------------------------------------------------------
338 override protected void RemoveActionListeners()
339 {
340 super.RemoveActionListeners();
341
343
344 // Quick actions 1-9
345 if (!m_RadialControllerInputs.m_bUseQuickActions)
346 return;
347
348 GetGame().GetInputManager().RemoveActionListener("InventoryQuickSlot1", EActionTrigger.DOWN, OnQuickAction1);
349 GetGame().GetInputManager().RemoveActionListener("InventoryQuickSlot2", EActionTrigger.DOWN, OnQuickAction2);
350 GetGame().GetInputManager().RemoveActionListener("InventoryQuickSlot3", EActionTrigger.DOWN, OnQuickAction3);
351 GetGame().GetInputManager().RemoveActionListener("InventoryQuickSlot4", EActionTrigger.DOWN, OnQuickAction4);
352 GetGame().GetInputManager().RemoveActionListener("InventoryQuickSlot5", EActionTrigger.DOWN, OnQuickAction5);
353 GetGame().GetInputManager().RemoveActionListener("InventoryQuickSlot6", EActionTrigger.DOWN, OnQuickAction6);
354 GetGame().GetInputManager().RemoveActionListener("InventoryQuickSlot7", EActionTrigger.DOWN, OnQuickAction7);
355 GetGame().GetInputManager().RemoveActionListener("InventoryQuickSlot8", EActionTrigger.DOWN, OnQuickAction8);
356 GetGame().GetInputManager().RemoveActionListener("InventoryQuickSlot9", EActionTrigger.DOWN, OnQuickAction9);
357 }
358
359 //------------------------------------------------------------------------------------------------
360 protected void OnQuickAction1() { QuickActionUse(1); }
361 protected void OnQuickAction2() { QuickActionUse(2); }
362 protected void OnQuickAction3() { QuickActionUse(3); }
363 protected void OnQuickAction4() { QuickActionUse(4); }
364 protected void OnQuickAction5() { QuickActionUse(5); }
365 protected void OnQuickAction6() { QuickActionUse(6); }
366 protected void OnQuickAction7() { QuickActionUse(7); }
367 protected void OnQuickAction8() { QuickActionUse(8); }
368 protected void OnQuickAction9() { QuickActionUse(9); }
369
370 //------------------------------------------------------------------------------------------------
371 protected void QuickActionUse(int id)
372 {
373 // - 1 because slot actions starts with 1, but entries with 0
374 id -= 1;
375
376 if (!m_aEntries.IsIndexValid(id))
377 return;
378
381
384
385 m_bEntryPerformed = true;
387 }
388
389 //------------------------------------------------------------------------------------------------
390 // Custom
391 //------------------------------------------------------------------------------------------------
392
393 //------------------------------------------------------------------------------------------------
394 protected int GetSelectedElementIndex(float angle, int elementCount)
395 {
396 if (elementCount == 0)
397 return -1;
398
399 float angleDeg = Math.Repeat(angle * Math.RAD2DEG, 360) - m_fEntryAngleOffset;
400 float overflow = m_fEntriesAngleDistance * 0.5;
401
402 // compensate overflowing offset
403 if (angleDeg < 0)
404 {
405 angleDeg = Math.Repeat(angleDeg, 360);
406 }
407
409 {
410 #ifdef RADMENU_DEBUG
411 DebugPrint("GetSelectedElementIndex", "No distance between entries!");
412 #endif
413 return -1;
414 }
415
416 // Find entry index withing circle
417 int idx = Math.Round(angleDeg / m_fEntriesAngleDistance);
418
419 if (idx < 0 || idx >= elementCount)
420 {
421 idx = -1;
422 }
423
424 // Count with overflow
425 if (idx == -1)
426 {
427 if (angleDeg > (360 - overflow + m_fEntryAngleOffset))
428 return 0;
429 else
430 return -1;
431 }
432
433 return idx;
434 }
435
436 //------------------------------------------------------------------------------------------------
440 {
441 // Current
442 float curW, curH;
443 GetGame().GetWorkspace().GetScreenSize(curW, curH);
444
445 if (curW == 0 || curH == 0)
446 return distance;
447
448 // Reference 1920x1080
449 int refW, refH;
450 WidgetManager.GetReferenceScreenSize(refW, refH);
451
452 float ratioX = curW / refW;
453 float ratioY = curH / refH;
454
455 float ratioDist = vector.Distance(
456 Vector(m_vMenuCenterPos[0] / refW, m_vMenuCenterPos[1] / refH, 0),
457 Vector(curW / refW, curH / refH,
458 0));
459
460 return distance / ratioDist;
461 }
462
463 //------------------------------------------------------------------------------------------------
465 {
466 // Check m_Inputs
468 return null;
469
470 float dist;
471 vector dir;
472
473 // Handle used input
474 if (GetGame().GetInputManager().IsUsingMouseAndKeyboard())
475 {
476 // Mouse
477 int mouseX, mouseY;
478 WidgetManager.GetMousePos(mouseX, mouseY);
479 dir = Vector(mouseX, mouseY, 0);
480
481 dist = vector.Distance(m_vMenuCenterPos, dir);
482 dist = AdjustDistanceWithResolution(dist);
483
484 // Center the direction
485 dir[0] = mouseX - m_vMenuCenterPos[0];
486 dir[1] = (mouseY - m_vMenuCenterPos[1]) * -1;
487 dir.Normalize();
488
489 // Deselect if in center
491 m_RadialControllerInputs.m_bDeselectInCenter && dist < m_fDynamicMouseSelectionTreshold);
492
494 return null;
495 }
496 else
497 {
498 // Gamepad
499 float x, y;
500 m_RadialInputs.GetRadialXYInput(x, y);
501
502 dir[0] = x;
503 dir[1] = y;
504 dist = vector.Distance(vector.Zero, Vector(x, y, 0));
505
506 // Deselect if in center
508 m_RadialControllerInputs.m_bDeselectInCenter && dist < m_RadialInputs.m_fGamepadSelectionTreshhold);
509
511 return null;
512 }
513
514 // Selected pointed
515 float angle = Math.Atan2(dir[0], dir[1]);
516 id = GetSelectedElementIndex(angle, m_aEntries.Count());
517
518 m_fPointingAngle = angle * Math.RAD2DEG;
519
520 if (m_aEntries.IsIndexValid(id))
521 return m_aEntries[id];
522
523 id = -1;
524 return null;
525 }
526
527 //------------------------------------------------------------------------------------------------
528 protected void DeselectEntry()
529 {
530 m_SelectedEntry = null;
531 InvokeOnSelect(null, -1);
532 }
533
534 //------------------------------------------------------------------------------------------------
536 protected void ReactQuickInput()
537 {
538 for (int i = 1; i < 9; i++)
539 {
540 if (GetGame().GetInputManager().GetActionTriggered("InventoryQuickSlot" + i))
541 {
542 // - 1 because slot actions starts with 1, but entries with 0
543 int id = i-1;
544
545 if (!m_aEntries.IsIndexValid(id))
546 continue;
547
550
553
554 m_bEntryPerformed = true;
556 }
557 }
558 }
559
560 //------------------------------------------------------------------------------------------------
564 void ChangeDisplaySize(bool useLarge = true, float customSize = -1)
565 {
566 float size = SIZE_LARGE;
567 if (!useLarge)
569
570 if (customSize > 0)
571 size = customSize;
572
573 // Change seletion treshold
574 m_fDynamicMouseSelectionTreshold = m_RadialInputs.m_fMouseSelectionTreshold;
575
576 if (m_RadialInputs.m_bDynamicMouseTreshold)
577 m_fDynamicMouseSelectionTreshold *= size / SIZE_LARGE; // Mutliply with large size based ratio
578
579 // Invoke
581 }
582
583 //------------------------------------------------------------------------------------------------
585 void SetActionHint(string action)
586 {
587 m_sActionHint = action;
589 }
590
591 //------------------------------------------------------------------------------------------------
592 //1 Invoke emtpy action to hide in radial menu display
594 {
596 }
597
598 //------------------------------------------------------------------------------------------------
599 // Get set
600 //------------------------------------------------------------------------------------------------
601
602 //------------------------------------------------------------------------------------------------
603 void SetMenuCenterPos(vector centerPos)
604 {
605 m_vMenuCenterPos = centerPos;
606 }
607
608 //------------------------------------------------------------------------------------------------
610 {
612 }
613
614 //------------------------------------------------------------------------------------------------
616 {
617 return m_fPointingAngle;
618 }
619
620 //------------------------------------------------------------------------------------------------
622 {
624 }
625
626 //------------------------------------------------------------------------------------------------
627 // Debug
628 //------------------------------------------------------------------------------------------------
629
630 #ifdef RADMENU_DEBUG
631
632 //------------------------------------------------------------------------------------------------
633 override protected void DebugPrint(string method, string msg)
634 {
635 Print(string.Format("[SCR_RadialMenu] - %1() - '%2'", method, msg));
636 }
637
638 //------------------------------------------------------------------------------------------------
639 protected void DebugSetupDiagMenu()
640 {
641 string rmDiagName = "Radial menu (refactored)";
642
643 DiagMenu.RegisterMenu(SCR_DebugMenuID.DEBUGUI_RADIALMENU_MENU, rmDiagName, "UI");
644
645 DiagMenu.RegisterBool(SCR_DebugMenuID.DEBUGUI_RADIALMENU_CONFIG_DEBUG, "", "Override config", rmDiagName);
646 DiagMenu.RegisterBool(SCR_DebugMenuID.DEBUGUI_RADIALMENU_CLOSE_ON_RELEASE_OPEN, "", "Close on open", rmDiagName);
647 DiagMenu.RegisterBool(SCR_DebugMenuID.DEBUGUI_RADIALMENU_PERFORM_ON_CLOSE, "", "Perform on close", rmDiagName);
648 DiagMenu.RegisterBool(SCR_DebugMenuID.DEBUGUI_RADIALMENU_CLOSE_ON_PERFORM, "", "Close on perform", rmDiagName);
649 DiagMenu.RegisterBool(SCR_DebugMenuID.DEBUGUI_RADIALMENU_DESELECT_IN_CENTER, "", "Delect in center", rmDiagName);
650 DiagMenu.RegisterBool(SCR_DebugMenuID.DEBUGUI_RADIALMENU_USE_LARGE_SIZE, "", "Large size", rmDiagName);
651
652 DiagMenu.RegisterBool(SCR_DebugMenuID.DEBUGUI_RADIALMENU_CUSTOM_SIZE_ENABLE, "", "Override size", rmDiagName);
653 DiagMenu.RegisterRange(SCR_DebugMenuID.DEBUGUI_RADIALMENU_CUSTOM_SIZE, "", "Sustom size", rmDiagName, "100, 1000, 100, 1");
654
655 DiagMenu.RegisterBool(SCR_DebugMenuID.DEBUGUI_RADIALMENU_ENTRY_COUNT_ENABLE, "", "Entries setup", rmDiagName);
656 DiagMenu.RegisterRange(SCR_DebugMenuID.DEBUGUI_RADIALMENU_ENTRY_COUNT, "", "Entries", rmDiagName, "2, 32, 2, 1");
657 }
658
659 //------------------------------------------------------------------------------------------------
660 protected void DebugCleanup()
661 {
662 DiagMenu.Unregister(SCR_DebugMenuID.DEBUGUI_RADIALMENU_CONFIG_DEBUG);
663 DiagMenu.Unregister(SCR_DebugMenuID.DEBUGUI_RADIALMENU_CLOSE_ON_RELEASE_OPEN);
664 DiagMenu.Unregister(SCR_DebugMenuID.DEBUGUI_RADIALMENU_PERFORM_ON_CLOSE);
665 DiagMenu.Unregister(SCR_DebugMenuID.DEBUGUI_RADIALMENU_CLOSE_ON_PERFORM);
666 DiagMenu.Unregister(SCR_DebugMenuID.DEBUGUI_RADIALMENU_DESELECT_IN_CENTER);
667 DiagMenu.Unregister(SCR_DebugMenuID.DEBUGUI_RADIALMENU_USE_LARGE_SIZE);
668 DiagMenu.Unregister(SCR_DebugMenuID.DEBUGUI_RADIALMENU_CUSTOM_SIZE_ENABLE);
669 DiagMenu.Unregister(SCR_DebugMenuID.DEBUGUI_RADIALMENU_CUSTOM_SIZE);
670 DiagMenu.Unregister(SCR_DebugMenuID.DEBUGUI_RADIALMENU_ENTRY_COUNT_ENABLE);
671 DiagMenu.Unregister(SCR_DebugMenuID.DEBUGUI_RADIALMENU_ENTRY_COUNT);
672 }
673
674 //------------------------------------------------------------------------------------------------
676 protected void DebugSetupControllerInputs(out notnull SCR_RadialMenuControllerInputs inputs)
677 {
678 // Check if debug is enabled
679 if (!DiagMenu.GetBool(SCR_DebugMenuID.DEBUGUI_RADIALMENU_CONFIG_DEBUG))
680 return;
681
682 inputs.m_bCloseOnReleaseOpen = DiagMenu.GetBool(SCR_DebugMenuID.DEBUGUI_RADIALMENU_CLOSE_ON_RELEASE_OPEN);
683 inputs.m_bPerformOnClose = DiagMenu.GetBool(SCR_DebugMenuID.DEBUGUI_RADIALMENU_PERFORM_ON_CLOSE);
684 inputs.m_bCloseOnPerform = DiagMenu.GetBool(SCR_DebugMenuID.DEBUGUI_RADIALMENU_CLOSE_ON_PERFORM);
685 inputs.m_bDeselectInCenter = DiagMenu.GetBool(SCR_DebugMenuID.DEBUGUI_RADIALMENU_DESELECT_IN_CENTER);
686 inputs.m_bUseLargeSize = DiagMenu.GetBool(SCR_DebugMenuID.DEBUGUI_RADIALMENU_USE_LARGE_SIZE);
687
688 if (DiagMenu.GetBool(SCR_DebugMenuID.DEBUGUI_RADIALMENU_CUSTOM_SIZE_ENABLE))
689 inputs.m_fCustomSize = DiagMenu.GetRangeValue(SCR_DebugMenuID.DEBUGUI_RADIALMENU_CUSTOM_SIZE);
690 else
691 inputs.m_fCustomSize = -1;
692 }
693
694 //------------------------------------------------------------------------------------------------
695 protected void DebugFillWithEntries()
696 {
697 if (!DiagMenu.GetBool(SCR_DebugMenuID.DEBUGUI_RADIALMENU_ENTRY_COUNT_ENABLE))
698 return;
699
700 m_aEntries.Clear();
701
702 int count = DiagMenu.GetRangeValue(SCR_DebugMenuID.DEBUGUI_RADIALMENU_ENTRY_COUNT);
703 for (int i = 0; i < count; i++)
704 {
705 SCR_SelectionMenuEntry entry = new SCR_SelectionMenuEntry();
706 entry.SetName("Debug entry " + i);
707 entry.Enable(true);
708
709 AddEntry(entry);
710 }
711 }
712
713 #endif
714
715 //------------------------------------------------------------------------------------------------
717 {
718 #ifdef RADMENU_DEBUG
719 DebugSetupDiagMenu();
720 #endif
721 }
722
723 //------------------------------------------------------------------------------------------------
725 {
726 #ifdef RADMENU_DEBUG
727 DebugCleanup();
728 #endif
729 }
730
731 //------------------------------------------------------------------------------------------------
733 {
735 }
736
737 //------------------------------------------------------------------------------------------------
742
743 //------------------------------------------------------------------------------------------------
745 {
747 return false;
748
749 return m_RadialControllerInputs.m_bUseQuickActions;
750 }
751};
752
753//------------------------------------------------------------------------------------------------
757[BaseContainerProps(configRoot: true)]
759{
760 protected const string RADIAL_LEFT_CONTEXT = "RadialMenuLeftContext";
761 protected const string RADIAL_RIGHT_CONTEXT = "RadialMenuRightContext";
762 protected const string DEFAULT_RADIAL_LEFT_X = "RadialX";
763 protected const string DEFAULT_RADIAL_LEFT_Y = "RadialY";
764 protected const string DEFAULT_RADIAL_RIGHT_X = "RadialX2";
765 protected const string DEFAULT_RADIAL_RIGHT_Y = "RadialY2";
766
767 [Attribute("100", desc: "How far from center needs to be to select entry. Use when controller m_bDeselectInCenter = true")]
769
770 [Attribute("250", UIWidgets.Slider, desc: "Delay in ms for how long should context be active - prevents character rotation and other unwanted input", "0 1000 1")]
772
773 [Attribute("1", desc: "Allow dynamically setup inner mouse selection treshold base on menu size from SIZE_LARGE")]
775
776 [Attribute("0.5", "0 1 0.01", desc: "How far from center needs to be to select entry. Use when controller m_bDeselectInCenter = true")]
778
779 [Attribute("500", UIWidgets.Slider, desc: "How long in milisecond should selection stay when moving to center.", "0 1000 1")]
781
782 protected bool m_bUseRightStick;
783
784 //------------------------------------------------------------------------------------------------
787 override void Init()
788 {
790 }
791
792 //------------------------------------------------------------------------------------------------
793 void GetRadialXYInput(out float x, out float y)
794 {
795 InputManager inputManager = GetGame().GetInputManager();
797 {
798 inputManager.ActivateContext(RADIAL_RIGHT_CONTEXT, m_iGamepadDeselectionDelay);
799 x = inputManager.GetActionValue(DEFAULT_RADIAL_RIGHT_X);
800 y = inputManager.GetActionValue(DEFAULT_RADIAL_RIGHT_Y);
801 }
802 else
803 {
804 inputManager.ActivateContext(RADIAL_LEFT_CONTEXT, m_iGamepadDeselectionDelay);
805 x = inputManager.GetActionValue(DEFAULT_RADIAL_LEFT_X);
806 y = inputManager.GetActionValue(DEFAULT_RADIAL_LEFT_Y);
807 }
808 }
809
810 //------------------------------------------------------------------------------------------------
811 void SetUseRightStick(bool use)
812 {
813 m_bUseRightStick = use;
814 }
815};
816
817//------------------------------------------------------------------------------------------------
818[BaseContainerProps(configRoot: true)]
820{
821 const static int MAX_HINTS = 9;
822
823 [Attribute("1", desc: "True = right thumbstick used for menu navigation, otherwise use left thumbstick")]
824 bool m_bUseRightStick;
825
826 [Attribute("1", desc: "Select no entry if selection is pointing into menu center")]
827 bool m_bDeselectInCenter;
828
829 [Attribute("1", desc: "Use large or small size for radial menu visuals")]
830 bool m_bUseLargeSize;
831
832 [Attribute("-1", UIWidgets.Slider, desc: "Base radial menu size. Will ignore m_bUseLargeSize and use custom size instead of presets if it's more than 0", "-1 1000 1")]
833 float m_fCustomSize;
834
835 [Attribute("0", UIWidgets.Slider, desc: "Display the crosshair in the center of the layout")]
836 bool m_bShowCrosshair;
837
838 [Attribute("1", UIWidgets.Slider, desc: "Display inner circle backround if true")]
839 bool m_bShowInnerBackground;
840
841 [Attribute("0", UIWidgets.Slider, desc: "Allows to use entries with quick 1-10 input")]
842 bool m_bUseQuickActions;
843}
AddonBuildInfoTool id
SCR_DebugMenuID
This enum contains all IDs for DiagMenu entries added in script.
Definition DebugMenuID.c:4
ArmaReforgerScripted GetGame()
Definition game.c:1398
int size
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
ScriptCallQueue GetCallqueue()
Returns CallQueue of this AI. It gets updated from EvaluateBehavior, so that it's synchronous with ot...
InputManager GetInputManager()
float distance
override void OnUpdate()
ScriptInvokerBase< ScriptInvokerSelectionMenuEntryMethod > ScriptInvokerSelectionMenuEntry
func ScriptInvokerSelectionMenuEntryMethod
ADD_COMMANDS_MENU
SCR_ERadialMenuType
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Constant variables used in various menus.
Input management system for user interactions.
Definition Math.c:13
SCR_InfoDisplay FindInfoDisplay(typename type)
Return hud component of given type.
static SCR_HUDManagerComponent GetHUDManager()
static ScriptInvokerMenu GetOnMenuOpened()
void InvokeOnSetActionHint(string action)
ScriptInvokerSelectionMenuEntry GetOnEntryPerformed()
float m_fDynamicMouseSelectionTreshold
const float SIZE_LARGE
void InvokeOnDisplaySizeChange(float size)
static SCR_RadialMenu m_OpenedRadialMenu
void SetMenuCenterPos(vector centerPos)
ref ScriptInvoker< SCR_RadialMenu, string > m_OnSetActionHint
vector m_vMenuCenterPos
SCR_RadialMenuInputs m_RadialInputs
ScriptInvoker GetOnDisplaySizeChange()
static SCR_RadialMenu GetOpenedRadialMenu()
Find and get reference to global redial menu.
override event void OnOpen()
bool GetUseQuickActions()
override void SetMenuDisplay(SCR_SelectionMenuDisplay display=null)
Radial menu set menu display will auto find HUD manager radial menu display if display is null.
void OnUpdate(float timeSlice)
Empty method called on update ready for override.
void RemoveActionListeners()
Remove 1-9 quick actions.
ScriptInvoker GetOnSetActionHint()
void ChangeDisplaySize(bool useLarge=true, float customSize=-1)
void SelectEntry()
For gamepad - based on direction of stick.
SCR_RadialMenuControllerInputs m_RadialControllerInputs
bool m_bPreventSelectionContext
override event void OnClose()
void SetPreventSelectionContext(bool enable)
ref ScriptInvoker< SCR_RadialMenu, float > m_OnDisplaySizeChange
void ReactQuickInput()
Check quick 1-10 actions and perform entry on action trigger.
SCR_SelectionMenuEntry HandleSelection(out int id)
int GetSelectedElementIndex(float angle, int elementCount)
float AdjustDistanceWithResolution(float distance)
bool IsPointingToCenter()
ref ScriptInvokerSelectionMenuEntry m_OnEntryPerformed
const float SIZE_SMALL
override void SetController(IEntity owner, SCR_SelectionMenuControllerInputs controls)
float m_fEntriesAngleDistance
void OnMenuOpened(ChimeraMenuBase menu)
float GetPointingAngle()
static SCR_RadialMenu m_GlobalRadialMenu
void AddActionListeners()
Add 1-9 quick actions.
void InvokeOnUpdateEntries(array< ref SCR_SelectionMenuEntry > entries)
float GetEntriesAngleDistance()
override void Update(float timeSlice)
static SCR_RadialMenu GlobalRadialMenu()
Find and get reference to global redial menu.
void QuickActionUse(int id)
float m_fEntryAngleOffset
SCR_ERadialMenuType m_eRadialType
bool GetPreventSelectionContext()
void SetActionHint(string action)
Set current hint to display and send invoke it so radial menu display will show the hint.
override void Init()
const string RADIAL_LEFT_CONTEXT
const string DEFAULT_RADIAL_RIGHT_X
const string DEFAULT_RADIAL_LEFT_Y
void GetRadialXYInput(out float x, out float y)
const string DEFAULT_RADIAL_RIGHT_Y
const string DEFAULT_RADIAL_LEFT_X
void SetUseRightStick(bool use)
const string RADIAL_RIGHT_CONTEXT
void SetName(string name)
string GetInputAction()
void Enable(bool enable)
void DebugPrint(string method, string msg)
SCR_SelectionMenuEntry m_SelectedEntry
ref array< ref SCR_SelectionMenuEntry > m_aEntries
ref SCR_SelectionMenuInputs m_Inputs
ref SCR_SelectionMenuControllerInputs m_ControllerInputs
void AddEntry(SCR_SelectionMenuEntry entry=null)
void InvokeOnSelect(SCR_SelectionMenuEntry entry, int id)
void PlaySound(string sound)
void Close()
Callback when close is requested.
void PerformEntry(notnull SCR_SelectionMenuEntry entry)
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
@ DEFAULT
Use currently set main RT format (based on game options).
SCR_FieldOfViewSettings Attribute
EActionTrigger
proto native vector Vector(float x, float y, float z)
proto int GetRemainingTime(func fn)
return Remaining time to the call execution (in miliseconds)
ScriptInvokerBase< func > ScriptInvoker
Definition tools.c:134