DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено

◆ GetConfig()

TStringArray PluginBase::GetConfig ( string class_path,
string filter_char )
inlineprivate

См. определение в файле PluginConfigViewer.c строка 320

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 }
map
Определения ControlsXboxNew.c:4
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 int ConfigGetChildrenCount(string path)
Get count of subclasses in config class on path.
void PluginDeveloper()
Определения PluginDeveloper.c:49
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
proto native CGame GetGame()
array< string > TStringArray
Определения EnScript.c:685
proto native int Length()
Returns length of string.
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 IndexOf(string sample)
Finds 'sample' in 'str'. Returns -1 when not found.
proto int ToLower()
Changes string to lowercase. Returns length.

Перекрестные ссылки class_name, CGame::ConfigGetChildName(), CGame::ConfigGetChildrenCount(), string::Get(), GetConfigRecursive(), GetGame(), GetPlugin(), string::IndexOf(), string::Length(), MakeTabs(), PluginDeveloper(), string::Split(), string::Substring() и string::ToLower().

Используется в GetConfigHierarchy() и GetConfigVariables().