DayZ 1.24
Loading...
Searching...
No Matches
ControlsXbox.c
Go to the documentation of this file.
1/*
2 DEPRECATED CONTENT
3*/
4
12
13class ControlsXbox extends UIScriptedMenu
14{
15 protected string m_BackButtonTextID;
16
19 protected const int TABS_COUNT = 4;
22
23 //============================================
24 // ControlsXbox
25 //============================================
27 {
28
29 }
30
32 {
34 }
35
36 void Back()
37 {
38 GetGame().GetUIManager().Back();
39 }
40
42 {
45
48
51 float dot_pos_x, dot_pos_y;
52 float dot_width, dot_height;
54
55 CanvasWidget canvas_widget = CanvasWidget.Cast(layoutRoot.FindAnyWidget("CanvasWidget_" + index));
56 canvas_widget.Clear();
58
59 for (int i = 0; i < m_TabScript.GetTabCount(); i++)
60 {
62 for (int j = 0; j < 20; j++)
63 tab_array[i].Insert(null);
64 }
65
66 // insert json info to array by index, so it is sorted
67 for (i = 0; i < control_mapping_info.Count(); i++)
68 {
70 tab_array[info.m_TabID][info.m_TextWidgetID] = info;
71 }
72
73 // create group of buttons which are connected together with line
74 for (int l = 0; l < control_mapping_info.Count(); l++)
75 {
77 string button_name = info1.m_ButtonName;
78 int text_widget_id = info1.m_TextWidgetID;
79 if (info1.m_TabID != index)
80 continue;
82 {
85 }
86 else
88 }
89
90 // we want groups which are bigger than 1
91 for (l = 0; l < button_marker_groups_unflitred.Count(); l++)
92 {
93 if (button_marker_groups_unflitred.GetElement(l).Count() > 1)
94 {
95 string key = button_marker_groups_unflitred.GetKey(l);
97 }
98 }
99
101 // hide all button markers
102#ifdef PLATFORM_XBOX
103 controls_image = layoutRoot.FindAnyWidget("XboxControlsImage");
104#else
105#ifdef PLATFORM_PS4
106 controls_image = layoutRoot.FindAnyWidget("PSControlsImage");
107#endif
108#endif
109
110 Widget child = controls_image.GetChildren();
111 child.Show(false);
112 while (child.GetSibling())
113 {
114 child = child.GetSibling();
115 child.Show(false);
116 }
117
120
121 for (l = 0; l < tab_array[index].Count(); l++)
122 {
123 panel_widget = layoutRoot.FindAnyWidget("PanelWidget" + l);
124 if (tab_array[index][l] != null)
125 {
126 TextWidget text_widget = TextWidget.Cast(panel_widget.FindAnyWidget("TextWidget" + l));
127
128 string key_prefix;
129#ifdef PLATFORM_XBOX
130 key_prefix = "xb_button_marker_";
131#else
132#ifdef PLATFORM_PS4
133 key_prefix = "ps_button_marker_";
134#endif
135#endif
136
137 button_marker_widget = layoutRoot.FindAnyWidget(key_prefix + tab_array[index][l].m_ButtonName);
138 text_widget.SetText(tab_array[index][l].m_InfoText);
139 panel_widget.Show(true);
140 button_marker_widget.Show(true);
141 panel_widget.Update();
142 if (!button_marker_groups.Contains(tab_array[index][l].m_ButtonName))
143 {
146
149
151 if (l < 10)
153 else
155 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));
156 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));
157 }
158 }
159 else
160 panel_widget.Show(false);
161 panel_widget.Update();
162 }
163
164 // draw connecting lines
165 for (l = 0; l < button_marker_groups.Count(); l++)
166 {
171 float group_point_x = 0, group_point_y = 0;
172 float first_x = 0, first_y = 0;
173
175 string key_name = button_marker_groups.GetKey(l);
176#ifdef PLATFORM_XBOX
177 key_prefix = "xb_button_marker_";
178#else
179#ifdef PLATFORM_PS4
180 key_prefix = "ps_button_marker_";
181#endif
182#endif
183 button_marker_widget = layoutRoot.FindAnyWidget(key_prefix + key_name);
184
185 for (int g = 0; g < element.Count(); g++)
186 {
187 panel_widget = layoutRoot.FindAnyWidget("PanelWidget" + element[g]);
188
191
192 if (g == 0)
193 {
194 if (element[0] < 10)
196 else
198
200 }
201
204 if (element[0] < 10)
206 else
208 }
209 if (element[0] < 10)
211 else
212 group_point_x = group_point_x / element.Count() - 50;
213
214 if (element.Count() % 2 == 0)
216 else
217 {
220
221 panel_widget = layoutRoot.FindAnyWidget("PanelWidget" + element[1]);
222
225
227 }
228
231
233 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));
234
235 if (element[0] < 10)
237 else
239 }
240 }
241
243 {
245
246 string file_path = "xbox/pagedatacontroller.json";
247#ifdef PLATFORM_PS4
248 file_path = "ps4/pagedatacontroller.json";
249#endif
252
253 string js_error = "";
254 string line_content = "";
255 string content = "";
256 if (file_handle)
257 {
258 while (FGets(file_handle, line_content) >= 0)
261
262 if (js.ReadFromString(control_mapping_info, content, js_error))
264 else
265 ErrorEx("JSON ERROR => [ControlMappingInfo.json]: " + js_error, ErrorExSeverity.INFO);
266 }
267
269 }
270
271 //============================================
272 // Init
273 //============================================
274 override Widget Init()
275 {
276 layoutRoot = GetGame().GetWorkspace().CreateWidgets("gui/layouts/xbox/control_mapping_info_screen.layout");
277
278 layoutRoot.FindAnyWidget("Tabber").GetScript(m_TabScript);
279
280 m_TabScript.m_OnTabSwitch.Insert(DrawConnectingLines);
281
282 m_Back = ButtonWidget.Cast(layoutRoot.FindAnyWidget("back"));
283
284#ifdef PLATFORM_CONSOLE
285 RichTextWidget toolbar_switch = RichTextWidget.Cast(layoutRoot.FindAnyWidget("ChangePresetIcon"));
286 RichTextWidget toolbar_back = RichTextWidget.Cast(layoutRoot.FindAnyWidget("BackIcon"));
289#endif
290
291#ifdef PLATFORM_XBOX
292 layoutRoot.FindAnyWidget("XboxControlsImage").Show(true);
293#else
294#ifdef PLATFORM_PS4
295 layoutRoot.FindAnyWidget("PSControlsImage").Show(true);
296#endif
297#endif
298
299 m_tab_images[0] = ImageWidget.Cast(layoutRoot.FindAnyWidget("MovementTabBackdropImageWidget"));
300 m_tab_images[1] = ImageWidget.Cast(layoutRoot.FindAnyWidget("WeaponsAndActionsBackdropImageWidget"));
301 m_tab_images[2] = ImageWidget.Cast(layoutRoot.FindAnyWidget("InventoryTabBackdropImageWidget"));
302 m_tab_images[3] = ImageWidget.Cast(layoutRoot.FindAnyWidget("MenusTabBackdropImageWidget"));
303
305 Class.CastTo(requester, PPERequesterBank.GetRequester(PPERequesterBank.REQ_MENUEFFECTS));
306 requester.SetVignetteIntensity(0.6);
307
309
310 return layoutRoot;
311 }
312
313 override void OnShow()
314 {
315 super.OnShow();
316#ifdef PLATFORM_CONSOLE
317 //layoutRoot.FindAnyWidget("toolbar_bg").Show(!GetGame().GetInput().IsEnabledMouseAndKeyboard());
318 layoutRoot.FindAnyWidget("toolbar_bg").Show(true);//TODO: temporarily always on for preset switching
319
320 string preset_text;
323 if (Class.CastTo(nameWidget, layoutRoot.FindAnyWidget("PresetText")));
324 {
325 preset_text = inputAPI.PresetName(inputAPI.PresetCurrent());
326 nameWidget.SetText(preset_text);
327 }
328#endif
329 }
330
331 override bool OnClick(Widget w, int x, int y, int button)
332 {
333 if (button == MouseState.LEFT)
334 {
335 if (w == m_Back)
336 {
337 Back();
338 return true;
339 }
340 }
341 return false;
342 }
343
344 override void Update(float timeslice)
345 {
346 if (GetUApi().GetInputByID(UAUITabLeft).LocalPress())
347 m_TabScript.PreviousTab();
348
349 if (GetUApi().GetInputByID(UAUITabRight).LocalPress())
350 m_TabScript.NextTab();
351
352 if (GetUApi().GetInputByID(UAUIBack).LocalPress())
353 Back();
354
355 if (GetUApi().GetInputByID(UASwitchPreset).LocalPress())
356 SwitchPreset();
357 }
358
360 protected void LoadFooterButtonTexts()
361 {
362 TextWidget uiBackText = TextWidget.Cast(layoutRoot.FindAnyWidget("BackText"));
363 if (uiBackText)
365 }
366
368 protected void LoadTextStrings()
369 {
370#ifdef PLATFORM_PS4
371 m_BackButtonTextID = "ps4_ingame_menu_back";
372#else
373 m_BackButtonTextID = "STR_rootFrame_toolbar_bg_ConsoleToolbar_Back_BackText0";
374#endif
375 }
376
377 protected void SwitchPreset()
378 {
379 int index;
380 string preset_text;
383
384 index = inputAPI.PresetCurrent() + 1;
385 if (index >= inputAPI.PresetCount())
386 index = 0;
387
388 inputAPI.PresetSelect(index);
389 if (Class.CastTo(nameWidget, layoutRoot.FindAnyWidget("PresetText")));
390 {
391 preset_text = inputAPI.PresetName(inputAPI.PresetCurrent());
392 nameWidget.SetText(preset_text);
393 }
394
395 GetGame().GetInput().SetProfile(index);
396 GetUApi().Export();
397 GetGame().GetMission().GetOnInputPresetChanged().Invoke();
398 }
399}
class JsonControlMappingInfo m_BackButtonTextID
void ~ControlsXbox()
const int TABS_COUNT
void SwitchPreset()
void DrawConnectingLines(int index)
TabberUI m_TabScript
ButtonWidget m_Back
ImageWidget m_tab_images[TABS_COUNT]
void ControlsXbox()
Icon x
Icon y
proto native UAInputAPI GetUApi()
Super root of all classes in Enforce script.
Definition EnScript.c:11
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 LoadFooterButtonTexts()
Initial texts load for the footer buttons.
override void OnShow()
string m_BackButtonTextID
void LoadTextStrings()
Set correct bottom button texts based on platform (ps4 vs xbox texts)
ImageWidget m_ControlsLayoutImage
void DrawConnectingLines(int index)
const int TABS_COUNT
ButtonWidget m_Back
override Widget Init()
Definition BookMenu.c:11
override bool OnClick(Widget w, int x, int y, int button)
Definition BookMenu.c:34
array< ref JsonControlMappingInfo > GetControlMappingInfo()
proto native CGame GetGame()
ErrorExSeverity
Definition EnDebug.c:62
enum ShapeType ErrorEx
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
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 volatile void Update()
int ARGBF(float fa, float fr, float fg, float fb)
Converts <0.0, 1.0> ARGB into color.
Definition proto.c:332