DayZ 1.29
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
KeybindingsMenu.c
См. документацию.
1class KeybindingsMenu extends UIScriptedMenu
2{
3 protected TabberUI m_Tabber;
4 protected ref DropdownPrefab m_KBDropdown; //DEPRECATED
5 protected ref OptionSelectorMultistate m_PresetSelector;
6 protected ref KeybindingsContainer m_GroupsContainer;
7 protected ref array<ref KeybindingsGroup> m_Tabs; //DEPRECATED
8
9 protected TextWidget m_Version;
10 protected ButtonWidget m_Apply;
11 protected ButtonWidget m_Back;
12 protected ButtonWidget m_Undo;
13 protected ButtonWidget m_Defaults;
14 protected ButtonWidget m_HardReset;
15
16 protected int m_CurrentSettingKeyIndex = -1;
18 protected int m_OriginalPresetIndex;
19 protected int m_TargetPresetIndex;
21
22 const int MODAL_ID_BACK = 1337;
23 const int MODAL_ID_DEFAULT = 100;
24 const int MODAL_ID_DEFAULT_ALL = 101;
25 const int MODAL_ID_PRESET_CHANGE = 200;
28
29 override Widget Init()
30 {
31 Input input = g_Game.GetInput();
32 #ifdef PLATFORM_MSSTORE
33 layoutRoot = g_Game.GetWorkspace().CreateWidgets("gui/layouts/new_ui/options/msstore/keybinding_menu.layout", null);
34 #else
35 layoutRoot = g_Game.GetWorkspace().CreateWidgets("gui/layouts/new_ui/options/pc/keybinding_menu.layout", null);
36 #endif
37
38 m_Version = TextWidget.Cast(layoutRoot.FindAnyWidget("version"));
39 m_Apply = ButtonWidget.Cast(layoutRoot.FindAnyWidget("apply"));
40 m_Back = ButtonWidget.Cast(layoutRoot.FindAnyWidget("back"));
41 m_Undo = ButtonWidget.Cast(layoutRoot.FindAnyWidget("undo"));
42 m_Defaults = ButtonWidget.Cast(layoutRoot.FindAnyWidget("reset"));
43 m_HardReset = ButtonWidget.Cast(layoutRoot.FindAnyWidget("reset_all"));
44
45 layoutRoot.FindAnyWidget("Tabber").GetScript(m_Tabber);
46
47 string version;
48 g_Game.GetVersion(version);
49 #ifdef PLATFORM_CONSOLE
50 version = "#main_menu_version" + " " + version + " (" + g_Game.GetDatabaseID() + ")";
51 #else
52 version = "#main_menu_version" + " " + version;
53 #endif
54 m_Version.SetText(version);
55
56 #ifdef PLATFORM_PS4
57 string back = "circle";
58 if (g_Game.GetInput().GetEnterButton() != GamepadButton.A)
59 back = "cross";
60
61 ImageWidget toolbar_b = ImageWidget.Cast(layoutRoot.FindAnyWidget("BackIcon"));
62 toolbar_b.LoadImageFile(0, "set:playstation_buttons image:" + back);
63 #endif
64
66 CreateTabs();
68
69 InitPresets(-1, layoutRoot.FindAnyWidget("group_header"), input);
70 m_Tabber.m_OnTabSwitch.Insert(UpdateTabContent);
71 m_Tabber.SelectTabControl(0);
72 m_Tabber.SelectTabPanel(0);
73 g_Game.SetKeyboardHandle(this);
74 m_Tabber.RefreshTab(true);
75
77 m_Apply.SetFlags(WidgetFlags.IGNOREPOINTER);
79 m_Undo.SetFlags(WidgetFlags.IGNOREPOINTER);
81 m_Defaults.ClearFlags(WidgetFlags.IGNOREPOINTER);
82
83 return layoutRoot;
84 }
85
87 {
88 int sort_count = InputUtils.GetInputActionSortingMap().Count();
89 for (int i = 0; i < sort_count; i++)
90 {
91 if (InputUtils.GetInputActionSortingMap().GetElement(i) && InputUtils.GetInputActionSortingMap().GetElement(i).Count() > 0)
92 {
93 string group_name = GetUApi().SortingLocalization(InputUtils.GetInputActionSortingMap().GetKey(i));
94 group_name = Widget.TranslateString("#" + group_name); //oof
95 m_Tabber.AddTab(group_name);
96 }
97 }
98
100 {
101 m_Tabber.AddTab(Widget.TranslateString("#layout_pc_keybinding_unsorted"));
102 }
103 m_Tabber.DisableTabs(true);
104 }
105
107 {
108 m_GroupsContainer = new KeybindingsContainer(-1,g_Game.GetInput(),layoutRoot.FindAnyWidget("TabContentsHolder"),this);
109 }
110
111 void UpdateTabContent(int tab_index)
112 {
113 m_GroupsContainer.SwitchSubgroup(tab_index);
114 }
115
116 void ClearKeybind(int key_index)
117 {
118 ColorWhite(m_Apply, null);
119 m_Apply.ClearFlags(WidgetFlags.IGNOREPOINTER);
120 ColorWhite(m_Undo, null);
121 m_Undo.ClearFlags(WidgetFlags.IGNOREPOINTER);
122 }
123
124 void ClearAlternativeKeybind(int key_index)
125 {
126 ColorWhite(m_Apply, null);
127 m_Apply.ClearFlags(WidgetFlags.IGNOREPOINTER);
128 ColorWhite(m_Undo, null);
129 m_Undo.ClearFlags(WidgetFlags.IGNOREPOINTER);
130 }
131
132 void StartEnteringKeybind(int key_index)
133 {
135 m_CurrentSettingKeyIndex = key_index;
136 }
137
139 {
140 m_GroupsContainer.CancelEnteringKeybind();
142 }
143
145 {
148 }
149
151 {
152 m_GroupsContainer.CancelEnteringAlternateKeybind();
154 }
155
157 {
159 ColorWhite(m_Apply, null);
160 m_Apply.ClearFlags(WidgetFlags.IGNOREPOINTER);
161 ColorWhite(m_Undo, null);
162 m_Undo.ClearFlags(WidgetFlags.IGNOREPOINTER);
163 }
164
166 {
168 ColorWhite(m_Apply, null);
169 m_Apply.ClearFlags(WidgetFlags.IGNOREPOINTER);
170 ColorWhite(m_Undo, null);
171 m_Undo.ClearFlags(WidgetFlags.IGNOREPOINTER);
172 }
173
174 override void Update(float timeslice)
175 {
176 if (GetUApi().GetInputByID(UAUITabLeft).LocalPress())
177 {
178 m_Tabber.PreviousTab();
179 }
180
181 if (GetUApi().GetInputByID(UAUITabRight).LocalPress())
182 {
183 m_Tabber.NextTab();
184 }
185
186 if (GetUApi().GetInputByID(UAUIBack).LocalPress())
187 {
188 Back();
189 }
190
192 {
193 m_GroupsContainer.Update(timeslice);
194 }
195 }
196
197 override bool OnClick(Widget w, int x, int y, int button)
198 {
199 #ifndef PLATFORM_MSSTORE
200 if (button == MouseState.LEFT)
201 #endif
202 {
203 if (w == m_Apply)
204 {
205 Apply();
206 return true;
207 }
208 else if (w == m_Back)
209 {
210 Back();
211 return true;
212 }
213 else if (w == m_Undo)
214 {
215 Reset();
216 return true;
217 }
218 else if (w == m_Defaults)
219 {
221 return true;
222 }
223 else if (w == m_HardReset)
224 {
225 HardReset();
226 return true;
227 }
228 }
229 return false;
230 }
231
232 void Apply()
233 {
235 m_Apply.SetFlags(WidgetFlags.IGNOREPOINTER);
237 m_Undo.SetFlags(WidgetFlags.IGNOREPOINTER);
238 ColorWhite(m_Defaults, null);
239 m_Defaults.ClearFlags(WidgetFlags.IGNOREPOINTER);
240
241 m_GroupsContainer.Apply();
242
243 // save input configuration
244 GetUApi().Export();
245 }
246
247 void Back()
248 {
249 if (m_CurrentSettingKeyIndex != -1)
250 {
252 return;
253 }
254
256 {
258 return;
259 }
260
261 bool changed = m_GroupsContainer.IsChanged();
262
263 if (changed)
264 {
265 g_Game.GetUIManager().ShowDialog("#main_menu_configure", "#main_menu_configure_desc", MODAL_ID_BACK, DBT_YESNO, DBB_YES, DMT_QUESTION, this);
266 }
267 else
268 {
269 g_Game.GetUIManager().Back();
270 }
271 }
272
274 void Reset()
275 {
277 m_Apply.SetFlags(WidgetFlags.IGNOREPOINTER);
279 m_Undo.SetFlags(WidgetFlags.IGNOREPOINTER);
280
281 m_GroupsContainer.Reset();
282 }
283
285 {
286 g_Game.GetUIManager().ShowDialog("#menu_default_cap", "#menu_default_desc", MODAL_ID_DEFAULT, DBT_YESNO, DBB_YES, DMT_QUESTION, this);
287 }
288
290 {
291 g_Game.GetUIManager().ShowDialog("#menu_default_cap", "#menu_default_all_desc", MODAL_ID_DEFAULT_ALL, DBT_YESNO, DBB_YES, DMT_QUESTION, this);
292 }
293
295 {
296 switch (mode)
297 {
300 break;
301
303 GetUApi().Revert();
304 break;
305 }
306
308 m_Apply.SetFlags(WidgetFlags.IGNOREPOINTER);
310 m_Undo.SetFlags(WidgetFlags.IGNOREPOINTER);
311 g_Game.GetCallQueue(CALL_CATEGORY_GUI).Call(g_Game.GetMission().RefreshExcludes);
312 m_GroupsContainer.Reset(true);
313 }
314
315 override bool OnModalResult(Widget w, int x, int y, int code, int result)
316 {
317 if (code == MODAL_ID_BACK)
318 {
319 if (result == DBB_YES)
320 {
321 Reset();
322 g_Game.GetUIManager().Back();
323 }
324 return true;
325 }
326 else if (code == MODAL_ID_DEFAULT)
327 {
328 if (result == DBB_YES)
329 {
331 }
332 return true;
333 }
334 else if (code == MODAL_ID_DEFAULT_ALL)
335 {
336 if (result == DBB_YES)
337 {
339 }
340 }
341 else if (code == MODAL_ID_PRESET_CHANGE)
342 {
343 if (result == DBB_YES)
344 {
345 Reset();
346 m_PresetSelector.PerformSetOption(m_TargetPresetIndex);
347 }
348 return true;
349 }
350
351 return false;
352 }
353
354 override void Refresh()
355 {
356 string version;
357 g_Game.GetVersion(version);
358 #ifdef PLATFORM_CONSOLE
359 version = "#main_menu_version" + " " + version + " (" + g_Game.GetDatabaseID() + ")";
360 #else
361 version = "#main_menu_version" + " " + version;
362 #endif
363 m_Version.SetText(version);
364 }
365
366 override bool OnMouseEnter(Widget w, int x, int y)
367 {
368 if (w && IsFocusable(w))
369 {
370 ColorRed(w);
371 return true;
372 }
373 return false;
374 }
375
376 override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
377 {
378 if (w && IsFocusable(w))
379 {
380 if ((w.GetFlags() & WidgetFlags.DISABLED) || (w.GetFlags() & WidgetFlags.IGNOREPOINTER))
381 {
382 ColorDisabled(w);
383 }
384 else
385 {
386 ColorWhite(w, enterW);
387 }
388 return true;
389 }
390 return false;
391 }
392
393 override bool OnMouseWheel(Widget w, int x, int y, int wheel)
394 {
395 return super.OnMouseWheel(w, x, y, wheel);
396 }
397
398 override bool OnFocus(Widget w, int x, int y)
399 {
400 if (w && IsFocusable(w))
401 {
402 ColorRed(w);
403 return true;
404 }
405 return false;
406 }
407
408 override bool OnFocusLost(Widget w, int x, int y)
409 {
410 if (w && IsFocusable(w))
411 {
412 if ((w.GetFlags() & WidgetFlags.DISABLED) || (w.GetFlags() & WidgetFlags.IGNOREPOINTER))
413 {
414 ColorDisabled(w);
415 }
416 else
417 {
418 ColorWhite(w, null);
419 }
420 return true;
421 }
422 return false;
423 }
424
426 {
427 if (w)
428 {
429 return (w == m_Apply || w == m_Back || w == m_Undo || w == m_Defaults || w == m_HardReset);
430 }
431 return false;
432 }
433
434 //Coloring functions (Until WidgetStyles are useful)
436 {
437 SetFocus(w);
438
439 ButtonWidget button = ButtonWidget.Cast(w);
440 if (button && button != m_Apply)
441 {
442 button.SetTextColor(ARGB(255, 200, 0, 0));
443 }
444 }
445
446 void ColorWhite(Widget w, Widget enterW)
447 {
448 #ifdef PLATFORM_WINDOWS
449 SetFocus(null);
450 #endif
451
452 ButtonWidget button = ButtonWidget.Cast(w);
453 if (button)
454 {
455 if (button.GetFlags() & WidgetFlags.DISABLED)
456 {
457 button.SetTextColor(ColorManager.COLOR_DISABLED_TEXT);
458 }
459 else
460 {
461 button.SetTextColor(ColorManager.COLOR_NORMAL_TEXT);
462 }
463 }
464 }
465
467 {
468 #ifdef PLATFORM_WINDOWS
469 SetFocus(null);
470 #endif
471
472 ButtonWidget button = ButtonWidget.Cast(w);
473 if (button)
474 {
475 button.SetTextColor(ColorManager.COLOR_DISABLED_TEXT);
476 }
477 }
478
479 protected void InitInputSortingMap()
480 {
482 }
483
484 void InitPresets(int index, Widget parent, Input input)
485 {
486 Widget kb_root = parent.FindAnyWidget("keyboard_dropown");
487 if (kb_root)
488 {
489 kb_root.Show(false);
490 }
491
492 array<string> opt1 = new array<string>;
493 string profile_text;
494
495 for (int i = 0; i < input.GetProfilesCount(); i++)
496 {
497 input.GetProfileName(i, profile_text);
498 opt1.Insert(profile_text);
499 }
500
501 int current_idx = input.GetCurrentProfile();
502 m_OriginalPresetIndex = current_idx;
503 m_PresetSelector = new OptionSelectorMultistate(layoutRoot.FindAnyWidget("profile_setting_option"), current_idx, null, false, opt1);
504 m_PresetSelector.m_AttemptOptionChange.Insert(OnAttemptSelectPreset);
505 m_PresetSelector.m_OptionChanged.Insert(OnSelectKBPreset);
506 }
507
508 void OnAttemptSelectPreset(int index)
509 {
510 bool changed = m_GroupsContainer.IsChanged() && m_OriginalPresetIndex != index;
511 m_TargetPresetIndex = index;
512
513 if (changed)
514 {
515 g_Game.GetUIManager().ShowDialog("#main_menu_configure", "#main_menu_configure_desc", MODAL_ID_PRESET_CHANGE, DBT_YESNO, DBB_YES, DMT_QUESTION, this);
516 }
517
518 m_PresetSelector.SetCanSwitch(!changed);
519 }
520
521 void OnSelectKBPreset(int index)
522 {
523 m_OriginalPresetIndex = index;
524 m_GroupsContainer.OnSelectKBPreset(index);
525 string profile_text;
526 g_Game.GetInput().GetProfileName(index, profile_text);
527
528 g_Game.GetMission().GetOnInputPresetChanged().Invoke();
529 }
530
532// OBSOLETE METHODS //
534 KeybindingsContainer GetCurrentTab()
535 {
536 return m_GroupsContainer;
537 }
538
539 void AddGroup(int index, Input input)
540 {
541 }
542
548
550 {
551 }
552}
DayZGame g_Game
Определения DayZGame.c:3942
Icon x
Icon y
proto native UAInputAPI GetUApi()
static int COLOR_NORMAL_TEXT
Определения ColorManager.c:5
static int COLOR_DISABLED_TEXT
Определения ColorManager.c:11
Определения ColorManager.c:2
proto native int GetProfilesCount()
gets profile by name
proto int GetProfileName(int profile_index, out string name)
gets profile by index
proto native int GetCurrentProfile()
gets currently selected profile
Определения input.c:11
static map< int, ref array< int > > GetInputActionSortingMap()
Определения InputUtils.c:229
static bool InitInputMetadata()
Определения InputUtils.c:239
static array< int > GetUnsortedInputActions()
Определения InputUtils.c:234
Определения InputUtils.c:2
Определения EnWidgets.c:220
proto native owned string SortingLocalization(int index)
proto native void Export()
proto native void Revert()
proto native void PresetReset()
Resets current 'main' preset without reverting anything else ('softer' Revert)
override bool OnMouseEnter(Widget w, int x, int y)
Определения KeybindingsMenu.c:366
void PerformSetToDefaultsExt(int mode)
Определения KeybindingsMenu.c:294
ref array< int > m_SetKeybinds
Определения KeybindingsMenu.c:20
ButtonWidget m_HardReset
Определения KeybindingsMenu.c:14
void ClearAlternativeKeybind(int key_index)
Определения KeybindingsMenu.c:124
void AddGroup(int index, Input input)
Определения KeybindingsMenu.c:539
override bool OnFocus(Widget w, int x, int y)
Определения KeybindingsMenu.c:398
override void Update(float timeslice)
Определения KeybindingsMenu.c:174
void StartEnteringAlternateKeybind(int key_index)
Определения KeybindingsMenu.c:144
override void Refresh()
Определения KeybindingsMenu.c:354
TabberUI m_Tabber
Определения KeybindingsMenu.c:3
TextWidget m_Version
Определения InGameMenuXbox.c:36
const int MODAL_ID_DEFAULT
Определения KeybindingsMenu.c:23
void Reset()
Undoes the unsaved changes and reverts to previous state. Does not reset to defaults!
Определения KeybindingsMenu.c:274
int m_CurrentSettingKeyIndex
Определения KeybindingsMenu.c:16
bool IsFocusable(Widget w)
Определения CameraToolsMenu.c:960
Widget m_Apply
Определения CharacterCreationMenu.c:14
void DeferredDefaultsInit()
deprecated
Определения KeybindingsMenu.c:549
const int MODAL_RESULT_DEFAULT_ALL
Определения KeybindingsMenu.c:27
void Apply()
renames character
Определения CharacterCreationMenu.c:191
override bool OnMouseWheel(Widget w, int x, int y, int wheel)
Определения KeybindingsMenu.c:393
ref OptionSelectorMultistate m_PresetSelector
Определения KeybindingsMenu.c:5
ref KeybindingsContainer m_GroupsContainer
Определения KeybindingsMenu.c:6
void ConfirmKeybindEntry(TIntArray new_keys)
Определения KeybindingsMenu.c:156
void InitPresets(int index, Widget parent, Input input)
Определения KeybindingsMenu.c:484
KeybindingsContainer GetCurrentTab()
Определения KeybindingsMenu.c:534
void ColorWhite(Widget w, Widget enterW)
Определения CameraToolsMenu.c:1021
void SetToDefaults()
Определения KeybindingsMenu.c:284
void ClearKeybind(int key_index)
Определения KeybindingsMenu.c:116
override bool OnFocusLost(Widget w, int x, int y)
Определения KeybindingsMenu.c:408
override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
Определения KeybindingsMenu.c:376
void Back()
Определения ControlsXboxNew.c:96
void CancelEnteringKeybind()
Определения KeybindingsMenu.c:138
const int MODAL_RESULT_DEFAULT_CURRENT
Определения KeybindingsMenu.c:26
void ColorRed(Widget w)
Определения CameraToolsMenu.c:1010
void HardReset()
Определения KeybindingsMenu.c:289
ref array< ref KeybindingsGroup > m_Tabs
Определения KeybindingsMenu.c:7
void OnSelectKBPreset(int index)
Определения KeybindingsMenu.c:521
void UpdateTabContent(int tab_index)
Определения ControlsXboxNew.c:101
ButtonWidget m_Defaults
Определения KeybindingsMenu.c:13
ref DropdownPrefab m_KBDropdown
Определения KeybindingsMenu.c:4
int m_TargetPresetIndex
Определения KeybindingsMenu.c:19
void StartEnteringKeybind(int key_index)
Определения KeybindingsMenu.c:132
const int MODAL_ID_BACK
Определения KeybindingsMenu.c:22
ButtonWidget m_Back
Определения ControlsXboxNew.c:35
override Widget Init()
Определения KeybindingsMenu.c:29
void CreateTabs()
Определения KeybindingsMenu.c:86
void CreateGroupContainer()
Определения KeybindingsMenu.c:106
override bool OnClick(Widget w, int x, int y, int button)
Определения KeybindingsMenu.c:197
const int MODAL_ID_PRESET_CHANGE
Определения KeybindingsMenu.c:25
int m_OriginalPresetIndex
Определения KeybindingsMenu.c:18
override bool OnModalResult(Widget w, int x, int y, int code, int result)
Определения KeybindingsMenu.c:315
void ConfirmAlternateKeybindEntry(TIntArray new_keys)
Определения KeybindingsMenu.c:165
void ColorDisabled(Widget w)
Определения KeybindingsMenu.c:466
int m_CurrentSettingAlternateKeyIndex
Определения KeybindingsMenu.c:17
void OnAttemptSelectPreset(int index)
Определения KeybindingsMenu.c:508
void PerformSetToDefaults()
deprecated, resets all (as before ~1.20)
Определения KeybindingsMenu.c:544
const int MODAL_ID_DEFAULT_ALL
Определения KeybindingsMenu.c:24
ButtonWidget m_Undo
Определения KeybindingsMenu.c:12
void CancelEnteringAlternateKeybind()
Определения KeybindingsMenu.c:150
void InitInputSortingMap()
Определения KeybindingsMenu.c:479
Определения DayZGame.c:64
Определения EnWidgets.c:190
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
array< int > TIntArray
Определения EnScript.c:714
GamepadButton
Определения EnSystem.c:341
MouseState
Определения EnSystem.c:311
const int CALL_CATEGORY_GUI
Определения 3_Game/DayZ/tools/tools.c:9
WidgetFlags
Определения EnWidgets.c:58
proto native void SetFocus(Widget w)
int ARGB(int a, int r, int g, int b)
Определения proto.c:322