DayZ 1.24
Loading...
Searching...
No Matches
ControlsXbox.c File Reference

Go to the source code of this file.

Classes

class  JsonControlMappingInfo
 

Functions

void ControlsXbox ()
 
void ~ControlsXbox ()
 
void Back ()
 
void DrawConnectingLines (int index)
 
array< ref JsonControlMappingInfoGetControlMappingInfo ()
 
override Widget Init ()
 Launched from 'DayZGame.DeferredInit' to make earlier access, use, and updates impossible (downside of a non-static system)
 
override void OnShow ()
 
override bool OnClick (Widget w, int x, int y, int button)
 
override void Update (float timeslice)
 
void LoadFooterButtonTexts ()
 Initial texts load for the footer buttons.
 
void LoadTextStrings ()
 Set correct bottom button texts based on platform (ps4 vs xbox texts)
 
void SwitchPreset ()
 

Variables

class JsonControlMappingInfo m_BackButtonTextID
 
ButtonWidget m_Back
 
ImageWidget m_ControlsLayoutImage
 
const int TABS_COUNT = 4
 
ImageWidget m_tab_images [TABS_COUNT]
 
TabberUI m_TabScript
 

Function Documentation

◆ Back()

void Back ( )
protected

Definition at line 36 of file ControlsXbox.c.

37 {
38 GetGame().GetUIManager().Back();
39 }
proto native CGame GetGame()

References GetGame().

Referenced by UIScriptedMenu::OnClick(), and UIScriptedMenu::Update().

◆ ControlsXbox()

void ControlsXbox ( )
protected

Definition at line 26 of file ControlsXbox.c.

27 {
28
29 }

◆ DrawConnectingLines()

void DrawConnectingLines ( int index)
protected

Definition at line 41 of file ControlsXbox.c.

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 }
TabberUI m_TabScript
array< ref JsonControlMappingInfo > GetControlMappingInfo()
int ARGBF(float fa, float fr, float fg, float fb)
Converts <0.0, 1.0> ARGB into color.
Definition proto.c:332

References ARGBF(), UIScriptedMenu::GetControlMappingInfo(), and m_TabScript.

Referenced by Init(), UIScriptedMenu::Init(), UIScriptedMenu::UpdateTabContent(), and UIScriptedMenu::~TutorialsMenu().

◆ GetControlMappingInfo()

array< ref JsonControlMappingInfo > GetControlMappingInfo ( )
protected

Definition at line 242 of file ControlsXbox.c.

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 }
Class for sending RPC over network.
Definition gameplay.c:50
ErrorExSeverity
Definition EnDebug.c:62
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.

References CloseFile(), ErrorEx, FGets(), and OpenFile().

Referenced by UIScriptedMenu::DrawConnectingLines().

◆ Init()

override Widget Init ( )
protected

Launched from 'DayZGame.DeferredInit' to make earlier access, use, and updates impossible (downside of a non-static system)

pre-init arrays

Definition at line 274 of file ControlsXbox.c.

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 }
void DrawConnectingLines(int index)
ButtonWidget m_Back
ImageWidget m_tab_images[TABS_COUNT]
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
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.

References Class::CastTo(), DrawConnectingLines(), UIScriptedMenu::DrawConnectingLines(), GetGame(), InputUtils::GetRichtextButtonIconFromInputAction(), InputUtils::ICON_SCALE_TOOLBAR, m_Back, m_tab_images, and m_TabScript.

◆ LoadFooterButtonTexts()

void LoadFooterButtonTexts ( )
protected

Initial texts load for the footer buttons.

Definition at line 360 of file ControlsXbox.c.

361 {
362 TextWidget uiBackText = TextWidget.Cast(layoutRoot.FindAnyWidget("BackText"));
363 if (uiBackText)
365 }
class JsonControlMappingInfo m_BackButtonTextID

References m_BackButtonTextID.

◆ LoadTextStrings()

void LoadTextStrings ( )
protected

Set correct bottom button texts based on platform (ps4 vs xbox texts)

Definition at line 368 of file ControlsXbox.c.

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 }

References m_BackButtonTextID.

◆ OnClick()

override bool OnClick ( Widget w,
int x,
int y,
int button )
protected

Definition at line 331 of file ControlsXbox.c.

332 {
333 if (button == MouseState.LEFT)
334 {
335 if (w == m_Back)
336 {
337 Back();
338 return true;
339 }
340 }
341 return false;
342 }
void Back()
MouseState
Definition EnSystem.c:311

References UIScriptedMenu::Back(), and m_Back.

◆ OnShow()

override void OnShow ( )
protected

Definition at line 313 of file ControlsXbox.c.

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 }
proto native UAInputAPI GetUApi()

References Class::CastTo(), and GetUApi().

Referenced by Container::Open(), ClosableContainer::Open(), and Container::SetOpenState().

◆ SwitchPreset()

void SwitchPreset ( )
protected

Definition at line 377 of file ControlsXbox.c.

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 }

References Class::CastTo(), GetGame(), and GetUApi().

Referenced by Update().

◆ Update()

override void Update ( float timeslice)
protected

Definition at line 344 of file ControlsXbox.c.

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 }
void SwitchPreset()

References UIScriptedMenu::Back(), GetUApi(), m_TabScript, and SwitchPreset().

◆ ~ControlsXbox()

void ~ControlsXbox ( )
protected

Definition at line 31 of file ControlsXbox.c.

32 {
34 }

Variable Documentation

◆ m_Back

◆ m_BackButtonTextID

◆ m_ControlsLayoutImage

ImageWidget m_ControlsLayoutImage
protected

Definition at line 18 of file ControlsXbox.c.

◆ m_tab_images

ImageWidget m_tab_images[TABS_COUNT]
protected

Definition at line 20 of file ControlsXbox.c.

Referenced by Init(), and UIScriptedMenu::Init().

◆ m_TabScript

◆ TABS_COUNT

const int TABS_COUNT = 4
protected

Definition at line 19 of file ControlsXbox.c.