DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
KeybindingsGroup.c
См. документацию.
1
2class KeybindingsGroup extends ScriptedWidgetEventHandler
3{
4 protected Widget m_Root;
5 protected KeybindingsMenu m_Menu;
6
8 protected int m_CurrentSettingKeyIndex = -1;
10
12
13 void KeybindingsGroup( int index, Input input, Widget parent, KeybindingsMenu menu )
14 {
16 m_Menu = menu;
17
18 string group_name;
19 input.GetActionGroupName( index, group_name );
20
22 Widget subgroup = m_Root.FindAnyWidget( "group_content" );
23
24// for( int i = 0; i < 1; i++ )
25// {
26 AddSubgroup( /*index, */subgroup, input );
27// }
28
29 InitPresets( index, m_Root.FindAnyWidget( "group_header" ), input );
30
31 subgroup.Update();
32
33 m_Root.SetHandler( this );
34 }
35
37 {
38 return "gui/layouts/new_ui/options/keybindings_selectors/keybinding_group.layout";
39 }
40
41 void InitPresets( int index, Widget parent, Input input )
42 {
43 Widget kb_root = parent.FindAnyWidget( "keyboard_dropown" );
44
45 string profile_text;
46 input.GetProfileName( input.GetCurrentProfile(), profile_text );
47
48 m_KBDropdown = new DropdownPrefab( kb_root, profile_text );
49
50 m_KBDropdown.m_OnSelectItem.Insert( OnSelectKBPreset );
51
52 for( int i = 0; i < input.GetProfilesCount(); i++ )
53 {
54 input.GetProfileName( i, profile_text );
55 m_KBDropdown.AddElement( profile_text );
56 }
57
58 kb_root.Update();
59 }
60
61 void OnSelectKBPreset( int index )
62 {
63 string profile_text;
64 GetGame().GetInput().GetProfileName( index, profile_text );
65 m_KBDropdown.SetText( profile_text );
66 GetGame().GetInput().SetProfile( index );
68 m_KBDropdown.Close();
69 }
70
71 void OnSelectConsolePreset( int index )
72 {
73 string profile_text;
74 GetGame().GetInput().GetProfileName( index, profile_text );
75 GetGame().GetInput().SetProfile( index );
77 }
78
80 {
81 foreach( int index, KeybindingElement element : m_KeyWidgets )
82 {
83 element.Reload();
84 }
85 }
86
87 void AddSubgroup( /*int index, */Widget parent, Input input )
88 {
89 Widget subgroup = GetGame().GetWorkspace().CreateWidgets( "gui/layouts/new_ui/options/keybindings_selectors/keybinding_subgroup.layout", parent );
90 TextWidget subgroup_name = TextWidget.Cast( subgroup.FindAnyWidget( "subgroup_text" ) );
91
92 subgroup_name.SetText( "TestSubgroup" );
93 Widget subgroup_content = subgroup.FindAnyWidget( "subgroup_content" );
94
95 TIntArray actions = new TIntArray;
96 GetUApi().GetActiveInputs(actions);
97 for( int i = 0; i < actions.Count(); i++ )
98 {
99 AddAction( actions.Get( i ), subgroup_content, input );
100 }
101
102 subgroup_content.Update();
103 }
104
105 void AddAction( int index, Widget parent, Input input )
106 {
107 m_KeyWidgets.Insert( index, new KeybindingElement( index, parent, this ) );
108 }
109
110 void ReloadAction( int index )
111 {
112 if( m_KeyWidgets.Contains( index ) )
113 {
114 m_KeyWidgets.Get( index ).Reload();
115 }
116 }
117
119 {
121 }
122
123 void ClearKeybind( int key_index )
124 {
125 m_Menu.ClearKeybind( key_index );
126 }
127
128 void ClearAlternativeKeybind( int key_index )
129 {
130 m_Menu.ClearAlternativeKeybind( key_index );
131 }
132
133 void StartEnteringKeybind( int key_index )
134 {
136 m_CurrentSettingKeyIndex = key_index;
137 m_Menu.StartEnteringKeybind( key_index );
138 }
139
141 {
142 if( m_CurrentSettingKeyIndex != -1 )
143 {
144 m_KeyWidgets.Get( m_CurrentSettingKeyIndex ).CancelEnteringKeybind();
146 }
147 }
148
149 void StartEnteringAlternateKeybind( int key_index )
150 {
153 m_Menu.StartEnteringAlternateKeybind( key_index );
154 }
155
157 {
159 {
160 m_KeyWidgets.Get( m_CurrentSettingAlternateKeyIndex ).CancelEnteringAlternateKeybind();
162 }
163 }
164
166 {
167 foreach( int index, KeybindingElement element : m_KeyWidgets )
168 {
169 if( element.IsChanged() || element.IsAlternateChanged() )
170 {
171 return true;
172 }
173 }
174 return false;
175 }
176
177 void Apply()
178 {
179 UAInputAPI ua_api = GetUApi();
180 foreach( int index, KeybindingElement element : m_KeyWidgets )
181 {
182 UAInput input = ua_api.GetInputByID( index );
183 int i;
184 if( element.IsChanged() )
185 {
186 array<int> new_keys = element.GetChangedBinds();
187
188/* if( input.AlternativeCount() == 0 )
189 {
190 input.AddAlternative();
191 }
192 else*/
193 {
194 input.ClearDeviceBind(EUAINPUT_DEVICE_KEYBOARDMOUSE);
195// input.SelectAlternative( 0 );
196// input.ClearAlternative( 0 );
197 }
198
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/* if( input.AlternativeCount() < 2 )
219 {
220 input.AddAlternative();
221 }
222 else*/
223 {
224 input.ClearDeviceBind(EUAINPUT_DEVICE_CONTROLLER);
225// input.SelectAlternative( 1 );
226// input.ClearAlternative( 1 );
227 }
228
229 if( new_alt_keys.Count() > 0 )
230 {
231 input.BindComboByHash( new_alt_keys.Get( 0 ) );
232 for( i = 1; i < new_alt_keys.Count(); i++ )
233 {
234 input.BindComboByHash( new_alt_keys.Get( i ) );
235 }
236 }
237 }
238 element.Reload();
239 }
240 }
241
242 //DEPRECATED
243 void Reset()
244 {
245 ResetEx();
246 }
247
248 void ResetEx(bool forced = false)
249 {
250 foreach( int index, KeybindingElement element : m_KeyWidgets )
251 {
252 if( element.IsChanged() || element.IsAlternateChanged() || forced )
253 {
254 element.Reload();
255 }
256 }
257 }
258
259 void Update( float timeslice )
260 {
262 {
263 UAInputAPI ua_api = GetUApi();
264 if( ua_api.DeterminePressedButton() != 0 )
265 {
266 string name;
267 string text;
268 ref array<int> new_keybinds = new array<int>;
269
270 // remove previous backlit
271 GetDayZGame().GetBacklit().KeybindingClear();
272
273 for( int i = 0; i < ua_api.DeterminedCount(); ++i )
274 {
275 int kb_id = ua_api.GetDetermined( i );
276 new_keybinds.Insert( kb_id );
277
278 // light up specific key
279 GetDayZGame().GetBacklit().KeybindingShow(kb_id);
280 }
281
282 if( m_CurrentSettingKeyIndex != -1 )
283 {
284 m_Menu.ConfirmKeybindEntry( new_keybinds );
285 m_KeyWidgets.Get( m_CurrentSettingKeyIndex ).Reload( new_keybinds, false );
287 }
288 else if( m_CurrentSettingAlternateKeyIndex != -1 )
289 {
290 m_Menu.ConfirmAlternateKeybindEntry( new_keybinds );
291 m_KeyWidgets.Get( m_CurrentSettingAlternateKeyIndex ).Reload( new_keybinds, true );
293 }
294 }
295 }
296 }
297
298 override bool OnMouseButtonDown( Widget w, int x, int y, int button )
299 {
300 if( !ButtonWidget.Cast( w ) )
301 {
302 m_KBDropdown.Close();
303 }
304 return false;
305 }
306}
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
map
Определения ControlsXboxNew.c:4
DayZGame GetDayZGame()
Определения DayZGame.c:3870
Icon x
Icon y
Widget m_Root
Определения SizeToChild.c:91
proto native UAInputAPI GetUApi()
proto native WorkspaceWidget GetWorkspace()
proto native Input GetInput()
proto native int GetProfilesCount()
gets profile by name
proto native int SetProfile(int index)
setting active profile
proto int GetActionGroupName(int group_index, out string name)
proto int GetProfileName(int profile_index, out string name)
gets profile by index
proto native int GetCurrentProfile()
gets currently selected profile
Определения input.c:11
void KeybindingsGroup(int index, Input input, Widget parent, KeybindingsMenu menu)
Определения KeybindingsGroup.c:13
int m_CurrentSettingKeyIndex
Определения KeybindingsGroup.c:8
void ClearAlternativeKeybind(int key_index)
Определения KeybindingsGroup.c:128
int m_CurrentSettingAlternateKeyIndex
Определения KeybindingsGroup.c:9
void Update(float timeslice)
Определения KeybindingsGroup.c:259
void DropdownPrefab(Widget root, string text="")
Определения DropdownPrefab.c:18
void OnSelectConsolePreset(int index)
Определения KeybindingsGroup.c:71
Widget m_Root
Определения SizeToChild.c:9
ref DropdownPrefab m_KBDropdown
Определения KeybindingsGroup.c:11
void InitPresets(int index, Widget parent, Input input)
Определения KeybindingsGroup.c:41
void AddSubgroup(Widget parent, Input input)
Определения KeybindingsGroup.c:87
ref map< int, ref KeybindingElement > m_KeyWidgets
Определения KeybindingsGroup.c:7
void AddAction(int index, Widget parent, Input input)
Определения KeybindingsGroup.c:105
void OnSelectKBPreset(int index)
Определения KeybindingsGroup.c:61
CameraToolsMenu m_Menu
Определения CTEvent.c:8
void ClearKeybind(int key_index)
Определения KeybindingsGroup.c:123
void ReloadAction(int index)
Определения KeybindingsGroup.c:110
void ReloadProfiles()
Определения KeybindingsGroup.c:79
bool IsEnteringKeyBind()
Определения KeybindingsGroup.c:118
void KeybindingElement(int key_index, Widget parent, KeybindingsGroup group)
Определения KeybindingElement.c:23
void CancelEnteringKeybind()
Определения KeybindingsGroup.c:140
void ResetEx(bool forced=false)
Определения KeybindingsGroup.c:248
void StartEnteringAlternateKeybind(int key_index)
Определения KeybindingsGroup.c:149
void CancelEnteringAlternateKeybind()
Определения KeybindingsGroup.c:156
void StartEnteringKeybind(int key_index)
Определения KeybindingsGroup.c:133
override bool OnMouseButtonDown(Widget w, int x, int y, int button)
Определения KeybindingsGroup.c:298
map: item x vector(index, width, height)
Определения EnWidgets.c:651
Определения EnWidgets.c:220
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 int DeterminePressedButton()
proto native void GetActiveInputs(out TIntArray items)
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
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.
WorkspaceWidget Widget
Defined in code.