DayZ 1.24
Loading...
Searching...
No Matches
UIPopupScriptConfigs.c
Go to the documentation of this file.
1class UIPopupScriptConfigs extends UIPopupScript
2{
6
9
10 private PluginConfigViewer m_ModuleConfigViewer;
11
13
15 {
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"));
21 }
22
24 {
25 if (m_ObjectConfigFilter.GetText() == "")
27 else
28 FindInHierarchy(m_ObjectConfigFilter.GetText());
29 }
30
31 override void OnOpen(Param param)
32 {
33 m_ModuleConfigViewer = PluginConfigViewer.Cast(GetPlugin(PluginConfigViewer));
35 }
36
38 {
39 int selected_row_index = text_listbox_widget.GetSelectedRow();
40 if (selected_row_index != -1)
41 {
42 string item_name;
44 GetGame().CopyToClipboard(item_name);
45 }
46 }
47
49 {
51 if (row > -1 && row < m_ConfigHierarchyTextListbox.GetNumItems())
52 {
53 m_ConfigHierarchyTextListbox.GetItemData(row, 0, config_params);
54 m_ConfigVariablesTextListbox.ClearItems();
56 string path = config_params.param4;
57 variables = m_ModuleConfigViewer.GetConfigVariables(path);
58 for (int i = 0; i < variables.Count(); i++)
59 m_ConfigVariablesTextListbox.AddItem(variables.Get(i), NULL, 0);
60 }
61 }
62
64 {
65 if (row <= -1 && row >= m_ConfigHierarchyTextListbox.GetNumItems())
66 return;
67
69
70 // get current row data
72 m_ConfigHierarchyTextListbox.GetItemData(row, 0, config_params);
73
74 string config_path = config_params.param4;
75 int deep = config_params.param5;
76
77 string offset = "";
78 for (int i = 0; i < deep; i++)
79 offset = offset + " ";
80
81 // change selected node
82 variables = m_ModuleConfigViewer.GetConfigHierarchy(config_path);
83 int childrens_count = variables.Count();
84 m_ConfigHierarchyTextListbox.SetItem(row, offset + "- " + config_params.param2, new ConfigParams(true, config_params.param2, childrens_count, config_path, deep), 0);
85
86 offset = offset + " ";
87
88 // render childrens
89 deep = deep + 1;
91 for (i = variables.Count() - 1; i >= 0; i--)
92 {
93 string new_config_path = (config_path + " " + variables.Get(i)).Trim();
94 m_ConfigHierarchyTextListbox.AddItem(offset + "+ " + variables.Get(i), new ConfigParams(false, variables.Get(i), childrens_count, new_config_path, deep), 0, (row + 1));
95 }
96 }
97
98 // 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
100 {
101 if (row <= -1 && row >= m_ConfigHierarchyTextListbox.GetNumItems())
102 return;
103
106 m_ConfigHierarchyTextListbox.GetItemData(row, 0, config_params);
107 m_ConfigHierarchyTextListbox.GetItemData(row + 1, 0, config_params_next);
108
109 int deep = config_params.param5;
110 int deep_next = config_params_next.param5;
111 int max_count = m_ConfigHierarchyTextListbox.GetNumItems();
112 int remove_lines_count = 0;
113 // Print(max_count);
114 for (int i = row + 1; i < max_count; i++)
115 {
116 if (deep < deep_next && i <= max_count)
117 {
119 m_ConfigHierarchyTextListbox.GetItemData(i, 0, config_params_next);
121 }
122 }
123
124 // remove remove_lines_count lines from row
125 // remove_lines_count = remove_lines_count - 1;
126 for (i = 1; i < remove_lines_count; i++)
127 {
128 int x = row + 1;
129 if (x < max_count)
130 m_ConfigHierarchyTextListbox.RemoveRow(x);
131 }
132
133 string offset = "";
134 for (i = 0; i < deep; i++)
135 offset = offset + " ";
136 m_ConfigHierarchyTextListbox.SetItem(row, offset + "+ " + config_params.param2, new ConfigParams(false, config_params.param2, 0, config_params.param4, deep), 0);
137 }
138
140 {
141 // config hierarchy
142 // string config_path = "configfile CfgVehicles APC";
143 // string config_path = "";
144
145 m_ConfigHierarchyTextListbox.ClearItems();
146 m_ConfigVariablesTextListbox.ClearItems();
147
150
151 string config_path = "configfile";
152 ref TStringArray variables = m_ModuleConfigViewer.GetConfigHierarchy(config_path);
153 for (int i = 0; i < variables.Count(); i++)
154 {
155 string variable = variables.Get(i);
156
157 for (int j = 0; j < base_classes.Count(); j++)
158 {
159 if (variable == base_classes.Get(j))
160 {
161 string new_config_path = (config_path + " " + variable).Trim();
162 m_ConfigHierarchyTextListbox.AddItem("+ " + variable, new ConfigParams(false, variable, 0, new_config_path, 0), 0);
163 }
164 }
165 }
166 }
167
169 {
170 m_ConfigHierarchyTextListbox.ClearItems();
171 m_ConfigVariablesTextListbox.ClearItems();
172
173 class_name.ToLower();
174 string config_base_path = "configfile";
175
178
179 string filter_lower = class_name;
180 filter_lower.ToLower();
181
183 filter_lower.Split(" ", filters);
184
185 for (int i = 0; i < base_classes.Count(); i++)
186 {
187 string config_path = config_base_path + " " + base_classes.Get(i);
188 ref TStringArray variables = m_ModuleConfigViewer.GetConfigHierarchy(config_path);
189
190 for (int j = 0; j < variables.Count(); j++)
191 {
192 string variable = variables.Get(j);
193 string variable_lower = variable;
194 variable_lower.ToLower();
195
196 for (int k = 0; k < filters.Count(); k++)
197 {
198 if (variable_lower.Contains(filters.Get(k)))
199 {
200 string new_config_path = (config_path + " " + variable).Trim();
201 m_ConfigHierarchyTextListbox.AddItem("+ " + variable, new ConfigParams(false, variable, 0, new_config_path, 0), 0);
202 break;
203 }
204 }
205 }
206 }
207 }
208
209 override bool OnChange(Widget w, int x, int y, bool finished)
210 {
211 super.OnChange(w, x, y, finished);
212
213 if (w == m_ObjectConfigFilter)
215
216 return false;
217 }
218
219 override bool OnClick(Widget w, int x, int y, int button)
220 {
221 super.OnClick(w, x, y, button);
222
223 if (w == m_BtnOk)
224 {
225 PopupBack();
226 return true;
227 }
228 else if (w == m_BtnCancel)
229 {
230 PopupBack();
231 return true;
232 }
233 else if (w == m_BtnCopyToClipboard)
234 {
235 AddItemToClipboard(m_ConfigVariablesTextListbox);
236 return true;
237 }
238 else if (w == m_ConfigHierarchyTextListbox)
239 {
240 int objects_row_index = m_ConfigHierarchyTextListbox.GetSelectedRow();
241
242 if (objects_row_index > -1 && objects_row_index < m_ConfigHierarchyTextListbox.GetNumItems())
243 {
245 m_ConfigHierarchyTextListbox.GetItemData(objects_row_index, 0, config_params);
246
247 if (config_params.param1 == false)
249 else
252 }
253
254 return true;
255 }
256
257 return false;
258 }
259}
Icon x
Icon y
class OptionSelectorMultistate extends OptionSelector class_name
PluginBase GetPlugin(typename plugin_type)
Param5< bool, string, int, string, int > ConfigParams
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
Base Param Class with no parameters. Used as general purpose parameter overloaded with Param1 to Para...
Definition param.c:12
override bool OnClick(Widget w, int x, int y, int button)
void AddItemToClipboard(TextListboxWidget text_listbox_widget)
void UIPopupScriptConfigs(Widget wgt)
ButtonWidget m_BtnOk
TextListboxWidget m_ConfigHierarchyTextListbox
UIPopupScript PopupBack()
void RenderVariables(int row)
ButtonWidget m_BtnCancel
override void OnOpen(Param param)
void ExpandHierarchy(int row)
EditBoxWidget m_ObjectConfigFilter
PluginConfigViewer m_ModuleConfigViewer
TextListboxWidget m_ConfigVariablesTextListbox
void FindInHierarchy(string class_name)
override bool OnChange(Widget w, int x, int y, bool finished)
ButtonWidget m_BtnCopyToClipboard
void CollapseHierarchy(int row)
proto native CGame GetGame()
array< string > TStringArray
Definition EnScript.c:666