3 private ButtonWidget m_BtnOk;
4 private ButtonWidget m_BtnCancel;
5 private ButtonWidget m_BtnCopyToClipboard;
7 private TextListboxWidget m_ConfigHierarchyTextListbox;
8 private TextListboxWidget m_ConfigVariablesTextListbox;
10 private PluginConfigViewer m_ModuleConfigViewer;
14 void UIPopupScriptConfigs(
Widget wgt )
16 m_BtnOk = ButtonWidget.Cast( wgt.FindAnyWidget(
"btn_ppp_pc_ok") );
17 m_ConfigHierarchyTextListbox = TextListboxWidget.Cast( wgt.FindAnyWidget(
"ConfigHierarchy") );
18 m_ConfigVariablesTextListbox = TextListboxWidget.Cast( wgt.FindAnyWidget(
"ConfigVariables") );
19 m_BtnCopyToClipboard = ButtonWidget.Cast( wgt.FindAnyWidget(
"btn_ppp_pc_copy") );
20 m_ObjectConfigFilter =
EditBoxWidget.Cast( wgt.FindAnyWidget(
"ObjectConfigFilter") );
23 void ChangeConfigFilter()
25 if ( m_ObjectConfigFilter.GetText() ==
"" )
31 FindInHierarchy( m_ObjectConfigFilter.GetText() );
35 override void OnOpen(
Param param)
37 m_ModuleConfigViewer = PluginConfigViewer.Cast(
GetPlugin( PluginConfigViewer ) );
41 void AddItemToClipboard( TextListboxWidget text_listbox_widget )
43 int selected_row_index = text_listbox_widget.GetSelectedRow();
44 if ( selected_row_index != -1 )
47 text_listbox_widget.GetItemText( selected_row_index, 0, item_name );
48 GetGame().CopyToClipboard( item_name );
52 void RenderVariables(
int row )
55 if( row > -1 && row < m_ConfigHierarchyTextListbox.GetNumItems() )
57 m_ConfigHierarchyTextListbox.GetItemData( row, 0, config_params );
58 m_ConfigVariablesTextListbox.ClearItems();
60 string path = config_params.param4;
61 variables = m_ModuleConfigViewer.GetConfigVariables(
path );
62 for (
int i = 0; i < variables.Count(); i++ )
64 m_ConfigVariablesTextListbox.AddItem( variables.Get(i), NULL, 0);
69 void ExpandHierarchy(
int row )
71 if( row <= -1 && row >= m_ConfigHierarchyTextListbox.GetNumItems() )
80 m_ConfigHierarchyTextListbox.GetItemData( row, 0, config_params );
82 string config_path = config_params.param4;
83 int deep = config_params.param5;
86 for (
int i = 0; i < deep; i++)
88 offset = offset +
" ";
92 variables = m_ModuleConfigViewer.GetConfigHierarchy( config_path );
93 int childrens_count = variables.Count();
94 m_ConfigHierarchyTextListbox.SetItem( row, offset +
"- " + config_params.param2,
new ConfigParams(
true, config_params.param2, childrens_count, config_path, deep ), 0 );
96 offset = offset +
" ";
101 for ( i = variables.Count() - 1; i >= 0; i-- )
103 string new_config_path = ( config_path +
" " + variables.Get(i) ).Trim();
104 m_ConfigHierarchyTextListbox.AddItem( offset +
"+ " + variables.Get(i),
new ConfigParams(
false, variables.Get(i), childrens_count, new_config_path, deep ), 0, (row + 1) );
109 void CollapseHierarchy(
int row )
111 if( row <= -1 && row >= m_ConfigHierarchyTextListbox.GetNumItems() )
118 m_ConfigHierarchyTextListbox.GetItemData( row, 0, config_params );
119 m_ConfigHierarchyTextListbox.GetItemData( row + 1, 0, config_params_next );
121 int deep = config_params.param5;
122 int deep_next = config_params_next.param5;
123 int max_count = m_ConfigHierarchyTextListbox.GetNumItems();
124 int remove_lines_count = 0;
126 for (
int i = row + 1; i < max_count; i++)
128 if ( deep < deep_next && i <= max_count )
130 remove_lines_count = remove_lines_count + 1;
131 m_ConfigHierarchyTextListbox.GetItemData( i, 0, config_params_next );
132 deep_next = config_params_next.param5;
138 for ( i = 1; i < remove_lines_count; i++ )
143 m_ConfigHierarchyTextListbox.RemoveRow(
x );
148 for ( i = 0; i < deep; i++)
150 offset = offset +
" ";
152 m_ConfigHierarchyTextListbox.SetItem( row, offset +
"+ " + config_params.param2,
new ConfigParams(
false, config_params.param2, 0, config_params.param4, deep ), 0 );
155 void ClearHierarchy()
161 m_ConfigHierarchyTextListbox.ClearItems();
162 m_ConfigVariablesTextListbox.ClearItems();
165 Debug.GetBaseConfigClasses( base_classes );
167 string config_path =
"configfile";
168 ref
TStringArray variables = m_ModuleConfigViewer.GetConfigHierarchy( config_path );
169 for (
int i = 0; i < variables.Count(); i++ )
171 string variable = variables.Get(i);
173 for (
int j = 0; j < base_classes.Count(); j++ )
175 if ( variable == base_classes.Get(j) )
177 string new_config_path = ( config_path +
" " + variable ).Trim();
178 m_ConfigHierarchyTextListbox.AddItem(
"+ " + variable,
new ConfigParams(
false, variable, 0, new_config_path, 0 ), 0);
186 m_ConfigHierarchyTextListbox.ClearItems();
187 m_ConfigVariablesTextListbox.ClearItems();
190 string config_base_path =
"configfile";
193 Debug.GetBaseConfigClasses( base_classes );
196 filter_lower.ToLower( );
199 filter_lower.Split(
" ", filters );
201 for (
int i = 0; i < base_classes.Count(); i++ )
203 string config_path = config_base_path +
" " + base_classes.Get(i);
204 ref
TStringArray variables = m_ModuleConfigViewer.GetConfigHierarchy( config_path );
206 for (
int j = 0; j < variables.Count(); j++ )
208 string variable = variables.Get(j);
209 string variable_lower = variable;
210 variable_lower.ToLower( );
212 for (
int k = 0; k < filters.Count(); k++ )
214 if ( variable_lower.Contains(filters.Get(k)))
216 string new_config_path = ( config_path +
" " + variable ).Trim();
217 m_ConfigHierarchyTextListbox.AddItem(
"+ " + variable,
new ConfigParams(
false, variable, 0, new_config_path, 0 ), 0);
227 super.OnChange( w,
x,
y, finished );
229 if ( w == m_ObjectConfigFilter )
231 ChangeConfigFilter();
239 super.OnClick( w,
x,
y, button );
246 else if ( w == m_BtnCancel )
251 else if ( w == m_BtnCopyToClipboard )
253 AddItemToClipboard( m_ConfigVariablesTextListbox );
256 else if ( w == m_ConfigHierarchyTextListbox )
258 int objects_row_index = m_ConfigHierarchyTextListbox.GetSelectedRow();
260 if ( objects_row_index > -1 && objects_row_index < m_ConfigHierarchyTextListbox.GetNumItems() )
263 m_ConfigHierarchyTextListbox.GetItemData( objects_row_index, 0, config_params );
265 if ( config_params.param1 ==
false )
267 ExpandHierarchy( objects_row_index );
271 CollapseHierarchy( objects_row_index );
273 RenderVariables( objects_row_index );