Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_HideEditorUIComponent.c
Go to the documentation of this file.
1
2
4{
5 [Attribute("10", UIWidgets.Auto, "Speed of smooth transition between visible and hidden state.")]
6 protected float m_fTransitionSpeed;
7
8 [Attribute(desc: "Show interface again when any of these actions is triggered")]
9 protected ref array<string> m_aShowActions;
10
12 protected float m_fTargetOpacity = 1;
13 protected bool m_bInTransition;
15
16 //------------------------------------------------------------------------------------------------
20 void SetVisible(bool visible, bool instant = false)
21 {
22 Widget widget = GetWidget();
23 if (!widget)
24 return;
25
26 widget.SetEnabled(visible);
27
28 if (visible)
30 else
32
33 if (instant)
35 else
36 m_bInTransition = true;
37 }
38
39 //------------------------------------------------------------------------------------------------
48
49 //------------------------------------------------------------------------------------------------
50 protected void Show()
51 {
52 //--- Use delay, so clicking on hidden button won't activate it instantly
53 GetGame().GetCallqueue().CallLater(SetMenuVisible, 1, false, true);
54 }
55
56 //------------------------------------------------------------------------------------------------
57 protected void SetMenuVisible(bool visible)
58 {
60 m_EditorMenuManager.SetVisible(visible);
61 }
62
63 //------------------------------------------------------------------------------------------------
64 protected void SetWidgetOpacity(Widget widget, float opacity)
65 {
66 if (widget)
67 widget.SetOpacity(opacity);
68
70 Event_OnOpacityChange.Invoke(opacity);
71 }
72
73 //------------------------------------------------------------------------------------------------
74 protected void OnMenuUpdate(float tDelta)
75 {
76 Widget widget = GetWidget();
77 if (!widget)
78 return;
79
80 //--- Disabled, handled by SCR_ToggleInterfaceToolbarAction now
81// if (m_InputManager.GetActionTriggered("EditorToggleUI"))
82// {
83// if (m_EditorMenuManager)
84// m_EditorMenuManager.ToggleVisible();
85// else
86// SetVisible(!widget.IsEnabled());
87// }
88
90 {
91 float opacity = widget.GetOpacity();
92 if (Math.AbsFloat(opacity - m_fTargetOpacity) < 0.01)
93 {
95 m_bInTransition = false;
96 return;
97 }
98 SetWidgetOpacity(widget, Math.Lerp(opacity, m_fTargetOpacity, m_fTransitionSpeed * tDelta));
99 }
100 }
101
102 //------------------------------------------------------------------------------------------------
103 protected void OnMenuInit()
104 {
106 SetVisible(m_EditorMenuManager.IsVisible(), true);
107 }
108
109 //------------------------------------------------------------------------------------------------
111 {
112 super.HandlerAttachedScripted(w);
114 return; //--- Run-time only
115
116 MenuRootBase menu = GetMenu();
117 if (!menu)
118 return;
119
120 OnMenuInit();
121 menu.GetOnMenuInit().Insert(OnMenuInit);
122 menu.GetOnMenuUpdate().Insert(OnMenuUpdate);
123
125
126 InputManager inputManager = GetGame().GetInputManager();
127 if (inputManager)
128 {
129 foreach (string showAction : m_aShowActions)
130 {
131 inputManager.AddActionListener(showAction, EActionTrigger.DOWN, Show);
132 }
133 }
134 }
135
136 //------------------------------------------------------------------------------------------------
137 override void HandlerDeattached(Widget w)
138 {
139 super.HandlerDeattached(w);
140
141 InputManager inputManager = GetGame().GetInputManager();
142 if (inputManager)
143 {
144 foreach (string showAction : m_aShowActions)
145 {
146 inputManager.RemoveActionListener(showAction, EActionTrigger.DOWN, Show);
147 }
148 }
149 }
150}
ArmaReforgerScripted GetGame()
Definition game.c:1398
SCR_RadialMenu GetMenu()
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Widget GetWidget()
Input management system for user interactions.
Definition Math.c:13
ScriptInvoker GetOnMenuInit()
ScriptInvoker GetOnMenuUpdate()
static bool IsEditMode()
Definition Functions.c:1566
override void HandlerAttachedScripted(Widget w)
void SetWidgetOpacity(Widget widget, float opacity)
SCR_MenuEditorComponent m_EditorMenuManager
void SetVisible(bool visible, bool instant=false)
override void HandlerDeattached(Widget w)
SCR_FieldOfViewSettings Attribute
EActionTrigger
ScriptInvokerBase< func > ScriptInvoker
Definition tools.c:134