Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_SpinningWidgetComponent.c
Go to the documentation of this file.
1
5
7{
8 [Attribute("1", UIWidgets.Auto, "Speed, revolutions per second. Positive values mean clockwise rotation.")]
9 float m_fSpeedRps;
10
11 protected Widget m_wRoot;
12
14
15
16 //-----------------------------------------------------------------------------
17 override void HandlerAttached(Widget w)
18 {
19 if (!GetGame().InPlayMode())
20 return;
21
22 m_wRoot = w;
23
24 if (TextWidget.Cast(w))
25 m_Anim = new SCR_SpinningWidgetAnimation<TextWidget>(w);
26 else if (ImageWidget.Cast(w))
27 m_Anim = new SCR_SpinningWidgetAnimation<ImageWidget>(w);
28
29 if (!m_Anim)
30 return;
31
32 ScriptCallQueue queue = GetGame().GetCallqueue();
33 queue.CallLater(OnEachFrame, 0, true);
34 }
35
36 //-----------------------------------------------------------------------------
37 override void HandlerDeattached(Widget w)
38 {
39 if (!GetGame() || !GetGame().InPlayMode())
40 return;
41
42 ScriptCallQueue queue = GetGame().GetCallqueue();
43 queue.Remove(OnEachFrame);
44 }
45
46 //-----------------------------------------------------------------------------
47 protected void OnEachFrame()
48 {
49 if (!m_wRoot.IsEnabled() || !m_wRoot.IsVisible() || !m_Anim)
50 return;
51
52 float tDelta = ftime / 1000.0;
53 m_Anim.Animate(tDelta, m_fSpeedRps);
54 }
55};
56
57//-----------------------------------------------------------------------------
60{
61 void Animate(float tDelta, float speedRps);
62};
63
64//-----------------------------------------------------------------------------
66class SCR_SpinningWidgetAnimation<Widget TWidget> : SCR_SpinningWidgetAnimationAbstract
67{
68 TWidget m_wTarget;
69
70
71 //-----------------------------------------------------------------------------
72 void SCR_SpinningWidgetAnimation(Widget w)
73 {
74 m_wTarget = TWidget.Cast(w);
75 }
76
77 //-----------------------------------------------------------------------------
78 override void Animate(float tDelta, float speedRps)
79 {
80 float angle = m_wTarget.GetRotation();
81 angle += tDelta*speedRps*360.0;
82 if (angle > 360.0)
83 angle -= 360.0;
84 if (angle < 0)
85 angle += 360.0;
86 m_wTarget.SetRotation(angle);
87 }
88};
ArmaReforgerScripted GetGame()
Definition game.c:1398
void Animate(bool finished)
Abstract class of a spinning animation.
ref SCR_SpinningWidgetAnimationAbstract m_Anim
override void HandlerDeattached(Widget w)
ScriptCallQueue Class provide "lazy" calls - when we don't want to execute function immediately but l...
Definition tools.c:53
SCR_FieldOfViewSettings Attribute