Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_RadialProgressBarUIComponent.c
Go to the documentation of this file.
1 class SCR_RadialProgressBarUIComponent: ScriptedWidgetComponent
2 {
3  [Attribute(defvalue: "0", desc: "Progress of bar, value between min value and maxvalue")]
4  protected float m_iProgress;
5 
6  [Attribute(defvalue: "0", desc: "Progress of bar, lowest value")]
7  protected float m_fMinValue;
8 
9  [Attribute(defvalue: "1", desc: "Progress of bar, highest value")]
10  protected float m_fMaxValue;
11 
12  [Attribute(defvalue: "0", desc: "Mirrors the Progress bar, by default true")]
13  protected bool m_bIsMirrored;
14 
15  [Attribute("ProgressBar")]
16  protected string m_sRadialProgressBarName;
17 
18  [Attribute("PreviewBar")]
19  protected string m_sRadialProgressPreviewName;
20 
21  [Attribute("Background")]
22  protected string m_sBackgroundName;
23 
24  protected ImageWidget m_wRadialProgressBar;
25  protected ImageWidget m_wRadialProgressPreview;
26  protected ImageWidget m_wBackground;
27 
28  protected ref ScriptInvoker Event_OnProgressFull = new ScriptInvoker;
29  protected ref ScriptInvoker Event_OnProgressEmpty = new ScriptInvoker;
30 
31  protected bool m_bProgressFull;
32 
37  void SetProgress(float progress)
38  {
39  m_iProgress = Math.Clamp(progress, m_fMinValue, m_fMaxValue);
40 
41  float maskProgress = (progress - m_fMinValue) / (m_fMaxValue - m_fMinValue);
42 
43  if (m_bIsMirrored)
44  m_wRadialProgressBar.SetMaskProgress(1 - maskProgress);
45  else
46  m_wRadialProgressBar.SetMaskProgress(maskProgress);
47 
48  if (progress == m_fMaxValue && !m_bProgressFull)
49  {
50  m_bProgressFull = true;
51  Event_OnProgressFull.Invoke(this);
52  }
53  else if (progress == m_fMinValue && m_bProgressFull)
54  {
55  m_bProgressFull = false;
56  Event_OnProgressEmpty.Invoke(this);
57  }
58  }
59 
64  void SetPreviewProgress(float progress)
65  {
66  progress = Math.Clamp(progress, m_fMinValue, m_fMaxValue);
67 
68  if (m_bIsMirrored)
69  m_wRadialProgressPreview.SetMaskProgress(m_fMaxValue - progress);
70  else
71  m_wRadialProgressPreview.SetMaskProgress(progress);
72 
73  m_wRadialProgressPreview.SetVisible(progress > m_fMinValue);
74  }
75 
80  float GetProgress()
81  {
82  return m_iProgress;
83  }
84 
89  ImageWidget GetRadialProgressBarWidget()
90  {
91  return m_wRadialProgressBar;
92  }
93 
98  ImageWidget GetBackgroundWidget()
99  {
100  return m_wBackground;
101  }
102 
107  void SetProgressBarImage(ResourceName RadialProgressBarImage)
108  {
109  if (m_wRadialProgressBar)
110  m_wRadialProgressBar.LoadImageTexture(0, RadialProgressBarImage);
111  }
112 
117  void SetBackgroundImage(ResourceName BackgroundImage)
118  {
119  if (m_wBackground)
120  m_wBackground.LoadImageTexture(0, BackgroundImage);
121  }
122 
123  ScriptInvoker GetOnProgressFull()
124  {
125  return Event_OnProgressFull;
126  }
127 
128  ScriptInvoker GetOnProgressEmpty()
129  {
130  return Event_OnProgressEmpty;
131  }
132 
133 
134  override void HandlerAttached(Widget w)
135  {
136  if (SCR_Global.IsEditMode())
137  return;
138 
139  m_wRadialProgressBar = ImageWidget.Cast(w.FindAnyWidget(m_sRadialProgressBarName));
140  m_wRadialProgressPreview = ImageWidget.Cast(w.FindAnyWidget(m_sRadialProgressPreviewName));
141  m_wBackground = ImageWidget.Cast(w.FindAnyWidget(m_sBackgroundName));
142 
143  if (!m_wRadialProgressBar)
144  {
145  Print("SCR_RadialProgressBarUIComponent could not find m_wRadialProgressBar!", LogLevel.ERROR);
146  return;
147  }
148 
149  if (m_bIsMirrored)
150  {
151  m_wRadialProgressBar.SetMaskMode(ImageMaskMode.INVERTED);
152  m_wRadialProgressPreview.SetMaskMode(ImageMaskMode.INVERTED);
153  }
154  else
155  {
156  m_wRadialProgressBar.SetMaskMode(ImageMaskMode.REGULAR);
157  m_wRadialProgressPreview.SetMaskMode(ImageMaskMode.REGULAR);
158  }
159 
160  m_bProgressFull = false;
161  SetProgress(m_iProgress);
162  SetPreviewProgress(0);
163  }
164 
165 };
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition: SCR_RespawnBriefingComponent.c:17
SCR_RadialProgressBarUIComponent
Definition: SCR_RadialProgressBarUIComponent.c:1
Attribute
typedef Attribute
Post-process effect of scripted camera.
m_wBackground
protected ImageWidget m_wBackground
Definition: SCR_InventoryHitZonePointUI.c:382
SCR_Global
Definition: Functions.c:6