DayZ 1.24
Loading...
Searching...
No Matches
ScriptConsoleConfigTab.c
Go to the documentation of this file.
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
21
22
24 protected PluginConfigViewer m_ModuleConfigViewer;
25 protected int m_Row;
26
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);
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 {
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
99
100 if (w == m_DumpParamButton)
101 {
102 int selectedRowIndex = m_ConfigVariablesTextListbox.GetSelectedRow();
103 string paramFinal;
104 if (selectedRowIndex > -1)
105 {
106 string param;
108 int index = param.IndexOf("=");
109 if (index > 0)
110 paramFinal = param.Substring(0, index).Trim();
111 }
112
116 {
119 string path = params.param4;
121 path.Split(" ", pathArr);
122 string relativePath;
123
124 foreach (int indx, string s: pathArr)
125 {
126 if (indx > 2)
127 relativePath += s + " ";
128 }
129
130 if (relativePath)
131 relativePath = relativePath.Trim();
132
134 Print(path);
135 }
136
137 if (paramFinal)
139
140 return true;
141 }
143 {
145 //Print(objects_row_index);
146
148 {
151
152 if (config_params.param1 == false)
154 else
156
159 }
160 return true;
161 }
162 else if (cbw && m_ClassCheckboxes.Contains(cbw))
163 {
166
168
169 int flag, new_flag;
170
172 flag = m_ConfigDebugProfile.GetConfigClassesFlag();
173
174 if (cbw.IsChecked())
175 {
176 if (index_toggled == -1)//not found
177 {
179
182 }
183 }
184 else if (index_toggled != -1)
185 {
187
190 }
191 m_ConfigDebugProfile.SetConfigClassesFlag(new_flag);
192 /*
193 Print("-----------------------------------------");
194 Print("flag = " + new_flag);
195 foreach (string text:m_BaseConfigClassesToggled)
196 {
197 Print(text);
198 }
199 Print("-----------------------------------------");
200 */
202 }
203 else if (w == m_SelectedRowCopy)
204 {
206 return true;
207 }
208 return false;
209 }
210
211 override void Update(float timeslice)
212 {
213 super.Update(timeslice);
214
215 }
216
217 protected void Init()
218 {
220 m_ModuleConfigViewer = PluginConfigViewer.Cast(GetPlugin(PluginConfigViewer));
221 int flag1;
222
224 flag1 = m_ConfigDebugProfile.GetConfigClassesFlag();
225 //Print("------------------------------------------------");
226 foreach (string s: m_BaseConfigClasses)
227 {
228 Widget w = GetGame().GetWorkspace().CreateWidgets("gui/layouts/script_console/config_class_item.layout", m_WgtClassesConfig);
229 CheckBoxWidget cbw = CheckBoxWidget.Cast(w.FindAnyWidget("Item"));
230 //cbw.SetColor(Colors.RED);
231 cbw.SetText(s);
232 int indx = m_ClassCheckboxes.Count();
233 m_ClassCheckboxes.Insert(cbw, indx);
234 //Print("adding "+cbw +" at index:" + indx);
235
236 if (flag1 & (int)Math.Pow(2, indx))
237 {
240 cbw.SetChecked(true);
241 }
242 }
243
246 }
247
248 protected void DumpParam(string param, string relativePath)
249 {
250 if (relativePath)
252 for (int i = 0; i < m_BaseConfigClassesToggled.Count(); i++)
253 {
255
256 int objects_count = GetGame().ConfigGetChildrenCount(config_path);
257
258 for (int j = 0; j < objects_count; j++)
259 {
260 string child_name;
261 GetGame().ConfigGetChildName(config_path, j, child_name);
262
263
264 //string dispName;
265 //GetGame().ConfigGetText( config_path + " " + child_name + " displayName",dispName );
266 string value;
267 string path = config_path + " " + child_name + relativePath + " " + param;
268 if (GetGame().ConfigIsExisting(path))
269 {
270 GetGame().ConfigGetText(path, value);
271 if (value)
272 Print(child_name + "," + param + "," + value);
273 }
274
275
276 /*
277 int scope = GetGame().ConfigGetInt( config_path + " " + child_name + " scope" );
278 {
279 if ( scope == 2)
280 {
281
282 }
283 }*/
284 }
285 }
286 }
287
288 protected void ChangeConfigFilter()
289 {
291
292 if (m_ConfigTextField == "")
294 else
296 }
297
298 protected void ClearHierarchy()
299 {
300 m_ConfigHierarchyTextListbox.ClearItems();
301 m_ConfigVariablesTextListbox.ClearItems();
302
303 string config_path = "configfile";
305 for (int i = 0; i < variables.Count(); i++)
306 {
307 string variable = variables.Get(i);
308
309 for (int j = 0; j < m_BaseConfigClassesToggled.Count(); j++)
310 {
312 {
313 string new_config_path = (config_path + " " + variable).Trim();
315 }
316 }
317 }
318 }
319
320 protected void FindInHierarchy(string class_name)
321 {
322 m_ConfigHierarchyTextListbox.ClearItems();
323 m_ConfigVariablesTextListbox.ClearItems();
324
325 class_name.ToLower();
326 string config_base_path = "configfile";
327
328 string filter_lower = class_name;
329 filter_lower.ToLower();
330
332 filter_lower.Split(" ", filters);
333
334 for (int i = 0; i < m_BaseConfigClassesToggled.Count(); i++)
335 {
339
340 for (int j = 0; j < variables.Count(); j++)
341 {
342 string variable = variables.Get(j);
343 string variable_lower = variable;
344 variable_lower.ToLower();
345
346 for (int k = 0; k < filters.Count(); k++)
347 {
348 if (variable_lower.Contains(filters.Get(k)))
349 {
350 string new_config_path = (config_path + " " + variable).Trim();
352 break;
353 }
354 }
355 }
356 }
357 }
358
359 protected void ExpandHierarchy(int row)
360 {
362 return;
363
365
366 // get current row data
369
370 string config_path = config_params.param4;
371 int deep = config_params.param5;
372
373
374 string offset = "";
375 for (int i = 0; i < deep; i++)
376 offset = offset + " ";
377
378 // change selected node
379 variables = m_ModuleConfigViewer.GetConfigHierarchy(config_path);
380 int childrens_count = variables.Count();
382
383 offset = offset + " ";
384
385 // render children
386 deep = deep + 1;
387 childrens_count = 0;
388 for (i = variables.Count() - 1; i >= 0; i--)
389 {
390 string new_config_path = (config_path + " " + variables.Get(i)).Trim();
391 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));
392 }
393 }
394
395 // 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
396 protected void CollapseHierarchy(int row)
397 {
399 return;
400
405
407 return;
408 int deep = config_params.param5;
409 int deep_next = config_params_next.param5;
410 int max_count = m_ConfigHierarchyTextListbox.GetNumItems();
411 int remove_lines_count = 0;
412 // Print(max_count);
413 for (int i = row + 1; i < max_count; i++)
414 {
415 if (deep < deep_next && i <= max_count)
416 {
420 }
421 }
422
423 // remove remove_lines_count lines from row
424 // remove_lines_count = remove_lines_count - 1;
425 for (i = 1; i < remove_lines_count; i++)
426 {
427 int x = row + 1;
428 if (x < max_count)
430 }
431
432 string offset = "";
433 for (i = 0; i < deep; i++)
434 offset = offset + " ";
435 m_ConfigHierarchyTextListbox.SetItem(row, offset + "+ " + config_params.param2, new ConfigParamsEx(false, config_params.param2, 0, config_params.param4, deep, ""), 0);
436 /* //not sure why this is here, but it's causing issues when collapsing items in config viewer, disabling for now
437 if (deep == 0)
438 {
439 ClearHierarchy();
440 }
441 */
442 }
443
444 protected void RenderVariables(int row)
445 {
446 if (row > -1 && row < m_ConfigHierarchyTextListbox.GetNumItems())
447 {
448 string filter_lower = m_VariableConfigFilter.GetText();
449 filter_lower.ToLower();
450
452 filter_lower.Split(" ", filters);
453
455
457 m_ConfigVariablesTextListbox.ClearItems();
459 string path = config_params.param4;
460 variables = m_ModuleConfigViewer.GetConfigVariables(path);
461
462 for (int i = 0; i < variables.Count(); i++)
463 {
464 string var = variables.Get(i);
465
466 if (filters.Count() == 0)
468 else
469 {
470 foreach (string f: filters)
471 {
472 var.ToLower();
473 if (var.Contains(f))
475 }
476 }
477 }
478 }
479 }
480
481}
Param3 int
Icon x
Icon y
class OptionSelectorMultistate extends OptionSelector class_name
PluginBase GetPlugin(typename plugin_type)
Param5< bool, string, int, string, int > ConfigParams
Param6< bool, string, int, string, int, string > ConfigParamsEx
Definition Debug.c:14
static void GetBaseConfigClasses(out TStringArray base_classes)
Returns some of base config classes strings like CfgVehicles, CfgWeapons, etc. for searching purposes...
Definition Debug.c:523
Definition EnMath.c:7
override bool OnClick(Widget w, int x, int y, int button)
override bool OnChange(Widget w, int x, int y, bool finished)
TextListboxWidget m_ConfigVariablesTextListbox
void FindInHierarchy(string class_name)
void DumpParam(string param, string relativePath)
override void Update(float timeslice)
ref TStringArray m_BaseConfigClasses
ref map< CheckBoxWidget, int > m_ClassCheckboxes
TextListboxWidget m_ConfigHierarchyTextListbox
PluginConfigViewer m_ModuleConfigViewer
void ScriptConsoleConfigTab(Widget root, ScriptConsole console, Widget button, ScriptConsoleTabBase parent=null)
override bool OnItemSelected(Widget w, int x, int y, int row, int column, int oldRow, int oldColumn)
static ref ConfigParamsEx m_ConfigData
ref TStringArray m_BaseConfigClassesToggled
PluginConfigDebugProfile m_ConfigDebugProfile
void AddItemToClipboard(TextListboxWidget text_listbox_widget)
proto native CGame GetGame()
proto void Print(void var)
Prints content of variable to console/log.
array< string > TStringArray
Definition EnScript.c:666
static proto float Pow(float v, float power)
Return power of v ^ power.
void Split(string sample, out array< string > output)
Splits string into array of strings separated by 'sample'.
Definition EnString.c:396