DayZ 1.27
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 {
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);
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();
446 }
447}
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:423
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
map
Определения ControlsXboxNew.c:4
Icon x
Icon y
proto native UAInputAPI GetUApi()
proto native UIManager GetUIManager()
proto native WorkspaceWidget GetWorkspace()
proto native Input GetInput()
proto native Mission GetMission()
Super root of all classes in Enforce script.
Определения EnScript.c:11
proto native int SetProfile(int index)
setting active profile
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
ScriptInvoker GetOnInputPresetChanged()
Определения gameplay.c:859
Определения gameplay.c:317
proto void Invoke(void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL)
invoke call on all inserted methods with given arguments
Определения 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
bool Back()
Close top window on windows stack, returns true when any window is closed.
Определения UIManager.c:62
void LoadFooterButtonTexts()
Initial texts load for the footer buttons.
Определения InGameMenuXbox.c:820
override void OnShow()
Определения CameraToolsMenu.c:99
void LoadTextStrings()
Set correct bottom button texts based on platform (ps4 vs xbox texts)
Определения InGameMenuXbox.c:802
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.
proto native CGame GetGame()
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 external Widget CreateWidgets(string layout, Widget parentWidget=NULL, bool immedUpdate=true)
Create widgets from *.layout file.
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