3 [
Attribute(defvalue:
"0",
desc:
"Progress of bar, value between min value and maxvalue")]
4 protected float m_iProgress;
6 [
Attribute(defvalue:
"0",
desc:
"Progress of bar, lowest value")]
7 protected float m_fMinValue;
9 [
Attribute(defvalue:
"1",
desc:
"Progress of bar, highest value")]
10 protected float m_fMaxValue;
12 [
Attribute(defvalue:
"0",
desc:
"Mirrors the Progress bar, by default true")]
13 protected bool m_bIsMirrored;
16 protected string m_sRadialProgressBarName;
19 protected string m_sRadialProgressPreviewName;
22 protected string m_sBackgroundName;
24 protected ImageWidget m_wRadialProgressBar;
25 protected ImageWidget m_wRadialProgressPreview;
26 protected ImageWidget m_wBackground;
28 protected ref ScriptInvoker Event_OnProgressFull =
new ScriptInvoker;
29 protected ref ScriptInvoker Event_OnProgressEmpty =
new ScriptInvoker;
31 protected bool m_bProgressFull;
37 void SetProgress(
float progress)
39 m_iProgress = Math.Clamp(progress, m_fMinValue, m_fMaxValue);
41 float maskProgress = (progress - m_fMinValue) / (m_fMaxValue - m_fMinValue);
44 m_wRadialProgressBar.SetMaskProgress(1 - maskProgress);
46 m_wRadialProgressBar.SetMaskProgress(maskProgress);
48 if (progress == m_fMaxValue && !m_bProgressFull)
50 m_bProgressFull =
true;
51 Event_OnProgressFull.Invoke(
this);
53 else if (progress == m_fMinValue && m_bProgressFull)
55 m_bProgressFull =
false;
56 Event_OnProgressEmpty.Invoke(
this);
64 void SetPreviewProgress(
float progress)
66 progress = Math.Clamp(progress, m_fMinValue, m_fMaxValue);
69 m_wRadialProgressPreview.SetMaskProgress(m_fMaxValue - progress);
71 m_wRadialProgressPreview.SetMaskProgress(progress);
73 m_wRadialProgressPreview.SetVisible(progress > m_fMinValue);
89 ImageWidget GetRadialProgressBarWidget()
91 return m_wRadialProgressBar;
98 ImageWidget GetBackgroundWidget()
107 void SetProgressBarImage(ResourceName RadialProgressBarImage)
109 if (m_wRadialProgressBar)
110 m_wRadialProgressBar.LoadImageTexture(0, RadialProgressBarImage);
117 void SetBackgroundImage(ResourceName BackgroundImage)
123 ScriptInvoker GetOnProgressFull()
125 return Event_OnProgressFull;
128 ScriptInvoker GetOnProgressEmpty()
130 return Event_OnProgressEmpty;
134 override void HandlerAttached(Widget w)
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));
143 if (!m_wRadialProgressBar)
145 Print(
"SCR_RadialProgressBarUIComponent could not find m_wRadialProgressBar!", LogLevel.ERROR);
151 m_wRadialProgressBar.SetMaskMode(ImageMaskMode.INVERTED);
152 m_wRadialProgressPreview.SetMaskMode(ImageMaskMode.INVERTED);
156 m_wRadialProgressBar.SetMaskMode(ImageMaskMode.REGULAR);
157 m_wRadialProgressPreview.SetMaskMode(ImageMaskMode.REGULAR);
160 m_bProgressFull =
false;
161 SetProgress(m_iProgress);
162 SetPreviewProgress(0);