Arma Reforger Explorer
1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Toggle main menu visibility
Loading...
Searching...
No Matches
SCR_HorizontalScrollAnimationComponent.c
Go to the documentation of this file.
1
16
17
[
EnumLinear
()]
18
enum
SCR_EScrollAnimationState
19
{
20
NONE
,
21
22
MOVING_LEFT
,
23
MOVING_LEFT_DONE_WAITING
,
24
MOVING_RIGHT
,
25
MOVING_RIGHT_DONE_WAITING
,
26
27
MOVING_TOP
,
28
MOVING_TOP_DONE_WAITING
,
29
MOVING_BOTTOM
,
30
MOVING_BOTTOM_DONE_WAITING
31
}
32
33
class
SCR_HorizontalScrollAnimationComponent :
ScriptedWidgetComponent
34
{
35
[
Attribute
(
"Content"
, UIWidgets.EditBox,
"Name of widget which will be animated"
)]
36
protected
string
m_sAnimationContentWidget;
37
38
[
Attribute
(
"10"
, UIWidgets.EditBox,
"Animation speed"
)]
39
protected
float
m_fAnimationSpeedPxPerSec
;
40
41
[
Attribute
(
"0.5"
,
UIWidgets
.EditBox,
"Wait time while animating when content is on the left"
)]
42
protected
float
m_fWaitTimeLeftSec
;
43
44
[
Attribute
(
"0.5"
,
UIWidgets
.EditBox,
"Wait time while animating when content is on the right"
)]
45
protected
float
m_fWaitTimeRightSec
;
46
47
[
Attribute
(
"false"
,
UIWidgets
.CheckBox,
"When true, content will animate to start after it has animated left. Otherwise it will jump to start instantly."
)]
48
protected
bool
m_bAnimateBack
;
49
50
[
Attribute
(
"0"
,
UIWidgets
.CheckBox,
"Inwards offset from right edge of root widget to be used in calculations"
)]
51
protected
float
m_fOffsetRight
;
52
53
[
Attribute
(
"0"
,
UIWidgets
.CheckBox,
"Inwards offset from left edge of root widget to be used in calculations"
)]
54
protected
float
m_fOffsetLeft
;
55
56
[
Attribute
(
typename
.EnumToString(
SCR_EScrollAnimationState
,
SCR_EScrollAnimationState
.NONE),
UIWidgets
.ComboBox,
"Start state of animation"
,
""
, ParamEnumArray.FromEnum(
SCR_EScrollAnimationState
))]
57
protected
SCR_EScrollAnimationState
m_eInitialState
;
58
59
protected
SCR_EScrollAnimationState
m_eState
;
60
protected
Widget
m_wContent
;
61
protected
Widget
m_wRoot
;
62
63
protected
float
m_fStartPosX
;
64
protected
float
m_fStartPosY
;
65
protected
float
m_fTimer
;
66
67
protected
float
m_fTargetPosX
;
68
protected
float
m_fTargetPosY
;
69
70
protected
bool
m_bIsVerticalAnimation
;
71
72
//------------------------------------------------------------------------------------------------
73
// P U B L I C
74
75
//------------------------------------------------------------------------------------------------
76
void
AnimationStop
()
77
{
78
m_eState
=
SCR_EScrollAnimationState
.NONE;
79
80
if
(
GetGame
() &&
GetGame
().
GetCallqueue
())
81
GetGame
().GetCallqueue().Remove(
OnFrame
);
82
}
83
84
//------------------------------------------------------------------------------------------------
85
void
AnimationStart
(
bool
IsVerticalAnimation =
false
)
86
{
87
// If not animating, start animation
88
if
(
m_eState
==
SCR_EScrollAnimationState
.NONE)
89
{
90
ResetPosition
();
91
GetGame
().GetCallqueue().CallLater(
SetupValues
, 0);
92
GetGame
().GetCallqueue().CallLater(
OnFrame
, 0,
true
);
93
94
m_bIsVerticalAnimation
= IsVerticalAnimation;
95
96
if
(
m_bIsVerticalAnimation
)
97
m_eState
=
SCR_EScrollAnimationState
.MOVING_TOP;
98
else
99
m_eState
=
SCR_EScrollAnimationState
.MOVING_LEFT;
100
}
101
102
// Otherwise it's already animating in some state, do nothing
103
}
104
105
//------------------------------------------------------------------------------------------------
106
bool
IsAnimating
()
107
{
108
return
m_eState
!=
SCR_EScrollAnimationState
.NONE;
109
}
110
111
//------------------------------------------------------------------------------------------------
112
protected
void
SetupValues
()
113
{
114
float
contentw, contenth, contentx, contenty, rootw, rooth, rootx, rooty;
115
m_wContent
.GetScreenSize(contentw, contenth);
116
m_wContent
.GetScreenPos(contentx, contenty);
117
m_wRoot
.GetScreenSize(rootw, rooth);
118
m_wRoot
.GetScreenPos(rootx, rooty);
119
120
m_fStartPosX
=
FrameSlot
.GetPosX(
m_wContent
);
121
m_fStartPosY
=
FrameSlot
.GetPosY(
m_wContent
);
122
123
WorkspaceWidget
workspace =
GetGame
().GetWorkspace();
124
125
m_fTargetPosX
= rootw - contentw - workspace.DPIScale(
m_fOffsetLeft
);
126
m_fTargetPosY
= rooth - contenth + workspace.DPIScale(
m_fOffsetLeft
);
127
}
128
129
//------------------------------------------------------------------------------------------------
131
void
ResetPosition
()
132
{
133
if
(!
m_wContent
)
134
return
;
135
136
if
(
m_bIsVerticalAnimation
)
137
FrameSlot
.SetPosY(
m_wContent
,
m_fStartPosY
);
138
else
139
FrameSlot
.SetPosX(
m_wContent
,
m_fStartPosX
);
140
}
141
142
//------------------------------------------------------------------------------------------------
144
bool
GetContentFitX
()
145
{
146
if
(!
m_wContent
)
147
return
true
;
148
149
float
rootw, rooth, contentw, contenth;
150
m_wContent
.GetScreenSize(contentw, contenth);
151
m_wRoot
.GetScreenSize(rootw, rooth);
152
153
return
rootw > contentw +
GetGame
().GetWorkspace().DPIScale(
m_fOffsetLeft
+
m_fOffsetRight
);
154
}
155
156
//------------------------------------------------------------------------------------------------
158
bool
GetContentFitY
()
159
{
160
if
(!
m_wContent
)
161
return
true
;
162
163
float
rootw, rooth, contentw, contenth;
164
m_wContent
.GetScreenSize(contentw, contenth);
165
m_wRoot
.GetScreenSize(rootw, rooth);
166
167
return
rooth > contenth +
GetGame
().GetWorkspace().DPIScale(
m_fOffsetLeft
+
m_fOffsetRight
);
168
}
169
170
//------------------------------------------------------------------------------------------------
171
// P R O T E C T E D
172
173
//------------------------------------------------------------------------------------------------
174
protected
override
void
HandlerAttached
(
Widget
w)
175
{
176
if
(!
GetGame
().InPlayMode())
177
return
;
178
179
m_wRoot
= w;
180
m_wContent
= w.FindAnyWidget(m_sAnimationContentWidget);
181
182
if
(!
m_wContent
)
183
{
184
PrintFormat
(
"[SCR_HorizontalScrollAnimationComponent] Widget %1 was not found"
, m_sAnimationContentWidget, level:
LogLevel
.ERROR);
185
return
;
186
}
187
188
m_eState
=
m_eInitialState
;
189
190
//use CallLater, it seems that Call() might not have a loop/repeat option
191
if
(
m_eState
!=
SCR_EScrollAnimationState
.NONE)
192
{
193
GetGame
().GetCallqueue().CallLater(
SetupValues
, 0);
194
GetGame
().GetCallqueue().CallLater(
OnFrame
, 0,
true
);
195
}
196
}
197
198
//------------------------------------------------------------------------------------------------
199
override
void
HandlerDeattached
(
Widget
w)
200
{
201
if
(
GetGame
() &&
GetGame
().
GetCallqueue
())
202
GetGame
().GetCallqueue().Remove(
OnFrame
);
203
}
204
205
//------------------------------------------------------------------------------------------------
206
protected
void
OnFrame
()
207
{
208
float
tDelta = ftime * 0.001;
209
210
switch
(
m_eState
)
211
{
212
case
SCR_EScrollAnimationState
.NONE:
213
// Doing nothing
214
break
;
215
216
case
SCR_EScrollAnimationState
.MOVING_LEFT:
217
{
218
if
(
AnimateHorizontalPosition
(tDelta, -
m_fAnimationSpeedPxPerSec
,
m_fTargetPosX
))
219
{
220
m_eState
=
SCR_EScrollAnimationState
.MOVING_LEFT_DONE_WAITING;
221
m_fTimer
=
m_fWaitTimeLeftSec
;
222
}
223
224
break
;
225
}
226
227
case
SCR_EScrollAnimationState
.MOVING_LEFT_DONE_WAITING:
228
{
229
m_fTimer
-= tDelta;
230
if
(
m_fTimer
< 0)
231
{
232
if
(
m_bAnimateBack
)
233
{
234
m_eState
=
SCR_EScrollAnimationState
.MOVING_RIGHT;
235
}
236
else
237
{
238
ResetPosition
();
239
m_fTimer
=
m_fWaitTimeRightSec
;
240
m_eState
=
SCR_EScrollAnimationState
.MOVING_RIGHT_DONE_WAITING;
241
}
242
}
243
244
break
;
245
}
246
247
case
SCR_EScrollAnimationState
.MOVING_RIGHT:
248
{
249
WorkspaceWidget
workspace =
GetGame
().GetWorkspace();
250
if
(
AnimateHorizontalPosition
(tDelta,
m_fAnimationSpeedPxPerSec
, workspace.DPIScale(
m_fOffsetRight
)))
251
{
252
m_eState
=
SCR_EScrollAnimationState
.MOVING_RIGHT_DONE_WAITING;
253
m_fTimer
=
m_fWaitTimeRightSec
;
254
}
255
256
break
;
257
}
258
259
case
SCR_EScrollAnimationState
.MOVING_RIGHT_DONE_WAITING:
260
{
261
m_fTimer
-= tDelta;
262
if
(
m_fTimer
< 0)
263
{
264
m_eState
=
SCR_EScrollAnimationState
.MOVING_LEFT;
265
}
266
267
break
;
268
}
269
270
case
SCR_EScrollAnimationState
.MOVING_TOP:
271
{
272
if
(
AnimateVerticalPosition
(tDelta, -
m_fAnimationSpeedPxPerSec
,
m_fTargetPosY
))
273
{
274
m_eState
=
SCR_EScrollAnimationState
.MOVING_TOP_DONE_WAITING;
275
m_fTimer
=
m_fWaitTimeLeftSec
;
276
}
277
278
break
;
279
}
280
281
case
SCR_EScrollAnimationState
.MOVING_TOP_DONE_WAITING:
282
{
283
m_fTimer
-= tDelta;
284
if
(
m_fTimer
< 0)
285
{
286
if
(
m_bAnimateBack
)
287
{
288
m_eState
=
SCR_EScrollAnimationState
.MOVING_BOTTOM;
289
}
290
else
291
{
292
ResetPosition
();
293
m_fTimer
=
m_fWaitTimeRightSec
;
294
m_eState
=
SCR_EScrollAnimationState
.MOVING_BOTTOM_DONE_WAITING;
295
}
296
}
297
298
break
;
299
}
300
301
case
SCR_EScrollAnimationState
.MOVING_BOTTOM:
302
{
303
WorkspaceWidget
workspace =
GetGame
().GetWorkspace();
304
if
(
AnimateVerticalPosition
(tDelta, -
m_fAnimationSpeedPxPerSec
, workspace.DPIScale(
m_fOffsetRight
)))
305
{
306
m_eState
=
SCR_EScrollAnimationState
.MOVING_BOTTOM_DONE_WAITING;
307
m_fTimer
=
m_fWaitTimeRightSec
;
308
}
309
310
break
;
311
}
312
313
case
SCR_EScrollAnimationState
.MOVING_BOTTOM_DONE_WAITING:
314
{
315
m_fTimer
-= tDelta;
316
if
(
m_fTimer
< 0)
317
{
318
m_eState
=
SCR_EScrollAnimationState
.MOVING_TOP;
319
}
320
321
break
;
322
}
323
}
324
}
325
326
//------------------------------------------------------------------------------------------------
327
protected
bool
AnimateHorizontalPosition
(
float
tDelta,
float
speed,
float
target)
328
{
329
float
currentPos =
FrameSlot
.GetPosX(
m_wContent
);
330
float
newPos = currentPos + tDelta * speed;
331
332
if
((currentPos - target) * (newPos - target) <= 0)
333
{
334
FrameSlot
.SetPosX(
m_wContent
, target);
335
return
true
;
// reached destination !
336
}
337
else
338
{
339
FrameSlot
.SetPosX(
m_wContent
, newPos);
340
return
false
;
341
}
342
343
return
false
;
344
}
345
346
//------------------------------------------------------------------------------------------------
347
protected
bool
AnimateVerticalPosition
(
float
tDelta,
float
speed,
float
target)
348
{
349
float
currentPos =
FrameSlot
.GetPosY(
m_wContent
);
350
float
newPos = currentPos + tDelta * speed;
351
352
if
((currentPos - target) * (newPos - target) <= 0)
353
{
354
FrameSlot
.SetPosY(
m_wContent
, target);
355
return
true
;
// reached destination !
356
}
357
else
358
{
359
FrameSlot
.SetPosY(
m_wContent
, newPos);
360
return
false
;
361
}
362
}
363
364
//------------------------------------------------------------------------------------------------
365
static
SCR_HorizontalScrollAnimationComponent FindComponent(notnull Widget w)
366
{
367
return
SCR_HorizontalScrollAnimationComponent.Cast(w.FindHandler(SCR_HorizontalScrollAnimationComponent));
368
}
369
}
GetGame
ArmaReforgerScripted GetGame()
Definition
game.c:1398
m_eState
EAITargetClusterState m_eState
Definition
SCR_AITargetClusterState.c:24
GetCallqueue
ScriptCallQueue GetCallqueue()
Returns CallQueue of this AI. It gets updated from EvaluateBehavior, so that it's synchronous with ot...
Definition
SCR_AIUtilityComponent.c:478
m_fTimer
float m_fTimer
Definition
SCR_CampaignMilitaryBaseComponent.c:82
EnumLinear
SCR_CampaignSeizingComponent SCR_SeizingComponent EnumLinear()] enum SCR_EBaseCaptureState
Definition
SCR_CampaignSeizingComponent.c:333
m_wRoot
Widget m_wRoot
Definition
SCR_GameModeCleanSweep.c:25
m_fTargetPosX
float m_fTargetPosX
Definition
SCR_HorizontalScrollAnimationComponent.c:67
m_fStartPosX
float m_fStartPosX
Definition
SCR_HorizontalScrollAnimationComponent.c:63
AnimationStop
void AnimationStop()
Definition
SCR_HorizontalScrollAnimationComponent.c:76
m_fOffsetLeft
float m_fOffsetLeft
Definition
SCR_HorizontalScrollAnimationComponent.c:54
MOVING_TOP
MOVING_TOP
Definition
SCR_HorizontalScrollAnimationComponent.c:7
m_fWaitTimeRightSec
float m_fWaitTimeRightSec
Definition
SCR_HorizontalScrollAnimationComponent.c:45
MOVING_BOTTOM_DONE_WAITING
MOVING_BOTTOM_DONE_WAITING
Definition
SCR_HorizontalScrollAnimationComponent.c:11
m_fAnimationSpeedPxPerSec
float m_fAnimationSpeedPxPerSec
Definition
SCR_HorizontalScrollAnimationComponent.c:39
OnFrame
void OnFrame()
Definition
SCR_HorizontalScrollAnimationComponent.c:206
m_eInitialState
SCR_EScrollAnimationState m_eInitialState
Definition
SCR_HorizontalScrollAnimationComponent.c:57
MOVING_LEFT
MOVING_LEFT
Definition
SCR_HorizontalScrollAnimationComponent.c:2
MOVING_RIGHT
MOVING_RIGHT
Definition
SCR_HorizontalScrollAnimationComponent.c:4
IsAnimating
bool IsAnimating()
Definition
SCR_HorizontalScrollAnimationComponent.c:106
m_fOffsetRight
float m_fOffsetRight
Definition
SCR_HorizontalScrollAnimationComponent.c:51
m_wContent
Widget m_wContent
Definition
SCR_HorizontalScrollAnimationComponent.c:60
MOVING_TOP_DONE_WAITING
MOVING_TOP_DONE_WAITING
Definition
SCR_HorizontalScrollAnimationComponent.c:8
m_fWaitTimeLeftSec
float m_fWaitTimeLeftSec
Definition
SCR_HorizontalScrollAnimationComponent.c:42
AnimationStart
void AnimationStart(bool IsVerticalAnimation=false)
Definition
SCR_HorizontalScrollAnimationComponent.c:85
m_bAnimateBack
bool m_bAnimateBack
Definition
SCR_HorizontalScrollAnimationComponent.c:48
AnimateVerticalPosition
bool AnimateVerticalPosition(float tDelta, float speed, float target)
Definition
SCR_HorizontalScrollAnimationComponent.c:347
SCR_EScrollAnimationState
SCR_EScrollAnimationState
Definition
SCR_HorizontalScrollAnimationComponent.c:19
ResetPosition
void ResetPosition()
Sets X position to its initial value when component was initialized.
Definition
SCR_HorizontalScrollAnimationComponent.c:131
MOVING_BOTTOM
MOVING_BOTTOM
Definition
SCR_HorizontalScrollAnimationComponent.c:9
MOVING_RIGHT_DONE_WAITING
MOVING_RIGHT_DONE_WAITING
Definition
SCR_HorizontalScrollAnimationComponent.c:5
GetContentFitY
bool GetContentFitY()
Returns true when content fits the parent widget.
Definition
SCR_HorizontalScrollAnimationComponent.c:158
m_fStartPosY
float m_fStartPosY
Definition
SCR_HorizontalScrollAnimationComponent.c:64
m_bIsVerticalAnimation
bool m_bIsVerticalAnimation
Definition
SCR_HorizontalScrollAnimationComponent.c:70
GetContentFitX
bool GetContentFitX()
Returns true when content fits the parent widget.
Definition
SCR_HorizontalScrollAnimationComponent.c:144
AnimateHorizontalPosition
bool AnimateHorizontalPosition(float tDelta, float speed, float target)
Definition
SCR_HorizontalScrollAnimationComponent.c:327
MOVING_LEFT_DONE_WAITING
MOVING_LEFT_DONE_WAITING
Definition
SCR_HorizontalScrollAnimationComponent.c:3
SetupValues
void SetupValues()
Definition
SCR_HorizontalScrollAnimationComponent.c:112
m_fTargetPosY
float m_fTargetPosY
Definition
SCR_HorizontalScrollAnimationComponent.c:68
HandlerAttached
override void HandlerAttached(Widget w)
Definition
SCR_ServicesStatusDialogComponent.c:556
HandlerDeattached
override void HandlerDeattached(Widget w)
Definition
SCR_ServicesStatusDialogComponent.c:602
FrameSlot
Definition
FrameSlot.c:13
ScriptedWidgetComponent
Definition
ScriptedWidgetComponent.c:13
UIWidgets
Definition
attributes.c:40
Widget
Definition
Widget.c:13
WorkspaceWidget
Definition
WorkspaceWidget.c:16
OnFrame
override void OnFrame(IEntity owner, float timeSlice)
Definition
SCR_VehicleDamageManagerComponent.c:1466
LogLevel
LogLevel
Enum with severity of the logging message.
Definition
LogLevel.c:14
PrintFormat
proto void PrintFormat(string fmt, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL, LogLevel level=LogLevel.NORMAL)
NONE
@ NONE
When Shape is created and not initialized yet.
Definition
ShapeType.c:15
Attribute
SCR_FieldOfViewSettings Attribute
Definition
SendGoalMessage.c:170
scripts
Game
UI
Components
SCR_HorizontalScrollAnimationComponent.c
Generated by
1.17.0