3 void PluginConfigViewer()
7 string MakeTabs(
int count,
bool inheritance =
false )
20 for (
int i = 0; i < count - 1; i++ )
28 string GetOnlyChildPath(
string config_class_path,
string class_path )
30 int config_class_path_len = config_class_path.Length();
31 int class_path_len = class_path.Length();
33 if ( class_path_len > config_class_path_len )
35 int start = config_class_path_len;
36 int count = class_path_len - start;
38 return class_path.Substring(start, count).Trim();
46 string GetBaseClassPath(
string config_class_path,
string class_path,
string config_class )
48 if ( class_path ==
"" )
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 );
58 GetGame().ConfigGetFullPath( config_class_path, full_path );
60 if ( full_path.Count() > 1 && class_path_without_config_class !=
"" )
62 return GetBaseClassPathRecursive( config_class +
" " + full_path.Get(1), class_path_without_config_class, config_class );
70 string GetBaseClassPathCombined(
string child_path,
string base_class )
77 current = child_path.IndexOfFrom(last,
" " );
88 string result = child_path.Substring(0, last ) + base_class;
92 string GetBaseClassPathRecursive(
string config_class_path,
string class_path,
string config_class )
94 if ( ContainsFirstClass(config_class_path, class_path) )
96 return config_class_path +
" " + class_path;
101 GetGame().ConfigGetFullPath( config_class_path, full_path );
103 if ( full_path.Count() > 1 )
105 return GetBaseClassPathRecursive( config_class +
" " + full_path.Get(1), class_path, config_class );
114 bool ContainsFirstClass(
string config_class_path,
string class_path )
116 int start = class_path.IndexOf(
" ");
117 string name = class_path;
120 name = class_path.Substring(0, start );
123 int cfg_class_count =
GetGame().ConfigGetChildrenCount( config_class_path );
125 for (
int i = 0; i < cfg_class_count; i++ )
127 string cfg_class_name =
"";
128 GetGame().ConfigGetChildName( config_class_path, i, cfg_class_name );
130 if ( cfg_class_name ==
name )
132 string full_name = config_class_path +
" " +
name;
133 int type =
GetGame().ConfigGetType( full_name );
135 if ( type == CT_CLASS )
148 string new_name = class_path.Substring(start + 1, class_path.Length() - (start + 1) );
149 return ContainsFirstClass( config_class_path +
" " +
name, new_name );
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 )
155 string tabs = MakeTabs( depth + 1 );
156 string child_path =
path;
157 int count =
GetGame().ConfigGetChildrenCount( child_path );
160 bool name_printed =
false;
164 for ( i = 0; i < count; i++ )
166 string child_name =
"";
167 GetGame().ConfigGetChildName( child_path, i, child_name );
168 string c_child_path = child_path +
" " + child_name;
170 string child_name_lower = child_name;
171 child_name_lower.ToLower();
173 if ( overridden.Find(child_name_lower) == -1 )
177 result.Insert(
":" + MakeTabs(depth, check_base_class_of_class) +
"!" +
name );
180 overridden.Insert( child_name_lower );
182 int type =
GetGame().ConfigGetType( c_child_path );
184 if ( type != CT_CLASS )
186 if ( type != CT_ARRAY )
188 result.Insert(
"-" + tabs +
"!" + child_name +
" = " +
GetGame().ConfigGetTextOut(c_child_path) );
192 result.Insert(
"-" + tabs +
"!" + child_name +
"[] = {" );
195 GetGame().ConfigGetTextArray( c_child_path, strs );
196 string tabs_array = MakeTabs( depth + 2 );
198 for ( j = 0; j < strs.Count(); j++ )
200 result.Insert(
"-" + tabs +
"!" + child_name +
"[]" + j.ToStringLen(6) +
"~" + strs.Get(j) +
"," );
203 result.Insert(
"-" + tabs +
"!" + child_name +
"[]" + j.ToStringLen(6) +
"~}" );
210 if (
GetGame().ConfigGetChildrenCount(c_child_path) > 0 )
212 TStringArray config1 = GetConfigRecursive( c_child_path, child_name, config_class_path, config_class, overridden_sub, depth + 1 );
213 result.InsertAll( config1 );
217 result.Insert(
":" + tabs +
"!" + child_name );
220 string cc_child_path = c_child_path;
221 string c_config_class_path = config_class_path;
222 string c_child_name = child_name;
228 string base_class =
"";
230 GetGame().ConfigGetBaseName( cc_child_path, base_class );
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();
237 if ( base_class !=
"" )
239 string only_child_path =
"";
242 only_child_path = base_class;
246 only_child_path = cc_child_path.Substring( start, len ) +
" " + base_class;
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 );
252 if ( base_class_path !=
"" )
254 TStringArray config2 = GetConfigRecursive( base_class_path, base_class, base_class_path, config_class, overridden_sub, depth + 1,
true );
255 result.InsertAll( config2 );
259 TStringArray config3 = GetConfigRecursive( base_class, base_class, base_class, config_class, overridden_sub, depth + 1,
true );
260 result.InsertAll( config3 );
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);
280 result.Insert(
":" + MakeTabs(depth, check_base_class_of_class) +
"#" +
name );
283 if ( !check_base_class_of_class )
286 GetGame().ConfigGetFullPath( child_path, full_path );
288 if ( full_path.Count() > 1 )
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 );
296 string class_base_class =
"";
297 GetGame().ConfigGetBaseName( child_path, class_base_class );
299 if ( class_base_class !=
"" )
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 );
304 if ( cc_base_child_path !=
"" )
306 TStringArray config5 = GetConfigRecursive( cc_base_child_path, class_base_class, cc_base_child_path, config_class, overridden, depth,
true );
307 result.InsertAll( config5 );
311 TStringArray config6 = GetConfigRecursive( class_base_class, class_base_class, class_base_class, config_class, overridden, depth,
true );
312 result.InsertAll( config6 );
320 TStringArray GetConfig(
string class_path,
string filter_char )
325 if ( class_path !=
"" )
327 PluginDeveloper module_dev = PluginDeveloper.Cast(
GetPlugin( PluginDeveloper ) );
330 class_path.Split(
" ", path_nodes );
332 if ( path_nodes.Count() >= 3 )
334 string c_class_path = path_nodes.Get(0) +
" " + path_nodes.Get(1) +
" " + path_nodes.Get(2);
337 string config_class = path_nodes.Get( 1 );
340 TStringArray result = GetConfigRecursive( c_class_path,
class_name, c_class_path, config_class, overridden );
346 string tabs = MakeTabs( 1 );
347 string tabs_inherited = MakeTabs( 1,
true );
348 string check_tabs = MakeTabs( path_nodes.Count() - 1,
true );
350 nested_start.Insert(
":!" );
351 nested_end.Insert(
":#" );
352 nested_inherited_start.Insert(
":!" );
353 nested_inherited_end.Insert(
":#" );
355 string last_node = filter_char + MakeTabs( nested_start.Count() ) +
"!";
357 if ( path_nodes.Count() == 3 )
359 last_node = filter_char + MakeTabs( 1 ) +
"!";
363 for ( i = 1; i < path_nodes.Count() - 2; i++ )
365 tabs = MakeTabs( i );
366 tabs_inherited = MakeTabs( i,
true );
368 string path_node = path_nodes.Get(i+2);
369 path_node.ToLower( );
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 );
377 last_node = filter_char + MakeTabs( i ) +
"!";
380 int current_nest = 0;
382 for ( i = 0; i < result.Count(); i++ )
384 string current = result.Get( i );
385 string current_lower = current;
386 current_lower.ToLower( );
388 int len_current = current.Length();
390 if ( current_nest < nested_start.Count() )
392 int len_start = nested_start.Get(current_nest).Length();
394 if ( len_current >= len_start )
396 string prefix_start = current_lower;
398 if ( current_nest == 0 )
400 prefix_start = current_lower.Substring( 0, len_start );
403 if ( prefix_start == nested_start.Get(current_nest) || prefix_start == nested_inherited_start.Get(current_nest) )
411 if ( current_nest >= 1 )
413 int len_end = nested_end.Get(current_nest - 1).Length();
415 if ( len_current >= len_end )
417 string prefix_end = current_lower;
419 if ( current_nest == 0 )
421 prefix_start = current_lower.Substring( 0, len_start );
424 if ( prefix_end == nested_end.Get(current_nest - 1) || prefix_end == nested_inherited_end.Get(current_nest - 1) )
431 if ( current_nest == nested_start.Count() )
433 string first_char = current.Substring( 0, 1 );
435 if ( first_char == filter_char )
437 int bang_pos = current.IndexOf(
"!" );
441 int len_last_node = last_node.Length();
443 if ( len_current >= len_last_node )
445 string prefix_current = current_lower.Substring( 0, len_last_node );
447 if ( last_node == prefix_current )
449 filtered.Insert( current.Substring(bang_pos + 1, current.Length() - (bang_pos + 1)) );
461 for ( i = 0; i < filtered.Count(); i++ )
463 string c = filtered.Get( i );
467 if ( without_duplications.Find(lower_c) < 0 )
469 without_duplications.Insert( lower_c );
473 lowered.Set( lower_c, c );
478 module_dev.SortStringArray( without_duplications );
480 for ( i = 0; i < without_duplications.Count(); i++ )
482 string cc = without_duplications.Get( i );
484 if ( lowered.Contains(cc) )
486 cc = lowered.Get( cc );
489 int tilda_index = cc.IndexOf(
"~" );
490 if ( tilda_index > -1 )
493 if ( cc.IndexOf(
"~}" ) > -1 )
497 cc = spaces + cc.Substring(tilda_index + 1, cc.Length() - (tilda_index + 1) );
500 without_duplications.Set( i, cc );
503 return without_duplications;
505 else if ( filter_char ==
":" )
507 int cnt_config =
GetGame().ConfigGetChildrenCount( class_path );
509 for ( i = 0; i < cnt_config; i++ )
511 string config_name =
"";
512 GetGame().ConfigGetChildName( class_path, i, config_name );
513 filtered.Insert( config_name );
516 module_dev.SortStringArray( filtered );
519 else if ( filter_char ==
":" )
521 filtered.Insert(
"configfile" );
522 filtered.Insert(
"missionconfigfile" );
530 return GetConfig( class_path,
"-" );
535 return GetConfig( class_path,
":" );
538 string GetBaseClasses(
string path,
string item)
540 string adjustedPath =
path;
543 resultArr.Insert(item);
547 string baseClass =
"";
548 run =
GetGame().ConfigGetBaseName( adjustedPath, baseClass );
552 adjustedPath.Split(
" ",strs);
553 strs.Remove(strs.Count() - 1);
554 strs.Insert(baseClass);
556 adjustedPath =
string.Join(
" ", strs);
557 resultArr.Insert(baseClass);
558 if (adjustedPath ==
path)
565 foreach (
int i,
string str: resultArr)
568 result +=
" >> " + str;