Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
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 = GetGame().GetWorkspace().CreateWidgets(GetLayoutName(), parent);
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 
163  void ~TutorialKeybinds()
164  {
165 
166  }
167 
168  string GetLayoutName()
169  {
170  return "gui/layouts/new_ui/tutorials/xbox/keybinds_tab.layout";
171  }
172 }
GetGame
proto native CGame GetGame()
UAInput
Definition: uainput.c:23
m_Menu
protected ServerBrowserMenuNew m_Menu
Definition: serverbrowsertab.c:30
ErrorEx
enum ShapeType ErrorEx
TIntArray
array< int > TIntArray
Definition: enscript.c:687
TextWidget
Definition: enwidgets.c:219
ErrorExSeverity
ErrorExSeverity
Definition: endebug.c:61
array
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
Definition: isboxcollidinggeometryproxyclasses.c:27
name
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
Widget
Definition: enwidgets.c:189
GetUApi
proto native UAInputAPI GetUApi()
Math
Definition: enmath.c:6
m_Root
protected Widget m_Root
Definition: sizetochild.c:91
ScriptedWidgetEventHandler
map: item x vector(index, width, height)
Definition: enwidgets.c:650