DayZ 1.24
Loading...
Searching...
No Matches
TutorialsMenu.c
Go to the documentation of this file.
2{
3 protected const string PATH_MOUSEKEY = "scripts/data/pagedatatutorials.json";
4 protected const string PATH_X1_OLD = "xbox/pagedatatutorials.json";
5 protected const string PATH_X1_NEW = "xbox/pagedatatutorialsalternate.json";
6 protected const string PATH_PS_OLD = "ps4/pagedatatutorials.json";
7 protected const string PATH_PS_NEW = "ps4/pagedatatutorialsalternate.json";
8
9 protected string m_BackButtonTextID;
10
13 protected ButtonWidget m_Back;
14
16 protected const int TABS_COUNT = 4;
18 protected TabberUI m_TabScript;
19 protected ref TutorialKeybinds m_KeybindsTab;
20
21 //============================================
22 // Init
23 //============================================
24 override Widget Init()
25 {
26#ifdef PLATFORM_CONSOLE
27 layoutRoot = GetGame().GetWorkspace().CreateWidgets("gui/layouts/new_ui/tutorials/xbox/tutorials.layout");
28#else
29 layoutRoot = GetGame().GetWorkspace().CreateWidgets("gui/layouts/new_ui/tutorials/pc/tutorials.layout");
30#endif
31
32 m_InfoTextLeft = layoutRoot.FindAnyWidget("InfoTextLeft");
33 m_InfoTextRight = layoutRoot.FindAnyWidget("InfoTextRight");
34
35 m_Back = ButtonWidget.Cast(layoutRoot.FindAnyWidget("back"));
36
37 layoutRoot.FindAnyWidget("Tabber").GetScript(m_TabScript);
38 m_TabScript.m_OnTabSwitch.Insert(DrawConnectingLines);
39
40#ifdef PLATFORM_CONSOLE
41 if (GetGame().GetInput().IsEnabledMouseAndKeyboard())
42 {
43 m_KeybindsTab = new TutorialKeybinds(layoutRoot.FindAnyWidget("Tab_6"), this);
44 m_TabScript.EnableTabControl(6, true);
45 }
46#endif
47
48 m_tab_images[0] = ImageWidget.Cast(layoutRoot.FindAnyWidget("MovementTabBackdropImageWidget"));
49 m_tab_images[1] = ImageWidget.Cast(layoutRoot.FindAnyWidget("WeaponsAndActionsBackdropImageWidget"));
50 m_tab_images[2] = ImageWidget.Cast(layoutRoot.FindAnyWidget("InventoryTabBackdropImageWidget"));
51 m_tab_images[3] = ImageWidget.Cast(layoutRoot.FindAnyWidget("MenusTabBackdropImageWidget"));
52
55
56 PPERequesterBank.GetRequester(PPERequester_TutorialMenu).Start(new Param1<float>(0.6));
58
59 GetGame().GetMission().GetOnInputPresetChanged().Insert(OnInputPresetChanged);
60 GetGame().GetMission().GetOnInputDeviceChanged().Insert(OnInputDeviceChanged);
61
62 OnInputDeviceChanged(GetGame().GetInput().GetCurrentInputDevice());
63
64 return layoutRoot;
65 }
66
68 {
69 m_TabScript.m_OnTabSwitch.Remove(DrawConnectingLines);
71 }
72
73 protected void OnInputPresetChanged()
74 {
75#ifdef PLATFORM_CONSOLE
78#endif
79 }
80
85
86 override void OnShow()
87 {
88 super.OnShow();
89
91 }
92
93 void Back()
94 {
95 GetGame().GetUIManager().Back();
96 }
97
99 {
100 if (index == 6)
101 {
102 m_InfoTextLeft.Show(false);
103 m_InfoTextRight.Show(false);
104 }
105 else
106 {
107 m_InfoTextLeft.Show(true);
108 m_InfoTextRight.Show(true);
111
114
117 float dot_pos_x, dot_pos_y;
118 float dot_width, dot_height;
119 float draw_pos_x, draw_pos_y;
120
121 CanvasWidget canvas_widget = CanvasWidget.Cast(layoutRoot.FindAnyWidget("CanvasWidget_" + index));
122 canvas_widget.Clear();
124
125 for (int i = 0; i < m_TabScript.GetTabCount(); i++)
126 {
128 for (int j = 0; j < 30; j++)
129 tab_array[i].Insert(NULL);
130 }
131
132 // insert json info to array by index, so it is sorted
133 for (i = 0; i < control_mapping_info.Count(); i++)
134 {
136 tab_array[info.m_TabID][info.m_TextWidgetID] = info;
137 }
138
139 // create group of buttons which are connected together with line
140 for (int l = 0; l < control_mapping_info.Count(); l++)
141 {
143 string button_name = info1.m_ButtonName;
144 int text_widget_id = info1.m_TextWidgetID;
145 if (info1.m_TabID != index)
146 continue;
148 {
151 }
152 else
154 }
155
156 // we want groups which are bigger than 1
157 for (l = 0; l < button_marker_groups_unflitred.Count(); l++)
158 {
159 if (button_marker_groups_unflitred.GetElement(l).Count() > 1)
160 {
161 string key = button_marker_groups_unflitred.GetKey(l);
163 }
164 }
165
166 // hide all button markers
167 Widget xbox_controls_image = layoutRoot.FindAnyWidget("Markers_" + index);
168
171
172 for (l = 0; l < tab_array[index].Count(); l++)
173 {
174 panel_widget = layoutRoot.FindAnyWidget("PanelWidget" + l);
175 if (tab_array[index][l] != NULL)
176 {
177 TextWidget text_widget = TextWidget.Cast(panel_widget.FindAnyWidget("TextWidget" + l));
178 button_marker_widget = layoutRoot.FindAnyWidget("button_marker_" + tab_array[index][l].m_ButtonName);
179 text_widget.SetText(tab_array[index][l].m_InfoText);
180 panel_widget.Show(true);
181 panel_widget.Update();
182
183 if (!button_marker_groups.Contains(tab_array[index][l].m_ButtonName))
184 {
187
190
192
193 if (l < 15)
195 else
197
198 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));
199 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));
200 }
201 }
202 else
203 panel_widget.Show(false);
204 panel_widget.Update();
205 }
206
207 // draw connecting lines
208 for (l = 0; l < button_marker_groups.Count(); l++)
209 {
214 float group_point_x = 0, group_point_y = 0;
215 float first_x = 0, first_y = 0;
216
218 string key_name = button_marker_groups.GetKey(l);
219 button_marker_widget = layoutRoot.FindAnyWidget("button_marker_" + key_name);
220
221 for (int g = 0; g < element.Count(); g++)
222 {
223 panel_widget = layoutRoot.FindAnyWidget("PanelWidget" + element[g]);
224
227
228 if (g == 0)
229 {
230 if (element[0] < 15)
232 else
235
236 }
237
240
241 if (element[0] < 15)
243 else
245 }
246
247 if (element[0] < 15)
249 else
250 group_point_x = group_point_x / element.Count() - 50;
251
253
256
258 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));
259
260 if (element[0] < 15)
262 else
264 }
265 }
266 }
267
269 {
271 string file_path = PATH_MOUSEKEY; //remains set for PC vatiant
272 string profile_name = "";
273 GetGame().GetInput().GetProfileName(GetGame().GetInput().GetCurrentProfile(), profile_name);
274
275#ifdef PLATFORM_CONSOLE
276 if (!GetGame().GetInput().IsEnabledMouseAndKeyboardEvenOnServer())
277 {
278 if (profile_name == "#STR_UAPRESET_0")
279 {
280#ifdef PLATFORM_XBOX
281 file_path = PATH_X1_OLD;
282#else
283 file_path = PATH_PS_OLD;
284#endif
285 }
286 else if (profile_name == "#STR_UAPRESET_1")
287 {
288#ifdef PLATFORM_XBOX
289 file_path = PATH_X1_NEW;
290#else
291 file_path = PATH_PS_NEW;
292#endif
293 }
294 else
295 {
296 ErrorEx("Invalid file path!");
297 file_path = "";
298 }
299 }
300#endif
303
304 string js_error = "";
305 string line_content = "";
306 string content = "";
307 if (file_handle)
308 {
309 while (FGets(file_handle, line_content) >= 0)
312
313 if (js.ReadFromString(control_mapping_info, content, js_error))
315 else
316 ErrorEx("JSON ERROR => [TutorialsMenu]: " + js_error);
317 }
318 else
319 ErrorEx("FILEHANDLE ERROR => [TutorialsMenu]: " + js_error);
320
322 }
323
324 override void Update(float timeslice)
325 {
326 if (GetUApi().GetInputByID(UAUITabLeft).LocalPress())
327 m_TabScript.PreviousTab();
328
329 //RIGHT BUMPER - TAB RIGHT
330 if (GetUApi().GetInputByID(UAUITabRight).LocalPress())
331 m_TabScript.NextTab();
332
333 if (GetUApi().GetInputByID(UAUIBack).LocalPress())
334 Back();
335 }
336
338 protected void LoadFooterButtonTexts()
339 {
340 TextWidget uiBackText = TextWidget.Cast(layoutRoot.FindAnyWidget("BackText"));
341
342 if (uiBackText)
344 }
346 protected void LoadTextStrings()
347 {
348#ifdef PLATFORM_PS4
349 m_BackButtonTextID = "ps4_ingame_menu_back";
350#else
351 m_BackButtonTextID = "STR_rootFrame_toolbar_bg_ConsoleToolbar_Back_BackText0";
352#endif
353 }
354
355 override bool OnClick(Widget w, int x, int y, int button)
356 {
357 if (button == MouseState.LEFT)
358 {
359 if (w == m_Back)
360 {
361 Back();
362 return true;
363 }
364 }
365 return false;
366 }
367
368 override bool OnMouseEnter(Widget w, int x, int y)
369 {
370 if (IsFocusable(w))
371 {
373 return true;
374 }
375 return false;
376 }
377
378 override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
379 {
380 if (IsFocusable(w))
381 {
382 ColorNormal(w);
383 return true;
384 }
385 return false;
386 }
387
388 override bool OnFocus(Widget w, int x, int y)
389 {
390 if (IsFocusable(w))
391 {
393 return true;
394 }
395 return false;
396 }
397
398 override bool OnFocusLost(Widget w, int x, int y)
399 {
400 if (IsFocusable(w))
401 {
402 ColorNormal(w);
403 return true;
404 }
405 return false;
406 }
407
409 {
410 return (w && w == m_Back);
411 }
412
413 //Coloring functions (Until WidgetStyles are useful)
415 {
416 if (!w)
417 return;
418
419 int color_pnl = ARGB(255, 0, 0, 0);
420 int color_lbl = ARGB(255, 255, 0, 0);
421 int color_img = ARGB(255, 200, 0, 0);
422
423#ifdef PLATFORM_CONSOLE
424 color_pnl = ARGB(255, 200, 0, 0);
425 color_lbl = ARGB(255, 255, 255, 255);
426#endif
427
428 ButtonSetColor(w, color_pnl);
429 ButtonSetTextColor(w, color_lbl);
430 ImagenSetColor(w, color_img);
431 }
432
434 {
435 if (!w)
436 return;
437
438 int color_pnl = ARGB(0, 0, 0, 0);
439 int color_lbl = ARGB(255, 255, 255, 255);
440 int color_img = ARGB(255, 255, 255, 255);
441
442 ButtonSetColor(w, color_pnl);
443 ButtonSetTextColor(w, color_lbl);
444 ImagenSetColor(w, color_img);
445 }
446
448 {
449 if (!w)
450 return;
451
452 TextWidget label = TextWidget.Cast(w.FindWidget(w.GetName() + "_label"));
453
454 if (label)
455 label.SetText(text);
456
457 }
458
460 {
461 if (!w)
462 return;
463
464 Widget panel = w.FindWidget(w.GetName() + "_panel");
465
466 if (panel)
467 panel.SetColor(color);
468 }
469
471 {
472 if (!w)
473 return;
474
475 Widget panel = w.FindWidget(w.GetName() + "_image");
476
477 if (panel)
478 panel.SetColor(color);
479 }
480
482 {
483 if (!w)
484 return;
485
486 TextWidget label = TextWidget.Cast(w.FindAnyWidget(w.GetName() + "_label"));
487 TextWidget text = TextWidget.Cast(w.FindAnyWidget(w.GetName() + "_text"));
488 TextWidget text2 = TextWidget.Cast(w.FindAnyWidget(w.GetName() + "_text_1"));
489
490 if (label)
491 label.SetColor(color);
492
493 if (text)
494 text.SetColor(color);
495
496 if (text2)
497 text2.SetColor(color);
498 }
499
500 protected void UpdateControlsElements()
501 {
502#ifdef PLATFORM_CONSOLE
503 RichTextWidget toolbar_text = RichTextWidget.Cast(layoutRoot.FindAnyWidget("ContextToolbarText"));
504 if (toolbar_text)
505 {
506 string text = string.Format(" %1", InputUtils.GetRichtextButtonIconFromInputAction("UAUIBack", "#STR_settings_menu_root_toolbar_bg_ConsoleToolbar_Back_BackText0", EUAINPUT_DEVICE_CONTROLLER, InputUtils.ICON_SCALE_TOOLBAR));
507 toolbar_text.SetText(text);
508 }
509
510 RichTextWidget toolbar_b2 = RichTextWidget.Cast(layoutRoot.FindAnyWidget("BackIcon0"));
512#endif
513 }
514
516 {
517 bool toolbarShow = false;
518#ifdef PLATFORM_CONSOLE
519 toolbarShow = !GetGame().GetInput().IsEnabledMouseAndKeyboardEvenOnServer() || GetGame().GetInput().GetCurrentInputDevice() == EInputDeviceType.CONTROLLER;
520#endif
521
522#ifdef PLATFORM_CONSOLE
523 layoutRoot.FindAnyWidget("toolbar_bg").Show(toolbarShow);
524#endif
525 layoutRoot.FindAnyWidget("play_panel_root").Show(!toolbarShow);
526 }
527}
void OnInputPresetChanged()
Definition Inventory.c:160
void OnInputDeviceChanged(EInputDeviceType pInputDeviceType)
Definition Inventory.c:167
ActionInput GetInput()
Definition ActionBase.c:989
class JsonControlMappingInfo m_BackButtonTextID
const int TABS_COUNT
ImageWidget m_ControlsLayoutImage
void DrawConnectingLines(int index)
TabberUI m_TabScript
ButtonWidget m_Back
ImageWidget m_tab_images[TABS_COUNT]
array< ref JsonControlMappingInfo > GetControlMappingInfo()
void Back()
Icon x
Icon y
void UpdateControlsElementVisibility()
void UpdateControlsElements()
void ColorNormal(Widget w)
bool IsFocusable(Widget w)
void ColorHighlight(Widget w)
proto native UAInputAPI GetUApi()
static string GetRichtextButtonIconFromInputAction(notnull UAInput pInput, string pLocalizedDescription, int pInputDeviceType=EUAINPUT_DEVICE_CONTROLLER, float pScale=ICON_SCALE_NORMAL, bool pVertical=false)
Definition InputUtils.c:151
static const float ICON_SCALE_TOOLBAR
Definition InputUtils.c:15
Class for sending RPC over network.
Definition gameplay.c:50
void UpdateControlsElementVisibility()
void LoadFooterButtonTexts()
Initial texts load for the footer buttons.
override bool OnMouseEnter(Widget w, int x, int y)
override void OnShow()
override bool OnFocus(Widget w, int x, int y)
ref TutorialKeybinds m_KeybindsTab
override void Update(float timeslice)
Widget m_InfoTextRight
void ColorHighlight(Widget w)
bool IsFocusable(Widget w)
void LoadTextStrings()
Set correct bottom button texts based on platform (ps4 vs xbox texts)
void OnInputDeviceChanged(EInputDeviceType pInputDeviceType)
void ~TutorialsMenu()
void ButtonSetText(Widget w, string text)
override bool OnFocusLost(Widget w, int x, int y)
override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
void DrawConnectingLines(int index)
Widget m_InfoTextLeft
void UpdateControlsElements()
void ButtonSetTextColor(Widget w, int color)
override Widget Init()
override bool OnClick(Widget w, int x, int y, int button)
void ImagenSetColor(Widget w, int color)
void ButtonSetColor(Widget w, int color)
void ColorNormal(Widget w)
array< ref JsonControlMappingInfo > GetControlMappingInfo()
void OnInputPresetChanged()
proto native CGame GetGame()
enum ShapeType ErrorEx
FileMode
Definition EnSystem.c:383
proto void CloseFile(FileHandle file)
Close the File.
proto int FGets(FileHandle file, string var)
Get line from file, every next call of this function returns next line.
proto FileHandle OpenFile(string name, FileMode mode)
Opens File.
MouseState
Definition EnSystem.c:311
proto native void SetFocus(Widget w)
EInputDeviceType
Definition input.c:3
int ARGB(int a, int r, int g, int b)
Definition proto.c:322
int ARGBF(float fa, float fr, float fg, float fb)
Converts <0.0, 1.0> ARGB into color.
Definition proto.c:332