DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено

◆ DrawConnectingLines() [2/2]

void UIScriptedMenu::DrawConnectingLines ( int index)
inlineprotected

См. определение в файле TutorialsMenu.c строка 117

118 {
119 if (index == 6)
120 {
121 m_InfoTextLeft.Show(false);
122 m_InfoTextRight.Show(false);
123 }
124 else
125 {
126 m_InfoTextLeft.Show(true);
127 m_InfoTextRight.Show(true);
128 ref array<ref JsonControlMappingInfo> control_mapping_info = new array<ref JsonControlMappingInfo>;
129 ref array<ref array <ref JsonControlMappingInfo>> tab_array = new array<ref array <ref JsonControlMappingInfo>>;
130
131 map<string, ref array<int>> button_marker_groups_unflitred = new map<string, ref array<int>>;
132 map<string, ref array<int>> button_marker_groups = new map<string, ref array<int>>;
133
134 float text_widget_pos_x, text_widget_pos_y;
135 float text_widget_width, text_widget_height;
136 float dot_pos_x, dot_pos_y;
137 float dot_width, dot_height;
138 float draw_pos_x, draw_pos_y;
139
140 CanvasWidget canvas_widget = CanvasWidget.Cast(layoutRoot.FindAnyWidget("CanvasWidget_" + index));
141 canvas_widget.Clear();
142 control_mapping_info = GetControlMappingInfo();
143
144 for (int i = 0; i < m_TabScript.GetTabCount(); i++)
145 {
146 tab_array.Insert(new array<ref JsonControlMappingInfo>);
147 for (int j = 0; j < 30; j++)
148 {
149 tab_array[i].Insert(NULL);
150 }
151 }
152
153 // insert json info to array by index, so it is sorted
154 for (i = 0; i < control_mapping_info.Count(); i++)
155 {
156 JsonControlMappingInfo info = control_mapping_info.Get(i);
157 tab_array[info.m_TabID][info.m_TextWidgetID] = info;
158 }
159
160 // create group of buttons which are connected together with line
161 for (int l = 0; l < control_mapping_info.Count(); l++)
162 {
163 JsonControlMappingInfo info1 = control_mapping_info[l];
164 string button_name = info1.m_ButtonName;
165 int text_widget_id = info1.m_TextWidgetID;
166 if (info1.m_TabID != index)
167 {
168 continue;
169 }
170 if (!button_marker_groups_unflitred.Contains(button_name))
171 {
172 button_marker_groups_unflitred.Insert(button_name, new array<int>);
173 button_marker_groups_unflitred.Get(button_name).Insert(text_widget_id);
174 }
175 else
176 {
177 button_marker_groups_unflitred.Get(button_name).Insert(text_widget_id);
178 }
179 }
180
181 // we want groups which are bigger than 1
182 for (l = 0; l < button_marker_groups_unflitred.Count(); l++)
183 {
184 if (button_marker_groups_unflitred.GetElement(l).Count() > 1)
185 {
186 string key = button_marker_groups_unflitred.GetKey(l);
187 button_marker_groups.Insert(button_marker_groups_unflitred.GetKey(l), button_marker_groups_unflitred.Get(key));
188 }
189 }
190
191 // hide all button markers
192 Widget xbox_controls_image = layoutRoot.FindAnyWidget("Markers_" + index);
193
194 Widget panel_widget;
195 Widget button_marker_widget;
196
197 for (l = 0; l < tab_array[index].Count(); l++)
198 {
199 panel_widget = layoutRoot.FindAnyWidget("PanelWidget" + l);
200 if (tab_array[index][l] != NULL)
201 {
202 TextWidget text_widget = TextWidget.Cast(panel_widget.FindAnyWidget("TextWidget" + l));
203 button_marker_widget = layoutRoot.FindAnyWidget("button_marker_" + tab_array[index][l].m_ButtonName);
204 text_widget.SetText(tab_array[index][l].m_InfoText);
205 panel_widget.Show(true);
206 panel_widget.Update();
207
208 if (!button_marker_groups.Contains(tab_array[index][l].m_ButtonName))
209 {
210 panel_widget.GetScreenPos(text_widget_pos_x, text_widget_pos_y);
211 panel_widget.GetScreenSize(text_widget_width,text_widget_height);
212
213 button_marker_widget.GetScreenPos(dot_pos_x, dot_pos_y);
214 button_marker_widget.GetScreenSize(dot_width, dot_height);
215
216 draw_pos_y = text_widget_pos_y + text_widget_height / 2;
217
218 if (l < 15)
219 {
220 draw_pos_x = text_widget_pos_x + text_widget_width - 1;
221 }
222 else
223 {
224 draw_pos_x = text_widget_pos_x;
225 }
226
227 canvas_widget.DrawLine(draw_pos_x, draw_pos_y, dot_pos_x+dot_width/2, draw_pos_y, 2, ARGBF(0.6, 1, 1, 1));
228 canvas_widget.DrawLine(dot_pos_x+dot_width/2, draw_pos_y, dot_pos_x+dot_width/2, dot_pos_y+dot_height/2, 2, ARGBF(0.6, 1, 1, 1));
229 }
230 }
231 else
232 {
233 panel_widget.Show(false);
234 }
235 panel_widget.Update();
236 }
237
238 // draw connecting lines
239 for (l = 0; l < button_marker_groups.Count(); l++)
240 {
241 text_widget_pos_x = 0;
242 text_widget_pos_y = 0;
243 text_widget_width = 0;
244 text_widget_height = 0;
245 float group_point_x = 0, group_point_y = 0;
246 float first_x = 0, first_y = 0;
247
248 ref array<int> element = button_marker_groups.GetElement(l);
249 string key_name = button_marker_groups.GetKey(l);
250 button_marker_widget = layoutRoot.FindAnyWidget("button_marker_" + key_name);
251
252 for (int g = 0; g < element.Count(); g++)
253 {
254 panel_widget = layoutRoot.FindAnyWidget("PanelWidget" + element[g]);
255
256 panel_widget.GetScreenPos(text_widget_pos_x, text_widget_pos_y);
257 panel_widget.GetScreenSize(text_widget_width, text_widget_height);
258
259 if (g == 0)
260 {
261 if (element[0] < 15)
262 {
263 first_x = text_widget_pos_x + text_widget_width +50;
264 }
265 else
266 {
267 first_x = text_widget_pos_x - 50;
268 }
269 first_y = text_widget_pos_y + text_widget_height/2;
270
271 }
272
273 group_point_x += text_widget_pos_x;
274 group_point_y += text_widget_pos_y;
275
276 if (element[0] < 15)
277 {
278 canvas_widget.DrawLine(text_widget_pos_x + text_widget_width - 1, text_widget_pos_y + text_widget_height/2, text_widget_pos_x + text_widget_width +50, text_widget_pos_y + text_widget_height/2, 2, ARGBF(0.6, 1, 1, 1));
279 }
280 else
281 {
282 canvas_widget.DrawLine(text_widget_pos_x, text_widget_pos_y + text_widget_height/2, text_widget_pos_x - 50, text_widget_pos_y + text_widget_height/2, 2, ARGBF(0.6, 1, 1, 1));
283 }
284 }
285
286 if (element[0] < 15)
287 {
288 group_point_x = group_point_x/element.Count() + text_widget_width + 50;
289 }
290 else
291 {
292 group_point_x = group_point_x/element.Count() - 50;
293 }
294
295 group_point_y = group_point_y/element.Count() + text_widget_height/2;
296
297 button_marker_widget.GetScreenPos(dot_pos_x, dot_pos_y);
298 button_marker_widget.GetScreenSize(dot_width, dot_height);
299
300 canvas_widget.DrawLine(group_point_x, group_point_y, dot_pos_x+dot_width/2, group_point_y, 2, ARGBF(0.6, 1, 1, 1));
301 canvas_widget.DrawLine(dot_pos_x+dot_width/2, group_point_y, dot_pos_x+dot_width/2, dot_pos_y, 2, ARGBF(0.6, 1, 1, 1));
302
303 if (element[0] < 15)
304 {
305 canvas_widget.DrawLine(first_x, first_y, text_widget_pos_x + text_widget_width +50, text_widget_pos_y + text_widget_height/2, 2, ARGBF(0.6, 1, 1, 1));
306 }
307 else
308 {
309 canvas_widget.DrawLine(first_x, first_y, text_widget_pos_x - 50, text_widget_pos_y + text_widget_height/2, 2, ARGBF(0.6, 1, 1, 1));
310 }
311 }
312 }
313 }
map
Определения ControlsXboxNew.c:4
int m_TabID
Определения ControlsXbox.c:7
int m_TextWidgetID
Определения ControlsXbox.c:8
string m_ButtonName
Определения ControlsXbox.c:9
TabberUI m_TabScript
Определения ControlsXboxNew.c:40
Widget m_InfoTextRight
Определения TutorialsMenu.c:12
Widget m_InfoTextLeft
Определения TutorialsMenu.c:11
array< ref JsonControlMappingInfo > GetControlMappingInfo()
Определения TutorialsMenu.c:315
WorkspaceWidget Widget
Defined in code.
proto native void DrawLine(float x1, float y1, float x2, float y2, float width, int color)
int ARGBF(float fa, float fr, float fg, float fb)
Converts <0.0, 1.0> ARGB into color.
Определения proto.c:332

Перекрестные ссылки ARGBF(), Widget::DrawLine(), GetControlMappingInfo(), JsonControlMappingInfo::m_ButtonName, m_InfoTextLeft, m_InfoTextRight, JsonControlMappingInfo::m_TabID, m_TabScript и JsonControlMappingInfo::m_TextWidgetID.