Dayz
Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Toggle main menu visibility
Loading...
Searching...
No Matches
controlmappingkeybinds.c
Go to the documentation of this file.
1
class
TutorialKeybinds
extends
ScriptedWidgetEventHandler
2
{
3
protected
Widget
m_Root
;
4
protected
Widget
m_DetailsRoot
;
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
{
19
ClearBindingPanels
();
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
202
void
~TutorialKeybinds
()
203
{
204
205
}
206
207
string
GetLayoutName
()
208
{
209
return
"gui/layouts/new_ui/tutorials/xbox/keybinds_tab.layout"
;
210
}
211
}
name
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
Math
Definition
enmath.c:7
ScriptedWidgetEventHandler
map: item x vector(index, width, height)
Definition
enwidgets.c:657
ScriptedWidgetEventHandler::GetActiveDeviceFlags
int GetActiveDeviceFlags()
Definition
controlmappingkeybinds.c:82
ScriptedWidgetEventHandler::m_Root
Widget m_Root
Definition
sizetochild.c:9
ScriptedWidgetEventHandler::SetElementTitle
bool SetElementTitle(UAInput pInput, int iDeviceFlags, out string output)
assemble all active bindings at widget element
Definition
controlmappingkeybinds.c:113
ScriptedWidgetEventHandler::~TutorialKeybinds
void ~TutorialKeybinds()
Definition
controlmappingkeybinds.c:202
ScriptedWidgetEventHandler::ClearBindingPanels
void ClearBindingPanels()
Definition
controlmappingkeybinds.c:93
ScriptedWidgetEventHandler::GetLayoutName
string GetLayoutName()
Definition
controlmappingkeybinds.c:207
ScriptedWidgetEventHandler::m_Menu
CameraToolsMenu m_Menu
Definition
ctevent.c:8
ScriptedWidgetEventHandler::TutorialKeybinds
void TutorialKeybinds(Widget parent, TutorialsMenu menu)
Definition
controlmappingkeybinds.c:8
ScriptedWidgetEventHandler::m_DetailsRoot
Widget m_DetailsRoot
Definition
controlmappingkeybinds.c:4
ScriptedWidgetEventHandler::SetElementModifier
bool SetElementModifier(UAInput pInput, out string output)
Determine the active limiter of the bindings (currently unreliable, multiple limiters can be active o...
Definition
controlmappingkeybinds.c:165
ScriptedWidgetEventHandler::Rebuild
void Rebuild()
Definition
controlmappingkeybinds.c:17
TextWidget
Definition
enwidgets.c:220
UAInputAPI::GetInputByID
proto native UAInput GetInputByID(int iID)
returns list of all bindable (i.e. visible) inputs from the active group ('core' by default)
UAInputAPI::GetButtonName
proto native owned string GetButtonName(int iHash)
UAInputAPI::GetActiveInputs
proto native void GetActiveInputs(out TIntArray items)
UAInput
Definition
uainput.c:24
UAInput::IsCombo
proto native bool IsCombo()
UAInput::CheckBindDevice
proto native bool CheckBindDevice(int iIndex, int iDeviceFlags)
UAInput::SelectAlternative
proto native void SelectAlternative(int iIndex)
UAInput::IsDoubleClickLimit
proto native bool IsDoubleClickLimit()
UAInput::AlternativeCount
proto native int AlternativeCount()
UAInput::IsHoldBeginLimit
proto native bool IsHoldBeginLimit()
UAInput::IsHoldLimit
proto native bool IsHoldLimit()
UAInput::BindingCount
proto native int BindingCount()
UAInput::Binding
proto native int Binding(int iIndex)
UAInput::IsPressLimit
proto native bool IsPressLimit()
UAInput::IsClickLimit
proto native bool IsClickLimit()
UAInput::IsLimited
proto native bool IsLimited()
UAInput::IsReleaseLimit
proto native bool IsReleaseLimit()
Widget
Definition
enwidgets.c:190
g_Game
DayZGame g_Game
Definition
dayzgame.c:3942
ErrorExSeverity
ErrorExSeverity
Definition
endebug.c:62
ErrorEx
enum ShapeType ErrorEx
TIntArray
array< int > TIntArray
Definition
enscript.c:714
Math::Floor
static proto float Floor(float f)
Returns floor of value.
Widget
WorkspaceWidget Widget
Defined in code.
EInputDeviceType
EInputDeviceType
Definition
input.c:3
m_Root
Widget m_Root
Definition
sizetochild.c:91
GetUApi
proto native UAInputAPI GetUApi()
Games
Dayz
scripts
5_mission
gui
newui
controlmapping
controlmappingkeybinds.c
Generated by
1.17.0