Dayz Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
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 {
10 m_Root = g_Game.GetWorkspace().CreateWidgets(GetLayoutName(), parent);
11 m_Menu = menu;
12
13 Rebuild();
14 m_Root.SetHandler(this);
15 }
16
17 void Rebuild()
18 {
20
21 int actionMax = 80;
22 int column_index = 0;
23 int item_index = 0;
24 string output = "";
25 string option_text = "";
26 int deviceFlags = GetActiveDeviceFlags();
27 TIntArray actions = new TIntArray;
28 GetUApi().GetActiveInputs(actions);
29
30 int actionCount = actions.Count();
31 for (int i = 0; i < actionCount; ++i)
32 {
33 UAInput input = GetUApi().GetInputByID(actions.Get(i));
34 if (!input)
35 continue;
36
37 if (item_index < actionMax)
38 {
39 output = "";
40 option_text = "";
41 g_Game.GetInput().GetActionDesc(actions.Get(i), option_text);
42
43 if (SetElementTitle(input, deviceFlags, output))
44 {
45 column_index = Math.Floor(item_index / 21);
46 Widget container = m_Root.FindAnyWidget("container" + column_index);
47 if (!container)
48 continue;
49
50 Widget w = g_Game.GetWorkspace().CreateWidgets("gui/layouts/new_ui/tutorials/xbox/keybindings_panels/keybinding_panel.layout", container);
51 Widget spacer = w.FindWidget("Spacer");
52 TextWidget name = TextWidget.Cast(w.FindWidget("KeybindName"));
53 TextWidget mod = TextWidget.Cast(spacer.FindWidget("KeybindModifier"));
54 TextWidget value = TextWidget.Cast(spacer.FindWidget("KeybindButton"));
55
56 string modifier_text = "";
57 name.SetText(option_text);
58 value.SetText(output);
59
60 if (SetElementModifier(input, modifier_text))
61 {
62 mod.SetText(modifier_text);
63 }
64
65 name.Update();
66 mod.Update();
67 value.Update();
68 spacer.Update();
69
70 item_index++;
71 }
72 }
73 else
74 {
75 option_text = "";
76 g_Game.GetInput().GetActionDesc(actions.Get(i), option_text);
77 ErrorEx("input action " + option_text + " index out of bounds!", ErrorExSeverity.INFO);
78 }
79 }
80 }
81
82 protected int GetActiveDeviceFlags()
83 {
84#ifdef PLATFORM_CONSOLE
85 if (g_Game.GetInput().GetCurrentInputDevice() == EInputDeviceType.CONTROLLER)
86 {
87 return EUAINPUT_DEVICE_CONTROLLER;
88 }
89#endif
90 return EUAINPUT_DEVICE_KEYBOARDMOUSE;
91 }
92
93 protected void ClearBindingPanels()
94 {
95 int columnIndex = 0;
96 Widget container = m_Root.FindAnyWidget("container" + columnIndex);
97
98 while (container)
99 {
100 Widget child = container.GetChildren();
101 while (child)
102 {
103 Widget next = child.GetSibling();
104 child = next;
105 }
106
107 columnIndex++;
108 container = m_Root.FindAnyWidget("container" + columnIndex);
109 }
110 }
111
113 bool SetElementTitle(UAInput pInput, int iDeviceFlags, out string output)
114 {
115 int a, i, countbind = 0;
116
117 for (a = 0; a < pInput.AlternativeCount(); a++)
118 {
119 pInput.SelectAlternative(a);
120 if (pInput.IsCombo())
121 {
122 if (pInput.BindingCount() > 0)
123 {
124 if (pInput.Binding(0) != 0 && pInput.CheckBindDevice(0,iDeviceFlags))
125 {
126 if (countbind > 0)
127 output += ", ";
128
129 output += GetUApi().GetButtonName(pInput.Binding(0));
130 countbind++;
131
132 for (i = 1; i < pInput.BindingCount(); i++)
133 {
134 if (pInput.Binding(i) != 0)
135 {
136 output += " + " + GetUApi().GetButtonName(pInput.Binding(i));
137 countbind++;
138 }
139 }
140
141 }
142 }
143 }
144 else
145 {
146 if (pInput.BindingCount() > 0)
147 {
148 if (pInput.Binding(0) != 0 && pInput.CheckBindDevice(0,iDeviceFlags))
149 {
150 if (countbind > 0)
151 output += ", ";
152
153 output += GetUApi().GetButtonName(pInput.Binding(0));
154 countbind++;
155 }
156 }
157 }
158
159 }
160
161 return (countbind > 0);
162 }
163
165 bool SetElementModifier(UAInput pInput, out string output)
166 {
167 if (pInput.IsLimited())
168 {
169 if (pInput.IsPressLimit())
170 {
171 output = "#keybind_press";
172 }
173 if (pInput.IsReleaseLimit())
174 {
175 output = "#keybind_release";
176 }
177 if (pInput.IsHoldLimit())
178 {
179 output = "#keybind_hold";
180 }
181 if (pInput.IsHoldBeginLimit())
182 {
183 output = "#keybind_holdbegin";
184 }
185 if (pInput.IsClickLimit())
186 {
187 output = "#keybind_click";
188 }
189 if (pInput.IsDoubleClickLimit())
190 {
191 output = "#keybind_doubletap";
192 }
193
194 return true;
195 }
196 else
197 {
198 return false;
199 }
200 }
201
203 {
204
205 }
206
208 {
209 return "gui/layouts/new_ui/tutorials/xbox/keybinds_tab.layout";
210 }
211}
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
Definition enmath.c:7
map: item x vector(index, width, height)
Definition enwidgets.c:657
bool SetElementTitle(UAInput pInput, int iDeviceFlags, out string output)
assemble all active bindings at widget element
CameraToolsMenu m_Menu
Definition ctevent.c:8
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()
DayZGame g_Game
Definition dayzgame.c:3942
ErrorExSeverity
Definition endebug.c:62
enum ShapeType ErrorEx
array< int > TIntArray
Definition enscript.c:714
static proto float Floor(float f)
Returns floor of value.
WorkspaceWidget Widget
Defined in code.
EInputDeviceType
Definition input.c:3
Widget m_Root
Definition sizetochild.c:91
proto native UAInputAPI GetUApi()