Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_DropdownEditorAttributeUIComponent.c
Go to the documentation of this file.
1
4{
7 protected bool m_bInitCalled;
8
9 protected ref array<string> m_aDropdownArray = {};
10
11 override void Init(Widget w, SCR_BaseEditorAttribute attribute)
12 {
13 Widget comboBoxWidget = w.FindAnyWidget(m_sUiComponentName);
14
15 if (!comboBoxWidget)
16 return;
17
18 m_ComboBoxComponent = SCR_ComboBoxComponent.Cast(comboBoxWidget.FindHandler(SCR_ComboBoxComponent));
19
21 return;
22
23 m_ComboBoxComponent.m_OnChanged.Insert(OnChangeComboBox);
24
26 if (var)
27 {
28 array<ref SCR_BaseEditorAttributeEntry> entries = new array<ref SCR_BaseEditorAttributeEntry>;
29 attribute.GetEntries(entries);
30
31 foreach (SCR_BaseEditorAttributeEntry entry: entries)
32 {
35 {
36 int count = m_comboboxData.GetValueCount();
37
38 for (int i = 0; i < count; i++)
39 {
40 m_ComboBoxComponent.AddItem(m_comboboxData.GetValuesEntry(i).GetName());
41 }
42
43 continue;
44 }
45 }
46
47 //Drop box uses text entries
48 if (!m_comboboxData)
49 {
50 int entriesCount = entries.Count();
51 for (int i = 0; i < entriesCount; i++)
52 {
54 if (entry)
55 m_aDropdownArray.Insert(entry.GetText());
56 }
57 }
58 }
59
60 //~ Create the entries
62
63 super.Init(w, attribute);
64 }
65
66 //~ Create the actual dropdown array
67 protected void CreateDropdownEntries()
68 {
70 return;
71
72 foreach(string entry : m_aDropdownArray)
73 {
75 }
76 }
77
78 //~ Override for any additional functionality for the text entries
79 protected string GetFullDropdownEntryText(string text)
80 {
81 return text;
82 }
83
92
93 //Sets a default state for the UI and var value if conflicting attribute
95 {
96 m_ComboBoxComponent.SetCurrentItem(0);
97
98 if (var)
99 var.SetInt(0);
100 }
101
103 {
104 super.SetFromVar(var);
105
106 if (!var)
107 return;
108
109 m_ComboBoxComponent.SetCurrentItem(var.GetInt(), false, false);
110 m_bInitCalled = true;
111
112 }
113
114 override bool OnChangeInternal(Widget w, int x, int y, bool finished)
115 {
117 if (!attribute) return false;
118 SCR_BaseEditorAttributeVar var = attribute.GetVariable(true);
119
120 if (var.GetInt() == x)
121 return false;
122
123 var.SetInt(x);
124 super.OnChangeInternal(w, x, y, finished);
125 return false;
126 }
127
128 protected void OnChangeComboBox(SCR_ComboBoxComponent comboBox, int value)
129 {
130 if (m_bInitCalled)
131 OnChangeInternal(comboBox.GetRootWidget(), value, 0, false);
132 }
133
134
135 override void HandlerDeattached(Widget w)
136 {
138 m_ComboBoxComponent.m_OnChanged.Remove(OnChangeComboBox);
139 }
140};
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 SetFromVar(SCR_BaseEditorAttributeVar var)
override bool OnChangeInternal(Widget w, int x, int y, bool finished)
SCR_BaseEditorAttributeFloatStringValues GetComboBoxData()
override void SetVariableToDefaultValue(SCR_BaseEditorAttributeVar var)
override void Init(Widget w, SCR_BaseEditorAttribute attribute)
ref SCR_BaseEditorAttributeFloatStringValues m_comboboxData
void OnChangeComboBox(SCR_ComboBoxComponent comboBox, int value)