Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
controlsxbox.c
Go to the documentation of this file.
1 /*
2 DEPRECATED CONTENT
3 */
4 
6 {
7  int m_TabID;
8  int m_TextWidgetID;
9  string m_ButtonName;
10  string m_InfoText;
11 }
12 
13 class ControlsXbox extends UIScriptedMenu
14 {
15  protected string m_BackButtonTextID;
16 
17  protected ButtonWidget m_Back;
18  protected ImageWidget m_ControlsLayoutImage;
19  protected const int TABS_COUNT = 4;
20  protected ImageWidget m_tab_images[TABS_COUNT];
21  protected TabberUI m_TabScript;
22 
23  //============================================
24  // ControlsXbox
25  //============================================
26  void ControlsXbox()
27  {
28 
29  }
30 
32  {
33  PPERequesterBank.GetRequester(PPERequester_ControlsBlur).Stop();
34  }
35 
36  void Back()
37  {
38  GetGame().GetUIManager().Back();
39  }
40 
41  void DrawConnectingLines(int index)
42  {
45 
46  map<string, ref array<int>> button_marker_groups_unflitred = new map<string, ref array<int>>;
47  map<string, ref array<int>> button_marker_groups = new map<string, ref array<int>>;
48 
49  float text_widget_pos_x, text_widget_pos_y;
50  float text_widget_width, text_widget_height;
51  float dot_pos_x, dot_pos_y;
52  float dot_width, dot_height;
53  float draw_pos_x, draw_pos_y;
54 
55  CanvasWidget canvas_widget = CanvasWidget.Cast(layoutRoot.FindAnyWidget("CanvasWidget_" + index));
56  canvas_widget.Clear();
57  control_mapping_info = GetControlMappingInfo();
58 
59  for (int i = 0; i < m_TabScript.GetTabCount(); i++)
60  {
61  tab_array.Insert(new array<ref JsonControlMappingInfo>);
62  for (int j = 0; j < 20; j++)
63  {
64  tab_array[i].Insert(null);
65  }
66  }
67 
68  // insert json info to array by index, so it is sorted
69  for (i = 0; i < control_mapping_info.Count(); i++)
70  {
71  JsonControlMappingInfo info = control_mapping_info.Get(i);
72  tab_array[info.m_TabID][info.m_TextWidgetID] = info;
73  }
74 
75  // create group of buttons which are connected together with line
76  for (int l = 0; l < control_mapping_info.Count(); l++)
77  {
78  JsonControlMappingInfo info1 = control_mapping_info[l];
79  string button_name = info1.m_ButtonName;
80  int text_widget_id = info1.m_TextWidgetID;
81  if (info1.m_TabID != index)
82  {
83  continue;
84  }
85  if (!button_marker_groups_unflitred.Contains(button_name))
86  {
87  button_marker_groups_unflitred.Insert(button_name, new ref array<int>);
88  button_marker_groups_unflitred.Get(button_name).Insert(text_widget_id);
89  }
90  else
91  {
92  button_marker_groups_unflitred.Get(button_name).Insert(text_widget_id);
93  }
94  }
95 
96  // we want groups which are bigger than 1
97  for (l = 0; l < button_marker_groups_unflitred.Count(); l++)
98  {
99  if (button_marker_groups_unflitred.GetElement(l).Count() > 1)
100  {
101  string key = button_marker_groups_unflitred.GetKey(l);
102  button_marker_groups.Insert(button_marker_groups_unflitred.GetKey(l), button_marker_groups_unflitred.Get(key));
103  }
104  }
105 
106  Widget controls_image;
107  // hide all button markers
108  #ifdef PLATFORM_XBOX
109  controls_image = layoutRoot.FindAnyWidget("XboxControlsImage");
110  #else
111  #ifdef PLATFORM_PS4
112  controls_image = layoutRoot.FindAnyWidget("PSControlsImage");
113  #endif
114  #endif
115 
116  Widget child = controls_image.GetChildren();
117  child.Show(false);
118  while (child.GetSibling())
119  {
120  child = child.GetSibling();
121  child.Show(false);
122  }
123 
124  Widget panel_widget;
125  Widget button_marker_widget;
126 
127  for (l = 0; l < tab_array[index].Count(); l++)
128  {
129  panel_widget = layoutRoot.FindAnyWidget("PanelWidget" + l);
130  if (tab_array[index][l] != null)
131  {
132  TextWidget text_widget = TextWidget.Cast(panel_widget.FindAnyWidget("TextWidget" + l));
133 
134  string key_prefix;
135  #ifdef PLATFORM_XBOX
136  key_prefix = "xb_button_marker_";
137  #else
138  #ifdef PLATFORM_PS4
139  key_prefix = "ps_button_marker_";
140  #endif
141  #endif
142 
143  button_marker_widget = layoutRoot.FindAnyWidget(key_prefix + tab_array[index][l].m_ButtonName);
144  text_widget.SetText(tab_array[index][l].m_InfoText);
145  panel_widget.Show(true);
146  button_marker_widget.Show(true);
147  panel_widget.Update();
148  if (!button_marker_groups.Contains(tab_array[index][l].m_ButtonName))
149  {
150  panel_widget.GetScreenPos(text_widget_pos_x, text_widget_pos_y);
151  panel_widget.GetScreenSize(text_widget_width,text_widget_height);
152 
153  button_marker_widget.GetScreenPos(dot_pos_x, dot_pos_y);
154  button_marker_widget.GetScreenSize(dot_width, dot_height);
155 
156  draw_pos_y = text_widget_pos_y + text_widget_height / 2;
157  if (l < 10)
158  {
159  draw_pos_x = text_widget_pos_x + text_widget_width - 1;
160  }
161  else
162  {
163  draw_pos_x = text_widget_pos_x;
164  }
165  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));
166  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));
167  }
168  }
169  else
170  {
171  panel_widget.Show(false);
172  }
173  panel_widget.Update();
174  }
175 
176  // draw connecting lines
177  for (l = 0; l < button_marker_groups.Count(); l++)
178  {
179  text_widget_pos_x = 0;
180  text_widget_pos_y = 0;
181  text_widget_width = 0;
182  text_widget_height = 0;
183  float group_point_x = 0, group_point_y = 0;
184  float first_x = 0, first_y = 0;
185 
186  ref array<int> element = button_marker_groups.GetElement(l);
187  string key_name = button_marker_groups.GetKey(l);
188  #ifdef PLATFORM_XBOX
189  key_prefix = "xb_button_marker_";
190  #else
191  #ifdef PLATFORM_PS4
192  key_prefix = "ps_button_marker_";
193  #endif
194  #endif
195  button_marker_widget = layoutRoot.FindAnyWidget(key_prefix + key_name);
196 
197  for (int g = 0; g < element.Count(); g++)
198  {
199  panel_widget = layoutRoot.FindAnyWidget("PanelWidget" + element[g]);
200 
201  panel_widget.GetScreenPos(text_widget_pos_x, text_widget_pos_y);
202  panel_widget.GetScreenSize(text_widget_width, text_widget_height);
203 
204  if (g == 0)
205  {
206  if (element[0] < 10)
207  {
208  first_x = text_widget_pos_x + text_widget_width +50;
209  }
210  else
211  {
212  first_x = text_widget_pos_x - 50;
213  }
214 
215  first_y = text_widget_pos_y + text_widget_height/2;
216  }
217 
218  group_point_x += text_widget_pos_x;
219  group_point_y += text_widget_pos_y;
220  if (element[0] < 10)
221  {
222  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));
223  }
224  else
225  {
226  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));
227  }
228  }
229  if (element[0] < 10)
230  {
231  group_point_x = group_point_x/element.Count() + text_widget_width + 50;
232  }
233  else
234  {
235  group_point_x = group_point_x/element.Count() - 50;
236  }
237 
238  if (element.Count() % 2 == 0)
239  {
240  group_point_y = ((text_widget_pos_y + text_widget_height/2) - first_y) / 2 + first_y;
241  }
242  else
243  {
244  float text_widget_pos_x_center, text_widget_pos_y_center;
245  float text_widget_width_center, text_widget_height_center;
246 
247  panel_widget = layoutRoot.FindAnyWidget("PanelWidget" + element[1]);
248 
249  panel_widget.GetScreenPos(text_widget_pos_x_center, text_widget_pos_y_center);
250  panel_widget.GetScreenSize(text_widget_width_center, text_widget_height_center);
251 
252  group_point_y = text_widget_pos_y_center + text_widget_height_center / 2;
253  }
254 
255  button_marker_widget.GetScreenPos(dot_pos_x, dot_pos_y);
256  button_marker_widget.GetScreenSize(dot_width, dot_height);
257 
258  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));
259  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));
260 
261  if (element[0] < 10)
262  {
263  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));
264  }
265  else
266  {
267  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));
268  }
269  }
270  }
271 
273  {
275 
276  string file_path = "xbox/pagedatacontroller.json";
277  #ifdef PLATFORM_PS4
278  file_path = "ps4/pagedatacontroller.json";
279  #endif
280  FileHandle file_handle = OpenFile(file_path, FileMode.READ);
281  JsonSerializer js = new JsonSerializer();
282 
283  string js_error = "";
284  string line_content = "";
285  string content = "";
286  if (file_handle)
287  {
288  while (FGets(file_handle, line_content) >= 0)
289  {
290  content += line_content;
291  }
292  CloseFile(file_handle);
293 
294  if (js.ReadFromString(control_mapping_info, content, js_error))
295  {
296  return control_mapping_info;
297  }
298  else
299  {
300  ErrorEx("JSON ERROR => [ControlMappingInfo.json]: "+ js_error,ErrorExSeverity.INFO);
301  }
302  }
303 
304  return control_mapping_info;
305  }
306 
307  //============================================
308  // Init
309  //============================================
310  override Widget Init()
311  {
312  layoutRoot = GetGame().GetWorkspace().CreateWidgets("gui/layouts/xbox/control_mapping_info_screen.layout");
313 
314  layoutRoot.FindAnyWidget("Tabber").GetScript(m_TabScript);
315 
316  m_TabScript.m_OnTabSwitch.Insert(DrawConnectingLines);
317 
318  m_Back = ButtonWidget.Cast(layoutRoot.FindAnyWidget("back"));
319 
320  #ifdef PLATFORM_CONSOLE
321  RichTextWidget toolbar_switch = RichTextWidget.Cast(layoutRoot.FindAnyWidget("ChangePresetIcon"));
322  RichTextWidget toolbar_back = RichTextWidget.Cast(layoutRoot.FindAnyWidget("BackIcon"));
323  toolbar_switch.SetText(InputUtils.GetRichtextButtonIconFromInputAction("UASwitchPreset", "", EUAINPUT_DEVICE_CONTROLLER, InputUtils.ICON_SCALE_TOOLBAR));
324  toolbar_back.SetText(InputUtils.GetRichtextButtonIconFromInputAction("UAUIBack", "", EUAINPUT_DEVICE_CONTROLLER, InputUtils.ICON_SCALE_TOOLBAR));
325  #endif
326 
327  #ifdef PLATFORM_XBOX
328  layoutRoot.FindAnyWidget("XboxControlsImage").Show(true);
329  #else
330  #ifdef PLATFORM_PS4
331  layoutRoot.FindAnyWidget("PSControlsImage").Show(true);
332  #endif
333  #endif
334 
335  m_tab_images[0] = ImageWidget.Cast(layoutRoot.FindAnyWidget("MovementTabBackdropImageWidget"));
336  m_tab_images[1] = ImageWidget.Cast(layoutRoot.FindAnyWidget("WeaponsAndActionsBackdropImageWidget"));
337  m_tab_images[2] = ImageWidget.Cast(layoutRoot.FindAnyWidget("InventoryTabBackdropImageWidget"));
338  m_tab_images[3] = ImageWidget.Cast(layoutRoot.FindAnyWidget("MenusTabBackdropImageWidget"));
339 
340  PPERequester_MenuEffects requester;
341  Class.CastTo(requester,PPERequesterBank.GetRequester(PPERequesterBank.REQ_MENUEFFECTS));
342  requester.SetVignetteIntensity(0.6);
343 
345 
346  return layoutRoot;
347  }
348 
349  override void OnShow()
350  {
351  super.OnShow();
352  #ifdef PLATFORM_CONSOLE
353  //layoutRoot.FindAnyWidget("toolbar_bg").Show(!GetGame().GetInput().IsEnabledMouseAndKeyboard());
354  layoutRoot.FindAnyWidget("toolbar_bg").Show(true);//TODO: temporarily always on for preset switching
355 
356  string preset_text;
357  UAInputAPI inputAPI = GetUApi();
358  TextWidget nameWidget;
359  if (Class.CastTo(nameWidget,layoutRoot.FindAnyWidget("PresetText")));
360  {
361  preset_text = inputAPI.PresetName(inputAPI.PresetCurrent());
362  nameWidget.SetText(preset_text);
363  }
364  #endif
365  }
366 
367  override bool OnClick(Widget w, int x, int y, int button)
368  {
369  if (button == MouseState.LEFT)
370  {
371  if (w == m_Back)
372  {
373  Back();
374  return true;
375  }
376  }
377  return false;
378  }
379 
380  override void Update(float timeslice)
381  {
382  if (GetUApi().GetInputByID(UAUITabLeft).LocalPress())
383  {
384  m_TabScript.PreviousTab();
385  }
386 
387  if (GetUApi().GetInputByID(UAUITabRight).LocalPress())
388  {
389  m_TabScript.NextTab();
390  }
391 
392  if (GetUApi().GetInputByID(UAUIBack).LocalPress())
393  {
394  Back();
395  }
396 
397  if (GetUApi().GetInputByID(UASwitchPreset).LocalPress())
398  {
399  SwitchPreset();
400  }
401  }
402 
404  protected void LoadFooterButtonTexts()
405  {
406  TextWidget uiBackText = TextWidget.Cast(layoutRoot.FindAnyWidget("BackText"));
407  if (uiBackText)
408  {
409  uiBackText.SetText(m_BackButtonTextID);
410  }
411  }
412 
414  protected void LoadTextStrings()
415  {
416  #ifdef PLATFORM_PS4
417  m_BackButtonTextID = "ps4_ingame_menu_back";
418  #else
419  m_BackButtonTextID = "STR_rootFrame_toolbar_bg_ConsoleToolbar_Back_BackText0";
420  #endif
421  }
422 
423  protected void SwitchPreset()
424  {
425  int index;
426  string preset_text;
427  UAInputAPI inputAPI = GetUApi();
428  TextWidget nameWidget;
429 
430  index = inputAPI.PresetCurrent() + 1;
431  if (index >= inputAPI.PresetCount())
432  {
433  index = 0;
434  }
435 
436  inputAPI.PresetSelect(index);
437  if (Class.CastTo(nameWidget,layoutRoot.FindAnyWidget("PresetText")));
438  {
439  preset_text = inputAPI.PresetName(inputAPI.PresetCurrent());
440  nameWidget.SetText(preset_text);
441  }
442 
443  GetGame().GetInput().SetProfile(index);
444  GetUApi().Export();
445  GetGame().GetMission().GetOnInputPresetChanged().Invoke();
446  }
447 }
GetGame
proto native CGame GetGame()
UIScriptedMenu
Definition: dayzgame.c:63
CloseFile
proto void CloseFile(FileHandle file)
Close the File.
TABS_COUNT
const protected int TABS_COUNT
Definition: controlsxbox.c:19
JsonControlMappingInfo
Definition: controlsxbox.c:5
OnClick
override bool OnClick(Widget w, int x, int y, int button)
Definition: controlsxbox.c:367
OpenFile
proto FileHandle OpenFile(string name, FileMode mode)
Opens File.
InputUtils
Definition: inpututils.c:1
DrawConnectingLines
void DrawConnectingLines(int index)
Definition: controlsxbox.c:41
Back
void Back()
Definition: controlsxbox.c:36
JsonSerializer
Class for sending RPC over network.
Definition: gameplay.c:49
Init
override Widget Init()
Launched from 'DayZGame.DeferredInit' to make earlier access, use, and updates impossible (downside o...
Definition: controlsxbox.c:310
y
Icon y
m_BackButtonTextID
class JsonControlMappingInfo m_BackButtonTextID
FileMode
FileMode
Definition: ensystem.c:382
SwitchPreset
protected void SwitchPreset()
Definition: controlsxbox.c:423
ErrorEx
enum ShapeType ErrorEx
RichTextWidget
Definition: gameplay.c:315
map
map
Definition: controlsxboxnew.c:3
m_Back
protected ButtonWidget m_Back
Definition: controlsxbox.c:17
TextWidget
Definition: enwidgets.c:219
FGets
proto int FGets(FileHandle file, string var)
Get line from file, every next call of this function returns next line.
ErrorExSeverity
ErrorExSeverity
Definition: endebug.c:61
LoadFooterButtonTexts
protected void LoadFooterButtonTexts()
Initial texts load for the footer buttons.
Definition: controlsxbox.c:404
~ControlsXbox
void ~ControlsXbox()
Definition: controlsxbox.c:31
ARGBF
int ARGBF(float fa, float fr, float fg, float fb)
Converts <0.0, 1.0> ARGB into color.
Definition: proto.c:332
MouseState
MouseState
Definition: ensystem.c:310
m_ControlsLayoutImage
protected ImageWidget m_ControlsLayoutImage
Definition: controlsxbox.c:18
ControlsXbox
void ControlsXbox()
Definition: controlsxbox.c:26
LoadTextStrings
protected void LoadTextStrings()
Set correct bottom button texts based on platform (ps4 vs xbox texts)
Definition: controlsxbox.c:414
array
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
Definition: isboxcollidinggeometryproxyclasses.c:27
x
Icon x
FileHandle
int[] FileHandle
Definition: ensystem.c:390
OnShow
override void OnShow()
Definition: controlsxbox.c:349
Widget
Definition: enwidgets.c:189
UAInputAPI
Definition: uainput.c:164
GetUApi
proto native UAInputAPI GetUApi()
GetControlMappingInfo
protected array< ref JsonControlMappingInfo > GetControlMappingInfo()
Definition: controlsxbox.c:272
m_tab_images
protected ImageWidget m_tab_images[TABS_COUNT]
Definition: controlsxbox.c:20
Class
Super root of all classes in Enforce script.
Definition: enscript.c:10
Update
override void Update(float timeslice)
Definition: controlsxbox.c:380
m_TabScript
protected TabberUI m_TabScript
Definition: controlsxbox.c:21