DayZ 1.27
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 = GetGame().GetInput();
32 layoutRoot = GetGame().GetWorkspace().CreateWidgets("gui/layouts/new_ui/options/pc/keybinding_menu.layout", null);
33
34 m_Version = TextWidget.Cast(layoutRoot.FindAnyWidget("version"));
35 m_Apply = ButtonWidget.Cast(layoutRoot.FindAnyWidget("apply"));
36 m_Back = ButtonWidget.Cast(layoutRoot.FindAnyWidget("back"));
37 m_Undo = ButtonWidget.Cast(layoutRoot.FindAnyWidget("undo"));
38 m_Defaults = ButtonWidget.Cast(layoutRoot.FindAnyWidget("reset"));
39 m_HardReset = ButtonWidget.Cast(layoutRoot.FindAnyWidget("reset_all"));
40
41 layoutRoot.FindAnyWidget("Tabber").GetScript(m_Tabber);
42
43 string version;
44 GetGame().GetVersion(version);
45 #ifdef PLATFORM_CONSOLE
46 version = "#main_menu_version" + " " + version + " (" + g_Game.GetDatabaseID() + ")";
47 #else
48 version = "#main_menu_version" + " " + version;
49 #endif
50 m_Version.SetText(version);
51
52 #ifdef PLATFORM_PS4
53 string back = "circle";
54 if (GetGame().GetInput().GetEnterButton() != GamepadButton.A)
55 back = "cross";
56
57 ImageWidget toolbar_b = ImageWidget.Cast(layoutRoot.FindAnyWidget("BackIcon"));
58 toolbar_b.LoadImageFile(0, "set:playstation_buttons image:" + back);
59 #endif
60
62 CreateTabs();
64
65 InitPresets(-1, layoutRoot.FindAnyWidget("group_header"), input);
66 m_Tabber.m_OnTabSwitch.Insert(UpdateTabContent);
67 m_Tabber.SelectTabControl(0);
68 m_Tabber.SelectTabPanel(0);
69 g_Game.SetKeyboardHandle(this);
70 m_Tabber.RefreshTab(true);
71
73 m_Apply.SetFlags(WidgetFlags.IGNOREPOINTER);
75 m_Undo.SetFlags(WidgetFlags.IGNOREPOINTER);
77 m_Defaults.ClearFlags(WidgetFlags.IGNOREPOINTER);
78
79 return layoutRoot;
80 }
81
83 {
84 int sort_count = InputUtils.GetInputActionSortingMap().Count();
85 for (int i = 0; i < sort_count; i++)
86 {
87 if (InputUtils.GetInputActionSortingMap().GetElement(i) && InputUtils.GetInputActionSortingMap().GetElement(i).Count() > 0)
88 {
89 string group_name = GetUApi().SortingLocalization(InputUtils.GetInputActionSortingMap().GetKey(i));
90 group_name = Widget.TranslateString("#" + group_name); //oof
91 m_Tabber.AddTab(group_name);
92 }
93 }
94
96 {
97 m_Tabber.AddTab(Widget.TranslateString("#layout_pc_keybinding_unsorted"));
98 }
99 m_Tabber.DisableTabs(true);
100 }
101
103 {
104 m_GroupsContainer = new KeybindingsContainer(-1,GetGame().GetInput(),layoutRoot.FindAnyWidget("TabContentsHolder"),this);
105 }
106
107 void UpdateTabContent(int tab_index)
108 {
109 m_GroupsContainer.SwitchSubgroup(tab_index);
110 }
111
112 void ClearKeybind(int key_index)
113 {
114 ColorWhite(m_Apply, null);
115 m_Apply.ClearFlags(WidgetFlags.IGNOREPOINTER);
116 ColorWhite(m_Undo, null);
117 m_Undo.ClearFlags(WidgetFlags.IGNOREPOINTER);
118 }
119
120 void ClearAlternativeKeybind(int key_index)
121 {
122 ColorWhite(m_Apply, null);
123 m_Apply.ClearFlags(WidgetFlags.IGNOREPOINTER);
124 ColorWhite(m_Undo, null);
125 m_Undo.ClearFlags(WidgetFlags.IGNOREPOINTER);
126 }
127
128 void StartEnteringKeybind(int key_index)
129 {
131 m_CurrentSettingKeyIndex = key_index;
132 }
133
135 {
136 m_GroupsContainer.CancelEnteringKeybind();
138 }
139
141 {
144 }
145
147 {
148 m_GroupsContainer.CancelEnteringAlternateKeybind();
150 }
151
153 {
155 ColorWhite(m_Apply, null);
156 m_Apply.ClearFlags(WidgetFlags.IGNOREPOINTER);
157 ColorWhite(m_Undo, null);
158 m_Undo.ClearFlags(WidgetFlags.IGNOREPOINTER);
159 }
160
162 {
164 ColorWhite(m_Apply, null);
165 m_Apply.ClearFlags(WidgetFlags.IGNOREPOINTER);
166 ColorWhite(m_Undo, null);
167 m_Undo.ClearFlags(WidgetFlags.IGNOREPOINTER);
168 }
169
170 override void Update(float timeslice)
171 {
172 if (GetUApi().GetInputByID(UAUIBack).LocalPress())
173 {
174 Back();
175 }
176
178 {
179 m_GroupsContainer.Update(timeslice);
180 }
181 }
182
183 override bool OnClick(Widget w, int x, int y, int button)
184 {
185 if (button == MouseState.LEFT)
186 {
187 if (w == m_Apply)
188 {
189 Apply();
190 return true;
191 }
192 else if (w == m_Back)
193 {
194 Back();
195 return true;
196 }
197 else if (w == m_Undo)
198 {
199 Reset();
200 return true;
201 }
202 else if (w == m_Defaults)
203 {
205 return true;
206 }
207 else if (w == m_HardReset)
208 {
209 HardReset();
210 return true;
211 }
212 }
213 return false;
214 }
215
216 void Apply()
217 {
219 m_Apply.SetFlags(WidgetFlags.IGNOREPOINTER);
221 m_Undo.SetFlags(WidgetFlags.IGNOREPOINTER);
222 ColorWhite(m_Defaults, null);
223 m_Defaults.ClearFlags(WidgetFlags.IGNOREPOINTER);
224
225 m_GroupsContainer.Apply();
226
227 // save input configuration
228 GetUApi().Export();
229 }
230
231 void Back()
232 {
233 if (m_CurrentSettingKeyIndex != -1)
234 {
236 return;
237 }
238
240 {
242 return;
243 }
244
245 bool changed = m_GroupsContainer.IsChanged();
246
247 if (changed)
248 {
249 g_Game.GetUIManager().ShowDialog("#main_menu_configure", "#main_menu_configure_desc", MODAL_ID_BACK, DBT_YESNO, DBB_YES, DMT_QUESTION, this);
250 }
251 else
252 {
254 }
255 }
256
258 void Reset()
259 {
261 m_Apply.SetFlags(WidgetFlags.IGNOREPOINTER);
263 m_Undo.SetFlags(WidgetFlags.IGNOREPOINTER);
264
265 m_GroupsContainer.Reset();
266 }
267
269 {
270 g_Game.GetUIManager().ShowDialog("#menu_default_cap", "#menu_default_desc", MODAL_ID_DEFAULT, DBT_YESNO, DBB_YES, DMT_QUESTION, this);
271 }
272
274 {
275 g_Game.GetUIManager().ShowDialog("#menu_default_cap", "#menu_default_all_desc", MODAL_ID_DEFAULT_ALL, DBT_YESNO, DBB_YES, DMT_QUESTION, this);
276 }
277
279 {
280 switch (mode)
281 {
284 break;
285
287 GetUApi().Revert();
288 break;
289 }
290
292 m_Apply.SetFlags(WidgetFlags.IGNOREPOINTER);
294 m_Undo.SetFlags(WidgetFlags.IGNOREPOINTER);
295 GetGame().GetCallQueue(CALL_CATEGORY_GUI).Call(GetGame().GetMission().RefreshExcludes);
296 m_GroupsContainer.Reset(true);
297 }
298
299 override bool OnModalResult(Widget w, int x, int y, int code, int result)
300 {
301 if (code == MODAL_ID_BACK)
302 {
303 if (result == DBB_YES)
304 {
305 Reset();
307 }
308 return true;
309 }
310 else if (code == MODAL_ID_DEFAULT)
311 {
312 if (result == DBB_YES)
313 {
315 }
316 return true;
317 }
318 else if (code == MODAL_ID_DEFAULT_ALL)
319 {
320 if (result == DBB_YES)
321 {
323 }
324 }
325 else if (code == MODAL_ID_PRESET_CHANGE)
326 {
327 if (result == DBB_YES)
328 {
329 Reset();
330 m_PresetSelector.PerformSetOption(m_TargetPresetIndex);
331 }
332 return true;
333 }
334
335 return false;
336 }
337
338 override void Refresh()
339 {
340 string version;
341 GetGame().GetVersion(version);
342 #ifdef PLATFORM_CONSOLE
343 version = "#main_menu_version" + " " + version + " (" + g_Game.GetDatabaseID() + ")";
344 #else
345 version = "#main_menu_version" + " " + version;
346 #endif
347 m_Version.SetText(version);
348 }
349
350 override bool OnMouseEnter(Widget w, int x, int y)
351 {
352 if (w && IsFocusable(w))
353 {
354 ColorRed(w);
355 return true;
356 }
357 return false;
358 }
359
360 override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
361 {
362 if (w && IsFocusable(w))
363 {
364 if ((w.GetFlags() & WidgetFlags.DISABLED) || (w.GetFlags() & WidgetFlags.IGNOREPOINTER))
365 {
366 ColorDisabled(w);
367 }
368 else
369 {
370 ColorWhite(w, enterW);
371 }
372 return true;
373 }
374 return false;
375 }
376
377 override bool OnMouseWheel(Widget w, int x, int y, int wheel)
378 {
379 return super.OnMouseWheel(w, x, y, wheel);
380 }
381
382 override bool OnFocus(Widget w, int x, int y)
383 {
384 if (w && IsFocusable(w))
385 {
386 ColorRed(w);
387 return true;
388 }
389 return false;
390 }
391
392 override bool OnFocusLost(Widget w, int x, int y)
393 {
394 if (w && IsFocusable(w))
395 {
396 if ((w.GetFlags() & WidgetFlags.DISABLED) || (w.GetFlags() & WidgetFlags.IGNOREPOINTER))
397 {
398 ColorDisabled(w);
399 }
400 else
401 {
402 ColorWhite(w, null);
403 }
404 return true;
405 }
406 return false;
407 }
408
410 {
411 if (w)
412 {
413 return (w == m_Apply || w == m_Back || w == m_Undo || w == m_Defaults || w == m_HardReset);
414 }
415 return false;
416 }
417
418 //Coloring functions (Until WidgetStyles are useful)
420 {
421 SetFocus(w);
422
423 ButtonWidget button = ButtonWidget.Cast(w);
424 if (button && button != m_Apply)
425 {
426 button.SetTextColor(ARGB(255, 200, 0, 0));
427 }
428 }
429
430 void ColorWhite(Widget w, Widget enterW)
431 {
432 #ifdef PLATFORM_WINDOWS
433 SetFocus(null);
434 #endif
435
436 ButtonWidget button = ButtonWidget.Cast(w);
437 if (button)
438 {
439 if (button.GetFlags() & WidgetFlags.DISABLED)
440 {
441 button.SetTextColor(ColorManager.COLOR_DISABLED_TEXT);
442 }
443 else
444 {
445 button.SetTextColor(ColorManager.COLOR_NORMAL_TEXT);
446 }
447 }
448 }
449
451 {
452 #ifdef PLATFORM_WINDOWS
453 SetFocus(null);
454 #endif
455
456 ButtonWidget button = ButtonWidget.Cast(w);
457 if (button)
458 {
459 button.SetTextColor(ColorManager.COLOR_DISABLED_TEXT);
460 }
461 }
462
463 protected void InitInputSortingMap()
464 {
466 }
467
468 void InitPresets(int index, Widget parent, Input input)
469 {
470 Widget kb_root = parent.FindAnyWidget("keyboard_dropown");
471 if (kb_root)
472 {
473 kb_root.Show(false);
474 }
475
476 array<string> opt1 = new array<string>;
477 string profile_text;
478
479 for (int i = 0; i < input.GetProfilesCount(); i++)
480 {
481 input.GetProfileName(i, profile_text);
482 opt1.Insert(profile_text);
483 }
484
485 int current_idx = input.GetCurrentProfile();
486 m_OriginalPresetIndex = current_idx;
487 m_PresetSelector = new OptionSelectorMultistate(layoutRoot.FindAnyWidget("profile_setting_option"), current_idx, null, false, opt1);
488 m_PresetSelector.m_AttemptOptionChange.Insert(OnAttemptSelectPreset);
489 m_PresetSelector.m_OptionChanged.Insert(OnSelectKBPreset);
490 }
491
492 void OnAttemptSelectPreset(int index)
493 {
494 bool changed = m_GroupsContainer.IsChanged() && m_OriginalPresetIndex != index;
495 m_TargetPresetIndex = index;
496
497 if (changed)
498 {
499 g_Game.GetUIManager().ShowDialog("#main_menu_configure", "#main_menu_configure_desc", MODAL_ID_PRESET_CHANGE, DBT_YESNO, DBB_YES, DMT_QUESTION, this);
500 }
501
502 m_PresetSelector.SetCanSwitch(!changed);
503 }
504
505 void OnSelectKBPreset(int index)
506 {
507 m_OriginalPresetIndex = index;
508 m_GroupsContainer.OnSelectKBPreset(index);
509 string profile_text;
510 GetGame().GetInput().GetProfileName(index, profile_text);
511
513 }
514
516// OBSOLETE METHODS //
518 KeybindingsContainer GetCurrentTab()
519 {
520 return m_GroupsContainer;
521 }
522
523 void AddGroup(int index, Input input)
524 {
525 }
526
532
534 {
535 }
536}
DayZGame g_Game
Определения DayZGame.c:3868
Icon x
Icon y
proto native UAInputAPI GetUApi()
proto native UIManager GetUIManager()
override ScriptCallQueue GetCallQueue(int call_category)
Определения DayZGame.c:1187
proto native WorkspaceWidget GetWorkspace()
proto void GetVersion(out string version)
proto native Input GetInput()
proto native Mission GetMission()
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
ScriptInvoker GetOnInputPresetChanged()
Определения gameplay.c:859
proto void Call(func fn, 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)
adds call into the queue with given parameters and arguments (arguments are held in memory until the ...
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 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)
bool Back()
Close top window on windows stack, returns true when any window is closed.
Определения UIManager.c:62
override bool OnMouseEnter(Widget w, int x, int y)
Определения KeybindingsMenu.c:350
void PerformSetToDefaultsExt(int mode)
Определения KeybindingsMenu.c:278
ref array< int > m_SetKeybinds
Определения KeybindingsMenu.c:20
ButtonWidget m_HardReset
Определения KeybindingsMenu.c:14
void ClearAlternativeKeybind(int key_index)
Определения KeybindingsMenu.c:120
void AddGroup(int index, Input input)
Определения KeybindingsMenu.c:523
override bool OnFocus(Widget w, int x, int y)
Определения KeybindingsMenu.c:382
override void Update(float timeslice)
Определения KeybindingsMenu.c:170
void StartEnteringAlternateKeybind(int key_index)
Определения KeybindingsMenu.c:140
override void Refresh()
Определения KeybindingsMenu.c:338
TabberUI m_Tabber
Определения KeybindingsMenu.c:3
TextWidget m_Version
Определения InGameMenuXbox.c:33
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:258
int m_CurrentSettingKeyIndex
Определения KeybindingsMenu.c:16
bool IsFocusable(Widget w)
Определения CameraToolsMenu.c:960
Widget m_Apply
Определения CharacterCreationMenu.c:14
void DeferredDefaultsInit()
deprecated
Определения KeybindingsMenu.c:533
const int MODAL_RESULT_DEFAULT_ALL
Определения KeybindingsMenu.c:27
void Apply()
renames character
Определения CharacterCreationMenu.c:173
override bool OnMouseWheel(Widget w, int x, int y, int wheel)
Определения KeybindingsMenu.c:377
ref OptionSelectorMultistate m_PresetSelector
Определения KeybindingsMenu.c:5
ref KeybindingsContainer m_GroupsContainer
Определения KeybindingsMenu.c:6
void ConfirmKeybindEntry(TIntArray new_keys)
Определения KeybindingsMenu.c:152
void InitPresets(int index, Widget parent, Input input)
Определения KeybindingsMenu.c:468
KeybindingsContainer GetCurrentTab()
Определения KeybindingsMenu.c:518
void ColorWhite(Widget w, Widget enterW)
Определения CameraToolsMenu.c:1021
void SetToDefaults()
Определения KeybindingsMenu.c:268
void ClearKeybind(int key_index)
Определения KeybindingsMenu.c:112
override bool OnFocusLost(Widget w, int x, int y)
Определения KeybindingsMenu.c:392
override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
Определения KeybindingsMenu.c:360
void Back()
Определения ControlsXboxNew.c:96
void CancelEnteringKeybind()
Определения KeybindingsMenu.c:134
const int MODAL_RESULT_DEFAULT_CURRENT
Определения KeybindingsMenu.c:26
void ColorRed(Widget w)
Определения CameraToolsMenu.c:1010
void HardReset()
Определения KeybindingsMenu.c:273
ref array< ref KeybindingsGroup > m_Tabs
Определения KeybindingsMenu.c:7
void OnSelectKBPreset(int index)
Определения KeybindingsMenu.c:505
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:128
const int MODAL_ID_BACK
Определения KeybindingsMenu.c:22
ButtonWidget m_Back
Определения ControlsXboxNew.c:35
override Widget Init()
Определения KeybindingsMenu.c:29
void CreateTabs()
Определения KeybindingsMenu.c:82
void CreateGroupContainer()
Определения KeybindingsMenu.c:102
override bool OnClick(Widget w, int x, int y, int button)
Определения KeybindingsMenu.c:183
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:299
void ConfirmAlternateKeybindEntry(TIntArray new_keys)
Определения KeybindingsMenu.c:161
void ColorDisabled(Widget w)
Определения KeybindingsMenu.c:450
int m_CurrentSettingAlternateKeyIndex
Определения KeybindingsMenu.c:17
void OnAttemptSelectPreset(int index)
Определения KeybindingsMenu.c:492
void PerformSetToDefaults()
deprecated, resets all (as before ~1.20)
Определения KeybindingsMenu.c:528
const int MODAL_ID_DEFAULT_ALL
Определения KeybindingsMenu.c:24
ButtonWidget m_Undo
Определения KeybindingsMenu.c:12
void CancelEnteringAlternateKeybind()
Определения KeybindingsMenu.c:146
void InitInputSortingMap()
Определения KeybindingsMenu.c:463
Определения DayZGame.c:64
Определения EnWidgets.c:190
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
proto native CGame GetGame()
array< int > TIntArray
Определения EnScript.c:687
GamepadButton
Определения EnSystem.c:341
MouseState
Определения EnSystem.c:311
const int CALL_CATEGORY_GUI
Определения tools.c:9
WidgetFlags
Определения EnWidgets.c:58
proto native external Widget CreateWidgets(string layout, Widget parentWidget=NULL, bool immedUpdate=true)
Create widgets from *.layout file.
proto native void SetFocus(Widget w)
int ARGB(int a, int r, int g, int b)
Определения proto.c:322