Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_ProgressBarWithSegments.c
Go to the documentation of this file.
1 //------------------------------------------------------------------------------------------------
3 {
4  [Attribute(defvalue: "0.761 0.386 0.08 0.059", desc: "Progressed Bar Color")]
5  protected ref Color m_iProgressedBarColor;
6 
7  [Attribute(defvalue: "0.761 0.484 0.199 1", desc: "Minus Bar Color")]
8  protected ref Color m_iMinusBarColor;
9 
10  [Attribute("0.0")]
11  protected float m_fProgressed;
12 
13  [Attribute("0.0")]
14  protected float m_fMinus;
15 
16 
17  protected Widget m_wProgressedBar;
18  protected Widget m_wMinusBar;
19 
20  //------------------------------------------------------------------------------------------------
21  override void HandlerAttached(Widget w)
22  {
23  super.HandlerAttached(w);
24  m_wRoot.SetVisible(false);
25 
26  m_wProgressedBar = w.FindAnyWidget("ProgressedBar");
27  m_wMinusBar = w.FindAnyWidget("MinusBar");
28 
29  if (m_wProgressedBar)
30  {
31  m_wProgressedBar.SetColor(m_iProgressedBarColor);
32  if (m_bReverseDirection)
33  m_wBar.SetZOrder(1);
34  }
35 
36  if (m_wMinusBar)
37  {
38  m_wMinusBar.SetColor(m_iMinusBarColor);
39  if (m_bReverseDirection)
40  m_wBar.SetZOrder(1);
41  }
42  }
43 
44  //------------------------------------------------------------------------------------------------
45  protected override void UpdateVisuals(bool animate = true)
46  {
47  if (!m_wSpacer || !m_wBar || !m_wProgressedBar || !m_wMinusBar)
48  return;
49 
50  float original, progressed, minus;
51 
52  float range = m_fMax - m_fMin;
53  if (range <= 0)
54  return;
55 
56  original = m_fValue / range;
57  progressed = m_fProgressed / range;
58  minus = m_fMinus / range;
59 
60  original = Math.Clamp(original, 0, 1);
61  progressed = Math.Clamp(progressed, 0, 1);
62  minus = Math.Clamp(minus, 0, 1);
63 
64  HorizontalLayoutSlot.SetFillWeight(m_wBar, original);
65  HorizontalLayoutSlot.SetFillWeight(m_wSpacer, 1 - original - progressed - minus);
66 
67  if (progressed < original/1000)
68  {
69  m_wProgressedBar.SetVisible(false);
70  m_wProgressedBar.SetEnabled(false);
71  }
72  else
73  {
74  m_wProgressedBar.SetVisible(true);
75  m_wProgressedBar.SetEnabled(true);
76  HorizontalLayoutSlot.SetFillWeight(m_wProgressedBar, progressed);
77  }
78 
79  if (minus < original/1000)
80  {
81  m_wMinusBar.SetVisible(false);
82  m_wMinusBar.SetEnabled(false);
83  }
84  else
85  {
86  m_wMinusBar.SetVisible(true);
87  m_wMinusBar.SetEnabled(true);
88  HorizontalLayoutSlot.SetFillWeight(m_wMinusBar, minus);
89  }
90 
91  m_wRoot.SetVisible(true);
92  }
93 
94  //------------------------------------------------------------------------------------------------
95  void SetProgressBarValues (float value, float progressed, float minus)
96  {
97  m_fValue = value;
98  m_fProgressed = progressed;
99  m_fMinus = minus;
100  UpdateVisuals();
101  }
102 
103  //------------------------------------------------------------------------------------------------
104  override void SetValue(float value, bool animate = true)
105  {
106  super.SetValue(value, animate);
107 
108  if (m_wProgressedBar){
109  m_wProgressedBar.SetVisible(false);
110  m_wProgressedBar.SetEnabled(false);
111  }
112 
113  if (m_wMinusBar){
114  m_wMinusBar.SetVisible(false);
115  m_wMinusBar.SetEnabled(false);
116  }
117  }
118 };
m_wRoot
protected Widget m_wRoot
Definition: SCR_ScenarioFrameworkLayerTaskDefend.c:59
SCR_ProgressBarWithSegments
Definition: SCR_ProgressBarWithSegments.c:2
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition: SCR_RespawnBriefingComponent.c:17
m_fMax
protected float m_fMax
Definition: SCR_BaseEditorAttribute.c:520
Attribute
typedef Attribute
Post-process effect of scripted camera.
SCR_WLibProgressBarComponent
Minimalist progress bar.
Definition: SCR_WLibProgressBar.c:3
m_fMin
SCR_BaseEditorAttributeEntryUIInfo m_fMin