Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_SpinboxEditorAttributeUIComponent.c
Go to the documentation of this file.
1
4{
6 protected bool m_bInitCalled;
7
8 override void Init(Widget w, SCR_BaseEditorAttribute attribute)
9 {
10 Widget spingBoxWidget = w.FindAnyWidget(m_sUiComponentName);
11
12 if (!spingBoxWidget) return;
13 m_SpinboxWidgetComponent = SCR_SpinBoxComponent.Cast(spingBoxWidget.FindHandler(SCR_SpinBoxComponent));
14
15 if (!m_SpinboxWidgetComponent) return;
16 m_SpinboxWidgetComponent.m_OnChanged.Insert(OnChangeSpinbox);
17
19 if (var)
20 {
22 array<ref SCR_BaseEditorAttributeEntry> entries = new array<ref SCR_BaseEditorAttributeEntry>;
23 attribute.GetEntries(entries);
24
25 foreach (SCR_BaseEditorAttributeEntry entry: entries)
26 {
27 spinboxData = SCR_BaseEditorAttributeFloatStringValues.Cast(entry);
28 if (spinboxData)
29 {
30 int count = spinboxData.GetValueCount();
31
32 for (int i = 0; i < count; i++)
33 {
34 m_SpinboxWidgetComponent.AddItem(spinboxData.GetValuesEntry(i).GetName(), i == count - 1);
35 }
36
37 continue;
38 }
39 }
40
41 //Spin box uses text entries
42 if (!spinboxData)
43 {
44 int entriesCount = entries.Count();
45 for (int i = 0; i < entriesCount; i++)
46 {
48 if (entry)
49 m_SpinboxWidgetComponent.AddItem(entry.GetText(), i == entriesCount - 1);
50 }
51 }
52 }
53
54 super.Init(w, attribute);
55 }
56
57 //Sets a default state for the UI and var value if conflicting attribute
59 {
60 m_SpinboxWidgetComponent.SetCurrentItem(0);
61
62 if (var)
63 var.SetInt(0);
64 }
65
67 {
68 super.SetFromVar(var);
69
70 if (!var)
71 return;
72
73 m_SpinboxWidgetComponent.SetCurrentItem(var.GetInt(), false, false);
74 m_bInitCalled = true;
75 }
76
77 override bool OnChangeInternal(Widget w, int x, int y, bool finished)
78 {
80 if (!attribute) return false;
81 SCR_BaseEditorAttributeVar var = attribute.GetVariable(true);
82
83 if (var.GetInt() == x)
84 return false;
85
86 var.SetInt(x);
87 super.OnChangeInternal(w, x, y, finished);
88 return false;
89 }
90
91 protected void OnChangeSpinbox(SCR_SpinBoxComponent spinbox, int value)
92 {
93 if (m_bInitCalled)
94 OnChangeInternal(spinbox.GetRootWidget(), value, 0, false);
95 }
96
97
98 override void HandlerDeattached(Widget w)
99 {
101 m_SpinboxWidgetComponent.m_OnChanged.Remove(OnChangeSpinbox);
102 }
103};
void SCR_BaseEditorAttributeEntryText(string text)
void SCR_BaseEditorAttributeFloatStringValues(array< ref SCR_EditorAttributeFloatStringValueHolder > values)
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()
override void Init(Widget w, SCR_BaseEditorAttribute attribute)
override bool OnChangeInternal(Widget w, int x, int y, bool finished)
override void SetFromVar(SCR_BaseEditorAttributeVar var)
void OnChangeSpinbox(SCR_SpinBoxComponent spinbox, int value)
override void SetVariableToDefaultValue(SCR_BaseEditorAttributeVar var)