DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
Loading...
Searching...
No Matches
RadialProgressBar.c
Go to the documentation of this file.
1// -----------------------------------------------------------
3{
4 reference float speed;
5 reference float start_rotation;
6
7 protected string m_BarHider;
8 protected string m_BarPart;
9 protected Widget m_Root;
10 protected ref AnimatorTimer m_Anim;
11 protected float x, y, z;
12 protected float rotation = 0;
13 protected int stage = 0;
14
15 // -----------------------------------------------------------
17 {
18 m_Anim = new AnimatorTimer();
20 }
21
22 // -----------------------------------------------------------
24 {
26 }
27
28 void SetProgress( float progress )
29 {
30 if( progress < 50 )
31 {
32 stage = 0;
33 }
34 rotation = 360 * ( progress / 100 );
35 }
36
37 // -----------------------------------------------------------
38 protected void Update(float tDelta)
39 {
40 m_Anim.Tick(tDelta);
41
42 Widget child = m_Root.GetChildren();
43
44 int index = 0;
45 while ( child )
46 {
47 UpdateChild( child, index );
48 index++;
49 child = child.GetSibling();
50 }
51 }
52
53 protected void UpdateChild( Widget child, int index )
54 {
55 float rotation_value = ( m_Anim.GetTargetValue() * Math.RAD2DEG );
56 if( child.GetName() == m_BarHider )
57 {
58 if( stage == 0 )
59 {
60 if( rotation > 0 )
61 {
62 child.GetChildren().Show(true);
63 }
64 else
65 {
66 child.GetChildren().Show(false);
67 }
68
69 child.GetChildren().SetRotation( 0, 0, start_rotation + rotation);
70
71 if( rotation > 180 )
72 {
73 stage = 1;
74 child.GetChildren().SetRotation(0, 0, 360);
75 }
76
77 }
78 }
79 else if( child.GetName() == m_BarPart )
80 {
81 if( stage == 0 )
82 child.Show( false );
83 if( stage == 1 )
84 {
85 child.Show( true );
86 child.SetRotation( 0, 0, start_rotation + rotation );
87
88 if( rotation > 360 )
89 {
90 stage = 2;
91 child.SetRotation( 0, 0, 180 );
92 }
93 }
94 }
95 }
96
97 // -----------------------------------------------------------
99 {
100 m_Root = w;
101 m_BarHider = "BarHider_" + m_Root.GetName();
102 m_BarPart = "BarPart2_" + m_Root.GetName();
104 }
105};
void AnimateLoop(float speed=1.0)
Starts infinite animation loop <-1,1>. Based on sinus transition.
Definition tools.c:760
float GetTargetValue()
Returns target value. While AnimateLoop returns angle of cycle in radians.
Definition tools.c:779
void Tick(float timeslice)
Ticks the timer, is called by timer subsystem.
Definition tools.c:798
override ScriptInvoker GetUpdateQueue(int call_category)
Definition DayZGame.c:1158
Definition EnMath.c:7
protected float x
reference float speed
protected void UpdateChild(Widget child, int index)
protected string m_BarHider
reference float start_rotation
protected ref AnimatorTimer m_Anim
protected float y
protected float z
protected void Update(float tDelta)
protected float rotation
protected Widget m_Root
void OnWidgetScriptInit(Widget w)
protected string m_BarPart
void SetProgress(float progress)
proto bool Remove(func fn, int flags=EScriptInvokerRemoveFlags.ALL)
remove specific call from list
proto bool Insert(func fn, int flags=EScriptInvokerInsertFlags.IMMEDIATE)
insert method to list
proto native CGame GetGame()
static const float RAD2DEG
Definition EnMath.c:16
const int CALL_CATEGORY_GUI
Definition tools.c:9
proto native volatile void Update()