Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
continuousactionprogress.c
Go to the documentation of this file.
1 class 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  GetGame().GetUpdateQueue(CALL_CATEGORY_GUI).Insert(Update);
36  }
37 
38  void ~ContinuousActionProgress()
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  {
113  Class.CastTo(m_Player, GetGame().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 }
GetGame
proto native CGame GetGame()
mission
Mission mission
Definition: displaystatus.c:28
Mission
Mission class.
Definition: gameplay.c:670
OnWidgetScriptInit
void OnWidgetScriptInit(Widget w)
Definition: sizetochild.c:94
RadialProgressBar
Definition: radialprogressbar.c:2
GetActions
override void GetActions(typename action_input_type, out array< ActionBase_Basic > actions)
Definition: advancedcommunication.c:68
ActionInputType
ActionInputType
Definition: actioninput.c:1
ActionManagerBase
void ActionManagerBase(PlayerBase player)
Definition: actionmanagerbase.c:62
CALL_CATEGORY_GUI
const int CALL_CATEGORY_GUI
Definition: tools.c:9
PlayerBase
Definition: playerbaseclient.c:1
m_AM
protected ActionManagerBase m_AM
Definition: crosshairselector.c:57
UA_INITIALIZE
const int UA_INITIALIZE
Definition: constants.c:444
m_Player
DayZPlayer m_Player
Definition: hand_events.c:42
Update
proto native volatile void Update()
Definition: playersoundmanager.c:125
ActionBase
void ActionBase()
Definition: actionbase.c:73
GetActionManager
protected void GetActionManager()
Definition: crosshairselector.c:132
GetPlayer
protected void GetPlayer()
Definition: crosshairselector.c:127
UA_PROCESSING
const int UA_PROCESSING
Definition: constants.c:434
UA_AM_PENDING
const int UA_AM_PENDING
Definition: constants.c:446
Widget
Definition: enwidgets.c:189
SetProgress
void SetProgress(float val)
Definition: dayzgame.c:791
UA_NONE
const int UA_NONE
Definition: constants.c:432
Math
Definition: enmath.c:6
m_Action
enum ActionInputType m_Action
m_Root
protected Widget m_Root
Definition: sizetochild.c:91
Class
Super root of all classes in Enforce script.
Definition: enscript.c:10
ScriptedWidgetEventHandler
map: item x vector(index, width, height)
Definition: enwidgets.c:650