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

◆ DrawConnectingLines() [2/2]

void UIScriptedMenu::DrawConnectingLines ( int index)
inlineprotected

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

196 {
197 m_CurrentTabIndex = index;
198
199 if (index == 6)
200 {
201 m_InfoTextLeft.Show(false);
202 m_InfoTextRight.Show(false);
203 }
204 else
205 {
206 m_InfoTextLeft.Show(true);
207 m_InfoTextRight.Show(true);
208 array<ref JsonControlMappingInfo> controlMappingInfo = new array<ref JsonControlMappingInfo>;
209 array<ref array <ref JsonControlMappingInfo>> tabArray = new array<ref array <ref JsonControlMappingInfo>>;
210
211 map<string, ref array<int>> buttonMarkerGroupsUnfiltered = new map<string, ref array<int>>;
213
214 float textWidgetPosX, textWidgetPosY;
215 float textWidgetWidth, textWidgetHeight;
216 float dotPosX, dotPosY;
217 float dotWidth, dotHeight;
218 float drawPosX, drawPosY;
219 float lineThickness;
220 float branchOffset;
221
222 CanvasWidget canvasWidget = CanvasWidget.Cast(layoutRoot.FindAnyWidget("CanvasWidget_" + index));
223 canvasWidget.Clear();
224 lineThickness = GetTutorialLineThickness();
225 branchOffset = GetTutorialBranchOffset();
226 controlMappingInfo = GetControlMappingInfo();
227
228 for (int i = 0; i < m_TabScript.GetTabCount(); i++)
229 {
230 tabArray.Insert(new array<ref JsonControlMappingInfo>);
231 for (int j = 0; j < 30; j++)
232 {
233 tabArray[i].Insert(NULL);
234 }
235 }
236
237 // insert json info to array by index, so it is sorted
238 int controlMappingInfoCount = controlMappingInfo.Count();
239 for (i = 0; i < controlMappingInfoCount; i++)
240 {
241 JsonControlMappingInfo info = controlMappingInfo.Get(i);
242 tabArray[info.m_TabID][info.m_TextWidgetID] = info;
243 }
244
245 // create group of buttons which are connected together with line
246 for (int l = 0; l < controlMappingInfoCount; l++)
247 {
248 JsonControlMappingInfo info1 = controlMappingInfo[l];
249 string buttonName = info1.m_ButtonName;
250 int textWidgetID = info1.m_TextWidgetID;
251 if (info1.m_TabID != index)
252 {
253 continue;
254 }
255 if (!buttonMarkerGroupsUnfiltered.Contains(buttonName))
256 {
257 buttonMarkerGroupsUnfiltered.Insert(buttonName, new array<int>);
258 buttonMarkerGroupsUnfiltered.Get(buttonName).Insert(textWidgetID);
259 }
260 else
261 {
262 buttonMarkerGroupsUnfiltered.Get(buttonName).Insert(textWidgetID);
263 }
264 }
265
266 // we want groups which are bigger than 1
267 for (l = 0; l < buttonMarkerGroupsUnfiltered.Count(); l++)
268 {
269 if (buttonMarkerGroupsUnfiltered.GetElement(l).Count() > 1)
270 {
271 string key = buttonMarkerGroupsUnfiltered.GetKey(l);
272 buttonMarkerGroups.Insert(buttonMarkerGroupsUnfiltered.GetKey(l), buttonMarkerGroupsUnfiltered.Get(key));
273 }
274 }
275
276 // hide all button markers
277 Widget xboxControlsImage = layoutRoot.FindAnyWidget("Markers_" + index);
278
279 Widget panelWidget;
280 Widget buttonMarkerWidget;
281
282 for (l = 0; l < tabArray[index].Count(); l++)
283 {
284 panelWidget = layoutRoot.FindAnyWidget("PanelWidget" + l);
285 if (tabArray[index][l] != NULL)
286 {
287 RichTextWidget textWidget = RichTextWidget.Cast(panelWidget.FindAnyWidget("TextWidget" + l));
288 buttonMarkerWidget = layoutRoot.FindAnyWidget("button_marker_" + tabArray[index][l].m_ButtonName);
289
291 textWidget.SetTextExactSize(EXACT_TEXT_SIZE_LOW_RES);
292
293 textWidget.SetText(tabArray[index][l].m_InfoText);
294
295 panelWidget.Show(true);
296 panelWidget.Update();
297
298 if (!buttonMarkerGroups.Contains(tabArray[index][l].m_ButtonName))
299 {
300 panelWidget.GetScreenPos(textWidgetPosX, textWidgetPosY);
301 panelWidget.GetScreenSize(textWidgetWidth,textWidgetHeight);
302
303 buttonMarkerWidget.GetScreenPos(dotPosX, dotPosY);
304 buttonMarkerWidget.GetScreenSize(dotWidth, dotHeight);
305
306 drawPosY = textWidgetPosY + textWidgetHeight / 2;
307
308 if (l < 15)
309 {
310 drawPosX = textWidgetPosX + textWidgetWidth - 1;
311 }
312 else
313 {
314 drawPosX = textWidgetPosX;
315 }
316
317 canvasWidget.DrawLine(drawPosX, drawPosY, dotPosX + dotWidth / 2, drawPosY, lineThickness, ARGBF(0.6, 1, 1, 1));
318 canvasWidget.DrawLine(dotPosX + dotWidth / 2, drawPosY, dotPosX + dotWidth / 2, dotPosY + dotHeight / 2, lineThickness, ARGBF(0.6, 1, 1, 1));
319 }
320 }
321 else
322 {
323 panelWidget.Show(false);
324 }
325 panelWidget.Update();
326 }
327
328 // draw connecting lines
329 for (l = 0; l < buttonMarkerGroups.Count(); l++)
330 {
331 textWidgetPosX = 0;
332 textWidgetPosY = 0;
333 textWidgetWidth = 0;
334 textWidgetHeight = 0;
335 float groupPointX = 0, groupPointY = 0;
336 float firstX = 0, firstY = 0;
337
338 array<int> element = buttonMarkerGroups.GetElement(l);
339 string keyName = buttonMarkerGroups.GetKey(l);
340 buttonMarkerWidget = layoutRoot.FindAnyWidget("button_marker_" + keyName);
341
342 int elementsCount = element.Count();
343 for (int g = 0; g < elementsCount; g++)
344 {
345 panelWidget = layoutRoot.FindAnyWidget("PanelWidget" + element[g]);
346
347 panelWidget.GetScreenPos(textWidgetPosX, textWidgetPosY);
348 panelWidget.GetScreenSize(textWidgetWidth, textWidgetHeight);
349
350 if (g == 0)
351 {
352 if (element[0] < 15)
353 {
354 firstX = textWidgetPosX + textWidgetWidth + branchOffset;
355 }
356 else
357 {
358 firstX = textWidgetPosX - branchOffset;
359 }
360 firstY = textWidgetPosY + textWidgetHeight/2;
361
362 }
363
364 groupPointX += textWidgetPosX;
365 groupPointY += textWidgetPosY;
366
367 if (element[0] < 15)
368 {
369 canvasWidget.DrawLine(textWidgetPosX + textWidgetWidth - 1, textWidgetPosY + textWidgetHeight / 2, textWidgetPosX + textWidgetWidth + branchOffset, textWidgetPosY + textWidgetHeight / 2, lineThickness, ARGBF(0.6, 1, 1, 1));
370 }
371 else
372 {
373 canvasWidget.DrawLine(textWidgetPosX, textWidgetPosY + textWidgetHeight / 2, textWidgetPosX - branchOffset, textWidgetPosY + textWidgetHeight / 2, lineThickness, ARGBF(0.6, 1, 1, 1));
374 }
375 }
376
377 if (element[0] < 15)
378 {
379 groupPointX = groupPointX / elementsCount + textWidgetWidth + branchOffset;
380 }
381 else
382 {
383 groupPointX = groupPointX / elementsCount - branchOffset;
384 }
385
386 groupPointY = groupPointY/elementsCount + textWidgetHeight/2;
387
388 buttonMarkerWidget.GetScreenPos(dotPosX, dotPosY);
389 buttonMarkerWidget.GetScreenSize(dotWidth, dotHeight);
390
391 canvasWidget.DrawLine(groupPointX, groupPointY, dotPosX + dotWidth / 2, groupPointY, lineThickness, ARGBF(0.6, 1, 1, 1));
392 canvasWidget.DrawLine(dotPosX + dotWidth / 2, groupPointY, dotPosX + dotWidth / 2, dotPosY, lineThickness, ARGBF(0.6, 1, 1, 1));
393
394 if (element[0] < 15)
395 {
396 canvasWidget.DrawLine(firstX, firstY, textWidgetPosX + textWidgetWidth + branchOffset, textWidgetPosY + textWidgetHeight / 2, lineThickness, ARGBF(0.6, 1, 1, 1));
397 }
398 else
399 {
400 canvasWidget.DrawLine(firstX, firstY, textWidgetPosX - branchOffset, textWidgetPosY + textWidgetHeight / 2, lineThickness, ARGBF(0.6, 1, 1, 1));
401 }
402 }
403 }
404 }
map
Определения ControlsXboxNew.c:4
int m_TabID
Определения ControlsXbox.c:7
int m_TextWidgetID
Определения ControlsXbox.c:8
string m_ButtonName
Определения ControlsXbox.c:9
int m_CurrentTabIndex
Определения TutorialsMenu.c:32
TabberUI m_TabScript
Определения ControlsXboxNew.c:40
float GetTutorialLineThickness()
Определения TutorialsMenu.c:125
Widget m_InfoTextRight
Определения TutorialsMenu.c:24
bool m_LowResTutorialMode
Определения TutorialsMenu.c:35
const int EXACT_TEXT_SIZE_LOW_RES
Определения TutorialsMenu.c:19
Widget m_InfoTextLeft
Определения TutorialsMenu.c:23
float GetTutorialBranchOffset()
Определения TutorialsMenu.c:130
array< ref JsonControlMappingInfo > GetControlMappingInfo()
Определения TutorialsMenu.c:406
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(), EXACT_TEXT_SIZE_LOW_RES, GetControlMappingInfo(), GetTutorialBranchOffset(), GetTutorialLineThickness(), JsonControlMappingInfo::m_ButtonName, m_CurrentTabIndex, m_InfoTextLeft, m_InfoTextRight, m_LowResTutorialMode, JsonControlMappingInfo::m_TabID, m_TabScript и JsonControlMappingInfo::m_TextWidgetID.