Dayz Explorer 1.28.160049
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();
19 GetGame().GetUpdateQueue(CALL_CATEGORY_GUI).Insert(this.Update);
20 }
21
22 // -----------------------------------------------------------
24 {
25 GetGame().GetUpdateQueue(CALL_CATEGORY_GUI).Remove(this.Update);
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 // -----------------------------------------------------------
98 void OnWidgetScriptInit( Widget w )
99 {
100 m_Root = w;
101 m_BarHider = "BarHider_" + m_Root.GetName();
102 m_BarPart = "BarPart2_" + m_Root.GetName();
103 m_Anim.AnimateLoop( speed );
104 }
105};
Definition enmath.c:7
void SetProgress(float progress)
void OnWidgetScriptInit(Widget w)
ref AnimatorTimer m_Anim
void Update(float tDelta)
void UpdateChild(Widget child, int index)
proto native CGame GetGame()
const int CALL_CATEGORY_GUI
Definition tools.c:9