Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_SliderEditorAttributeUIComponent.c
Go to the documentation of this file.
1
4{
7 protected float m_fMaxSliderValue;
8 protected float m_fDefaultValue = float.MAX;
9
10 protected bool m_bIsTimeSlider;
11 //~ If value is 0 should it hide it or show it as 00. Eg if normally 23:05:19 (h:m:s) and s becomes 0 and is ticked here than it will be come 23:05
13 //~ If true than it will never show seconds even if seconds are not 0
14 protected bool m_bAlwaysHideSeconds;
15
16 override void Init(Widget w, SCR_BaseEditorAttribute attribute)
17 {
18 //Set slider label
19 Widget sliderWidgetLibary = w.FindAnyWidget(m_sUiComponentName);
20 if (!sliderWidgetLibary) return;
21
22 m_SliderWidgetComponent = SCR_SliderComponent.Cast(sliderWidgetLibary.FindHandler(SCR_SliderComponent));
24 return;
25
27 if (var)
28 {
29 array<ref SCR_BaseEditorAttributeEntry> entries = new array<ref SCR_BaseEditorAttributeEntry>;
30 attribute.GetEntries(entries);
31
32 foreach (SCR_BaseEditorAttributeEntry entry: entries)
33 {
35 if (timeSlider)
36 {
37 m_bIsTimeSlider = true;
39 continue;
40 }
41
43 if (data)
44 {
47 continue;
48 }
49
51 if (defaultValue)
52 {
53 m_fDefaultValue = defaultValue.GetDefaultFloatValue();
54 }
55 }
56 }
57
58 super.Init(w, attribute);
59 }
60
61 //~ Is overridden in SCR_VectorSliderEditorAttributeUIComponent
63 {
64 m_SliderData = sliderData;
65
66 float min, step;
67 m_SliderData.GetSliderMinMaxStep(min, m_fMaxSliderValue, step);
68 m_SliderWidgetComponent.SetSliderSettings(min, m_fMaxSliderValue, step, m_SliderData.GetSliderValueFormating());
69
70 if (m_fDefaultValue == float.MAX)
72 }
73
74 //Sets a default state for the UI and var value if conflicting attribute
83
85 {
86 super.SetFromVar(var);
87
88 if (!var)
89 return;
90
91 float value = var.GetFloat();
92
93 m_SliderWidgetComponent.SetValue(value);
94 m_SliderWidgetComponent.ShowCustomValue(GetSliderValueText(value));
95 OnChangeInternal(null, 0, 0, false);
96
97 if (value > m_fMaxSliderValue)
98 PrintFormat("%1 attribute slider is set to '%2' but can only support up to '%3'", GetAttribute().GetUIInfo().GetName(), value.ToString(), m_fMaxSliderValue.ToString());
99 }
100
101
102 override bool OnChangeInternal(Widget w, int x, int y, bool finished)
103 {
105 if (!attribute)
106 return false;
107
108 SCR_BaseEditorAttributeVar var = attribute.GetVariable(true);
109 if (!var)
110 return false;
111
112 float value = m_SliderWidgetComponent.GetValue();
113 m_SliderWidgetComponent.ShowCustomValue(GetSliderValueText(value));
114
115 if (var.GetFloat() == value)
116 return false;
117
118 var.SetFloat(value);
119 super.OnChangeInternal(w, x, y, finished);
120
121 return false;
122 }
123
124 protected string GetSliderValueText(float value)
125 {
126 if (m_SliderData)
127 {
128 if (!m_bIsTimeSlider)
129 {
130 return m_SliderData.GetText(value);
131 }
132 //~ Time slider
133 else
134 {
136 return SCR_FormatHelper.GetTimeFormatting(value, m_eHideIfZero);
137 else
139 }
140 }
141
142 return "MISSING m_SliderData!";
143 }
144};
ETimeFormatParam
void SCR_BaseEditorAttributeDefaultFloatValue(float floatValue)
void SCR_BaseEditorAttributeEntrySlider(SCR_EditorAttributeBaseValues sliderValues)
Get all prefabs that have the spawner data
void GetTimeSliderValues(out ETimeFormatParam hideIfZero, out bool alwaysHideSeconds)
Base Attribute Script for other attributes to inherent from to get and set varriables in Editor Attri...
sealed SCR_BaseEditorAttributeVar GetVariable(bool createWhenNull=false)
sealed SCR_BaseEditorAttributeVar GetVariableOrCopy()
int GetEntries(notnull array< ref SCR_BaseEditorAttributeEntry > outEntries)
Get attribute this component represents return Editor attribute *SCR_BaseEditorAttribute GetAttribute()
static string GetTimeFormattingHideSeconds(int totalSeconds, ETimeFormatParam hideEmpty=0, ETimeFormatParam hideLeadingZeroes=0)
override bool OnChangeInternal(Widget w, int x, int y, bool finished)
override void Init(Widget w, SCR_BaseEditorAttribute attribute)
void SetSliderSettings(SCR_BaseEditorAttributeVar var, SCR_BaseEditorAttributeEntrySlider sliderData)
ref SCR_BaseEditorAttributeEntrySlider m_SliderData
override void SetVariableToDefaultValue(SCR_BaseEditorAttributeVar var)
override void SetFromVar(SCR_BaseEditorAttributeVar var)
proto void PrintFormat(string fmt, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL, LogLevel level=LogLevel.NORMAL)
@ MAX