DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
PluginConfigViewer.c
См. документацию.
1class PluginConfigViewer extends PluginBase
2{
4 {
5 }
6
7 string MakeTabs( int count, bool inheritance = false )
8 {
9 if ( count == 0 )
10 {
11 return "";
12 }
13
14 string tabs = "|--";
15 if ( inheritance )
16 {
17 tabs = "|<<";
18 }
19
20 for ( int i = 0; i < count - 1; i++ )
21 {
22 tabs = "| " + tabs;
23 }
24
25 return tabs;
26 }
27
28 string GetOnlyChildPath( string config_class_path, string class_path )
29 {
30 int config_class_path_len = config_class_path.Length();
31 int class_path_len = class_path.Length();
32
33 if ( class_path_len > config_class_path_len )
34 {
35 int start = config_class_path_len;
36 int count = class_path_len - start;
37
38 return class_path.Substring(start, count).Trim();
39 }
40 else
41 {
42 return "";
43 }
44 }
45
46 string GetBaseClassPath( string config_class_path, string class_path, string config_class )
47 {
48 if ( class_path == "" )
49 {
50 return "";
51 }
52
53 int start = config_class_path.Length();
54 int count = class_path.Length() - start;
55 string class_path_without_config_class = GetOnlyChildPath( config_class_path, class_path );
56
57 ref TStringArray full_path = new TStringArray;
58 GetGame().ConfigGetFullPath( config_class_path, full_path );
59
60 if ( full_path.Count() > 1 && class_path_without_config_class != "" )
61 {
62 return GetBaseClassPathRecursive( config_class + " " + full_path.Get(1), class_path_without_config_class, config_class );
63 }
64 else
65 {
66 return "";
67 }
68 }
69
70 string GetBaseClassPathCombined( string child_path, string base_class )
71 {
72 int current = -1;
73 int last = 0;
74
75 while ( true )
76 {
77 current = child_path.IndexOfFrom(last, " " );
78 if ( current > -1 )
79 {
80 last = current+1;
81 }
82 else
83 {
84 break;
85 }
86 }
87
88 string result = child_path.Substring(0, last ) + base_class;
89 return result;
90 }
91
92 string GetBaseClassPathRecursive( string config_class_path, string class_path, string config_class )
93 {
94 if ( ContainsFirstClass(config_class_path, class_path) )
95 {
96 return config_class_path + " " + class_path;
97 }
98 else
99 {
100 ref TStringArray full_path = new TStringArray;
101 GetGame().ConfigGetFullPath( config_class_path, full_path );
102
103 if ( full_path.Count() > 1 )
104 {
105 return GetBaseClassPathRecursive( config_class + " " + full_path.Get(1), class_path, config_class );
106 }
107 else
108 {
109 return "";
110 }
111 }
112 }
113
114 bool ContainsFirstClass( string config_class_path, string class_path )
115 {
116 int start = class_path.IndexOf(" ");
117 string name = class_path;
118 if ( start > -1 )
119 {
120 name = class_path.Substring(0, start );
121 }
122
123 int cfg_class_count = GetGame().ConfigGetChildrenCount( config_class_path );
124
125 for ( int i = 0; i < cfg_class_count; i++ )
126 {
127 string cfg_class_name = "";
128 GetGame().ConfigGetChildName( config_class_path, i, cfg_class_name );
129
130 if ( cfg_class_name == name )
131 {
132 string full_name = config_class_path + " " + name;
133 int type = GetGame().ConfigGetType( full_name );
134
135 if ( type == CT_CLASS )
136 {
137 return true;
138 }
139 }
140 }
141
142 if ( start == -1 )
143 {
144 return false;
145 }
146 else
147 {
148 string new_name = class_path.Substring(start + 1, class_path.Length() - (start + 1) );
149 return ContainsFirstClass( config_class_path + " " + name, new_name );
150 }
151 }
152
153 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 )
154 {
155 string tabs = MakeTabs( depth + 1 );
156 string child_path = path;
157 int count = GetGame().ConfigGetChildrenCount( child_path );
158 int i = 0;
159
160 bool name_printed = false;
161
162 TStringArray result = new TStringArray;
163
164 for ( i = 0; i < count; i++ )
165 {
166 string child_name = "";
167 GetGame().ConfigGetChildName( child_path, i, child_name );
168 string c_child_path = child_path + " " + child_name;
169
170 string child_name_lower = child_name;
171 child_name_lower.ToLower();
172
173 if ( overridden.Find(child_name_lower) == -1 )
174 {
175 if ( !name_printed )
176 {
177 result.Insert( ":" + MakeTabs(depth, check_base_class_of_class) + "!" + name );
178 name_printed = true;
179 }
180 overridden.Insert( child_name_lower );
181
182 int type = GetGame().ConfigGetType( c_child_path );
183
184 if ( type != CT_CLASS )
185 {
186 if ( type != CT_ARRAY )
187 {
188 result.Insert( "-" + tabs + "!" + child_name + " = " + GetGame().ConfigGetTextOut(c_child_path) );
189 }
190 else
191 {
192 result.Insert( "-" + tabs + "!" + child_name + "[] = {" );
193
194 TStringArray strs = new TStringArray;
195 GetGame().ConfigGetTextArray( c_child_path, strs );
196 string tabs_array = MakeTabs( depth + 2 );
197 int j;
198 for ( j = 0; j < strs.Count(); j++ )
199 {
200 result.Insert( "-" + tabs + "!" + child_name + "[]" + j.ToStringLen(6) + "~" + strs.Get(j) + "," );
201 }
202
203 result.Insert( "-" + tabs + "!" + child_name + "[]" + j.ToStringLen(6) + "~}" );
204 }
205 }
206 else
207 {
208 array<string> overridden_sub = new array<string>;
209
210 if ( GetGame().ConfigGetChildrenCount(c_child_path) > 0 )
211 {
212 TStringArray config1 = GetConfigRecursive( c_child_path, child_name, config_class_path, config_class, overridden_sub, depth + 1 );
213 result.InsertAll( config1 );
214 }
215 else
216 {
217 result.Insert( ":" + tabs + "!" + child_name );
218 }
219
220 string cc_child_path = c_child_path;
221 string c_config_class_path = config_class_path;
222 string c_child_name = child_name;
223
224 int cc = 0;
225
226 while ( true )
227 {
228 string base_class = "";
229
230 GetGame().ConfigGetBaseName( cc_child_path, base_class );
231
232 int start = c_config_class_path.Length() + 1;
233 int len = cc_child_path.Length();
234 len -= c_config_class_path.Length() + c_child_name.Length();
235 len -= 2;
236
237 if ( base_class != "" )
238 {
239 string only_child_path = "";
240 if ( len < 0 )
241 {
242 only_child_path = base_class;
243 }
244 else
245 {
246 only_child_path = cc_child_path.Substring( start, len ) + " " + base_class;
247 }
248
249 string c_base_child_path = GetBaseClassPathCombined( cc_child_path, base_class );
250 string base_class_path = GetBaseClassPath( c_config_class_path, c_base_child_path, config_class );
251
252 if ( base_class_path != "" )
253 {
254 TStringArray config2 = GetConfigRecursive( base_class_path, base_class, base_class_path, config_class, overridden_sub, depth + 1, true );
255 result.InsertAll( config2 );
256 }
257 else
258 {
259 TStringArray config3 = GetConfigRecursive( base_class, base_class, base_class, config_class, overridden_sub, depth + 1, true );
260 result.InsertAll( config3 );
261
262 break;
263 }
264
265 cc_child_path = base_class_path;
266 c_child_name = base_class;
267 c_config_class_path = cc_child_path.Substring( 0, cc_child_path.Length() - only_child_path.Length() - 1);
268 }
269 else
270 {
271 break;
272 }
273 }
274 }
275 }
276 }
277
278 if ( name_printed )
279 {
280 result.Insert( ":" + MakeTabs(depth, check_base_class_of_class) + "#" + name );
281 }
282
283 if ( !check_base_class_of_class )
284 {
285 TStringArray full_path = new TStringArray;
286 GetGame().ConfigGetFullPath( child_path, full_path );
287
288 if ( full_path.Count() > 1 )
289 {
290 TStringArray config4 = GetConfigRecursive( config_class + " " + full_path.Get(1), full_path.Get(1), config_class + " " + full_path.Get(1), config_class, overridden, depth );
291 result.InsertAll( config4 );
292 }
293 }
294 else
295 {
296 string class_base_class = "";
297 GetGame().ConfigGetBaseName( child_path, class_base_class );
298
299 if ( class_base_class != "" )
300 {
301 string base_child_path = GetBaseClassPathCombined( child_path, class_base_class );
302 string cc_base_child_path = GetBaseClassPath( config_class_path, base_child_path, config_class );
303
304 if ( cc_base_child_path != "" )
305 {
306 TStringArray config5 = GetConfigRecursive( cc_base_child_path, class_base_class, cc_base_child_path, config_class, overridden, depth, true );
307 result.InsertAll( config5 );
308 }
309 else
310 {
311 TStringArray config6 = GetConfigRecursive( class_base_class, class_base_class, class_base_class, config_class, overridden, depth, true );
312 result.InsertAll( config6 );
313 }
314 }
315 }
316
317 return result;
318 }
319
320 TStringArray GetConfig( string class_path, string filter_char )
321 {
322 int i;
323 TStringArray filtered = new TStringArray;
324
325 if ( class_path != "" )
326 {
328
329 TStringArray path_nodes = new TStringArray;
330 class_path.Split( " ", path_nodes );
331
332 if ( path_nodes.Count() >= 3 )
333 {
334 string c_class_path = path_nodes.Get(0) + " " + path_nodes.Get(1) + " " + path_nodes.Get(2);
335
336 array<string> overridden = new array<string>;
337 string config_class = path_nodes.Get( 1 );
338 string class_name = path_nodes.Get( 2 );
339
340 TStringArray result = GetConfigRecursive( c_class_path, class_name, c_class_path, config_class, overridden );
341
342 TStringArray nested_start = new TStringArray;
343 TStringArray nested_end = new TStringArray;
344 TStringArray nested_inherited_start = new TStringArray;
345 TStringArray nested_inherited_end = new TStringArray;
346 string tabs = MakeTabs( 1 );
347 string tabs_inherited = MakeTabs( 1, true );
348 string check_tabs = MakeTabs( path_nodes.Count() - 1, true );
349
350 nested_start.Insert( ":!" );
351 nested_end.Insert( ":#" );
352 nested_inherited_start.Insert( ":!" );
353 nested_inherited_end.Insert( ":#" );
354
355 string last_node = filter_char + MakeTabs( nested_start.Count() ) + "!";
356
357 if ( path_nodes.Count() == 3 )
358 {
359 last_node = filter_char + MakeTabs( 1 ) + "!";
360 }
361 else
362 {
363 for ( i = 1; i < path_nodes.Count() - 2; i++ )
364 {
365 tabs = MakeTabs( i );
366 tabs_inherited = MakeTabs( i, true );
367
368 string path_node = path_nodes.Get(i+2);
369 path_node.ToLower( );
370
371 nested_start.Insert( ":" + tabs + "!" + path_node );
372 nested_end.Insert( ":" + tabs + "#" + path_node );
373 nested_inherited_start.Insert( ":" + tabs_inherited + "!" + path_node );
374 nested_inherited_end.Insert( ":" + tabs_inherited + "#" + path_node );
375 }
376
377 last_node = filter_char + MakeTabs( i ) + "!";
378 }
379
380 int current_nest = 0;
381
382 for ( i = 0; i < result.Count(); i++ )
383 {
384 string current = result.Get( i );
385 string current_lower = current;
386 current_lower.ToLower( );
387
388 int len_current = current.Length();
389
390 if ( current_nest < nested_start.Count() )
391 {
392 int len_start = nested_start.Get(current_nest).Length();
393
394 if ( len_current >= len_start )
395 {
396 string prefix_start = current_lower;
397
398 if ( current_nest == 0 )
399 {
400 prefix_start = current_lower.Substring( 0, len_start );
401 }
402
403 if ( prefix_start == nested_start.Get(current_nest) || prefix_start == nested_inherited_start.Get(current_nest) )
404 {
405 current_nest++;
406 continue;
407 }
408 }
409 }
410
411 if ( current_nest >= 1 )
412 {
413 int len_end = nested_end.Get(current_nest - 1).Length();
414
415 if ( len_current >= len_end )
416 {
417 string prefix_end = current_lower;
418
419 if ( current_nest == 0 )
420 {
421 prefix_start = current_lower.Substring( 0, len_start );
422 }
423
424 if ( prefix_end == nested_end.Get(current_nest - 1) || prefix_end == nested_inherited_end.Get(current_nest - 1) )
425 {
426 current_nest--;
427 }
428 }
429 }
430
431 if ( current_nest == nested_start.Count() )
432 {
433 string first_char = current.Substring( 0, 1 );
434
435 if ( first_char == filter_char )
436 {
437 int bang_pos = current.IndexOf( "!" );
438
439 if ( bang_pos > -1 )
440 {
441 int len_last_node = last_node.Length();
442
443 if ( len_current >= len_last_node )
444 {
445 string prefix_current = current_lower.Substring( 0, len_last_node );
446
447 if ( last_node == prefix_current )
448 {
449 filtered.Insert( current.Substring(bang_pos + 1, current.Length() - (bang_pos + 1)) );
450 }
451 }
452 }
453 }
454 }
455 }
456
457 TStringArray without_duplications = new TStringArray;
458
460
461 for ( i = 0; i < filtered.Count(); i++ )
462 {
463 string c = filtered.Get( i );
464 string lower_c = c;
465 lower_c.ToLower();
466
467 if ( without_duplications.Find(lower_c) < 0 )
468 {
469 without_duplications.Insert( lower_c );
470
471 if ( lower_c != c )
472 {
473 lowered.Set( lower_c, c );
474 }
475 }
476 }
477
478 module_dev.SortStringArray( without_duplications );
479
480 for ( i = 0; i < without_duplications.Count(); i++ )
481 {
482 string cc = without_duplications.Get( i );
483
484 if ( lowered.Contains(cc) )
485 {
486 cc = lowered.Get( cc );
487 }
488
489 int tilda_index = cc.IndexOf( "~" );
490 if ( tilda_index > -1 )
491 {
492 string spaces = " ";
493 if ( cc.IndexOf( "~}" ) > -1 )
494 {
495 spaces = "";
496 }
497 cc = spaces + cc.Substring(tilda_index + 1, cc.Length() - (tilda_index + 1) );
498 }
499
500 without_duplications.Set( i, cc );
501 }
502
503 return without_duplications;
504 }
505 else if ( filter_char == ":" )
506 {
507 int cnt_config = GetGame().ConfigGetChildrenCount( class_path );
508
509 for ( i = 0; i < cnt_config; i++ )
510 {
511 string config_name = "";
512 GetGame().ConfigGetChildName( class_path, i, config_name );
513 filtered.Insert( config_name );
514 }
515
516 module_dev.SortStringArray( filtered );
517 }
518 }
519 else if ( filter_char == ":" )
520 {
521 filtered.Insert( "configfile" );
522 filtered.Insert( "missionconfigfile" );
523 }
524
525 return filtered;
526 }
527
528 TStringArray GetConfigVariables( string class_path )
529 {
530 return GetConfig( class_path, "-" );
531 }
532
533 TStringArray GetConfigHierarchy( string class_path )
534 {
535 return GetConfig( class_path, ":" );
536 }
537
538 string GetBaseClasses(string path, string item)
539 {
540 string adjustedPath = path;
541 bool run = true;
542 TStringArray resultArr = new TStringArray();
543 resultArr.Insert(item);
544 while (run)
545 {
546 //Print("checking for path:'" + adjustedPath +"'");
547 string baseClass = "";
548 run = GetGame().ConfigGetBaseName( adjustedPath, baseClass );
549 if (baseClass)
550 {
551 TStringArray strs = new TStringArray;
552 adjustedPath.Split(" ",strs);
553 strs.Remove(strs.Count() - 1);
554 strs.Insert(baseClass);
555
556 adjustedPath = string.Join(" ", strs);
557 resultArr.Insert(baseClass);
558 if (adjustedPath == path)
559 break;
560 }
561
562 }
563 string result;
564 resultArr.Invert();
565 foreach (int i, string str: resultArr)
566 {
567 if (i != 0)
568 result += " >> " + str;
569 else
570 result += str;
571 }
572
573 return result;
574 }
575
576
577}
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
map
Определения ControlsXboxNew.c:4
string path
Определения OptionSelectorMultistate.c:142
class OptionSelectorMultistate extends OptionSelector class_name
PluginBase GetPlugin(typename plugin_type)
Определения PluginManager.c:316
proto bool ConfigGetChildName(string path, int index, out string name)
Get name of subclass in config class on path.
proto native void ConfigGetFullPath(string path, out TStringArray full_path)
proto bool ConfigGetBaseName(string path, out string base_name)
Get name of base class of config class on path.
proto native void ConfigGetTextArray(string path, out TStringArray values)
Get array of strings from config on path.
proto native int ConfigGetType(string path)
Returns type of config value.
proto native int ConfigGetChildrenCount(string path)
Get count of subclasses in config class on path.
bool ContainsFirstClass(string config_class_path, string class_path)
Определения PluginConfigViewer.c:114
TStringArray GetConfig(string class_path, string filter_char)
Определения PluginConfigViewer.c:320
string GetBaseClassPathCombined(string child_path, string base_class)
Определения PluginConfigViewer.c:70
string GetBaseClassPathRecursive(string config_class_path, string class_path, string config_class)
Определения PluginConfigViewer.c:92
TStringArray GetConfigVariables(string class_path)
Определения PluginConfigViewer.c:528
void PluginDeveloper()
Определения PluginDeveloper.c:49
string GetBaseClasses(string path, string item)
Определения PluginConfigViewer.c:538
void PluginConfigViewer()
Определения PluginConfigViewer.c:3
TStringArray GetConfigHierarchy(string class_path)
Определения PluginConfigViewer.c:533
string GetOnlyChildPath(string config_class_path, string class_path)
Определения PluginConfigViewer.c:28
string GetBaseClassPath(string config_class_path, string class_path, string config_class)
Определения PluginConfigViewer.c:46
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)
Определения PluginConfigViewer.c:153
string MakeTabs(int count, bool inheritance=false)
Определения PluginConfigViewer.c:7
Определения PluginBase.c:2
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
proto native CGame GetGame()
array< string > TStringArray
Определения EnScript.c:685
proto native int Length()
Returns length of string.
proto string Trim()
Returns trimmed string with removed leading and trailing whitespaces.
proto string Get(int index)
Gets n-th character from string.
void Split(string sample, out array< string > output)
Splits string into array of strings separated by 'sample'.
Определения EnString.c:396
proto string Substring(int start, int len)
Substring of 'str' from 'start' position 'len' number of characters.
proto native int IndexOfFrom(int start, string sample)
Finds 'sample' in 'str' from 'start' position. Returns -1 when not found.
static string Join(string separator, notnull TStringArray tokens)
Определения EnString.c:424
proto native int IndexOf(string sample)
Finds 'sample' in 'str'. Returns -1 when not found.
proto int ToLower()
Changes string to lowercase. Returns length.