DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
Loading...
Searching...
No Matches
PluginConfigDebugProfile.c
Go to the documentation of this file.
1typedef Param3<string, bool, vector> LocationParams;// param1 - name, param2 - isCustom?, param3 - position
3{
4 protected const string SCENE_DRAW_SELECTION = "scene_editor_draw_selection";
5 protected const string SCENE_LOAD_PLAYER_POS = "scene_editor_load_player_pos";
6 protected const string SCENE_ROTATION_ANGLE = "scene_editor_rotation_angle";
7 protected const string ITEM_TAB_SELECTED = "console_TabSelected";
8 protected const string PRESET_LIST = "console_presets";
9 protected const string PRESET_DEFAULT = "console_preset_default";
10 protected const string ITEM_SEARCH = "console_ItemSearch";
11 protected const string SPAWN_DISTANCE = "console_SpawnDistance";
12 protected const string CHAR_STATS_VIS = "console_character_stats_visible";
13 protected const string CHAR_LEVELS_VIS = "console_character_levels_visible";
14 protected const string CHAR_MODIFIERS_VIS = "console_character_modifiers_visible";
15 protected const string CHAR_AGENTS_VIS = "console_character_agents_visible";
16 protected const string CHAR_DEBUG_VIS = "console_character_debug_visible";
17 protected const string CHAR_STOMACH_VIS = "console_character_stomach_visible";
18 protected const string FREE_CAMERA_CROSSHAIR = "console_free_camera_crosshair_visible";
19 protected const string VERSION_VIS = "console_version_visible";
20 protected const string MERGE_TYPE = "category_merge_type";
21 protected const string TEMP_VIS = "console_temperature_visible";
22 protected const string SUB_PARAM_ITEM = "item";
23 protected const string SUB_PARAM_ITEM_NAME = "name";
24 protected const string SUB_PARAM_ITEM_HEALTH = "health";
25 protected const string SUB_PARAM_ITEM_QUANTITY = "quantity";
26 protected const string LOGS_ENABLED = "logs_enabled";
27 protected const string CONFIG_CLASSES_FLAG = "toggled_config_classes_flag";
28 protected const string ITEM_CATEGORY_FLAG = "toggled_item_categories_flag";
29 protected const string ITEM_PREVIEW = "show_item_preview";
30 protected const string BATCH_RECT = "batch_spawn_rect";
31 protected const string BATCH_QUANT = "batch_spawn_quantity";
32 protected const string SOUNDFILTER = "soundset_editbox";
33 protected const string ITEMDEBUG = "item_debug";
34 protected const string SPAWN_LOC_INDEX = "spawn_loc_index";
35 protected const string FILTER_REVERSED = "filter_order_reversed";
36
38 protected ref TStringArray m_PresetList;
39 protected const string POSITION_NAME_ROOT = "console_positions_";
40
41 //========================================
42 // GetInstance
43 //========================================
45 {
47 }
48
49 //========================================
50 // GetCfgParamArray
51 //========================================
52 protected CfgParamArray GetNewCfgParamArray( array<ref CfgParam> params )
53 {
54 CfgParamArray param = new CfgParamArray( "" );
55 param.SetParams( params );
56 return param;
57 }
58
59 //========================================
60 // GetCfgParamBool
61 //========================================
62 protected CfgParamBool GetNewCfgParamBool( bool value )
63 {
64 CfgParamBool param = new CfgParamBool( "" );
65 param.SetValue( value );
66 return param;
67 }
68
69 //========================================
70 // GetCfgParamFloat
71 //========================================
72 protected CfgParamFloat GetNewCfgParamFloat( float value )
73 {
74 CfgParamFloat param = new CfgParamFloat( "" );
75 param.SetValue( value );
76 return param;
77 }
78
79 //========================================
80 // GetCfgParamInt
81 //========================================
82 protected CfgParamInt GetNewCfgParamInt( int value )
83 {
84 CfgParamInt param = new CfgParamInt( "" );
85 param.SetValue( value );
86 return param;
87 }
88
89 //========================================
90 // GetCfgParamString
91 //========================================
92 protected CfgParamString GetNewCfgParamString( string value )
93 {
94 CfgParamString param = new CfgParamString( "" );
95 param.SetValue( value );
96 return param;
97 }
98
99 //========================================
100 // Array
101 //========================================
102 protected CfgParamArray SetArray( string key, array<ref CfgParam> params )
103 {
104 CfgParamArray param = CfgParamArray.Cast( GetParamByName( key, CFG_TYPE_ARRAY ) );
105 param.SetParams( params );
106 SaveConfigToFile();
107 return param;
108 }
109
110 protected array<ref CfgParam> GetArray( string key )
111 {
112 if ( ParamExist(key) )
113 {
114 CfgParamArray param = CfgParamArray.Cast( GetParamByName( key, CFG_TYPE_ARRAY ) );
115 return param.GetValues();
116 }
117 else
118 {
119 if ( m_DefaultValues.Contains(key) )
120 {
121 CfgParamArray default_param = CfgParamArray.Cast( m_DefaultValues.Get( key ) );
122 return SetArray( key, default_param.GetValues() ).GetValues();
123 }
124 else
125 {
126 return SetArray( key, new array<ref CfgParam> ).GetValues();
127 }
128 }
129 }
130
131 //========================================
132 // Bool
133 //========================================
134 protected CfgParamBool SetBool( string key, bool value )
135 {
136 CfgParamBool param = CfgParamBool.Cast( GetParamByName( key, CFG_TYPE_BOOL ) );
137 param.SetValue( value );
138 SaveConfigToFile();
139 return param;
140 }
141
142 protected bool GetBool( string key )
143 {
144 if ( ParamExist(key) )
145 {
146 CfgParamBool param = CfgParamBool.Cast( GetParamByName( key, CFG_TYPE_BOOL ) );
147 return param.GetValue();
148 }
149 else
150 {
151 if ( m_DefaultValues.Contains(key) )
152 {
153 CfgParamBool default_param = CfgParamBool.Cast( m_DefaultValues.Get( key ) );
154 return SetBool( key, default_param.GetValue() ).GetValue();
155 }
156 else
157 {
158 return SetBool( key, false ).GetValue();
159 }
160 }
161 }
162
163 //========================================
164 // Float
165 //========================================
166 protected CfgParamFloat SetFloat( string key, float value )
167 {
168 CfgParamFloat param = CfgParamFloat.Cast( GetParamByName( key, CFG_TYPE_FLOAT ) );
169 param.SetValue( value );
170 SaveConfigToFile();
171 return param;
172 }
173
174 protected float GetFloat( string key )
175 {
176 if ( ParamExist(key) )
177 {
178 CfgParamFloat param = CfgParamFloat.Cast( GetParamByName( key, CFG_TYPE_FLOAT ) );
179 return param.GetValue();
180 }
181 else
182 {
183 if ( m_DefaultValues.Contains(key) )
184 {
185 CfgParamFloat default_param = CfgParamFloat.Cast( m_DefaultValues.Get( key ) );
186 return SetFloat( key, default_param.GetValue() ).GetValue();
187 }
188 else
189 {
190 return SetFloat( key, 0.0 ).GetValue();
191 }
192 }
193 }
194
195 //========================================
196 // Int
197 //========================================
198 protected CfgParamInt SetInt( string key, int value )
199 {
200 CfgParamInt param = CfgParamInt.Cast( GetParamByName( key, CFG_TYPE_INT ) );
201 param.SetValue( value );
202 SaveConfigToFile();
203 return param;
204 }
205
206 protected int GetInt( string key )
207 {
208 if ( ParamExist(key) )
209 {
210 CfgParamInt param = CfgParamInt.Cast( GetParamByName( key, CFG_TYPE_INT ) );
211 return param.GetValue();
212 }
213 else
214 {
215 if ( m_DefaultValues.Contains(key) )
216 {
217 CfgParamInt default_param = CfgParamInt.Cast( m_DefaultValues.Get( key ) );
218 return SetInt( key, default_param.GetValue() ).GetValue();
219 }
220 else
221 {
222 return SetInt( key, 0 ).GetValue();
223 }
224 }
225 }
226
227 //========================================
228 // String
229 //========================================
230 protected CfgParamString SetString( string key, string value )
231 {
232 CfgParamString param = CfgParamString.Cast( GetParamByName( key, CFG_TYPE_STRING ) );
233 if(param)
234 {
235 param.SetValue( value );
236 SaveConfigToFile();
237 }
238 return param;
239 }
240
241 protected string GetString( string key )
242 {
243 CfgParamString param = CfgParamString.Cast( GetParamByName( key, CFG_TYPE_STRING ) );
244
245 if ( param && param.GetValue() != STRING_EMPTY )
246 {
247 return param.GetValue();
248 }
249 else
250 {
251 if ( m_DefaultValues.Contains(key) )
252 {
253 CfgParamString default_param = CfgParamString.Cast( m_DefaultValues.Get( key ) );
254 CfgParamString param_string = SetString( key, default_param.GetValue() );
255 if(param_string)
256 return param_string.GetValue();
257 }
258 else
259 {
260 return SetString( key, "" ).GetValue();
261 }
262 }
263 return "";
264 }
265
266 protected void GetSubParametersInStringArray( string setting_name, string sub_param_name, out TStringArray arr )
267 {
268 array<ref CfgParam> items = GetArray( setting_name );
269 for ( int i = 0; i < items.Count(); i++ )
270 {
271 CfgParamArray items_array = CfgParamArray.Cast( items.Get(i) );
272 array<ref CfgParam> item_params = items_array.GetValues();
273
274 for ( int j = 0; j < item_params.Count(); j++ )
275 {
276 if ( item_params.Get(j).GetName() == sub_param_name )
277 {
278 CfgParamString param_string = CfgParamString.Cast( item_params.Get( j ) );
279 arr.Insert( param_string.GetValue() );
280 }
281 }
282 }
283 }
284
285 //========================================
286 // PluginConfigDebugProfile
287 //========================================
289 {
290 m_DefaultValues = new map<string, ref CfgParam>;
291 m_DefaultValues.Insert(SCENE_DRAW_SELECTION, GetNewCfgParamBool(true) );
292 m_DefaultValues.Insert(SCENE_LOAD_PLAYER_POS, GetNewCfgParamBool(true) );
293 m_DefaultValues.Insert(SCENE_ROTATION_ANGLE, GetNewCfgParamInt(15) );
294 m_DefaultValues.Insert(ITEM_TAB_SELECTED, GetNewCfgParamInt(0) );
295 m_DefaultValues.Insert(PRESET_DEFAULT, GetNewCfgParamString("") );
296 m_DefaultValues.Insert(ITEM_SEARCH, GetNewCfgParamString("") );
297 m_DefaultValues.Insert(SPAWN_DISTANCE, GetNewCfgParamFloat(0.0) );
298 m_DefaultValues.Insert(LOGS_ENABLED, GetNewCfgParamBool(true) );
299 m_DefaultValues.Insert(CHAR_STATS_VIS, GetNewCfgParamBool(false) );
300 m_DefaultValues.Insert(CHAR_LEVELS_VIS, GetNewCfgParamBool(false) );
301 m_DefaultValues.Insert(CHAR_MODIFIERS_VIS, GetNewCfgParamBool(false) );
302 m_DefaultValues.Insert(CHAR_AGENTS_VIS, GetNewCfgParamBool(false) );
303 m_DefaultValues.Insert(CHAR_DEBUG_VIS, GetNewCfgParamBool(false) );
304 m_DefaultValues.Insert(FREE_CAMERA_CROSSHAIR, GetNewCfgParamBool(true) );
305 m_DefaultValues.Insert(VERSION_VIS, GetNewCfgParamBool(true) );
306 m_DefaultValues.Insert(CONFIG_CLASSES_FLAG, GetNewCfgParamInt(15) );
307 m_DefaultValues.Insert(TEMP_VIS, GetNewCfgParamBool(false) );
308 m_DefaultValues.Insert(MERGE_TYPE, GetNewCfgParamBool(false) );
309 m_DefaultValues.Insert(ITEM_PREVIEW, GetNewCfgParamBool(true) );
310 m_DefaultValues.Insert(BATCH_RECT, GetNewCfgParamArray(GetDefaultBatchRectParams()) );
311 m_DefaultValues.Insert(BATCH_QUANT, GetNewCfgParamInt(10) );
312 m_DefaultValues.Insert(SOUNDFILTER, GetNewCfgParamString("") );
313 m_DefaultValues.Insert(ITEMDEBUG, GetNewCfgParamString("0 0 0") );
314 m_DefaultValues.Insert(SPAWN_LOC_INDEX, GetNewCfgParamInt(0));
315 m_DefaultValues.Insert(FILTER_REVERSED, GetNewCfgParamBool(false));
316 }
317
319 {
321 CfgParamInt param1 = new CfgParamInt("");
322 param1.SetValue(5);
323 CfgParamInt param2 = new CfgParamInt("");
324 param2.SetValue(5);
325 CfgParamFloat param3 = new CfgParamFloat("");
326 param3.SetValue(1.0);
327 CfgParamFloat param4 = new CfgParamFloat("");
328 param4.SetValue(1.0);
329
330 params.Insert(param1);
331 params.Insert(param2);
332 params.Insert(param3);
333 params.Insert(param4);
334
335 return params;
336 }
337
338 //========================================
339 // OnInit
340 //========================================
341 override void OnInit()
342 {
343 super.OnInit();
344
345 array<ref CfgParam> params = GetArray( PRESET_LIST );
346
347 m_PresetList = new TStringArray;
348 for ( int i = 0; i < params.Count(); i++ )
349 {
350 CfgParamString param = CfgParamString.Cast( params.Get( i ) );
351 m_PresetList.Insert( param.GetValue() );
352 }
353 }
354
355 //========================================
356 // GetFileName
357 //========================================
358 override string GetFileName()
359 {
361 }
362
363 //========================================
364 // SceneEditorDrawSelection
365 //========================================
367 {
368 return GetBool( SCENE_DRAW_SELECTION );
369 }
370
372 {
373 SetBool( SCENE_DRAW_SELECTION, value );
374 }
375
376 //========================================
377 // SceneEditorSavePlayerPos
378 //========================================
380 {
381 return GetBool( SCENE_LOAD_PLAYER_POS );
382 }
383
385 {
386 SetBool( SCENE_LOAD_PLAYER_POS, value );
387 }
388
389 //========================================
390 // SceneEditorRotationAngle
391 //========================================
393 {
394 return GetInt( SCENE_ROTATION_ANGLE );
395 }
396
398 {
399 SetInt( SCENE_ROTATION_ANGLE, value );
400 }
401
402 //========================================
403 // TabSelected
404 //========================================
406 {
407 return GetInt( ITEM_TAB_SELECTED );
408 }
409
410 void SetTabSelected( int value )
411 {
412 SetInt( ITEM_TAB_SELECTED, value );
413 }
414
415 //========================================
416 // SpawnLocIndex
417 //========================================
419 {
420 return GetInt( SPAWN_LOC_INDEX );
421 }
422
423 void SetSpawnLocIndex( int value )
424 {
425 SetInt( SPAWN_LOC_INDEX, value );
426 }
427
428 //========================================
429 // FilterOrder
430 //========================================
432 {
433 return GetBool( FILTER_REVERSED );
434 }
435
436 void SetFilterOrderReversed( bool reversed )
437 {
438 SetBool( FILTER_REVERSED, reversed );
439 }
440
441 //========================================
442 // DefaultPreset
443 //========================================
445 {
446 return GetString( PRESET_DEFAULT );
447 }
448
449 void SetDefaultPreset( string value )
450 {
451 SetString( PRESET_DEFAULT, value );
452 }
453
454 //========================================
455 // Batch Spawn Params
456 //========================================
458 {
459 return GetArray( BATCH_RECT );
460 }
461
462 void SetBatchSpawnRectangle( int row, int column, float rowStep, float columnStep)
463 {
464 array<ref CfgParam> params = GetArray( BATCH_RECT );
465 params.Clear();
466 CfgParamString param;
467
468 CfgParamInt param1 = new CfgParamInt("");
469 param1.SetValue(row);
470 CfgParamInt param2 = new CfgParamInt("");
471 param2.SetValue(column);
472 CfgParamFloat param3 = new CfgParamFloat("");
473 param3.SetValue(rowStep);
474 CfgParamFloat param4 = new CfgParamFloat("");
475 param4.SetValue(columnStep);
476
477 params.Insert(param1);
478 params.Insert(param2);
479 params.Insert(param3);
480 params.Insert(param4);
481 SaveConfigToFile();
482 }
483
484 //========================================
485 // Batch Spawn Quantity
486 //========================================
488 {
489 return GetInt( BATCH_QUANT );
490 }
491
492 void SetBatchSpawnQuantity(int value)
493 {
494 SetInt( BATCH_QUANT, value );
495 }
496 //========================================
497 // ItemSearch
498 //========================================
500 {
501 return GetString( ITEM_SEARCH );
502 }
503
504 void SetItemSearch( string value )
505 {
506 SetString( ITEM_SEARCH, value );
507 }
508
509 //========================================
510 // SpawnDistance
511 //========================================
513 {
514 return GetFloat( SPAWN_DISTANCE );
515 }
516
517 void SetSpawnDistance( float value )
518 {
519 SetFloat( SPAWN_DISTANCE, value );
520 }
521
522 //========================================
523 // LogsEnabled
524 //========================================
526 {
527 return GetBool( LOGS_ENABLED );
528 }
529
530 void SetLogsEnabled( bool value )
531 {
532 SetBool( LOGS_ENABLED, value );
533 }
534
535 //========================================
536 // CharacterLevelsVisible
537 //========================================
539 {
540 return GetBool( CHAR_LEVELS_VIS );
541 }
542
543
544 void SetCharacterLevelsVisible( bool is_visible )
545 {
546 SetBool( CHAR_LEVELS_VIS, is_visible );
547 }
548
549
550 //========================================
551 // ItemDebugPos
552 //========================================
554 {
555 SetString( ITEMDEBUG ,pos.ToString(false));
556 }
557
558
560 {
561 return GetString( ITEMDEBUG ).ToVector();
562 }
563
564 //========================================
565 // CharacterStatsVisible
566 //========================================
568 {
569 return GetBool( CHAR_STATS_VIS );
570 }
571
572
573 void SetCharacterStatsVisible( bool is_visible )
574 {
575 SetBool( CHAR_STATS_VIS, is_visible );
576 }
577
578 //========================================
579 // CharacterModifiersVisible
580 //========================================
582 {
583 return GetBool( CHAR_MODIFIERS_VIS );
584 }
585
586 void SetCharacterModifiersVisible( bool is_visible )
587 {
588 SetBool( CHAR_MODIFIERS_VIS, is_visible );
589 }
590
591 //========================================
592 // CharacterAgentsVisible
593 //========================================
595 {
596 return GetBool( CHAR_AGENTS_VIS );
597 }
598
599 void SetCharacterAgentsVisible( bool is_visible )
600 {
601 SetBool( CHAR_AGENTS_VIS, is_visible );
602 }
603
604 //========================================
605 // CharacterDebugVisible
606 //========================================
608 {
609 return GetBool( CHAR_DEBUG_VIS );
610 }
611
612 void SetCharacterDebugVisible( bool is_visible )
613 {
614 SetBool( CHAR_DEBUG_VIS, is_visible );
615 }
616
617 //========================================
618 // CharacterStomachVisible
619 //========================================
621 {
622 return GetBool( CHAR_STOMACH_VIS );
623 }
624
625 void SetCharacterStomachVisible( bool is_visible )
626 {
627 SetBool( CHAR_STOMACH_VIS, is_visible );
628 }
629
630 //========================================
631 // FreeCameraCrosshairVisible
632 //========================================
634 {
635 return GetBool( FREE_CAMERA_CROSSHAIR );
636 }
637
638 void SetFreeCameraCrosshairVisible( bool is_visible )
639 {
640 SetBool( FREE_CAMERA_CROSSHAIR, is_visible );
641 }
642
643 //========================================
644 // VersionVisible
645 //========================================
647 {
648 return GetBool( VERSION_VIS );
649 }
650
651 void SetVersionVisible( bool is_visible )
652 {
653 SetBool( VERSION_VIS, is_visible );
654 }
655
656 //========================================
657 // Merge Type
658 //========================================
660 {
661 return GetBool( MERGE_TYPE );
662 }
663
664 void SetMergeType( bool is_visible )
665 {
666 SetBool( MERGE_TYPE, is_visible );
667 }
668
669 //========================================
670 // Soundset Filter
671 //========================================
673 {
674 return GetString( SOUNDFILTER );
675 }
676
677 void SetSoundsetFilter( string content )
678 {
679 SetString( SOUNDFILTER, content );
680 }
681
682 //========================================
683 // TemperatureVisible
684 //========================================
686 {
687 return GetBool( TEMP_VIS );
688 }
689
690 void SetTempVisible( bool is_visible )
691 {
692 SetBool( TEMP_VIS, is_visible );
693 }
694
695 //========================================
696 // Show Item Preview
697 //========================================
699 {
700 return GetBool( ITEM_PREVIEW );
701 }
702
703 void SetShowItemPreview( bool show )
704 {
705 SetBool( ITEM_PREVIEW, show );
706 }
707
708
709 //========================================
710 // ConfigClassesFlag
711 //========================================
713 {
714 return GetInt( CONFIG_CLASSES_FLAG );
715 }
716
717 void SetConfigClassesFlag( int flag )
718 {
719 SetInt( CONFIG_CLASSES_FLAG, flag );
720 }
721
722
723 //========================================
724 // Item Category Flag
725 //========================================
727 {
728 return GetInt( ITEM_CATEGORY_FLAG );
729 }
730
731 void SetItemCategoryFlag( int flag )
732 {
733 SetInt( ITEM_CATEGORY_FLAG, flag );
734 }
735
736 //========================================
737 // User Location
738 //========================================
739 bool CustomLocationsAdd( string name, vector position )
740 {
741 string world = g_Game.GetWorldName();
742 world.ToLower();
743
744 CfgParamString locationName = new CfgParamString(PluginConfigDebugProfileFixed.SUB_PARAM_POS_NAME);
745 locationName.SetValue(name);
746 CfgParamString locationPos = new CfgParamString(PluginConfigDebugProfileFixed.SUB_PARAM_POS_VEC);
747 locationPos.SetValue(position.ToString(false));
748
749 CfgParamArray locationEntry = new CfgParamArray( locationName.GetValue() );
750 locationEntry.InsertValue( locationName );
751 locationEntry.InsertValue( locationPos );
752
753 string paramName = POSITION_NAME_ROOT + world;
754 array<ref CfgParam> params = GetArray(paramName);
755 params.Insert(locationEntry);
756 SetArray(paramName, params);
757 SaveConfigToFile();
758
759 return true;
760 }
761
763 {
764 if (!name)
765 return;
766 string world = g_Game.GetWorldName();
767 world.ToLower();
768 string paramName = POSITION_NAME_ROOT + world;
769 array<ref CfgParam> params = GetArray(paramName);
770
771 for (int i = 0; i < params.Count(); i++)
772 {
773 CfgParamArray param = CfgParamArray.Cast(params.Get(i));
774 array<ref CfgParam> prms = param.GetValues();
775 CfgParamString par = CfgParamString.Cast(prms.Get(0));
776 if (par.GetValue() == name)
777 {
778 params.RemoveOrdered(i);
779 break;
780 }
781 }
782
783 //SetArray(paramName, params);
784 SaveConfigToFile();
785 }
786
787 //========================================
788 // Presets
789 //========================================
791 {
792 return m_PresetList;
793 }
794
795 protected void SetPreset( string preset_name, int index = -1 )
796 {
797 array<ref CfgParam> params = GetArray( PRESET_LIST );
798 CfgParamString param;
799
800 if ( index == -1 )
801 {
802 param = new CfgParamString( "" );
803 param.SetValue( preset_name );
804 params.Insert( param );
805 m_PresetList.Insert( preset_name );
806 }
807 else
808 {
809 param = CfgParamString.Cast( params.Get( index ) );
810 param.SetValue( preset_name );
811 params.Set( index, param );
812 m_PresetList.Set( index, preset_name );
813 }
814
815 SaveConfigToFile();
816 }
817
818 protected void RemovePreset( string preset_name )
819 {
820 array<ref CfgParam> params = GetArray( PRESET_LIST );
821 for ( int i = 0; i < params.Count(); i++ )
822 {
823 CfgParamString param = CfgParamString.Cast( params.Get(i) );
824 if ( param.GetValue() == preset_name )
825 {
826 params.RemoveItem( param );
827 m_PresetList.RemoveItem( preset_name );
828 }
829 }
830 }
831
832 bool GetPresetItems( string preset_name, out TStringArray arr, string param_name = "" )
833 {
834 if ( m_PresetList.Find(preset_name) == -1 )
835 {
836 return false;
837 }
838 if(param_name == "")
839 param_name = SUB_PARAM_ITEM_NAME;
840 GetSubParametersInStringArray( preset_name, param_name, arr );
841
842 return true;
843 }
844
845 bool PresetAdd( string preset_name )
846 {
847 if ( m_PresetList.Find(preset_name) > -1 )
848 {
849 return false;
850 }
851
852 SetPreset( preset_name );
853 SetArray( preset_name, new array<ref CfgParam> );
854 SaveConfigToFile();
855
856 return true;
857 }
858
859 bool PresetRemove( string preset_name )
860 {
861 if ( m_PresetList.Find(preset_name) == -1 )
862 {
863 return false;
864 }
865
866 RemovePreset( preset_name );
867 RemoveParamByName( preset_name );
868 SaveConfigToFile();
869
870 return true;
871 }
872
873 bool PresetRename( string old_preset_name, string new_preset_name )
874 {
875 int index = m_PresetList.Find( old_preset_name );
876
877 if ( index == -1 )
878 {
879 return false;
880 }
881
882 SetPreset( new_preset_name, index );
883 RenameParam( old_preset_name, new_preset_name );
884 SaveConfigToFile();
885
886 return true;
887 }
888
889 bool ItemAddToPreset( string preset_name, string item_name )
890 {
891 if ( m_PresetList.Find( preset_name ) == -1 )
892 {
893 return false;
894 }
895
896 CfgParamString param = new CfgParamString( SUB_PARAM_ITEM_NAME );
897 param.SetValue( item_name );
898
899 CfgParamArray item_params = new CfgParamArray( SUB_PARAM_ITEM );
900 item_params.InsertValue( param );
901
902 array<ref CfgParam> params = GetArray( preset_name );
903 params.Insert( item_params );
904
905 SaveConfigToFile();
906
907 return true;
908 }
909
910 bool ItemRemoveFromPreset( string preset_name, int item_index )
911 {
912 if ( m_PresetList.Find( preset_name ) == -1 )
913 {
914 return false;
915 }
916
917 array<ref CfgParam> params = GetArray( preset_name );
918
919 if ( item_index >= params.Count() )
920 {
921 return false;
922 }
923
924 params.Remove( item_index );
925
926 SaveConfigToFile();
927
928 return true;
929 }
930
931 bool SwapItem( string preset_name, int item1_index, int item2_index )
932 {
933 array<ref CfgParam> params = GetArray( preset_name );
934
935 if ( item1_index >= params.Count() || item2_index >= params.Count() )
936 {
937 return false;
938 }
939
940 params.SwapItems( item1_index, item2_index );
941 SaveConfigToFile();
942
943 return true;
944 }
945
946 protected array<ref CfgParam> GetItemParams( string preset_name, int item_index )
947 {
948 if ( m_PresetList.Find( preset_name ) == -1 )
949 {
950 return NULL;
951 }
952
953 array<ref CfgParam> params = GetArray( preset_name );
954
955 if ( !params || item_index >= params.Count() )
956 {
957 return NULL;
958 }
959 if (params.IsValidIndex(item_index))
960 CfgParamArray params_array = CfgParamArray.Cast( params.Get( item_index ) );
961 if (params_array)
962 return params_array.GetValues();
963
964 return null;
965 }
966
967 protected CfgParam GetItemParam( string preset_name, int item_index, string param_name )
968 {
969 array<ref CfgParam> item_params = GetItemParams( preset_name, item_index );
970
971 if ( item_params == NULL )
972 {
973 return NULL;
974 }
975
976 CfgParam param = NULL;
977 for ( int i = 0; i < item_params.Count(); i++ )
978 {
979 if ( item_params.Get(i).GetName() == param_name )
980 {
981 param = item_params.Get(i);
982 }
983 }
984
985 return param;
986 }
987
988 float GetItemHealth( string preset_name, int item_index )
989 {
990 CfgParam param = GetItemParam( preset_name, item_index, SUB_PARAM_ITEM_HEALTH );
991
992 if ( param == NULL )
993 {
994 return -1;
995 }
996 else
997 {
998 CfgParamFloat param_float = CfgParamFloat.Cast( param );
999 return param_float.GetValue();
1000 }
1001 }
1002
1003 bool SetItemHealth( string preset_name, int item_index, float health )
1004 {
1005 CfgParam param = GetItemParam( preset_name, item_index, SUB_PARAM_ITEM_HEALTH );
1006
1007 if ( param != NULL )
1008 {
1009 CfgParamFloat param_float = CfgParamFloat.Cast( param );
1010 param_float.SetValue( health );
1011 }
1012 else
1013 {
1014 array<ref CfgParam> item_params = GetItemParams( preset_name, item_index );
1015
1016 if ( item_params != NULL )
1017 {
1018 CfgParamFloat new_param = new CfgParamFloat( SUB_PARAM_ITEM_HEALTH );
1019 new_param.SetValue( health );
1020 item_params.Insert( new_param );
1021 }
1022 }
1023
1024 SaveConfigToFile();
1025
1026 return true;
1027 }
1028
1029 int GetItemQuantity( string preset_name, int item_index )
1030 {
1031 CfgParam param = GetItemParam( preset_name, item_index, SUB_PARAM_ITEM_QUANTITY );
1032
1033 if ( param == NULL )
1034 {
1035 return -1;
1036 }
1037 else
1038 {
1039 CfgParamInt param_int = CfgParamInt.Cast( param );
1040 return param_int.GetValue();
1041 }
1042 }
1043
1044 bool SetItemQuantity( string preset_name, int item_index, int quantity )
1045 {
1046 CfgParam param = GetItemParam( preset_name, item_index, SUB_PARAM_ITEM_QUANTITY );
1047
1048 if ( param != NULL )
1049 {
1050 CfgParamInt param_int = CfgParamInt.Cast( param );
1051 param_int.SetValue( quantity );
1052 }
1053 else
1054 {
1055 array<ref CfgParam> item_params = GetItemParams( preset_name, item_index );
1056
1057 if ( item_params != NULL )
1058 {
1059 CfgParamInt new_param = new CfgParamInt( SUB_PARAM_ITEM_QUANTITY );
1060 new_param.SetValue( quantity );
1061 item_params.Insert( new_param );
1062 }
1063 }
1064
1065 SaveConfigToFile();
1066
1067 return true;
1068 }
1069
1070 //========================================
1071 // Locations
1072 //========================================
1073
1074 void GetLocationsData( out array<ref LocationParams> arr , bool isCustom)
1075 {
1076 string world = g_Game.GetWorldName();
1077 world.ToLower();
1078 string paramName = POSITION_NAME_ROOT + world;
1079
1080 TStringArray names = new TStringArray();
1081 GetSubParametersInStringArray( paramName, PluginConfigDebugProfileFixed.SUB_PARAM_POS_NAME, names );
1082 TStringArray positions = new TStringArray();
1083 GetSubParametersInStringArray( paramName, PluginConfigDebugProfileFixed.SUB_PARAM_POS_VEC, positions );
1084 int i;
1085 if (isCustom)
1086 {
1087 for ( i = names.Count() - 1; i >= 0 ; i--)
1088 {
1089 arr.Insert(new LocationParams(names.Get(i), isCustom, positions.Get(i).ToVector()));
1090 }
1091 }
1092 else
1093 {
1094 for (i = 0; i < names.Count(); i++)
1095 {
1096 arr.Insert(new LocationParams(names.Get(i), isCustom, positions.Get(i).ToVector()));
1097 }
1098 }
1099 }
1100}
const int CFG_TYPE_BOOL
Definition CfgParam.c:4
const int CFG_TYPE_ARRAY
Definition CfgParam.c:5
const int CFG_TYPE_INT
Definition CfgParam.c:2
const int CFG_TYPE_STRING
Definition CfgParam.c:1
const int CFG_TYPE_FLOAT
Definition CfgParam.c:3
DayZGame g_Game
Definition DayZGame.c:3654
Param3< string, bool, vector > LocationParams
string name
int GetInt()
PluginBase GetPlugin(typename plugin_type)
protected CfgParamBool SetBool(string key, bool value)
protected CfgParamFloat SetFloat(string key, float value)
protected string GetString(string key)
protected CfgParamBool GetNewCfgParamBool(bool value)
void SetFreeCameraCrosshairVisible(bool is_visible)
protected CfgParamInt GetNewCfgParamInt(int value)
void SetCharacterLevelsVisible(bool is_visible)
bool SetItemQuantity(string preset_name, int item_index, int quantity)
void SetMergeType(bool is_visible)
void SetCharacterStatsVisible(bool is_visible)
protected ref TStringArray m_PresetList
protected array< ref CfgParam > GetItemParams(string preset_name, int item_index)
bool PresetRemove(string preset_name)
bool GetPresetItems(string preset_name, out TStringArray arr, string param_name="")
protected CfgParamArray SetArray(string key, array< ref CfgParam > params)
int GetItemQuantity(string preset_name, int item_index)
protected CfgParamString GetNewCfgParamString(string value)
void SetDefaultPreset(string value)
void SetItemSearch(string value)
protected void GetSubParametersInStringArray(string setting_name, string sub_param_name, out TStringArray arr)
array< ref CfgParam > GetDefaultBatchRectParams()
void SetSceneEditorDrawSelection(bool value)
protected CfgParamFloat GetNewCfgParamFloat(float value)
void GetLocationsData(out array< ref LocationParams > arr, bool isCustom)
void SetSceneEditorLoadPlayerPos(bool value)
protected bool GetBool(string key)
protected void RemovePreset(string preset_name)
protected CfgParamInt SetInt(string key, int value)
void SetTempVisible(bool is_visible)
float GetItemHealth(string preset_name, int item_index)
protected CfgParam GetItemParam(string preset_name, int item_index, string param_name)
protected array< ref CfgParam > GetArray(string key)
bool SetItemHealth(string preset_name, int item_index, float health)
void SetSoundsetFilter(string content)
void CustomLocationsRemove(string name)
protected float GetFloat(string key)
void SetSceneEditorRotationAngle(int value)
void SetCharacterStomachVisible(bool is_visible)
bool ItemAddToPreset(string preset_name, string item_name)
bool PresetAdd(string preset_name)
protected int GetInt(string key)
protected CfgParamArray GetNewCfgParamArray(array< ref CfgParam > params)
void SetCharacterDebugVisible(bool is_visible)
bool CustomLocationsAdd(string name, vector position)
protected ref map< string, ref CfgParam > m_DefaultValues
void SetBatchSpawnQuantity(int value)
array< ref CfgParam > GetBatchSpawnRectangle()
bool ItemRemoveFromPreset(string preset_name, int item_index)
bool SwapItem(string preset_name, int item1_index, int item2_index)
void SetFilterOrderReversed(bool reversed)
protected CfgParamString SetString(string key, string value)
void SetSpawnDistance(float value)
static PluginConfigDebugProfile GetInstance()
bool PresetRename(string old_preset_name, string new_preset_name)
void SetVersionVisible(bool is_visible)
protected void SetPreset(string preset_name, int index=-1)
void SetBatchSpawnRectangle(int row, int column, float rowStep, float columnStep)
void SetCharacterAgentsVisible(bool is_visible)
void SetCharacterModifiersVisible(bool is_visible)
proto string ToString(bool beautify=true)
Vector to string.
const string CFG_FILE_DEBUG_PROFILE
Definition constants.c:217
array< string > TStringArray
Definition EnScript.c:685
const string STRING_EMPTY
Definition constants.c:54
proto int ToLower()
Changes string to lowercase. Returns length.