DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
KeybindingsContainer.c
См. документацию.
1//container for various subgroups and their elements
2class KeybindingsContainer extends ScriptedWidgetEventHandler
3{
4 protected const int NO_SORTING = -1;
5 protected Widget m_Root;
6 protected KeybindingsMenu m_Menu;
7 protected ScrollWidget m_Scroll;
8
9 protected ref map<int, ref ElementArray> m_KeyWidgetElements; //<input_action_id,<KeybindingElementNew>>
10 protected int m_CurrentSettingKeyIndex = -1;
12
14
15 void KeybindingsContainer( int index, Input input, Widget parent, KeybindingsMenu menu )
16 {
18 m_Menu = menu;
19
21 m_Scroll = ScrollWidget.Cast(m_Root.FindAnyWidget("group_scroll"));
22 Widget container = m_Root.FindAnyWidget( "group_scroll" );
23
24 CreateSubgroups(container,input);
25
26 container.Update();
27
28 m_Root.SetHandler( this );
29 }
30
32 {
33 return "gui/layouts/new_ui/options/keybindings_selectors/keybinding_container.layout";
34 }
35
36 void OnSelectKBPreset( int index )
37 {
38 GetUApi().PresetSelect( index );
40 GetUApi().Export();
42 }
43
45 {
46 foreach ( ElementArray elements : m_KeyWidgetElements )
47 {
48 foreach (KeybindingElementNew element : elements)
49 {
50 element.Reload();
51 }
52 }
53 }
54
55 void AddSubgroup( int sort_index, Widget parent, Input input )
56 {
57 Widget subgroup = GetGame().GetWorkspace().CreateWidgets( "gui/layouts/new_ui/options/keybindings_selectors/keybinding_subgroup.layout", parent );
58 Widget subgroup_content = subgroup.FindAnyWidget( "subgroup_content" );
59
60 TIntArray input_actions;
61 if (sort_index != NO_SORTING)
62 {
63 input_actions = InputUtils.GetInputActionSortingMap().Get(sort_index);
64 }
65 else
66 {
67 input_actions = InputUtils.GetUnsortedInputActions();
68 }
69
70 for (int i = 0; i < input_actions.Count(); i++)
71 {
72 AddElement( input_actions[i], subgroup_content, input );
73 }
74
75 m_Subgroups.Insert(subgroup);
76
77 subgroup_content.Update();
78 }
79
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 {
90 }
91 }
92
93 //any unssorted inputs go here
95 {
97 }
98 }
99
100 void AddElement( int index, Widget parent, Input input )
101 {
102 //create array if needed
103 if (!m_KeyWidgetElements.Get(index))
104 {
105 ElementArray elements = new ElementArray;
106 m_KeyWidgetElements.Insert( index, elements );
107 }
108
109 KeybindingElementNew element = new KeybindingElementNew( index, parent, this );
110 m_KeyWidgetElements.Get(index).Insert(element);
111 }
112
114 {
116 }
117
118 void ClearKeybind( int key_index )
119 {
120 m_Menu.ClearKeybind( key_index );
121 }
122
123 void ClearAlternativeKeybind( int key_index )
124 {
125 m_Menu.ClearAlternativeKeybind( key_index );
126 }
127
128 void StartEnteringKeybind( int key_index )
129 {
131 m_CurrentSettingKeyIndex = key_index;
132 m_Menu.StartEnteringKeybind( key_index );
133 }
134
136 {
137 if ( m_CurrentSettingKeyIndex != -1 )
138 {
139 foreach (KeybindingElementNew element : m_KeyWidgetElements.Get( m_CurrentSettingKeyIndex ))
140 {
141 element.CancelEnteringKeybind();
142 }
144 }
145 }
146
147 void StartEnteringAlternateKeybind( int key_index )
148 {
151 m_Menu.StartEnteringAlternateKeybind( key_index );
152 }
153
155 {
157 {
158 foreach (KeybindingElementNew element : m_KeyWidgetElements.Get( m_CurrentSettingAlternateKeyIndex ))
159 {
160 element.CancelEnteringKeybind();
161 }
163 }
164 }
165
168 {
169 foreach (ElementArray elements : m_KeyWidgetElements)
170 {
171 foreach (KeybindingElementNew element : elements)
172 {
173 if (element.IsChanged() || element.IsAlternateChanged())
174 {
175 return true;
176 }
177 }
178 }
179 return false;
180 }
181
182 void Apply()
183 {
184 UAInputAPI ua_api = GetUApi();
185 int input_index = 0;
186
187 foreach (ElementArray elements : m_KeyWidgetElements)
188 {
189 foreach (int element_index, KeybindingElementNew element : elements)
190 {
191 if (element_index == 0)
192 {
193 UAInput input = ua_api.GetInputByID( m_KeyWidgetElements.GetKey(input_index) );
194 int i;
195 if ( element.IsChanged() )
196 {
197 array<int> new_keys = element.GetChangedBinds();
198 input.ClearDeviceBind(EUAINPUT_DEVICE_KEYBOARDMOUSE);
199 if ( new_keys.Count() > 0 )
200 {
201 input.BindComboByHash( new_keys.Get( 0 ) );
202 for( i = 1; i < new_keys.Count(); i++ )
203 {
204 input.BindComboByHash( new_keys.Get( i ) );
205 }
206 }
207 }
208
209 if ( element.IsAlternateChanged() )
210 {
211 array<int> new_alt_keys = element.GetChangedAlternateBinds();
212
213 if ( input.AlternativeCount() == 0 )
214 {
215 input.AddAlternative();
216 }
217
218 input.ClearDeviceBind(EUAINPUT_DEVICE_CONTROLLER);
219
220 if ( new_alt_keys.Count() > 0 )
221 {
222 input.BindComboByHash( new_alt_keys.Get( 0 ) );
223 for( i = 1; i < new_alt_keys.Count(); i++ )
224 {
225 input.BindComboByHash( new_alt_keys.Get( i ) );
226 }
227 }
228 }
229 }
230 element.Reload();
231 }
232 input_index++;
233 }
234 }
235
236 void Reset(bool forced = false)
237 {
238 foreach ( ElementArray elements : m_KeyWidgetElements )
239 {
240 foreach (KeybindingElementNew element : elements)
241 {
242 if ( element.IsChanged() || element.IsAlternateChanged() || forced )
243 {
244 element.Reload();
245 }
246 }
247 }
248 }
249
250 void Update( float timeslice )
251 {
253 {
254 UAInputAPI ua_api = GetUApi();
255 if ( ua_api.DeterminePressedButton() != 0 )
256 {
257 string name;
258 string text;
259 ref array<int> new_keybinds = new array<int>;
260
261 // remove previous backlit
262 GetDayZGame().GetBacklit().KeybindingClear();
263
264 for( int i = 0; i < ua_api.DeterminedCount(); ++i )
265 {
266 int kb_id = ua_api.GetDetermined( i );
267 new_keybinds.Insert( kb_id );
268
269 // light up specific key
270 GetDayZGame().GetBacklit().KeybindingShow(kb_id);
271 }
272
273 if ( m_CurrentSettingKeyIndex != -1 )
274 {
275 m_Menu.ConfirmKeybindEntry( new_keybinds );
276 foreach (KeybindingElementNew element : m_KeyWidgetElements.Get( m_CurrentSettingKeyIndex ))
277 {
278 element.Reload( new_keybinds, false );
279 }
281 }
282 else if ( m_CurrentSettingAlternateKeyIndex != -1 )
283 {
284 m_Menu.ConfirmAlternateKeybindEntry( new_keybinds );
285 foreach (KeybindingElementNew elementAlternate : m_KeyWidgetElements.Get( m_CurrentSettingAlternateKeyIndex ))
286 {
287 elementAlternate.Reload( new_keybinds, true );
288 }
290 }
291 }
292 }
293 }
294
295 void SwitchSubgroup(int index)
296 {
297 Widget w;
298 for (int i = 0; i < m_Subgroups.Count(); i++)
299 {
300 w = m_Subgroups[i];
301 w.Show(index == i);
302 }
303
304 m_Scroll.VScrollToPos01(0);
305 }
306}
307
308typedef array<ref KeybindingElementNew> ElementArray;
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
map
Определения ControlsXboxNew.c:4
DayZGame GetDayZGame()
Определения DayZGame.c:3870
proto native UAInputAPI GetUApi()
proto native WorkspaceWidget GetWorkspace()
Определения input.c:11
static map< int, ref array< int > > GetInputActionSortingMap()
Определения InputUtils.c:229
static array< int > GetUnsortedInputActions()
Определения InputUtils.c:234
Определения InputUtils.c:2
void AddSubgroup(Widget parent, Input input)
Определения KeybindingsGroup.c:87
int AddElement(string text, Widget content=null)
Определения DropdownPrefab.c:64
void KeybindingElementNew(int key_index, Widget parent, KeybindingsContainer group)
Определения KeybindingElementNew.c:22
map: item x vector(index, width, height)
Определения EnWidgets.c:651
proto native void AddAlternative()
proto native int AlternativeCount()
proto native int GetDetermined(int iIndex)
proto native UAInput GetInputByID(int iID)
returns list of all bindable (i.e. visible) inputs from the active group ('core' by default)
proto native void SaveInputPresetMiscData()
proto native void PresetSelect(int index)
proto native void Export()
proto native int DeterminePressedButton()
proto native int DeterminedCount()
Определения UAInput.c:166
proto native void ClearDeviceBind(int iDeviceFlags)
proto native void BindComboByHash(int iHash)
Определения UAInput.c:24
Определения EnWidgets.c:190
void SwitchSubgroup(int index)
Определения KeybindingsContainer.c:295
void ClearAlternativeKeybind(int key_index)
Определения KeybindingsContainer.c:123
void ReloadElements()
Определения KeybindingsContainer.c:44
void Reset(bool forced=false)
Определения KeybindingsContainer.c:236
ScrollWidget m_Scroll
Определения KeybindingsContainer.c:7
bool IsEnteringKeyBind()
Определения KeybindingsContainer.c:113
void CreateSubgroups(Widget parent, Input input)
Определения KeybindingsContainer.c:80
void OnSelectKBPreset(int index)
Определения KeybindingsContainer.c:36
Widget m_Root
Определения KeybindingsContainer.c:5
void StartEnteringAlternateKeybind(int key_index)
Определения KeybindingsContainer.c:147
ref array< Widget > m_Subgroups
Определения KeybindingsContainer.c:13
void AddElement(int index, Widget parent, Input input)
Определения KeybindingsContainer.c:100
bool IsChanged()
is anything changed?
Определения KeybindingsContainer.c:167
void AddSubgroup(int sort_index, Widget parent, Input input)
Определения KeybindingsContainer.c:55
string GetLayoutName()
Определения KeybindingsContainer.c:31
void StartEnteringKeybind(int key_index)
Определения KeybindingsContainer.c:128
void Update(float timeslice)
Определения KeybindingsContainer.c:250
KeybindingsMenu m_Menu
Определения KeybindingsContainer.c:6
void ClearKeybind(int key_index)
Определения KeybindingsContainer.c:118
void KeybindingsContainer(int index, Input input, Widget parent, KeybindingsMenu menu)
Определения KeybindingsContainer.c:15
void Apply()
Определения KeybindingsContainer.c:182
const int NO_SORTING
Определения KeybindingsContainer.c:4
void CancelEnteringAlternateKeybind()
Определения KeybindingsContainer.c:154
void CancelEnteringKeybind()
Определения KeybindingsContainer.c:135
ref map< int, ref ElementArray > m_KeyWidgetElements
Определения KeybindingsContainer.c:9
int m_CurrentSettingAlternateKeyIndex
Определения KeybindingsContainer.c:11
int m_CurrentSettingKeyIndex
Определения KeybindingsContainer.c:10
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
proto native CGame GetGame()
array< int > TIntArray
Определения EnScript.c:687
proto native external Widget CreateWidgets(string layout, Widget parentWidget=NULL, bool immedUpdate=true)
Create widgets from *.layout file.