Arma Reforger Explorer
1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Toggle main menu visibility
Loading...
Searching...
No Matches
SCR_DropdownEditorAttributeUIComponent.c
Go to the documentation of this file.
1
3
class
SCR_DropdownEditorAttributeUIComponent
:
SCR_BaseEditorAttributeUIComponent
4
{
5
protected
SCR_ComboBoxComponent
m_ComboBoxComponent
;
6
protected
ref
SCR_BaseEditorAttributeFloatStringValues
m_comboboxData
;
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
20
if
(!
m_ComboBoxComponent
)
21
return
;
22
23
m_ComboBoxComponent
.m_OnChanged.Insert(
OnChangeComboBox
);
24
25
SCR_BaseEditorAttributeVar
var = attribute.
GetVariableOrCopy
();
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
{
33
m_comboboxData
=
SCR_BaseEditorAttributeFloatStringValues
.Cast(entry);
34
if
(
m_comboboxData
)
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
{
53
SCR_BaseEditorAttributeEntryText
entry =
SCR_BaseEditorAttributeEntryText
.Cast(entries[i]);
54
if
(entry)
55
m_aDropdownArray
.Insert(entry.GetText());
56
}
57
}
58
}
59
60
//~ Create the entries
61
CreateDropdownEntries
();
62
63
super.Init(w, attribute);
64
}
65
66
//~ Create the actual dropdown array
67
protected
void
CreateDropdownEntries
()
68
{
69
if
(!
m_ComboBoxComponent
)
70
return
;
71
72
foreach
(
string
entry :
m_aDropdownArray
)
73
{
74
m_ComboBoxComponent
.AddItem(
GetFullDropdownEntryText
(entry));
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
88
SCR_BaseEditorAttributeFloatStringValues
GetComboBoxData
()
89
{
90
return
m_comboboxData
;
91
}
92
93
//Sets a default state for the UI and var value if conflicting attribute
94
override
void
SetVariableToDefaultValue
(
SCR_BaseEditorAttributeVar
var)
95
{
96
m_ComboBoxComponent
.SetCurrentItem(0);
97
98
if
(var)
99
var.
SetInt
(0);
100
}
101
102
override
void
SetFromVar
(
SCR_BaseEditorAttributeVar
var)
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
{
116
SCR_BaseEditorAttribute
attribute =
GetAttribute
();
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
{
137
if
(
m_ComboBoxComponent
)
138
m_ComboBoxComponent
.m_OnChanged.Remove(
OnChangeComboBox
);
139
}
140
};
SCR_BaseEditorAttributeEntryText
void SCR_BaseEditorAttributeEntryText(string text)
Definition
SCR_BaseEditorAttribute.c:494
SCR_BaseEditorAttributeFloatStringValues
void SCR_BaseEditorAttributeFloatStringValues(array< ref SCR_EditorAttributeFloatStringValueHolder > values)
Definition
SCR_BaseEditorAttribute.c:634
SCR_BaseEditorAttribute
Base Attribute Script for other attributes to inherent from to get and set varriables in Editor Attri...
Definition
SCR_BaseEditorAttribute.c:4
SCR_BaseEditorAttribute::GetVariable
sealed SCR_BaseEditorAttributeVar GetVariable(bool createWhenNull=false)
Definition
SCR_BaseEditorAttribute.c:307
SCR_BaseEditorAttribute::GetVariableOrCopy
sealed SCR_BaseEditorAttributeVar GetVariableOrCopy()
Definition
SCR_BaseEditorAttribute.c:326
SCR_BaseEditorAttribute::GetEntries
int GetEntries(notnull array< ref SCR_BaseEditorAttributeEntry > outEntries)
Definition
SCR_BaseEditorAttribute.c:458
SCR_BaseEditorAttributeUIComponent
Definition
SCR_BaseEditorAttributeUIComponent.c:4
SCR_BaseEditorAttributeUIComponent::GetAttribute
Get attribute this component represents return Editor attribute *SCR_BaseEditorAttribute GetAttribute()
Definition
SCR_BaseEditorAttributeUIComponent.c:59
SCR_BaseEditorAttributeUIComponent::m_sUiComponentName
string m_sUiComponentName
Definition
SCR_BaseEditorAttributeUIComponent.c:6
SCR_BaseEditorAttributeVar
Definition
SCR_BaseEditorAttributeVar.c:2
SCR_BaseEditorAttributeVar::GetInt
int GetInt()
Definition
SCR_BaseEditorAttributeVar.c:20
SCR_BaseEditorAttributeVar::SetInt
void SetInt(int value)
Definition
SCR_BaseEditorAttributeVar.c:12
SCR_ComboBoxComponent
Definition
SCR_ComboBoxComponent.c:2
SCR_DropdownEditorAttributeUIComponent
Definition
SCR_DropdownEditorAttributeUIComponent.c:4
SCR_DropdownEditorAttributeUIComponent::HandlerDeattached
override void HandlerDeattached(Widget w)
Definition
SCR_DropdownEditorAttributeUIComponent.c:135
SCR_DropdownEditorAttributeUIComponent::m_ComboBoxComponent
SCR_ComboBoxComponent m_ComboBoxComponent
Definition
SCR_DropdownEditorAttributeUIComponent.c:5
SCR_DropdownEditorAttributeUIComponent::m_bInitCalled
bool m_bInitCalled
Definition
SCR_DropdownEditorAttributeUIComponent.c:7
SCR_DropdownEditorAttributeUIComponent::SetFromVar
override void SetFromVar(SCR_BaseEditorAttributeVar var)
Definition
SCR_DropdownEditorAttributeUIComponent.c:102
SCR_DropdownEditorAttributeUIComponent::GetFullDropdownEntryText
string GetFullDropdownEntryText(string text)
Definition
SCR_DropdownEditorAttributeUIComponent.c:79
SCR_DropdownEditorAttributeUIComponent::OnChangeInternal
override bool OnChangeInternal(Widget w, int x, int y, bool finished)
Definition
SCR_DropdownEditorAttributeUIComponent.c:114
SCR_DropdownEditorAttributeUIComponent::GetComboBoxData
SCR_BaseEditorAttributeFloatStringValues GetComboBoxData()
Definition
SCR_DropdownEditorAttributeUIComponent.c:88
SCR_DropdownEditorAttributeUIComponent::SetVariableToDefaultValue
override void SetVariableToDefaultValue(SCR_BaseEditorAttributeVar var)
Definition
SCR_DropdownEditorAttributeUIComponent.c:94
SCR_DropdownEditorAttributeUIComponent::Init
override void Init(Widget w, SCR_BaseEditorAttribute attribute)
Definition
SCR_DropdownEditorAttributeUIComponent.c:11
SCR_DropdownEditorAttributeUIComponent::m_aDropdownArray
ref array< string > m_aDropdownArray
Definition
SCR_DropdownEditorAttributeUIComponent.c:9
SCR_DropdownEditorAttributeUIComponent::m_comboboxData
ref SCR_BaseEditorAttributeFloatStringValues m_comboboxData
Definition
SCR_DropdownEditorAttributeUIComponent.c:6
SCR_DropdownEditorAttributeUIComponent::CreateDropdownEntries
void CreateDropdownEntries()
Definition
SCR_DropdownEditorAttributeUIComponent.c:67
SCR_DropdownEditorAttributeUIComponent::OnChangeComboBox
void OnChangeComboBox(SCR_ComboBoxComponent comboBox, int value)
Definition
SCR_DropdownEditorAttributeUIComponent.c:128
Widget
Definition
Widget.c:13
scripts
Game
Editor
UI
Components
Attributes
SCR_DropdownEditorAttributeUIComponent.c
Generated by
1.17.0