DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
Loading...
Searching...
No Matches
ControlMappingKeybinds.c
Go to the documentation of this file.
1class TutorialKeybinds extends ScriptedWidgetEventHandler
2{
3 protected Widget m_Root;
5
6 protected TutorialsMenu m_Menu;
7
8 void TutorialKeybinds(Widget parent, TutorialsMenu menu)
9 {
11
12 m_Menu = menu;
13
14 int actionCount;
15 int actionMax = 80;
16
17 int column_index = 0;
18 int item_index;
19 string output = "";
20 string option_text = "";
21 TIntArray actions = new TIntArray;
22 GetUApi().GetActiveInputs(actions);
23
24 actionCount = actions.Count();
25 for (int i = 0; i < actionCount; i++)
26 {
27 UAInput input = GetUApi().GetInputByID(actions.Get(i));
28 if (input)
29 {
30 if (item_index < actionMax)
31 {
32 output = "";
33 option_text = "";
34 GetGame().GetInput().GetActionDesc(actions.Get(i), option_text);
35 if (SetElementTitle(input, EUAINPUT_DEVICE_KEYBOARDMOUSE, output))
36 {
37 column_index = Math.Floor(item_index / 21);
38 Widget w = GetGame().GetWorkspace().CreateWidgets("gui/layouts/new_ui/tutorials/xbox/keybindings_panels/keybinding_panel.layout", m_Root.FindAnyWidget("container" + column_index));
39 Widget spacer = w.FindWidget("Spacer");
40 TextWidget name = TextWidget.Cast(w.FindWidget("KeybindName"));
41 TextWidget mod = TextWidget.Cast(spacer.FindWidget("KeybindModifier"));
42 TextWidget value = TextWidget.Cast(spacer.FindWidget("KeybindButton"));
43
44 string modifier_text = "";
45 name.SetText(option_text);
46 value.SetText(output);
47
48 if (SetElementModifier(input, modifier_text))
49 {
50 mod.SetText(modifier_text);
51 }
52
53 name.Update();
54 mod.Update();
55 value.Update();
56 spacer.Update();
57
58 item_index++;
59 }
60 }
61 else
62 {
63 option_text = "";
64 GetGame().GetInput().GetActionDesc(actions[i], option_text);
65 ErrorEx("input action " + option_text + " index out of bounds!",ErrorExSeverity.INFO);
66 }
67 }
68 }
69
70 m_Root.SetHandler(this);
71 }
72
74 bool SetElementTitle(UAInput pInput, int iDeviceFlags, out string output)
75 {
76 int a, i, countbind = 0;
77
78 for (a = 0; a < pInput.AlternativeCount(); a++)
79 {
80 pInput.SelectAlternative(a);
81 if (pInput.IsCombo())
82 {
83 if (pInput.BindingCount() > 0)
84 {
85 if (pInput.Binding(0) != 0 && pInput.CheckBindDevice(0,iDeviceFlags))
86 {
87 if (countbind > 0)
88 output += ", ";
89
90 output += GetUApi().GetButtonName(pInput.Binding(0));
91 countbind++;
92
93 for (i = 1; i < pInput.BindingCount(); i++)
94 {
95 if (pInput.Binding(i) != 0)
96 {
97 output += " + " + GetUApi().GetButtonName(pInput.Binding(i));
98 countbind++;
99 }
100 }
101
102 }
103 }
104 }
105 else
106 {
107 if (pInput.BindingCount() > 0)
108 {
109 if (pInput.Binding(0) != 0 && pInput.CheckBindDevice(0,iDeviceFlags))
110 {
111 if (countbind > 0)
112 output += ", ";
113
114 output += GetUApi().GetButtonName(pInput.Binding(0));
115 countbind++;
116 }
117 }
118 }
119
120 }
121
122 return (countbind > 0);
123 }
124
126 bool SetElementModifier(UAInput pInput, out string output)
127 {
128 if (pInput.IsLimited())
129 {
130 if (pInput.IsPressLimit())
131 {
132 output = "#keybind_press";
133 }
134 if (pInput.IsReleaseLimit())
135 {
136 output = "#keybind_release";
137 }
138 if (pInput.IsHoldLimit())
139 {
140 output = "#keybind_hold";
141 }
142 if (pInput.IsHoldBeginLimit())
143 {
144 output = "#keybind_holdbegin";
145 }
146 if (pInput.IsClickLimit())
147 {
148 output = "#keybind_click";
149 }
150 if (pInput.IsDoubleClickLimit())
151 {
152 output = "#keybind_doubletap";
153 }
154
155 return true;
156 }
157 else
158 {
159 return false;
160 }
161 }
162
164 {
165
166 }
167
169 {
170 return "gui/layouts/new_ui/tutorials/xbox/keybinds_tab.layout";
171 }
172}
string name
protected ServerBrowserMenuNew m_Menu
protected Widget m_Root
Definition SizeToChild.c:91
proto native UAInputAPI GetUApi()
proto native Input GetInput()
proto native WorkspaceWidget GetWorkspace()
proto int GetActionDesc(int action_index, out string desc)
Definition EnMath.c:7
map: item x vector(index, width, height)
Definition EnWidgets.c:538
bool SetElementTitle(UAInput pInput, int iDeviceFlags, out string output)
assemble all active bindings at widget element
protected TutorialsMenu m_Menu
protected Widget m_Root
Definition SizeToChild.c:9
void TutorialKeybinds(Widget parent, TutorialsMenu menu)
bool SetElementModifier(UAInput pInput, out string output)
Determine the active limiter of the bindings (currently unreliable, multiple limiters can be active o...
proto native UAInput GetInputByID(int iID)
returns list of all bindable (i.e. visible) inputs from the active group ('core' by default)
proto native owned string GetButtonName(int iHash)
proto native void GetActiveInputs(out TIntArray items)
proto native bool IsCombo()
proto native bool CheckBindDevice(int iIndex, int iDeviceFlags)
proto native void SelectAlternative(int iIndex)
proto native bool IsDoubleClickLimit()
proto native int AlternativeCount()
proto native bool IsHoldBeginLimit()
proto native bool IsHoldLimit()
proto native int BindingCount()
proto native int Binding(int iIndex)
proto native bool IsPressLimit()
proto native bool IsClickLimit()
proto native bool IsLimited()
proto native bool IsReleaseLimit()
proto native CGame GetGame()
ErrorExSeverity
Definition EnDebug.c:62
enum ShapeType ErrorEx
array< int > TIntArray
Definition EnScript.c:687
static proto float Floor(float f)
Returns floor of value.
proto native external Widget CreateWidgets(string layout, Widget parentWidget=NULL, bool immedUpdate=true)
Create widgets from *.layout file.