DayZ 1.24
Loading...
Searching...
No Matches
ContinuousActionProgress.c
Go to the documentation of this file.
1class ContinuousActionProgress extends ScriptedWidgetEventHandler
2{
4
6 protected ActionBase m_Action;
7 protected int m_ActionState;
8 protected ActionManagerBase m_AM;
9
10 protected ref WidgetFadeTimer m_FadeTimer;
11 protected bool m_Faded;
12
13 protected float m_InitProgress;
14 protected float m_Speed;
15
16 protected Widget m_Root;
20
22 {
23 m_Action = null;
24 m_ActionState = -1;
25 m_AM = null;
26 m_RadialWidget = null;
27 m_LoaderImage = null;
28 m_Radial = null;
29 m_Speed = 0;
30 m_InitProgress = 100;
31
32 m_FadeTimer = new WidgetFadeTimer;
33 m_Faded = true;
34
35 GetGame().GetUpdateQueue(CALL_CATEGORY_GUI).Insert(Update);
36 }
37
39 {
40 GetGame().GetUpdateQueue(CALL_CATEGORY_GUI).Remove(Update);
41 }
42
43 protected void OnWidgetScriptInit(Widget w)
44 {
45 m_Root = w;
46 m_Root.SetHandler(this);
47 m_Root.Show(false);
48
49 m_RadialWidget = m_Root.FindAnyWidget("PBRadial1");
50 m_LoaderImage = ImageWidget.Cast(m_Root.FindAnyWidget("cap_init_loader"));
51 if (m_RadialWidget)
52 m_RadialWidget.GetScript(m_Radial);
53 m_Root.Update();
54 }
55
56 protected void Update()
57 {
59 Mission mission = GetGame().GetMission();
60 IngameHud hud;
61 if (mission && Class.CastTo(hud, mission.GetHud()) && (hud.IsHideHudPlayer() || !hud.GetHudState()))
62 {
63 m_Root.Show(false);
64 return;
65 }
66
67 if (m_Player && !m_Player.IsAlive()) // handle respawn
68 {
69 m_Player = null;
70 m_AM = null;
71 }
72 if (!m_Player) GetPlayer();
73 if (!m_AM) GetActionManager();
74
75 GetActions();
76
77 if (m_Action && m_Action.HasProgress() && m_ActionState != UA_NONE && GetGame().GetUIManager().GetMenu() == null)
78 {
79 if (m_ActionState == UA_INITIALIZE || m_ActionState == UA_AM_PENDING)
80 {
81 m_Speed += 0.02;
82 m_LoaderImage.SetRotation(0, 0, m_Speed * Math.RAD2DEG);
83 m_LoaderImage.Show(true);
84 }
85 else
86 {
87 m_Speed = 0.0;
88 m_LoaderImage.SetRotation(0, 0, 0);
89 m_LoaderImage.Show(false);
90 }
91
92 if (m_ActionState == UA_PROCESSING)
93 {
94 m_InitProgress = 100;
95 m_LoaderImage.SetRotation(0, 0, 0);
96 SetProgress(Math.AbsFloat(m_AM.GetActionComponentProgress() * 100));
97 }
98 m_Root.Show(true);
99 }
100 else
101 {
102 m_Speed = 0.0;
103 m_Root.Show(false);
104 m_LoaderImage.Show(false);
105 SetProgress(0.0);
106 m_LoaderImage.SetRotation(0, 0, 0);
107 }
108 }
109
110 // getters
111 private void GetPlayer()
112 {
114 }
115
116 private void GetActionManager()
117 {
119 Class.CastTo(m_AM, m_Player.GetActionManager());
120 else
121 m_AM = null;
122 }
123
124 private void GetActions()
125 {
126 if (!m_AM) return;
127
128 m_Action = null;
129 m_ActionState = -1;
130 m_Action = m_AM.GetRunningAction();
131
132 if (m_Action && m_Action.GetInput().GetInputType() == ActionInputType.AIT_CONTINUOUS)
133 m_ActionState = m_AM.GetActionState(m_Action);
134 else
135 m_Action = null;
136 }
137
138 private void SetProgress(float progress)
139 {
140 if (m_Radial)
141 m_Radial.SetProgress(progress);
142 }
143}
enum ActionInputType m_Action
ActionInputType
Definition ActionInput.c:2
ActionManagerBase m_AM
Mission mission
DayZPlayer m_Player
Definition Hand_Events.c:42
Widget m_Root
Definition SizeToChild.c:85
Super root of all classes in Enforce script.
Definition EnScript.c:11
Definition EnMath.c:7
Mission class.
Definition gameplay.c:668
Hud GetHud()
Definition gameplay.c:701
map: item x vector(index, width, height)
Definition EnWidgets.c:651
proto native CGame GetGame()
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
static const float RAD2DEG
Definition EnMath.c:16
static proto float AbsFloat(float f)
Returns absolute value.
const int CALL_CATEGORY_GUI
Definition tools.c:9
const int UA_INITIALIZE
Definition constants.c:444
const int UA_NONE
Definition constants.c:432
const int UA_AM_PENDING
Definition constants.c:446
const int UA_PROCESSING
Definition constants.c:434
proto native volatile void Update()