Dayz Explorer 1.29.162510
Loading...
Searching...
No Matches
continuousactionprogress.c
Go to the documentation of this file.
1class ContinuousActionProgress extends ScriptedWidgetEventHandler
2{
3 reference string RadialBarWidgetName;
4
5 protected PlayerBase m_Player;
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;
17 protected Widget m_RadialWidget;
18 protected ImageWidget m_LoaderImage;
19 ref RadialProgressBar m_Radial;
20
21 void ContinuousActionProgress()
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 g_Game.GetUpdateQueue(CALL_CATEGORY_GUI).Insert(Update);
36 }
37
38 void ~ContinuousActionProgress()
39 {
40 g_Game.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 = g_Game.GetMission();
60 IngameHud hud = IngameHud.Cast(mission.GetHud());
61 if (hud && hud.GetHudVisibility().IsContextFlagActive(IngameHudVisibility.HUD_HIDE_FLAGS))
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();
74
75 GetActions();
76
77 if(m_Action && m_Action.HasProgress() && m_ActionState != UA_NONE && g_Game.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 * m_AM.GetACProgressWidgetMultiplier()));
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 {
113 Class.CastTo(m_Player, g_Game.GetPlayer());
114 }
115
116 private void GetActionManager()
117 {
118 if( m_Player && m_Player.IsPlayerSelected() )
119 {
120 Class.CastTo(m_AM, m_Player.GetActionManager());
121 }
122 else
123 m_AM = null;
124 }
125
126 private void GetActions()
127 {
128 if(!m_AM) return;
129
130 m_Action = null;
131 m_ActionState = -1;
132 m_Action = m_AM.GetRunningAction();
133
134 if(m_Action && m_Action.GetInput().GetInputType() == ActionInputType.AIT_CONTINUOUS)
135 m_ActionState = m_AM.GetActionState(m_Action);
136 else
137 m_Action = null;
138 }
139
140 private void SetProgress(float progress)
141 {
142 if(m_Radial)
143 m_Radial.SetProgress(progress);
144 }
145}
ref ActionBase m_Action
Definition actionbase.c:41
ActionInputType
Definition actioninput.c:2
void ActionManagerBase(PlayerBase player)
override void GetActions(typename action_input_type, out array< ActionBase_Basic > actions)
map m_Player
bool HasProgress()
For UI: hiding of progress bar.
Definition actionbase.c:256
ActionInput GetInput()
int GetInputType()
Definition actioninput.c:89
ActionManagerBase m_AM
void GetActionManager()
void SetProgress(float val)
Definition dayzgame.c:808
DayZGame g_Game
Definition dayzgame.c:3942
Mission mission
const int CALL_CATEGORY_GUI
Definition tools.c:9
const int UA_INITIALIZE
Definition constants.c:477
const int UA_NONE
Definition constants.c:465
const int UA_AM_PENDING
Definition constants.c:479
const int UA_PROCESSING
Definition constants.c:467
void Update()
Definition radialmenu.c:518
PlayerBase GetPlayer()
Widget m_Root
Definition sizetochild.c:91
void OnWidgetScriptInit(Widget w)
Definition sizetochild.c:94