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