7 protected static string m_ConfigTextField;
8 protected static string m_VariableTextField;
16 protected TextListboxWidget m_ConfigHierarchyTextListbox;
17 protected TextListboxWidget m_ConfigVariablesTextListbox;
18 protected ButtonWidget m_SelectedRowCopy;
19 protected ButtonWidget m_DumpParamButton;
23 protected Widget m_WgtClassesConfig;
24 protected PluginConfigViewer m_ModuleConfigViewer;
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"));
38 if (m_ConfigTextField)
39 m_ObjectConfigFilter.SetText(m_ConfigTextField);
40 if (m_VariableTextField)
41 m_VariableConfigFilter.SetText(m_VariableTextField);
47 m_VariableTextField = m_VariableConfigFilter.GetText();
49 foreach (
int i:m_ClassCheckboxes)
51 Widget w = m_ClassCheckboxes.GetKeyByValue(i);
52 w.GetParent().Unlink();
56 override bool OnChange(
Widget w,
int x,
int y,
bool finished)
58 super.OnChange(w,
x,
y, finished);
59 if (w == m_ObjectConfigFilter)
64 else if (w == m_VariableConfigFilter)
66 RenderVariables(m_Row);
73 override bool OnItemSelected(
Widget w,
int x,
int y,
int row,
int column,
int oldRow,
int oldColumn)
75 super.OnItemSelected(w,
x,
y, row, column, oldRow, oldColumn);
77 if (w == m_ConfigHierarchyTextListbox)
79 TextListboxWidget wgt = TextListboxWidget.Cast(w);
80 wgt.GetItemData(row, 0,m_ConfigData);
88 void RenderClassPath()
90 m_ClassPath.SetText(m_ModuleConfigViewer.GetBaseClasses(m_ConfigData.param4, m_ConfigData.param2));
94 override bool OnClick(
Widget w,
int x,
int y,
int button)
96 super.OnClick(w,
x,
y,button);
98 CheckBoxWidget cbw = CheckBoxWidget.Cast(w);
100 if (w == m_DumpParamButton)
102 int selectedRowIndex = m_ConfigVariablesTextListbox.GetSelectedRow();
104 if (selectedRowIndex > -1)
107 m_ConfigVariablesTextListbox.GetItemText(selectedRowIndex,0,param);
108 int index = param.IndexOf(
"=");
110 paramFinal = param.Substring(0, index).Trim();
113 int objects_row_index;
114 objects_row_index = m_ConfigHierarchyTextListbox.GetSelectedRow();
115 if (objects_row_index > -1 && objects_row_index < m_ConfigHierarchyTextListbox.GetNumItems())
118 m_ConfigHierarchyTextListbox.GetItemData(objects_row_index, 0, params);
119 string path = params.param4;
121 path.Split(
" ", pathArr);
124 foreach (
int indx,
string s:pathArr)
128 relativePath+= s+
" ";
133 relativePath = relativePath.Trim();
140 DumpParam(paramFinal,relativePath);
144 else if (w == m_ConfigHierarchyTextListbox)
146 objects_row_index = m_ConfigHierarchyTextListbox.GetSelectedRow();
149 if (objects_row_index > -1 && objects_row_index < m_ConfigHierarchyTextListbox.GetNumItems())
152 m_ConfigHierarchyTextListbox.GetItemData(objects_row_index, 0, config_params);
154 if (config_params.param1 ==
false)
156 ExpandHierarchy(objects_row_index);
160 CollapseHierarchy(objects_row_index);
163 RenderVariables(objects_row_index);
164 m_Row = objects_row_index;
168 else if (cbw && m_ClassCheckboxes.Contains(cbw))
170 int checkbox_index = m_ClassCheckboxes.Get(cbw);
171 string base_class_name = m_BaseConfigClasses.Get(checkbox_index);
173 int index_toggled = m_BaseConfigClassesToggled.Find(base_class_name);
184 if (index_toggled == -1)
186 m_BaseConfigClassesToggled.Insert(base_class_name);
190 new_flag = (flag | (
int)
Math.Pow(2, checkbox_index));
194 else if (index_toggled != -1)
196 m_BaseConfigClassesToggled.Remove(index_toggled);
200 new_flag = (flag ^ (
int)
Math.Pow(2, checkbox_index));
215 else if (w == m_SelectedRowCopy)
217 AddItemToClipboard(m_ConfigVariablesTextListbox);
223 override void Update(
float timeslice)
225 super.Update(timeslice);
229 protected void Init()
231 Debug.GetBaseConfigClasses(m_BaseConfigClasses);
232 m_ModuleConfigViewer = PluginConfigViewer.Cast(
GetPlugin(PluginConfigViewer));
240 foreach (
string s:m_BaseConfigClasses)
242 Widget w =
GetGame().GetWorkspace().CreateWidgets(
"gui/layouts/script_console/config_class_item.layout", m_WgtClassesConfig);
243 CheckBoxWidget cbw = CheckBoxWidget.Cast(w.FindAnyWidget(
"Item"));
246 int indx = m_ClassCheckboxes.Count();
247 m_ClassCheckboxes.Insert(cbw,indx);
250 if (flag1 & (
int)
Math.Pow(2, indx))
252 string base_class_name = m_BaseConfigClasses.Get(indx);
253 m_BaseConfigClassesToggled.Insert(base_class_name);
254 cbw.SetChecked(
true);
259 ChangeConfigFilter();
262 protected void DumpParam(
string param,
string relativePath)
266 relativePath =
" " + relativePath;
268 for (
int i = 0; i < m_BaseConfigClassesToggled.Count(); i++ )
270 string config_path = m_BaseConfigClassesToggled.Get(i);
272 int objects_count =
GetGame().ConfigGetChildrenCount( config_path );
274 for (
int j = 0; j < objects_count; j++ )
277 GetGame().ConfigGetChildName( config_path, j, child_name );
283 string path = config_path +
" " + child_name + relativePath +
" " + param;
288 Print(child_name +
"," + param +
"," + value);
304 protected void ChangeConfigFilter()
306 m_ConfigTextField = m_ObjectConfigFilter.GetText();
308 if (m_ConfigTextField ==
"")
314 FindInHierarchy(m_ConfigTextField);
318 protected void ClearHierarchy()
320 m_ConfigHierarchyTextListbox.ClearItems();
321 m_ConfigVariablesTextListbox.ClearItems();
323 string config_path =
"configfile";
324 TStringArray variables = m_ModuleConfigViewer.GetConfigHierarchy(config_path);
325 for (
int i = 0; i < variables.Count(); i++)
327 string variable = variables.Get(i);
329 for (
int j = 0; j < m_BaseConfigClassesToggled.Count(); j++)
331 if (variable == m_BaseConfigClassesToggled.Get(j))
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);
340 protected void FindInHierarchy(
string class_name)
342 m_ConfigHierarchyTextListbox.ClearItems();
343 m_ConfigVariablesTextListbox.ClearItems();
346 string config_base_path =
"configfile";
349 filter_lower.ToLower();
352 filter_lower.Split(
" ", filters);
354 for (
int i = 0; i < m_BaseConfigClassesToggled.Count(); i++)
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);
360 for (
int j = 0; j < variables.Count(); j++)
362 string variable = variables.Get(j);
363 string variable_lower = variable;
364 variable_lower.ToLower();
366 for (
int k = 0; k < filters.Count(); k++)
368 if (variable_lower.Contains(filters.Get(k)))
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);
379 protected void ExpandHierarchy(
int row)
381 if (row <= -1 && row >= m_ConfigHierarchyTextListbox.GetNumItems())
390 m_ConfigHierarchyTextListbox.GetItemData(row, 0, config_params);
392 string config_path = config_params.param4;
393 int deep = config_params.param5;
397 for (
int i = 0; i < deep; i++)
399 offset = offset +
" ";
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);
407 offset = offset +
" ";
412 for (i = variables.Count() - 1; i >= 0; i--)
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));
420 protected void CollapseHierarchy(
int row)
422 if (row <= -1 && row >= m_ConfigHierarchyTextListbox.GetNumItems())
429 m_ConfigHierarchyTextListbox.GetItemData(row, 0, config_params);
430 m_ConfigHierarchyTextListbox.GetItemData(row + 1, 0, config_params_next);
432 if (!config_params || !config_params_next)
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;
439 for (
int i = row + 1; i < max_count; i++)
441 if (deep < deep_next && i <= max_count)
443 remove_lines_count = remove_lines_count + 1;
444 m_ConfigHierarchyTextListbox.GetItemData(i, 0, config_params_next);
445 deep_next = config_params_next.param5;
451 for (i = 1; i < remove_lines_count; i++)
456 m_ConfigHierarchyTextListbox.RemoveRow(
x);
461 for (i = 0; i < deep; i++)
463 offset = offset +
" ";
465 m_ConfigHierarchyTextListbox.SetItem(row, offset +
"+ " + config_params.param2,
new ConfigParamsEx(
false, config_params.param2, 0, config_params.param4, deep,
""), 0);
474 protected void RenderVariables(
int row)
476 if (row > -1 && row < m_ConfigHierarchyTextListbox.GetNumItems())
478 string filter_lower = m_VariableConfigFilter.GetText();
479 filter_lower.ToLower();
482 filter_lower.Split(
" ", filters);
486 m_ConfigHierarchyTextListbox.GetItemData(row, 0, config_params);
487 m_ConfigVariablesTextListbox.ClearItems();
489 string path = config_params.param4;
490 variables = m_ModuleConfigViewer.GetConfigVariables(
path);
492 for (
int i = 0; i < variables.Count(); i++)
494 string var = variables.Get(i);
496 if (filters.Count() == 0)
498 m_ConfigVariablesTextListbox.AddItem(var, NULL, 0);
502 foreach (
string f: filters)
506 m_ConfigVariablesTextListbox.AddItem(var, NULL, 0);