Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_SliderBloodAttributeComponent.c
Go to the documentation of this file.
2 {
3  [Attribute("BloodUnconsciousBar", desc: "Image that shows when Character becomes conscious")]
4  protected string m_sUnconsciousBarName;
5 
6  [Attribute("BloodUnconsciousBarTop", desc: "Set at the end of the bar")]
7  protected string m_sUnconsciousBarTopName;
8 
9  [Attribute("BloodUnconsciousFillRight", desc: "Filler make sure the bar is set the correct size")]
10  protected string m_sUnconsciousFillerRightName;
11 
12  [Attribute("1", desc: "Size of the BarTop")]
13  protected float m_iUnconsciousBarTopSize;
14 
15  protected float m_fUnconsciousLevel;
16 
17  protected Widget m_UnconsciousBar;
18  protected Widget m_UnconsciousBarTop;
19  protected Widget m_UnconsciousFillerRight;
20 
21  override void Init(Widget w, SCR_BaseEditorAttribute attribute)
22  {
23  m_UnconsciousBar = w.FindAnyWidget(m_sUnconsciousBarName);
24  m_UnconsciousBarTop = w.FindAnyWidget(m_sUnconsciousBarTopName);
25  m_UnconsciousFillerRight = w.FindAnyWidget(m_sUnconsciousFillerRightName);
26 
27  LayoutSlot.SetFillWeight(m_UnconsciousBarTop, m_iUnconsciousBarTopSize);
28 
29  if (!m_UnconsciousBar || !m_UnconsciousFillerRight || !m_UnconsciousBarTop)
30  return;
31 
32  SCR_BaseEditorAttributeVar var = attribute.GetVariableOrCopy();
33  if (!var)
34  return;
35 
36  vector bloodData = var.GetVector();
37 
38  m_fUnconsciousLevel = bloodData[1] * 100;
39 
40  super.Init(w, attribute);
41  }
42 
47  float GetUnconsciousLevel()
48  {
49  return m_fUnconsciousLevel;
50  }
51 
52  override void SetSliderSettings(SCR_BaseEditorAttributeVar var, SCR_BaseEditorAttributeEntrySlider sliderData)
53  {
54  super.SetSliderSettings(var, sliderData);
55  UpdateBloodSlider();
56  }
57 
58  //Sets a default state for the UI and var value if conflicting attribute
59  override void SetVariableToDefaultValue(SCR_BaseEditorAttributeVar var)
60  {
61  super.SetVariableToDefaultValue(var);
62  UpdateBloodSlider();
63  }
64 
65  override void SetFromVar(SCR_BaseEditorAttributeVar var)
66  {
67  super.SetFromVar(var);
68  UpdateBloodSlider();
69  }
70 
71  override bool OnChange(Widget w, int x, int y, bool finished)
72  {
73  super.OnChange(w, x, y, finished);
74  UpdateBloodSlider();
75  return false;
76  }
77 
78  protected void UpdateBloodSlider()
79  {
80  float value = m_SliderWidgetComponent.GetValue();
81 
82  if (value >= m_fUnconsciousLevel)
83  {
84  m_UnconsciousBarTop.SetVisible(true);
85  LayoutSlot.SetFillWeight(m_UnconsciousBar, Math.Clamp(m_fUnconsciousLevel - m_iUnconsciousBarTopSize, 0, 100));
86  LayoutSlot.SetFillWeight(m_UnconsciousFillerRight, Math.Clamp(100 - m_fUnconsciousLevel, 0, 100));
87  }
88  else
89  {
90  if (value >= m_iUnconsciousBarTopSize)
91  {
92  m_UnconsciousBarTop.SetVisible(true);
93  LayoutSlot.SetFillWeight(m_UnconsciousBar, Math.Clamp(value - m_iUnconsciousBarTopSize, 0 , 100));
94  LayoutSlot.SetFillWeight(m_UnconsciousFillerRight, Math.Clamp(100 - value, 0, 100));
95  }
96  else
97  {
98  m_UnconsciousBarTop.SetVisible(false);
99  LayoutSlot.SetFillWeight(m_UnconsciousBar, Math.Clamp(value, 0 , 100));
100  LayoutSlot.SetFillWeight(m_UnconsciousFillerRight, Math.Clamp(100 - value, 0, 100));
101  }
102  }
103  }
104 };
SCR_SliderEditorAttributeUIComponent
Definition: SCR_SliderEditorAttributeUIComponent.c:3
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition: SCR_RespawnBriefingComponent.c:17
SCR_BaseEditorAttributeVar
Definition: SCR_BaseEditorAttributeVar.c:1
Attribute
typedef Attribute
Post-process effect of scripted camera.
SCR_BaseEditorAttribute
Base Attribute Script for other attributes to inherent from to get and set varriables in Editor Attri...
Definition: SCR_BaseEditorAttribute.c:3
SCR_BaseEditorAttributeEntrySlider
void SCR_BaseEditorAttributeEntrySlider(SCR_EditorAttributeBaseValues sliderValues)
Definition: SCR_BaseEditorAttribute.c:581
SCR_SliderBloodAttributeComponent
Definition: SCR_SliderBloodAttributeComponent.c:1