Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_ButtonBoxMultiSelectAttributeUIComponent.c
Go to the documentation of this file.
1
4{
5 protected bool m_bUseCustomFlags = false;
6
7 override void Init(Widget w, SCR_BaseEditorAttribute attribute)
8 {
9 //Get if uses custom flags
10 array<ref SCR_BaseEditorAttributeEntry> entries = new array<ref SCR_BaseEditorAttributeEntry>;
11 attribute.GetEntries(entries);
12
13 foreach (SCR_BaseEditorAttributeEntry entry: entries)
14 {
16 if (multiSelectPresetEntry)
17 {
18 m_bUseCustomFlags = multiSelectPresetEntry.GetUsesCustomFlags();
19 break;
20 }
21 }
22
23 super.Init(w, attribute);
24 }
25
27 {
28 if (!var)
29 return;
30
31 int count = m_ToolBoxComponent.GetNumItems();
32 vector flags = var.GetVector();
33 int value;
34
36 {
37 int index = 0;
38 int flagPerIndex = 0;
39 int flag = 1;
40
41 //Set State
42 for (int i = 0; i < count; i++)
43 {
44 value = flags[index];
45 m_ToolBoxComponent.SetItemSelected(i, (value & flag), false);
46 flag *= 2;
47 flagPerIndex++;
48
49 if (flagPerIndex >= 31)
50 {
51 flagPerIndex = 0;
52 flag = 1;
53 index++;
54
55 if (index > 2)
56 break;
57 }
58 }
59 }
60 else
61 {
62 value = flags[0];
63
64 //Check if has custom flag
65 for (int i = 0; i < count; i++)
66 {
67 m_ToolBoxComponent.SetItemSelected(i, (value & (int)m_ButtonBoxData.GetEntryFloatValue(i)), false);
68 }
69
70 }
71
73
75 }
76
77 //x is index, y is selectState
78 override bool OnChangeInternal(Widget w, int x, int y, bool finished)
79 {
81 return false;
82
84 if (!attribute)
85 return false;
86 SCR_BaseEditorAttributeVar var = attribute.GetVariable(true);
87
89 int count = m_ToolBoxComponent.GetNumItems();
91 {
92 flags = Vector(0,0,0);
93 int index = 0;
94 int flagPerIndex = 0;
95 int flag = 1;
96 int value;
97
98 for (int i = 0; i < count; i++)
99 {
100 //If selected add
101 if (m_ToolBoxComponent.IsItemSelected(i))
102 {
103 value = flags[index];
104 value |= flag;
105 flags[index] = value;
106 }
107
108 flag *= 2;
109 flagPerIndex++;
110
111 if (flagPerIndex >= 31)
112 {
113 flagPerIndex = 0;
114 flag = 1;
115 index++;
116
117 if (index > 2)
118 break;
119 }
120 }
121 }
122 else
123 {
124 int flagValues = flags[0];
125
126 for (int i = 0; i < count; i++)
127 {
128 if (m_ToolBoxComponent.IsItemSelected(i))
129 flagValues |= (int)m_ButtonBoxData.GetEntryFloatValue(i);
130 else
131 flagValues &= ~(int)m_ButtonBoxData.GetEntryFloatValue(i);
132 }
133
134 flags[0] = flagValues;
135 }
136 var.SetVector(flags);
138 return false;
139 }
140
141 protected override void OnMultiSelectButton(SCR_ToolboxComponent toolbox, int index, bool state)
142 {
143 super.OnMultiSelectButton(toolbox, index, state);
144 OnChangeInternal(toolbox.GetRootWidget(), index, state, false);
145 }
146};
SCR_EAIThreatSectorFlags flags
void SCR_EditorAttributePresetMultiSelectEntry(int buttonsOnRow, bool hasRandomizeButton, ResourceName iconOfRandomizeButton=string.Empty, bool hasIcon=false, bool hasButtonDescription=false, string buttonDescription=string.Empty, int buttonHeight=-1, int customFlags=false)
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
Base Attribute Script for other attributes to inherent from to get and set varriables in Editor Attri...
sealed SCR_BaseEditorAttributeVar GetVariable(bool createWhenNull=false)
int GetEntries(notnull array< ref SCR_BaseEditorAttributeEntry > outEntries)
Get attribute this component represents return Editor attribute *SCR_BaseEditorAttribute GetAttribute()
ref SCR_BaseEditorAttributeFloatStringValues m_ButtonBoxData
override void OnMultiSelectButton(SCR_ToolboxComponent toolbox, int index, bool state)
override void Init(Widget w, SCR_BaseEditorAttribute attribute)
override bool OnChangeInternal(Widget w, int x, int y, bool finished)
Definition int.c:13
proto native vector Vector(float x, float y, float z)