Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_EditorToggleUIComponent.c
Go to the documentation of this file.
1
2
4{
5 [Attribute()]
6 protected string m_sProgressWidgetName;
7
8 [Attribute()]
9 protected string m_sInitLoadingWidgetName;
10
11 [Attribute()]
12 protected string m_sLoadingWidgetName;
13
14 [Attribute()]
15 protected string m_sBlurName;
16
17 [Attribute()]
18 protected string m_sAutoInitName;
19
20 [Attribute("0.4", desc: "When the actual charging starts. This should be after ping is evaluated. Thinging this value also means changing the process min of m_RadialProcessBar and the Ping input!")]
21 protected float m_fChargeThreshold;
22
25 protected Widget m_Widget;
26 protected Widget m_Blur;
27 protected Widget m_AutoInit;
32
33 //State
34 protected bool m_bCharging;
35
36 //------------------------------------------------------------------------------------------------
37 protected void ChargeStart()
38 {
39 if (m_MenuManager.IsAnyDialogOpen() || m_EditorManager.GetCurrentModeEntity().GetPreventClose())
40 return;
41
42 m_bCharging = true;
43 m_Blur.SetVisible(true);
44
45 if (m_Widget.IsVisible())
46 return;
47
48 m_Widget.SetVisible(true);
49 m_RadialProcessBar.FadeImage(true);
50 m_ProgressWidget.SetVisible(true);
51 m_LoadingWidget.GetFadeWidget().SetVisible(false);
52 }
53
54 //------------------------------------------------------------------------------------------------
55 protected void ChargeFail()
56 {
57 m_bCharging = false;
58 m_Blur.SetVisible(false);
59 m_Widget.SetVisible(false);
60
61 if (m_RadialProcessBar.GetProgress() == m_RadialProcessBar.GetMaxProgress() || m_RadialProcessBar.GetProgress() <= m_RadialProcessBar.GetMinProgress())
62 return;
63
64 m_RadialProcessBar.InstantProgressMaxMin(false);
65 }
66
67 //------------------------------------------------------------------------------------------------
68 protected void WaitStart()
69 {
70 SCR_EditorModeEntity mode = m_EditorManager.GetCurrentModeEntity();
71 if (mode)
72 mode.GetInfo().SetIconTo(m_RadialProcessBar.GetFadeImage());
73
74 if (!m_Widget.IsVisible())
75 {
76 m_AutoInit.SetVisible(m_EditorManager.IsAutoInit());
77 m_Blur.SetVisible(true);
78 m_Widget.SetVisible(true);
79 m_RadialProcessBar.InstantProgressMaxMin(false);
80 m_RadialProcessBar.FadeImage(true);
81 //m_InitLoadingWidget.FadeIn();
82 m_LoadingWidget.FadeIn();
83 }
84
85 if (m_InitLoadingWidget && m_EditorManager.IsAutoInit())
86 m_InitLoadingWidget.FadeIn();
87 }
88
89 //------------------------------------------------------------------------------------------------
90 protected void WaitEnd()
91 {
92 m_RadialProcessBar.SetProgress(m_RadialProcessBar.GetMinProgress());
93
94 if (m_AutoInit.IsVisible())
95 {
96 AnimateWidget.Opacity(m_AutoInit, 0, UIConstants.FADE_RATE_SUPER_SLOW);
97
99 m_InitLoadingWidget.FadeOut(true);
100 }
101
102 m_Blur.SetVisible(false);
103 m_LoadingWidget.FadeOut(false);
104 }
105
106 //------------------------------------------------------------------------------------------------
108 {
109 if (!m_bCharging && !isFadeIn)
110 {
111 m_RadialProcessBar.InstantProgressMaxMin(false);
112 m_Widget.SetVisible(false);
113 }
114 }
115
116 //------------------------------------------------------------------------------------------------
117 protected void OnEditorToggleValue(float value, EActionTrigger reason)
118 {
119 SCR_EditorModeEntity mode = m_EditorManager.GetCurrentModeEntity();
120
121 if (m_MenuManager.IsAnyDialogOpen() || mode && mode.GetPreventClose())
122 ChargeFail();
123
124 if (value == 0)
125 {
126 //Charge has failed
127 if (m_bCharging)
128 ChargeFail();
129
130 return;
131 }
132 //If cannot open editor
133 else if (!m_EditorManager || !m_EditorManager.CanToggle())
134 {
135 //Safty if rights where removed
136 if (m_bCharging)
137 ChargeFail();
138
139 return;
140 }
141 //Visualize the charge only after ping input time window
142 else if (value < m_fChargeThreshold)
143 {
144 return;
145 }
146
147 if (!m_bCharging)
148 ChargeStart();
149 else
150 m_RadialProcessBar.SetProgress(value);
151 }
152
153 //------------------------------------------------------------------------------------------------
154 protected void OnEditorToggleDone()
155 {
156 //Editor failed to open, terminate
157 if (!m_EditorManager.IsInTransition())
158 ChargeFail();
159
160 m_bCharging = false;
161 }
162
163 //------------------------------------------------------------------------------------------------
164 protected void OnRequest()
165 {
166 WaitStart();
167 }
168
169 //------------------------------------------------------------------------------------------------
170 protected void OnRequestEnd()
171 {
172 m_bCharging = false;
173 WaitEnd();
174 }
175
176 //------------------------------------------------------------------------------------------------
177 protected void OnAsyncLoad(float progress)
178 {
179 if (progress < 1)
180 WaitStart();
181 else
182 WaitEnd();
183 }
184
185 //------------------------------------------------------------------------------------------------
186 override void HandlerAttached(Widget w)
187 {
189 return;
190
192 if (!m_EditorManager)
193 return;
194
195 InputManager inputManager = GetGame().GetInputManager();
196 if (!inputManager)
197 return;
198
200 if (!m_ProgressWidget)
201 {
202 Print(string.Format("ProgressBarWidget '%1' not found!", m_sProgressWidgetName), LogLevel.WARNING);
203 return;
204 }
205
208 return;
209
210 m_RadialProcessBar.GetOnFadeDone().Insert(OnRadialProgressFadeDone);
211
212 m_Blur = w.FindWidget(m_sBlurName);
213 m_AutoInit = w.FindWidget(m_sAutoInitName);
214 m_AutoInit.SetVisible(false);
215
216 Widget loadingWidget = w.FindAnyWidget(m_sLoadingWidgetName);
217 m_LoadingWidget = SCR_FadeUIComponent.Cast(loadingWidget.FindHandler(SCR_FadeUIComponent));
218 m_LoadingWidget.GetFadeWidget().SetVisible(false);
219
220 Widget initLoadingWidget = w.FindAnyWidget(m_sInitLoadingWidgetName);
221 m_InitLoadingWidget = SCR_FadeUIComponent.Cast(initLoadingWidget.FindHandler(SCR_FadeUIComponent));
222
223 m_Widget = w;
224 m_Widget.SetVisible(false);
225
226 m_EditorManager.GetOnRequest().Insert(OnRequest);
227 m_EditorManager.GetOnOpened().Insert(OnRequestEnd);
228 m_EditorManager.GetOnClosed().Insert(OnRequestEnd);
229 m_EditorManager.GetOnAsyncLoad().Insert(OnAsyncLoad);
230
231 inputManager.AddActionListener("EditorToggle", EActionTrigger.VALUE, OnEditorToggleValue);
232 inputManager.AddActionListener("EditorToggle", EActionTrigger.UP, OnEditorToggleDone);
233
234 m_MenuManager = GetGame().GetMenuManager();
235 }
236
237 //------------------------------------------------------------------------------------------------
238 override void HandlerDeattached(Widget w)
239 {
240 if (m_EditorManager)
241 {
242 m_EditorManager.GetOnRequest().Remove(OnRequest);
243 m_EditorManager.GetOnOpened().Remove(OnRequestEnd);
244 m_EditorManager.GetOnClosed().Remove(OnRequestEnd);
245 m_EditorManager.GetOnAsyncLoad().Remove(OnAsyncLoad);
246 }
247
248 InputManager inputManager = GetGame().GetInputManager();
249 if (inputManager)
250 {
251 inputManager.RemoveActionListener("EditorToggle", EActionTrigger.VALUE, OnEditorToggleValue);
252 inputManager.RemoveActionListener("EditorToggle", EActionTrigger.UP, OnEditorToggleDone);
253
254 }
255
257 m_RadialProcessBar.GetOnFadeDone().Remove(OnRadialProgressFadeDone);
258 }
259}
ArmaReforgerScripted GetGame()
Definition game.c:1398
void SCR_EditorManagerEntity(IEntitySource src, IEntity parent)
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
static WidgetAnimationOpacity Opacity(Widget widget, float targetValue, float speed, bool toggleVisibility=false)
Input management system for user interactions.
SCR_ImageRadialProgressBarUIComponent m_RadialProcessBar
void OnRadialProgressFadeDone(SCR_ImageRadialProgressBarUIComponent radial, bool isFadeIn)
void OnEditorToggleValue(float value, EActionTrigger reason)
static bool IsEditMode()
Definition Functions.c:1566
bool SetIconTo(ImageWidget imageWidget)
Definition SCR_UIInfo.c:102
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
Definition LogLevel.c:14
SCR_FieldOfViewSettings Attribute
EActionTrigger