Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
LocParserRule_Custom.c
Go to the documentation of this file.
1[BaseContainerProps(namingConvention: NamingConvention.NC_MUST_HAVE_NAME)]
3{
4 [Attribute(category: "ID", desc: "Structure of the ID.\n\Params:\n%1 - file name\n%2 - variable name\n%3 - parent class\n%4 - parent name\n%5, %6, %7 - custom params (see Param attributes)")]
5 protected string m_sIdFormat;
6
7 [Attribute(category: "ID", desc: "Strings to be removed from the ID.\nTo mention multiple strings, separate them by a comma.")]
8 protected string m_sRemove;
9
10 [Attribute(desc: "Name of the variable which holds the string.\nTo mention multiple variables, separate them by a comma.")]
11 protected string m_sVarName;
12
13 [Attribute(desc: "Name of the parent (see 'Parent Type' for information which name is used).")]
14 protected string m_sParentName;
15
16 [Attribute(desc: "Depth of the queried parent.\n 0 means the class where the variable is defined, 1 is its parent, and so on.")]
17 protected int m_iParentDepth;
18
19 [Attribute(defvalue: "0", uiwidget: UIWidgets.ComboBox, enums: { ParamEnum("Class name (inherited)", "0", ""), ParamEnum("Class name (exact)", "1", ""), ParamEnum("Name", "2", "") }, desc: "What information from the queried parent will be used.")]
20 protected int m_iParentType;
21
22 [Attribute(category: "ID", desc: "Parameter read from parent's variable and inserted in the ID format as %6.")]
23 protected ref LocParserRule_Custom_BaseParam m_IdParam1;
24
25 [Attribute(category: "ID", desc: "Parameter read from parent's variable and inserted in the ID format as %7.")]
26 protected ref LocParserRule_Custom_BaseParam m_IdParam2;
27
28 [Attribute(category: "ID", desc: "Parameter read from parent's variable and inserted in the ID format as %8.")]
29 protected ref LocParserRule_Custom_BaseParam m_IdParam3;
30
31 protected ref array<string> m_aVarName = {};
32 protected ref array<string> m_aRemove = {};
33
34 //------------------------------------------------------------------------------------------------
35 protected void RemoveExpression(out string text)
36 {
37 foreach (string remove : m_aRemove)
38 {
39 text.Replace(remove, string.Empty);
40 }
41 }
42
43 //------------------------------------------------------------------------------------------------
44 override bool Evaluate(string fileName, string varName, array<BaseContainer> objects)
45 {
46 //--- Check variable name
47 if (m_aVarName.Find(varName) == -1)
48 return false;
49
50 //--- Check parent class
51 if (m_sParentName.IsEmpty())
52 return true;
53
54 if (objects.Count() > m_iParentDepth)
55 {
56 switch (m_iParentType)
57 {
58 //--- Class name (inherited)
59 case 0:
60 {
61 typename parentType = objects[m_iParentDepth].GetClassName().ToType();
62 if (parentType && parentType.IsInherited(m_sParentName.ToType()))
63 return true;
64 break;
65 }
66 //--- Class name (exact)
67 case 1:
68 {
69 if (objects[m_iParentDepth].GetClassName() == m_sParentName)
70 return true;
71 break;
72 }
73 case 2:
74 {
75 //--- Name
76 if (objects[m_iParentDepth].GetName() == m_sParentName)
77 return true;
78 break;
79 }
80 }
81 }
82
83 return false;
84 }
85
86 //------------------------------------------------------------------------------------------------
87 override string GetID(string fileName, string varName, array<BaseContainer> objects, array<int> indexes)
88 {
89 //--- Get parent params
90 string parentClass, parentName, param1, param2, param3;
91 if (m_sParentName.IsEmpty() || objects.Count() > m_iParentDepth)
92 {
93 BaseContainer parent = objects[m_iParentDepth];
94 int index = indexes[m_iParentDepth];
95 parentClass = parent.GetClassName();
96 if (parentClass == "TextWidgetClass" || parentClass == "RichTextWidgetClass")
97 parent.Get("Name", parentName);
98 else
99 parentName = parent.GetName();
100
101 RemoveExpression(parentClass);
102 RemoveExpression(parentName);
103
104 BaseContainer paramObject = parent;
105 int paramIndex = index;
106 if (m_IdParam1 && m_IdParam1.GetArguments(objects, paramObject, indexes, paramIndex))
107 {
108 param1 = m_IdParam1.GetParam(paramObject, paramIndex);
110 }
111 paramObject = parent;
112 paramIndex = index;
113 if (m_IdParam2 && m_IdParam2.GetArguments(objects, paramObject, indexes, paramIndex))
114 {
115 param2 = m_IdParam2.GetParam(paramObject, paramIndex);
117 }
118 paramObject = parent;
119 paramIndex = index;
120 if (m_IdParam3 && m_IdParam3.GetArguments(objects, paramObject, indexes, paramIndex))
121 {
122 param3 = m_IdParam3.GetParam(paramObject, paramIndex);
124 }
125 }
126
127 //--- Format the ID
128 RemoveExpression(fileName);
129 RemoveExpression(varName);
130 string id = string.Format(m_sIdFormat, fileName, varName, parentClass, parentName, param1, param2, param3);
131
132 return id;
133 }
134
135 //------------------------------------------------------------------------------------------------
136 // constructor
138 {
139 m_sVarName.Split(",", m_aVarName, true);
140 m_sRemove.Split(",", m_aRemove, true);
141 }
142}
143
145class LocParserRule_Custom_BaseParam
147 [Attribute("-1", desc: "Depth of the param parent.\n 0 means the class where the variable is defined, 1 is its parent, and so on.")]
148 protected int m_iParentDepth;
150 //------------------------------------------------------------------------------------------------
151 bool GetArguments(notnull array<BaseContainer> objects, out BaseContainer outObject, notnull array<int> indexes, out int outIndex)
153 if (objects.IsEmpty() || objects.Count() <= m_iParentDepth)
154 return false;
156 if (m_iParentDepth < 0)
157 return true;
159 outObject = objects[m_iParentDepth];
160 outIndex = indexes[m_iParentDepth];
161 return true;
162 }
163 string GetParam(BaseContainer object, int index)
165 return string.Empty;
166 }
168
170class LocParserRule_Custom_IndexParam : LocParserRule_Custom_BaseParam
171{
172 //------------------------------------------------------------------------------------------------
173 override string GetParam(BaseContainer object, int index)
174 {
175 return index.ToString();
177}
178
180class LocParserRule_Custom_StringParam : LocParserRule_Custom_BaseParam
181{
182 [Attribute()]
183 protected string m_sParamName;
184
185 //------------------------------------------------------------------------------------------------
186 override string GetParam(BaseContainer object, int index)
187 {
188 string text;
189 object.Get(m_sParamName, text);
190
191 if (text.StartsWith(LocParserManager.LOCALIZED_PREFIX))
192 text = WidgetManager.Translate(text);
193
194 string allowedChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_0123456789";
195 for (int i = text.Length() - 1; i >= 0; i--)
196 {
197 if (!allowedChars.Contains(text[i]))
198 text.Replace(text[i], string.Empty);
199 }
200 return text;
201 }
202}
203
205class LocParserRule_Custom_EnumParam : LocParserRule_Custom_BaseParam
206{
207 [Attribute()]
208 protected string m_sParamName;
209
210 [Attribute()]
211 protected string m_sEnumName;
212
213 [Attribute()]
214 protected bool m_bIsFlag;
215
216 //------------------------------------------------------------------------------------------------
217 override string GetParam(BaseContainer object, int index)
218 {
219 int value;
220 if (object.Get(m_sParamName, value))
221 {
222 typename type = m_sEnumName.ToType();
223 if (m_bIsFlag)
224 return SCR_Enum.FlagsToString(type, value, "_", "NONE");
225 else
226 return typename.EnumToString(type, value);
227 }
228 else
229 {
230 return string.Empty;
231 }
232 }
233}
234
235//------------------------------------------------------------------------------------------------
237class LocParserRule_Custom_ResourceNameParam : LocParserRule_Custom_BaseParam
238{
239 [Attribute()]
240 protected string m_sParamName;
241
242 override string GetParam(BaseContainer object, int index)
243 {
244 ResourceName path;
245 object.Get(m_sParamName, path);
246 return FilePath.StripExtension(FilePath.StripPath(path));
247 }
248}
249
251class LocParserRule_Custom_NotificationParam : LocParserRule_Custom_BaseParam
252{
253 [Attribute()]
254 protected string m_sParamName;
255
256 //------------------------------------------------------------------------------------------------
257 override string GetParam(BaseContainer object, int index)
258 {
259 ENotification notification;
260 object.Get(m_sParamName, notification);
261 return typename.EnumToString(ENotification, notification);
262 }
263}
264
266class LocParserRule_Custom_HintParam : LocParserRule_Custom_BaseParam
267{
268 [Attribute()]
269 protected string m_sParamName;
270
271 //------------------------------------------------------------------------------------------------
272 override string GetParam(BaseContainer object, int index)
273 {
274 EHint hint;
275 object.Get(m_sParamName, hint);
276 return typename.EnumToString(EHint, hint);
277 }
string path
AddonBuildInfoTool id
EHint
Definition EHint.c:11
ENotification
LocParserRule_Custom LocParserRule BaseContainerProps()] class LocParserRule_Custom_BaseParam
int m_iParentDepth
EDamageType type
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
override string GetParam()
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
static const string LOCALIZED_PREFIX
ref LocParserRule_Custom_BaseParam m_IdParam2
override string GetID(string fileName, string varName, array< BaseContainer > objects, array< int > indexes)
ref LocParserRule_Custom_BaseParam m_IdParam3
ref array< string > m_aVarName
void RemoveExpression(out string text)
ref array< string > m_aRemove
override bool Evaluate(string fileName, string varName, array< BaseContainer > objects)
ref LocParserRule_Custom_BaseParam m_IdParam1
SCR_FieldOfViewSettings Attribute
T3 param3
Definition tuple.c:93
T2 param2
Definition tuple.c:92
Tuple param1
proto T Get(int n)