DayZ 1.24
Loading...
Searching...
No Matches
PluginConfigViewer.c
Go to the documentation of this file.
1class PluginConfigViewer extends PluginBase
2{
4 {
5 }
6
7 string MakeTabs(int count, bool inheritance = false)
8 {
9 if (count == 0)
10 return "";
11
12 string tabs = "|--";
13 if (inheritance)
14 tabs = "|<<";
15
16 for (int i = 0; i < count - 1; i++)
17 tabs = "| " + tabs;
18
19 return tabs;
20 }
21
23 {
25 int class_path_len = class_path.Length();
26
28 {
31
32 return class_path.Substring(start, count).Trim();
33 }
34 else
35 return "";
36 }
37
39 {
40 if (class_path == "")
41 return "";
42
43 int start = config_class_path.Length();
44 int count = class_path.Length() - start;
46
48 GetGame().ConfigGetFullPath(config_class_path, full_path);
49
50 if (full_path.Count() > 1 && class_path_without_config_class != "")
52 else
53 return "";
54 }
55
57 {
58 int current = -1;
59 int last = 0;
60
61 while (true)
62 {
63 current = child_path.IndexOfFrom(last, " ");
64 if (current > -1)
65 last = current + 1;
66 else
67 break;
68 }
69
70 string result = child_path.Substring(0, last) + base_class;
71 return result;
72 }
73
75 {
77 return config_class_path + " " + class_path;
78 else
79 {
81 GetGame().ConfigGetFullPath(config_class_path, full_path);
82
83 if (full_path.Count() > 1)
85 else
86 return "";
87 }
88 }
89
91 {
92 int start = class_path.IndexOf(" ");
93 string name = class_path;
94 if (start > -1)
95 name = class_path.Substring(0, start);
96
97 int cfg_class_count = GetGame().ConfigGetChildrenCount(config_class_path);
98
99 for (int i = 0; i < cfg_class_count; i++)
100 {
101 string cfg_class_name = "";
102 GetGame().ConfigGetChildName(config_class_path, i, cfg_class_name);
103
104 if (cfg_class_name == name)
105 {
106 string full_name = config_class_path + " " + name;
107 int type = GetGame().ConfigGetType(full_name);
108
109 if (type == CT_CLASS)
110 return true;
111 }
112 }
113
114 if (start == -1)
115 return false;
116 else
117 {
118 string new_name = class_path.Substring(start + 1, class_path.Length() - (start + 1));
120 }
121 }
122
124 {
125 string tabs = MakeTabs(depth + 1);
126 string child_path = path;
127 int count = GetGame().ConfigGetChildrenCount(child_path);
128 int i = 0;
129
130 bool name_printed = false;
131
133
134 for (i = 0; i < count; i++)
135 {
136 string child_name = "";
137 GetGame().ConfigGetChildName(child_path, i, child_name);
138 string c_child_path = child_path + " " + child_name;
139
141 child_name_lower.ToLower();
142
143 if (overridden.Find(child_name_lower) == -1)
144 {
145 if (!name_printed)
146 {
147 result.Insert(":" + MakeTabs(depth, check_base_class_of_class) + "!" + name);
148 name_printed = true;
149 }
151
152 int type = GetGame().ConfigGetType(c_child_path);
153
154 if (type != CT_CLASS)
155 {
156 if (type != CT_ARRAY)
157 result.Insert("-" + tabs + "!" + child_name + " = " + GetGame().ConfigGetTextOut(c_child_path));
158 else
159 {
160 result.Insert("-" + tabs + "!" + child_name + "[] = {");
161
163 GetGame().ConfigGetTextArray(c_child_path, strs);
164 string tabs_array = MakeTabs(depth + 2);
165 int j;
166 for (j = 0; j < strs.Count(); j++)
167 result.Insert("-" + tabs + "!" + child_name + "[]" + j.ToStringLen(6) + "~" + strs.Get(j) + ",");
168
169 result.Insert("-" + tabs + "!" + child_name + "[]" + j.ToStringLen(6) + "~}");
170 }
171 }
172 else
173 {
175
176 if (GetGame().ConfigGetChildrenCount(c_child_path) > 0)
177 {
179 result.InsertAll(config1);
180 }
181 else
182 result.Insert(":" + tabs + "!" + child_name);
183
186 string c_child_name = child_name;
187
188 int cc = 0;
189
190 while (true)
191 {
192 string base_class = "";
193
194 GetGame().ConfigGetBaseName(cc_child_path, base_class);
195
196 int start = c_config_class_path.Length() + 1;
197 int len = cc_child_path.Length();
198 len -= c_config_class_path.Length() + c_child_name.Length();
199 len -= 2;
200
201 if (base_class != "")
202 {
203 string only_child_path = "";
204 if (len < 0)
206 else
207 only_child_path = cc_child_path.Substring(start, len) + " " + base_class;
208
211
212 if (base_class_path != "")
213 {
215 result.InsertAll(config2);
216 }
217 else
218 {
220 result.InsertAll(config3);
221
222 break;
223 }
224
227 c_config_class_path = cc_child_path.Substring(0, cc_child_path.Length() - only_child_path.Length() - 1);
228 }
229 else
230 break;
231 }
232 }
233 }
234 }
235
236 if (name_printed)
237 result.Insert(":" + MakeTabs(depth, check_base_class_of_class) + "#" + name);
238
240 {
242 GetGame().ConfigGetFullPath(child_path, full_path);
243
244 if (full_path.Count() > 1)
245 {
247 result.InsertAll(config4);
248 }
249 }
250 else
251 {
252 string class_base_class = "";
253 GetGame().ConfigGetBaseName(child_path, class_base_class);
254
255 if (class_base_class != "")
256 {
259
260 if (cc_base_child_path != "")
261 {
263 result.InsertAll(config5);
264 }
265 else
266 {
268 result.InsertAll(config6);
269 }
270 }
271 }
272
273 return result;
274 }
275
277 {
278 int i;
280
281 if (class_path != "")
282 {
283 PluginDeveloper module_dev = PluginDeveloper.Cast(GetPlugin(PluginDeveloper));
284
286 class_path.Split(" ", path_nodes);
287
288 if (path_nodes.Count() >= 3)
289 {
290 string c_class_path = path_nodes.Get(0) + " " + path_nodes.Get(1) + " " + path_nodes.Get(2);
291
293 string config_class = path_nodes.Get(1);
294 string class_name = path_nodes.Get(2);
295
297
302 string tabs = MakeTabs(1);
303 string tabs_inherited = MakeTabs(1, true);
304 string check_tabs = MakeTabs(path_nodes.Count() - 1, true);
305
306 nested_start.Insert(":!");
307 nested_end.Insert(":#");
308 nested_inherited_start.Insert(":!");
309 nested_inherited_end.Insert(":#");
310
311 string last_node = filter_char + MakeTabs(nested_start.Count()) + "!";
312
313 if (path_nodes.Count() == 3)
314 last_node = filter_char + MakeTabs(1) + "!";
315 else
316 {
317 for (i = 1; i < path_nodes.Count() - 2; i++)
318 {
319 tabs = MakeTabs(i);
320 tabs_inherited = MakeTabs(i, true);
321
322 string path_node = path_nodes.Get(i + 2);
323 path_node.ToLower();
324
325 nested_start.Insert(":" + tabs + "!" + path_node);
326 nested_end.Insert(":" + tabs + "#" + path_node);
327 nested_inherited_start.Insert(":" + tabs_inherited + "!" + path_node);
328 nested_inherited_end.Insert(":" + tabs_inherited + "#" + path_node);
329 }
330
331 last_node = filter_char + MakeTabs(i) + "!";
332 }
333
334 int current_nest = 0;
335
336 for (i = 0; i < result.Count(); i++)
337 {
338 string current = result.Get(i);
339 string current_lower = current;
340 current_lower.ToLower();
341
342 int len_current = current.Length();
343
344 if (current_nest < nested_start.Count())
345 {
346 int len_start = nested_start.Get(current_nest).Length();
347
348 if (len_current >= len_start)
349 {
351
352 if (current_nest == 0)
353 prefix_start = current_lower.Substring(0, len_start);
354
356 {
357 current_nest++;
358 continue;
359 }
360 }
361 }
362
363 if (current_nest >= 1)
364 {
365 int len_end = nested_end.Get(current_nest - 1).Length();
366
367 if (len_current >= len_end)
368 {
369 string prefix_end = current_lower;
370
371 if (current_nest == 0)
372 prefix_start = current_lower.Substring(0, len_start);
373
375 current_nest--;
376 }
377 }
378
379 if (current_nest == nested_start.Count())
380 {
381 string first_char = current.Substring(0, 1);
382
383 if (first_char == filter_char)
384 {
385 int bang_pos = current.IndexOf("!");
386
387 if (bang_pos > -1)
388 {
389 int len_last_node = last_node.Length();
390
392 {
393 string prefix_current = current_lower.Substring(0, len_last_node);
394
396 filtered.Insert(current.Substring(bang_pos + 1, current.Length() - (bang_pos + 1)));
397 }
398 }
399 }
400 }
401 }
402
404
406
407 for (i = 0; i < filtered.Count(); i++)
408 {
409 string c = filtered.Get(i);
410 string lower_c = c;
411 lower_c.ToLower();
412
413 if (without_duplications.Find(lower_c) < 0)
414 {
416
417 if (lower_c != c)
418 lowered.Set(lower_c, c);
419 }
420 }
421
422 module_dev.SortStringArray(without_duplications);
423
424 for (i = 0; i < without_duplications.Count(); i++)
425 {
426 string cc = without_duplications.Get(i);
427
428 if (lowered.Contains(cc))
429 cc = lowered.Get(cc);
430
431 int tilda_index = cc.IndexOf("~");
432 if (tilda_index > -1)
433 {
434 string spaces = " ";
435 if (cc.IndexOf("~}") > -1)
436 spaces = "";
437 cc = spaces + cc.Substring(tilda_index + 1, cc.Length() - (tilda_index + 1));
438 }
439
441 }
442
444 }
445 else if (filter_char == ":")
446 {
447 int cnt_config = GetGame().ConfigGetChildrenCount(class_path);
448
449 for (i = 0; i < cnt_config; i++)
450 {
451 string config_name = "";
452 GetGame().ConfigGetChildName(class_path, i, config_name);
453 filtered.Insert(config_name);
454 }
455
456 module_dev.SortStringArray(filtered);
457 }
458 }
459 else if (filter_char == ":")
460 {
461 filtered.Insert("configfile");
462 filtered.Insert("missionconfigfile");
463 }
464
465 return filtered;
466 }
467
469 {
470 return GetConfig(class_path, "-");
471 }
472
474 {
475 return GetConfig(class_path, ":");
476 }
477
478 string GetBaseClasses(string path, string item)
479 {
480 string adjustedPath = path;
481 bool run = true;
483 resultArr.Insert(item);
484 while (run)
485 {
486 //Print("checking for path:'" + adjustedPath +"'");
487 string baseClass = "";
488 run = GetGame().ConfigGetBaseName(adjustedPath, baseClass);
489 if (baseClass)
490 {
492 adjustedPath.Split(" ", strs);
493 strs.Remove(strs.Count() - 1);
494 strs.Insert(baseClass);
495
496 adjustedPath = string.Join(" ", strs);
497 resultArr.Insert(baseClass);
498 if (adjustedPath == path)
499 break;
500 }
501
502 }
503 string result;
504 resultArr.Invert();
505 foreach (int i, string str: resultArr)
506 {
507 if (i != 0)
508 result += " >> " + str;
509 else
510 result += str;
511 }
512
513 return result;
514 }
515
516
517}
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
class OptionSelectorMultistate extends OptionSelector class_name
PluginBase GetPlugin(typename plugin_type)
bool ContainsFirstClass(string config_class_path, string class_path)
TStringArray GetConfig(string class_path, string filter_char)
string GetBaseClassPathCombined(string child_path, string base_class)
string GetBaseClassPathRecursive(string config_class_path, string class_path, string config_class)
TStringArray GetConfigVariables(string class_path)
string GetBaseClasses(string path, string item)
void PluginConfigViewer()
TStringArray GetConfigHierarchy(string class_path)
string GetOnlyChildPath(string config_class_path, string class_path)
string GetBaseClassPath(string config_class_path, string class_path, string config_class)
TStringArray GetConfigRecursive(string path, string name, string config_class_path, string config_class, local array< string > overridden, int depth=0, local bool check_base_class_of_class=false)
string MakeTabs(int count, bool inheritance=false)
proto native CGame GetGame()
array< string > TStringArray
Definition EnScript.c:666