DayZ 1.30
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
ScriptConsoleConfigTab.c
См. документацию.
1typedef Param5<bool, string, int, string, int> ConfigParams; // param1 - isCollapsed, param2 - string name, param3 - num of childs, param4 - path, param5 - deep
2typedef Param6<bool, string, int, string, int, string> ConfigParamsEx; // param1 - isCollapsed, param2 - string name, param3 - num of childs, param4 - path, param5 - deep
3
5{
6
7 protected static string m_ConfigTextField;
8 protected static string m_VariableTextField;
9 protected static ref ConfigParamsEx m_ConfigData;
13
16 protected TextListboxWidget m_ConfigHierarchyTextListbox;
17 protected TextListboxWidget m_ConfigVariablesTextListbox;
18 protected ButtonWidget m_SelectedRowCopy;
19 protected ButtonWidget m_DumpParamButton;
21
22
24 protected PluginConfigViewer m_ModuleConfigViewer;
25 protected int m_Row;
26
27 override void InitializeTab(Widget root, ScriptConsole console, Widget button, ScriptConsoleTabBase parent = null)
28 {
29 super.InitializeTab(root, console, button, parent);
30
31 m_WgtClassesConfig = root.FindAnyWidget("ClassesPanel");
32 m_DumpParamButton = ButtonWidget.Cast(root.FindAnyWidget("DumpParamButton"));
33 m_ObjectConfigFilter = EditBoxWidget.Cast(root.FindAnyWidget("ObjectConfigFilter"));
34 m_VariableConfigFilter = EditBoxWidget.Cast(root.FindAnyWidget("VariableConfigFilter"));
35 m_ConfigHierarchyTextListbox = TextListboxWidget.Cast(root.FindAnyWidget("ConfigHierarchy"));
36 m_ConfigVariablesTextListbox = TextListboxWidget.Cast(root.FindAnyWidget("ConfigVariables"));
37 m_SelectedRowCopy = ButtonWidget.Cast(root.FindAnyWidget("SelectedRowCopy"));
38 m_ClassPath = TextWidget.Cast(root.FindAnyWidget("ClassPath"));
39
44 Init();
45 }
46
48 {
50
51 foreach (int i:m_ClassCheckboxes)
52 {
53 Widget w = m_ClassCheckboxes.GetKeyByValue(i);
54 w.GetParent().Unlink();
55 }
56 }
57
58 override bool OnChange(Widget w, int x, int y, bool finished)
59 {
60 super.OnChange(w, x, y, finished);
61 if (w == m_ObjectConfigFilter)
62 {
64 return true;
65 }
66 else if (w == m_VariableConfigFilter)
67 {
69 return true;
70 }
71
72 return false;
73 }
74
75 override bool OnItemSelected(Widget w, int x, int y, int row, int column, int oldRow, int oldColumn)
76 {
77 super.OnItemSelected(w, x, y, row, column, oldRow, oldColumn);
78
80 {
81 TextListboxWidget wgt = TextListboxWidget.Cast(w);
82 wgt.GetItemData(row, 0,m_ConfigData);
84
85 return true;
86 }
87 return false;
88 }
89
91 {
92 m_ClassPath.SetText(m_ModuleConfigViewer.GetBaseClasses(m_ConfigData.param4, m_ConfigData.param2));
93 }
94
95
96 override bool OnClick(Widget w, int x, int y, int button)
97 {
98 super.OnClick(w,x,y,button);
99
100 CheckBoxWidget cbw = CheckBoxWidget.Cast(w);
101
102 if (w == m_DumpParamButton)
103 {
104 int selectedRowIndex = m_ConfigVariablesTextListbox.GetSelectedRow();
105 string paramFinal;
106 if (selectedRowIndex > -1)
107 {
108 string param;
109 m_ConfigVariablesTextListbox.GetItemText(selectedRowIndex,0,param);
110 int index = param.IndexOf("=");
111 if (index > 0)
112 paramFinal = param.Substring(0, index).Trim();
113 }
114
115 int objects_row_index;
116 objects_row_index = m_ConfigHierarchyTextListbox.GetSelectedRow();
117 if (objects_row_index > -1 && objects_row_index < m_ConfigHierarchyTextListbox.GetNumItems())
118 {
119 ConfigParamsEx params;
120 m_ConfigHierarchyTextListbox.GetItemData(objects_row_index, 0, params);
121 string path = params.param4;
122 TStringArray pathArr = new TStringArray();
123 path.Split(" ", pathArr);
124 string relativePath;
125
126 foreach (int indx, string s:pathArr)
127 {
128 if (indx > 2)
129 {
130 relativePath+= s+" ";
131 }
132 }
133
134 if (relativePath)
135 relativePath = relativePath.Trim();
136
137 Print(relativePath);
138 Print(path);
139 }
140
141 if (paramFinal)
142 DumpParam(paramFinal,relativePath);
143
144 return true;
145 }
146 else if (w == m_ConfigHierarchyTextListbox)
147 {
148 objects_row_index = m_ConfigHierarchyTextListbox.GetSelectedRow();
149 //Print(objects_row_index);
150
151 if (objects_row_index > -1 && objects_row_index < m_ConfigHierarchyTextListbox.GetNumItems())
152 {
153 ConfigParamsEx config_params;
154 m_ConfigHierarchyTextListbox.GetItemData(objects_row_index, 0, config_params);
155
156 if (config_params.param1 == false)
157 {
158 ExpandHierarchy(objects_row_index);
159 }
160 else
161 {
162 CollapseHierarchy(objects_row_index);
163 }
164
165 RenderVariables(objects_row_index);
166 m_Row = objects_row_index;
167 }
168 return true;
169 }
170 else if (cbw && m_ClassCheckboxes.Contains(cbw))
171 {
172 int checkbox_index = m_ClassCheckboxes.Get(cbw);
173 string base_class_name = m_BaseConfigClasses.Get(checkbox_index);
174
175 int index_toggled = m_BaseConfigClassesToggled.Find(base_class_name);
176
177 int flag, new_flag;
178
180 {
181 flag = m_ConfigDebugProfile.GetConfigClassesFlag();
182 }
183
184 if (cbw.IsChecked())
185 {
186 if (index_toggled == -1)//not found
187 {
188 m_BaseConfigClassesToggled.Insert(base_class_name);
189
191 {
192 new_flag = (flag | (int)Math.Pow(2, checkbox_index));
193 }
194 }
195 }
196 else if (index_toggled != -1)
197 {
198 m_BaseConfigClassesToggled.Remove(index_toggled);
199
201 {
202 new_flag = (flag ^ (int)Math.Pow(2, checkbox_index));
203 }
204 }
205 m_ConfigDebugProfile.SetConfigClassesFlag(new_flag);
206 /*
207 Print("-----------------------------------------");
208 Print("flag = " + new_flag);
209 foreach (string text:m_BaseConfigClassesToggled)
210 {
211 Print(text);
212 }
213 Print("-----------------------------------------");
214 */
216 }
217 else if (w == m_SelectedRowCopy)
218 {
220 return true;
221 }
222 return false;
223 }
224
225 override void Update(float timeslice)
226 {
227 super.Update(timeslice);
228
229 }
230
231 protected void Init()
232 {
234 m_ModuleConfigViewer = PluginConfigViewer.Cast(GetPlugin(PluginConfigViewer));
235 int flag1;
236
238 {
239 flag1 = m_ConfigDebugProfile.GetConfigClassesFlag();
240 }
241 //Print("------------------------------------------------");
242 foreach (string s:m_BaseConfigClasses)
243 {
244 Widget w = g_Game.GetWorkspace().CreateWidgets("gui/layouts/script_console/config_class_item.layout", m_WgtClassesConfig);
245 CheckBoxWidget cbw = CheckBoxWidget.Cast(w.FindAnyWidget("Item"));
246 //cbw.SetColor(Colors.RED);
247 cbw.SetText(s);
248 int indx = m_ClassCheckboxes.Count();
249 m_ClassCheckboxes.Insert(cbw,indx);
250 //Print("adding "+cbw +" at index:" + indx);
251
252 if (flag1 & (int)Math.Pow(2, indx))
253 {
254 string base_class_name = m_BaseConfigClasses.Get(indx);
255 m_BaseConfigClassesToggled.Insert(base_class_name);
256 cbw.SetChecked(true);
257 }
258 }
259
262 }
263
264 protected void DumpParam(string param, string relativePath)
265 {
266 if (relativePath)
267 {
268 relativePath = " " + relativePath;
269 }
270 for ( int i = 0; i < m_BaseConfigClassesToggled.Count(); i++ )
271 {
272 string config_path = m_BaseConfigClassesToggled.Get(i);
273
274 int objects_count = g_Game.ConfigGetChildrenCount( config_path );
275
276 for ( int j = 0; j < objects_count; j++ )
277 {
278 string child_name;
279 g_Game.ConfigGetChildName( config_path, j, child_name );
280
281
282 //string dispName;
283 //g_Game.ConfigGetText( config_path + " " + child_name + " displayName",dispName );
284 string value;
285 string path = config_path + " " + child_name + relativePath + " " + param;
286 if (g_Game.ConfigIsExisting(path))
287 {
288 g_Game.ConfigGetText( path , value);
289 if (value)
290 Print(child_name + "," + param + "," + value);
291 }
292
293
294 /*
295 int scope = g_Game.ConfigGetInt( config_path + " " + child_name + " scope" );
296 {
297 if ( scope == 2)
298 {
299
300 }
301 }*/
302 }
303 }
304 }
305
306 protected void ChangeConfigFilter()
307 {
309
310 if (m_ConfigTextField == "")
311 {
313 }
314 else
315 {
317 }
318 }
319
320 protected void ClearHierarchy()
321 {
322 m_ConfigHierarchyTextListbox.ClearItems();
323 m_ConfigVariablesTextListbox.ClearItems();
324
325 string config_path = "configfile";
326 TStringArray variables = m_ModuleConfigViewer.GetConfigHierarchy(config_path);
327 for (int i = 0; i < variables.Count(); i++)
328 {
329 string variable = variables.Get(i);
330
331 for (int j = 0; j < m_BaseConfigClassesToggled.Count(); j++)
332 {
333 if (variable == m_BaseConfigClassesToggled.Get(j))
334 {
335 string new_config_path = (config_path + " " + variable).Trim();
336 m_ConfigHierarchyTextListbox.AddItem("+ " + variable, new ConfigParamsEx(false, variable, 0, new_config_path, 0,variable), 0);
337 }
338 }
339 }
340 }
341
342 protected void FindInHierarchy(string class_name)
343 {
344 m_ConfigHierarchyTextListbox.ClearItems();
345 m_ConfigVariablesTextListbox.ClearItems();
346
347 class_name.ToLower();
348 string config_base_path = "configfile";
349
350 string filter_lower = class_name;
351 filter_lower.ToLower();
352
353 TStringArray filters = new TStringArray;
354 filter_lower.Split(" ", filters);
355
356 for (int i = 0; i < m_BaseConfigClassesToggled.Count(); i++)
357 {
358 string config_root = m_BaseConfigClassesToggled.Get(i);
359 string config_path = config_base_path + " " + config_root;
360 TStringArray variables = m_ModuleConfigViewer.GetConfigHierarchy(config_path);
361
362 for (int j = 0; j < variables.Count(); j++)
363 {
364 string variable = variables.Get(j);
365 string variable_lower = variable;
366 variable_lower.ToLower();
367
368 for (int k = 0; k < filters.Count(); k++)
369 {
370 if (variable_lower.Contains(filters.Get(k)))
371 {
372 string new_config_path = (config_path + " " + variable).Trim();
373 m_ConfigHierarchyTextListbox.AddItem("+ " + variable, new ConfigParamsEx(false, variable, 0, new_config_path, 0, config_root), 0);
374 break;
375 }
376 }
377 }
378 }
379 }
380
381 protected void ExpandHierarchy(int row)
382 {
383 if (row <= -1 && row >= m_ConfigHierarchyTextListbox.GetNumItems())
384 {
385 return;
386 }
387
388 TStringArray variables;
389
390 // get current row data
391 ConfigParamsEx config_params;
392 m_ConfigHierarchyTextListbox.GetItemData(row, 0, config_params);
393
394 string config_path = config_params.param4;
395 int deep = config_params.param5;
396
397
398 string offset = "";
399 for (int i = 0; i < deep; i++)
400 {
401 offset = offset + " ";
402 }
403
404 // change selected node
405 variables = m_ModuleConfigViewer.GetConfigHierarchy(config_path);
406 int childrens_count = variables.Count();
407 m_ConfigHierarchyTextListbox.SetItem(row, offset + "- " + config_params.param2, new ConfigParamsEx(true, config_params.param2, childrens_count, config_path, deep,config_params.param6), 0);
408
409 offset = offset + " ";
410
411 // render children
412 deep = deep + 1;
413 childrens_count = 0;
414 for (i = variables.Count() - 1; i >= 0; i--)
415 {
416 string new_config_path = (config_path + " " + variables.Get(i)).Trim();
417 m_ConfigHierarchyTextListbox.AddItem(offset + "+ " + variables.Get(i), new ConfigParamsEx(false, variables.Get(i), childrens_count, new_config_path, deep,config_params.param2), 0, (row + 1));
418 }
419 }
420
421 // niekde je bug, ked su len 2 polozky a expand/collapse na prvu tak zmaze aj druhu. ak collapse a expand na druhu tak crash lebo sa snazi zmazat riadok co neexistuje
422 protected void CollapseHierarchy(int row)
423 {
424 if (row <= -1 && row >= m_ConfigHierarchyTextListbox.GetNumItems())
425 {
426 return;
427 }
428
429 ConfigParamsEx config_params;
430 ConfigParamsEx config_params_next;
431 m_ConfigHierarchyTextListbox.GetItemData(row, 0, config_params);
432 m_ConfigHierarchyTextListbox.GetItemData(row + 1, 0, config_params_next);
433
434 if (!config_params || !config_params_next)
435 return;
436 int deep = config_params.param5;
437 int deep_next = config_params_next.param5;
438 int max_count = m_ConfigHierarchyTextListbox.GetNumItems();
439 int remove_lines_count = 0;
440 // Print(max_count);
441 for (int i = row + 1; i < max_count; i++)
442 {
443 if (deep < deep_next && i <= max_count)
444 {
445 remove_lines_count = remove_lines_count + 1;
446 m_ConfigHierarchyTextListbox.GetItemData(i, 0, config_params_next);
447 deep_next = config_params_next.param5;
448 }
449 }
450
451 // remove remove_lines_count lines from row
452 // remove_lines_count = remove_lines_count - 1;
453 for (i = 1; i < remove_lines_count; i++)
454 {
455 int x = row + 1;
456 if (x < max_count)
457 {
459 }
460 }
461
462 string offset = "";
463 for (i = 0; i < deep; i++)
464 {
465 offset = offset + " ";
466 }
467 m_ConfigHierarchyTextListbox.SetItem(row, offset + "+ " + config_params.param2, new ConfigParamsEx(false, config_params.param2, 0, config_params.param4, deep,""), 0);
468 /* //not sure why this is here, but it's causing issues when collapsing items in config viewer, disabling for now
469 if (deep == 0)
470 {
471 ClearHierarchy();
472 }
473 */
474 }
475
476 protected void RenderVariables(int row)
477 {
478 if (row > -1 && row < m_ConfigHierarchyTextListbox.GetNumItems())
479 {
480 string filter_lower = m_VariableConfigFilter.GetText();
481 filter_lower.ToLower();
482
483 TStringArray filters = new TStringArray();
484 filter_lower.Split(" ", filters);
485
486 ConfigParamsEx config_params;
487
488 m_ConfigHierarchyTextListbox.GetItemData(row, 0, config_params);
489 m_ConfigVariablesTextListbox.ClearItems();
490 TStringArray variables;
491 string path = config_params.param4;
492 variables = m_ModuleConfigViewer.GetConfigVariables(path);
493
494 for (int i = 0; i < variables.Count(); i++)
495 {
496 string var = variables.Get(i);
497
498 if (filters.Count() == 0)
499 {
500 m_ConfigVariablesTextListbox.AddItem(var, NULL, 0);
501 }
502 else
503 {
504 foreach (string f: filters)
505 {
506 var.ToLower();
507 if (var.Contains(f))
508 m_ConfigVariablesTextListbox.AddItem(var, NULL, 0);
509 }
510 }
511 }
512 }
513 }
514
515}
ActionOverrideData int
DayZGame g_Game
Определения DayZGame.c:4074
Icon x
Icon y
string path
Определения OptionSelectorMultistate.c:142
class OptionSelectorMultistate extends OptionSelector class_name
PluginBase GetPlugin(typename plugin_type)
Определения PluginManager.c:326
void ScriptConsole()
Определения ScriptConsole.c:114
Param5< bool, string, int, string, int > ConfigParams
Определения ScriptConsoleConfigTab.c:1
Param6< bool, string, int, string, int, string > ConfigParamsEx
Определения ScriptConsoleConfigTab.c:2
static void GetBaseConfigClasses(out TStringArray base_classes)
Returns some of base config classes strings like CfgVehicles, CfgWeapons, etc. for searching purposes...
Определения 3_Game/DayZ/tools/Debug.c:527
Определения 3_Game/DayZ/tools/Debug.c:2
Определения EnWidgets.c:354
Определения EnMath.c:7
override bool OnClick(Widget w, int x, int y, int button)
Определения ScriptConsoleConfigTab.c:96
override bool OnChange(Widget w, int x, int y, bool finished)
Определения ScriptConsoleConfigTab.c:58
TextListboxWidget m_ConfigVariablesTextListbox
Определения ScriptConsoleConfigTab.c:17
void FindInHierarchy(string class_name)
Определения ScriptConsoleConfigTab.c:342
void DumpParam(string param, string relativePath)
Определения ScriptConsoleConfigTab.c:264
override void Update(float timeslice)
Определения ScriptConsoleConfigTab.c:225
void RenderVariables(int row)
Определения ScriptConsoleConfigTab.c:476
ref TStringArray m_BaseConfigClasses
Определения ScriptConsoleConfigTab.c:10
ref map< CheckBoxWidget, int > m_ClassCheckboxes
Определения ScriptConsoleConfigTab.c:12
void RenderClassPath()
Определения ScriptConsoleConfigTab.c:90
Widget m_WgtClassesConfig
Определения ScriptConsoleConfigTab.c:23
EditBoxWidget m_VariableConfigFilter
Определения ScriptConsoleConfigTab.c:15
TextListboxWidget m_ConfigHierarchyTextListbox
Определения ScriptConsoleConfigTab.c:16
void ClearHierarchy()
Определения ScriptConsoleConfigTab.c:320
static string m_VariableTextField
Определения ScriptConsoleConfigTab.c:8
void ~ScriptConsoleConfigTab()
Определения ScriptConsoleConfigTab.c:47
EditBoxWidget m_ObjectConfigFilter
Определения ScriptConsoleConfigTab.c:14
void ExpandHierarchy(int row)
Определения ScriptConsoleConfigTab.c:381
void ChangeConfigFilter()
Определения ScriptConsoleConfigTab.c:306
void CollapseHierarchy(int row)
Определения ScriptConsoleConfigTab.c:422
PluginConfigViewer m_ModuleConfigViewer
Определения ScriptConsoleConfigTab.c:24
override bool OnItemSelected(Widget w, int x, int y, int row, int column, int oldRow, int oldColumn)
Определения ScriptConsoleConfigTab.c:75
static ref ConfigParamsEx m_ConfigData
Определения ScriptConsoleConfigTab.c:9
ref TStringArray m_BaseConfigClassesToggled
Определения ScriptConsoleConfigTab.c:11
ButtonWidget m_DumpParamButton
Определения ScriptConsoleConfigTab.c:19
override void InitializeTab(Widget root, ScriptConsole console, Widget button, ScriptConsoleTabBase parent=null)
Определения ScriptConsoleConfigTab.c:27
ButtonWidget m_SelectedRowCopy
Определения ScriptConsoleConfigTab.c:18
static string m_ConfigTextField
Определения ScriptConsoleConfigTab.c:7
TextWidget m_ClassPath
Определения ScriptConsoleConfigTab.c:20
PluginConfigDebugProfile m_ConfigDebugProfile
Определения ScriptConsoleTabBase.c:11
void AddItemToClipboard(TextListboxWidget text_listbox_widget)
Определения ScriptConsoleTabBase.c:87
Определения EnWidgets.c:220
Определения EnWidgets.c:190
Определения Transport.c:70
proto void Print(void var)
Prints content of variable to console/log.
class array< Class T > TStringArray
static proto float Pow(float v, float power)
Return power of v ^ power.
proto string Trim()
Returns trimmed string with removed leading and trailing whitespaces.
proto string Get(int index)
Gets n-th character from string.
bool Contains(string sample)
Returns true if sample is substring of string.
Определения EnString.c:286
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.