Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_BaseMultiSelectPresetsEditorAttribute.c
Go to the documentation of this file.
1// Script File
2//Only works with SCR_ButtonBoxMultiSelectAttributeUIComponent layout
5{
6 [Attribute("0", "If multiselect uses custom flags. If false it will use the default system and sets states of flags either true or false")]
7 protected bool m_bCustomFlags;
8
9 //Which state will be checked
10 private int m_iFlagChecker = 1;
11
12 //Saves the true/false states
13 protected vector m_vFlags;
14
15 //Which vector index the states are saved
16 private int m_iStateVectorIndex;
17
18 //How many flags can be added to each vector index
19 private int m_iFlagsPerIndex = 31;
20
21 //Current flags for the current vector index
22 private int m_iCurrentFlagsPerIndex;
23
24 //---- REFACTOR NOTE START: Not ideal handling flag manipulation ----
25
26 //Saves the next entity state
27 protected void AddOrderedState(bool state)
28 {
29 if (m_iStateVectorIndex > 2)
30 {
31 Debug.Error2(Type().ToString(), string.Format("Attribute multiselect has reach the max element limit of '%1'!", (31 * 3).ToString()));
32 return;
33 }
34
35 if (state)
36 {
37 int stateValue = m_vFlags[m_iStateVectorIndex];
38 stateValue |= m_iFlagChecker;
39 m_vFlags[m_iStateVectorIndex] = stateValue;
40 }
41
42 m_iFlagChecker *= 2;
43 m_iCurrentFlagsPerIndex++;
44
45 if (m_iCurrentFlagsPerIndex >= m_iFlagsPerIndex)
46 ResetLoopValues(true);
47 }
48
49 //Gets the next entity state
50 protected bool GetOrderedState()
51 {
52 if (m_iStateVectorIndex > 2)
53 {
54 Print(string.Format("Attribute multiselect has reach the max element limit of '%1' and is therefore set to false!", (31 * 3).ToString()), LogLevel.WARNING);
55 return false;
56 }
57
58 int stateValue = m_vFlags[m_iStateVectorIndex];
59 bool returnState = (stateValue & m_iFlagChecker);
60
61 m_iFlagChecker *= 2;
62 m_iCurrentFlagsPerIndex++;
63
64 if (m_iCurrentFlagsPerIndex >= m_iFlagsPerIndex)
65 ResetLoopValues(true);
66
67 return returnState;
68 }
69
70 protected int GetStateVectorIndex()
71 {
72 return m_iStateVectorIndex;
73 }
74
75 //Add flag in specific vector index. Returns false if invalid index
76 protected bool AddFlag(int flag, int vectorIndex = 0)
77 {
78 if (vectorIndex > 2 || vectorIndex < 0)
79 return false;
80
81 int flagValue = m_vFlags[vectorIndex];
82 flagValue |= flag;
83 m_vFlags[vectorIndex] = flagValue;
84
85 return true;
86 }
87
88 //Sets all flags of the specific index. Returns false if vector indext is invalid
89 protected bool SetFlags(int flags, int vectorIndex = 0)
90 {
91 if (vectorIndex > 2 || vectorIndex < 0)
92 return false;
93
94 m_vFlags[vectorIndex] = flags;
95 return true;
96 }
97
98 //Gets all flags of index
99 protected int GetFlags(int vectorIndex)
100 {
101 if (vectorIndex > 2 || vectorIndex < 0)
102 return 0;
103
104 return m_vFlags[vectorIndex];
105 }
106
107 //Check if Var has flag
108 protected bool HasFlag(int flagToCheck)
109 {
110 int flagValue;
111 int vectorIndex = 0;
112
113 while (vectorIndex < 3)
114 {
115 flagValue = m_vFlags[vectorIndex];
116 if (flagValue & flagToCheck)
117 return true;
118
119 vectorIndex++;
120 }
121
122 return false;
123 }
124
125 protected void ResetLoopValues(bool increaseVectorIndex)
126 {
127 m_iFlagChecker = 1;
128 m_iCurrentFlagsPerIndex = 0;
129
130 if (increaseVectorIndex)
131 m_iStateVectorIndex++;
132 else
133 m_iStateVectorIndex = 0;
134 }
135
136 //---- REFACTOR NOTE END ----
137
139 {
140 return m_vFlags;
141 }
142
143 //Reset vars
144 override SCR_BaseEditorAttributeVar ReadVariable(Managed item, SCR_AttributesManagerEditorComponent manager)
145 {
146 ResetLoopValues(false);
147 m_vFlags = Vector(0,0,0);
148
149 return null;
150 }
151
152 //Reset bit check and get states
153 override void WriteVariable(Managed item, SCR_BaseEditorAttributeVar var, SCR_AttributesManagerEditorComponent manager, int playerID)
154 {
155 if (!var)
156 return;
157
158 ResetLoopValues(false);
159 m_vFlags = var.GetVector();
160 }
161
162 override int GetEntries(notnull array<ref SCR_BaseEditorAttributeEntry> outEntries)
163 {
167 return outEntries.Count();
168 }
169};
SCR_EAIThreatSectorFlags flags
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
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)
void SCR_BaseEditorAttributeFloatStringValues(array< ref SCR_EditorAttributeFloatStringValueHolder > values)
int Type
Definition Debug.c:13
ref array< ref SCR_EditorAttributeFloatStringValueHolder > m_aValues
override void WriteVariable(Managed item, SCR_BaseEditorAttributeVar var, SCR_AttributesManagerEditorComponent manager, int playerID)
override SCR_BaseEditorAttributeVar ReadVariable(Managed item, SCR_AttributesManagerEditorComponent manager)
override int GetEntries(notnull array< ref SCR_BaseEditorAttributeEntry > outEntries)
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
Definition LogLevel.c:14
SCR_FieldOfViewSettings Attribute
proto external string ToString()
Plain C++ pointer, no weak pointers, no memory management.
proto native vector Vector(float x, float y, float z)