DayZ 1.29
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
ControlsXbox.c
См. документацию.
1/*
2DEPRECATED CONTENT
3*/
4
12
13class 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 //============================================
27 {
28
29 }
30
32 {
33 PPERequesterBank.GetRequester(PPERequester_ControlsBlur).Stop();
34 }
35
36 void Back()
37 {
38 g_Game.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 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_MSSTORE
109 controls_image = layoutRoot.FindAnyWidget("XboxControlsImage");
110 #else
111 #ifdef PLATFORM_XBOX
112 controls_image = layoutRoot.FindAnyWidget("XboxControlsImage");
113 #else
114 #ifdef PLATFORM_PS4
115 controls_image = layoutRoot.FindAnyWidget("PSControlsImage");
116 #endif
117 #endif
118 #endif
119
120 Widget child = controls_image.GetChildren();
121 child.Show(false);
122 while (child.GetSibling())
123 {
124 child = child.GetSibling();
125 child.Show(false);
126 }
127
128 Widget panel_widget;
129 Widget button_marker_widget;
130
131 for (l = 0; l < tab_array[index].Count(); l++)
132 {
133 panel_widget = layoutRoot.FindAnyWidget("PanelWidget" + l);
134 if (tab_array[index][l] != null)
135 {
136 TextWidget text_widget = TextWidget.Cast(panel_widget.FindAnyWidget("TextWidget" + l));
137
138 string key_prefix;
139 #ifdef PLATFORM_MSSTORE
140 key_prefix = "xb_button_marker_";
141 #else
142 #ifdef PLATFORM_XBOX
143 key_prefix = "xb_button_marker_";
144 #else
145 #ifdef PLATFORM_PS4
146 key_prefix = "ps_button_marker_";
147 #endif
148 #endif
149 #endif
150
151 button_marker_widget = layoutRoot.FindAnyWidget(key_prefix + tab_array[index][l].m_ButtonName);
152 text_widget.SetText(tab_array[index][l].m_InfoText);
153 panel_widget.Show(true);
154 button_marker_widget.Show(true);
155 panel_widget.Update();
156 if (!button_marker_groups.Contains(tab_array[index][l].m_ButtonName))
157 {
158 panel_widget.GetScreenPos(text_widget_pos_x, text_widget_pos_y);
159 panel_widget.GetScreenSize(text_widget_width,text_widget_height);
160
161 button_marker_widget.GetScreenPos(dot_pos_x, dot_pos_y);
162 button_marker_widget.GetScreenSize(dot_width, dot_height);
163
164 draw_pos_y = text_widget_pos_y + text_widget_height / 2;
165 if (l < 10)
166 {
167 draw_pos_x = text_widget_pos_x + text_widget_width - 1;
168 }
169 else
170 {
171 draw_pos_x = text_widget_pos_x;
172 }
173 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));
174 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));
175 }
176 }
177 else
178 {
179 panel_widget.Show(false);
180 }
181 panel_widget.Update();
182 }
183
184 // draw connecting lines
185 for (l = 0; l < button_marker_groups.Count(); l++)
186 {
187 text_widget_pos_x = 0;
188 text_widget_pos_y = 0;
189 text_widget_width = 0;
190 text_widget_height = 0;
191 float group_point_x = 0, group_point_y = 0;
192 float first_x = 0, first_y = 0;
193
194 ref array<int> element = button_marker_groups.GetElement(l);
195 string key_name = button_marker_groups.GetKey(l);
196
197 #ifdef PLATFORM_MSSTORE
198 key_prefix = "xb_button_marker_";
199 #else
200 #ifdef PLATFORM_XBOX
201 key_prefix = "xb_button_marker_";
202 #else
203 #ifdef PLATFORM_PS4
204 key_prefix = "ps_button_marker_";
205 #endif
206 #endif
207 #endif
208 button_marker_widget = layoutRoot.FindAnyWidget(key_prefix + key_name);
209
210 for (int g = 0; g < element.Count(); g++)
211 {
212 panel_widget = layoutRoot.FindAnyWidget("PanelWidget" + element[g]);
213
214 panel_widget.GetScreenPos(text_widget_pos_x, text_widget_pos_y);
215 panel_widget.GetScreenSize(text_widget_width, text_widget_height);
216
217 if (g == 0)
218 {
219 if (element[0] < 10)
220 {
221 first_x = text_widget_pos_x + text_widget_width +50;
222 }
223 else
224 {
225 first_x = text_widget_pos_x - 50;
226 }
227
228 first_y = text_widget_pos_y + text_widget_height/2;
229 }
230
231 group_point_x += text_widget_pos_x;
232 group_point_y += text_widget_pos_y;
233 if (element[0] < 10)
234 {
235 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));
236 }
237 else
238 {
239 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));
240 }
241 }
242 if (element[0] < 10)
243 {
244 group_point_x = group_point_x/element.Count() + text_widget_width + 50;
245 }
246 else
247 {
248 group_point_x = group_point_x/element.Count() - 50;
249 }
250
251 if (element.Count() % 2 == 0)
252 {
253 group_point_y = ((text_widget_pos_y + text_widget_height/2) - first_y) / 2 + first_y;
254 }
255 else
256 {
257 float text_widget_pos_x_center, text_widget_pos_y_center;
258 float text_widget_width_center, text_widget_height_center;
259
260 panel_widget = layoutRoot.FindAnyWidget("PanelWidget" + element[1]);
261
262 panel_widget.GetScreenPos(text_widget_pos_x_center, text_widget_pos_y_center);
263 panel_widget.GetScreenSize(text_widget_width_center, text_widget_height_center);
264
265 group_point_y = text_widget_pos_y_center + text_widget_height_center / 2;
266 }
267
268 button_marker_widget.GetScreenPos(dot_pos_x, dot_pos_y);
269 button_marker_widget.GetScreenSize(dot_width, dot_height);
270
271 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));
272 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));
273
274 if (element[0] < 10)
275 {
276 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));
277 }
278 else
279 {
280 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));
281 }
282 }
283 }
284
286 {
288
289 string file_path = "xbox/pagedatacontroller.json";
290 #ifdef PLATFORM_PS4
291 file_path = "ps4/pagedatacontroller.json";
292 #endif
293 FileHandle file_handle = OpenFile(file_path, FileMode.READ);
295
296 string js_error = "";
297 string line_content = "";
298 string content = "";
299 if (file_handle)
300 {
301 while (FGets(file_handle, line_content) >= 0)
302 {
303 content += line_content;
304 }
305 CloseFile(file_handle);
306
307 if (js.ReadFromString(control_mapping_info, content, js_error))
308 {
309 return control_mapping_info;
310 }
311 else
312 {
313 ErrorEx("JSON ERROR => [ControlMappingInfo.json]: "+ js_error,ErrorExSeverity.INFO);
314 }
315 }
316
317 return control_mapping_info;
318 }
319
320 //============================================
321 // Init
322 //============================================
323 override Widget Init()
324 {
325 layoutRoot = g_Game.GetWorkspace().CreateWidgets("gui/layouts/xbox/control_mapping_info_screen.layout");
326
327 layoutRoot.FindAnyWidget("Tabber").GetScript(m_TabScript);
328
329 m_TabScript.m_OnTabSwitch.Insert(DrawConnectingLines);
330
331 m_Back = ButtonWidget.Cast(layoutRoot.FindAnyWidget("back"));
332
333 #ifdef PLATFORM_CONSOLE
334 RichTextWidget toolbar_switch = RichTextWidget.Cast(layoutRoot.FindAnyWidget("ChangePresetIcon"));
335 RichTextWidget toolbar_back = RichTextWidget.Cast(layoutRoot.FindAnyWidget("BackIcon"));
336 toolbar_switch.SetText(InputUtils.GetRichtextButtonIconFromInputAction("UASwitchPreset", "", EUAINPUT_DEVICE_CONTROLLER, InputUtils.ICON_SCALE_TOOLBAR));
337 toolbar_back.SetText(InputUtils.GetRichtextButtonIconFromInputAction("UAUIBack", "", EUAINPUT_DEVICE_CONTROLLER, InputUtils.ICON_SCALE_TOOLBAR));
338 #endif
339
340 #ifdef PLATFORM_XBOX
341 layoutRoot.FindAnyWidget("XboxControlsImage").Show(true);
342 #else
343 #ifdef PLATFORM_PS4
344 layoutRoot.FindAnyWidget("PSControlsImage").Show(true);
345 #endif
346 #endif
347
348 m_tab_images[0] = ImageWidget.Cast(layoutRoot.FindAnyWidget("MovementTabBackdropImageWidget"));
349 m_tab_images[1] = ImageWidget.Cast(layoutRoot.FindAnyWidget("WeaponsAndActionsBackdropImageWidget"));
350 m_tab_images[2] = ImageWidget.Cast(layoutRoot.FindAnyWidget("InventoryTabBackdropImageWidget"));
351 m_tab_images[3] = ImageWidget.Cast(layoutRoot.FindAnyWidget("MenusTabBackdropImageWidget"));
352
353 PPERequester_MenuEffects requester;
354 Class.CastTo(requester,PPERequesterBank.GetRequester(PPERequesterBank.REQ_MENUEFFECTS));
355 requester.SetVignetteIntensity(0.6);
356
358
359 return layoutRoot;
360 }
361
362 override void OnShow()
363 {
364 super.OnShow();
365 #ifdef PLATFORM_CONSOLE
366 //layoutRoot.FindAnyWidget("toolbar_bg").Show(!g_Game.GetInput().IsEnabledMouseAndKeyboard());
367 layoutRoot.FindAnyWidget("toolbar_bg").Show(true);//TODO: temporarily always on for preset switching
368
369 string preset_text;
370 UAInputAPI inputAPI = GetUApi();
371 TextWidget nameWidget;
372 if (Class.CastTo(nameWidget,layoutRoot.FindAnyWidget("PresetText")))
373 {
374 preset_text = inputAPI.PresetName(inputAPI.PresetCurrent());
375 nameWidget.SetText(preset_text);
376 }
377 #endif
378 }
379
380 override bool OnClick(Widget w, int x, int y, int button)
381 {
382 if (button == MouseState.LEFT)
383 {
384 if (w == m_Back)
385 {
386 Back();
387 return true;
388 }
389 }
390 return false;
391 }
392
393 override void Update(float timeslice)
394 {
395 if (GetUApi().GetInputByID(UAUITabLeft).LocalPress())
396 {
397 m_TabScript.PreviousTab();
398 }
399
400 if (GetUApi().GetInputByID(UAUITabRight).LocalPress())
401 {
402 m_TabScript.NextTab();
403 }
404
405 if (GetUApi().GetInputByID(UAUIBack).LocalPress())
406 {
407 Back();
408 }
409
410 if (GetUApi().GetInputByID(UASwitchPreset).LocalPress())
411 {
412 SwitchPreset();
413 }
414 }
415
417 protected void LoadFooterButtonTexts()
418 {
419 TextWidget uiBackText = TextWidget.Cast(layoutRoot.FindAnyWidget("BackText"));
420 if (uiBackText)
421 {
422 uiBackText.SetText(m_BackButtonTextID);
423 }
424 }
425
427 protected void LoadTextStrings()
428 {
429 #ifdef PLATFORM_PS4
430 m_BackButtonTextID = "ps4_ingame_menu_back";
431 #else
432 m_BackButtonTextID = "STR_rootFrame_toolbar_bg_ConsoleToolbar_Back_BackText0";
433 #endif
434 }
435
436 protected void SwitchPreset()
437 {
438 int index;
439 string preset_text;
440 UAInputAPI inputAPI = GetUApi();
441 TextWidget nameWidget;
442
443 index = inputAPI.PresetCurrent() + 1;
444 if (index >= inputAPI.PresetCount())
445 {
446 index = 0;
447 }
448
449 inputAPI.PresetSelect(index);
450 if (Class.CastTo(nameWidget,layoutRoot.FindAnyWidget("PresetText")))
451 {
452 preset_text = inputAPI.PresetName(inputAPI.PresetCurrent());
453 nameWidget.SetText(preset_text);
454 }
455
456 g_Game.GetInput().SetProfile(index);
457 GetUApi().Export();
458 g_Game.GetMission().GetOnInputPresetChanged().Invoke();
459 }
460}
class JsonControlMappingInfo m_BackButtonTextID
void ~ControlsXbox()
Определения ControlsXbox.c:31
const int TABS_COUNT
Определения ControlsXbox.c:19
ImageWidget m_ControlsLayoutImage
Определения ControlsXbox.c:18
void SwitchPreset()
Определения ControlsXbox.c:436
void DrawConnectingLines(int index)
Определения ControlsXbox.c:41
TabberUI m_TabScript
Определения ControlsXbox.c:21
ButtonWidget m_Back
Определения ControlsXbox.c:17
ImageWidget m_tab_images[TABS_COUNT]
Определения ControlsXbox.c:20
void ControlsXbox()
Определения ControlsXbox.c:26
DayZGame g_Game
Определения DayZGame.c:3942
Icon x
Icon y
proto native UAInputAPI GetUApi()
Super root of all classes in Enforce script.
Определения EnScript.c:11
static string GetRichtextButtonIconFromInputAction(notnull UAInput pInput, string pLocalizedDescription, int pInputDeviceType=EUAINPUT_DEVICE_CONTROLLER, float pScale=ICON_SCALE_NORMAL, bool pVertical=false)
Определения InputUtils.c:167
static const float ICON_SCALE_TOOLBAR
Определения InputUtils.c:15
Определения InputUtils.c:2
int m_TabID
Определения ControlsXbox.c:7
int m_TextWidgetID
Определения ControlsXbox.c:8
string m_ButtonName
Определения ControlsXbox.c:9
string m_InfoText
Определения ControlsXbox.c:10
proto bool ReadFromString(void variable_in, string jsonString, out string error)
Json string deserialization to script variable.
Class for sending RPC over network.
Определения gameplay.c:50
Определения gameplay.c:317
Определения EnWidgets.c:220
proto native owned string PresetName(int index)
proto native int PresetCurrent()
proto native void PresetSelect(int index)
proto native int PresetCount()
proto native void Export()
Определения UAInput.c:166
void LoadFooterButtonTexts()
Initial texts load for the footer buttons.
Определения InGameMenuXbox.c:939
override void OnShow()
Определения CameraToolsMenu.c:99
void LoadTextStrings()
Set correct bottom button texts based on platform (ps4 vs xbox texts)
Определения InGameMenuXbox.c:921
void Back()
Определения ControlsXboxNew.c:96
void DrawConnectingLines(int index)
Определения ControlsXboxNew.c:130
override Widget Init()
Определения BookMenu.c:11
override bool OnClick(Widget w, int x, int y, int button)
Определения BookMenu.c:34
array< ref JsonControlMappingInfo > GetControlMappingInfo()
Определения TutorialsMenu.c:315
Определения DayZGame.c:64
Определения EnWidgets.c:190
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
Определения CachedEquipmentStorage.c:4
ErrorExSeverity
Определения 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
Определения 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.
int[] FileHandle
Определения EnSystem.c:390
MouseState
Определения EnSystem.c:311
proto native volatile void Update()
Определения PlayerSoundManager.c:125
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