Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
optionsmenucontrols.c
Go to the documentation of this file.
1 class OptionsMenuControls extends ScriptedWidgetEventHandler
2 {
3  protected Widget m_Root;
4 
5  protected Widget m_SettingsRoot;
6  protected Widget m_DetailsRoot;
7  protected Widget m_DetailsBodyDefault;
8  protected Widget m_DetailsBodyConnectivity;
9 #ifdef PLATFORM_CONSOLE
10  protected bool m_MaKOptionAvailable;
11  protected Widget m_ConsoleControllerSensitivityWidget;
12  protected Widget m_ConsoleMouseSensitivityWidget;
13 #endif
14  protected TextWidget m_DetailsLabel;
15  protected RichTextWidget m_DetailsText;
16  protected GridSpacerWidget m_Keybindings;
17 
18  protected GameOptions m_Options;
19  protected OptionsMenu m_Menu;
20 
21  // console options accessors
22  protected ref SwitchOptionsAccess m_KeyboardOption;
23  protected ref SwitchOptionsAccess m_AimHelperOption;
24 
25  // console options selectors
26  protected ref OptionSelectorMultistate m_KeyboardSelector;
27  protected ref OptionSelectorMultistate m_AimHelperSelector;
28 
29  // mouse accessors
30  protected ref SwitchOptionsAccess m_Mouse_InvertOption;
31  protected ref NumericOptionsAccess m_Mouse_VSensitivityOption;
32  protected ref NumericOptionsAccess m_Mouse_HSensitivityOption;
33  protected ref NumericOptionsAccess m_Mouse_AimMod_VSensitivityOption;
34  protected ref NumericOptionsAccess m_Mouse_AimMod_HSensitivityOption;
35 
36  // mouse selectors
37  protected ref OptionSelectorMultistate m_Mouse_InvertSelector;
38  protected ref OptionSelectorSlider m_Mouse_VSensitivitySelector;
39  protected ref OptionSelectorSlider m_Mouse_HSensitivitySelector;
40  protected ref OptionSelectorSlider m_Mouse_AimMod_VSensitivitySelector;
41  protected ref OptionSelectorSlider m_Mouse_AimMod_HSensitivitySelector;
42 
43  // gamepad/controller accessors
44  protected ref NumericOptionsAccess m_ControllerLS_VSensitivityOption;
45  protected ref NumericOptionsAccess m_ControllerLS_HSensitivityOption;
46  protected ref NumericOptionsAccess m_ControllerLS_VehicleMod_HSensitivityOption;
47  protected ref SwitchOptionsAccess m_ControllerRS_InvertOption;
48  protected ref NumericOptionsAccess m_ControllerRS_VSensitivityOption;
49  protected ref NumericOptionsAccess m_ControllerRS_HSensitivityOption;
50  protected ref NumericOptionsAccess m_ControllerRS_CurvatureOption;
51  protected ref NumericOptionsAccess m_ControllerRS_AimMod_VSensitivityOption;
52  protected ref NumericOptionsAccess m_ControllerRS_AimMod_HSensitivityOption;
53  protected ref NumericOptionsAccess m_ControllerRS_AimMod_CurvatureOption;
54 
55  // gamepad/controller selectors
56  protected ref OptionSelectorSlider m_ControllerLS_VSensitivitySelector;
57  protected ref OptionSelectorSlider m_ControllerLS_HSensitivitySelector;
58  protected ref OptionSelectorSlider m_ControllerLS_VehicleMod_HSensitivitySelector;
59  protected ref OptionSelectorMultistate m_ControllerRS_InvertSelector;
60  protected ref OptionSelectorSlider m_ControllerRS_VSensitivitySelector;
61  protected ref OptionSelectorSlider m_ControllerRS_HSensitivitySelector;
62  protected ref OptionSelectorSlider m_ControllerRS_CurvatureSelector;
63  protected ref OptionSelectorSlider m_ControllerRS_AimMod_VSensitivitySelector;
64  protected ref OptionSelectorSlider m_ControllerRS_AimMod_HSensitivitySelector;
65  protected ref OptionSelectorSlider m_ControllerRS_AimMod_CurvatureSelector;
66 
67  protected ref map<int, ref Param2<string, string>> m_TextMap;
68 
69  static const float SLIDER_STEP = 0.025;
70 
71  void OptionsMenuControls( Widget parent, Widget details_root, GameOptions options, OptionsMenu menu )
72  {
73  array<string> opt = { "#options_controls_disabled", "#options_controls_enabled" };
74 
75  m_Root = GetGame().GetWorkspace().CreateWidgets( GetLayoutName(), parent );
76  m_Options = options;
77  m_Menu = menu;
78 
79  m_DetailsRoot = details_root;
80  m_DetailsBodyDefault = m_DetailsRoot.FindAnyWidget("settings_details_body");
81  m_DetailsBodyConnectivity = m_DetailsRoot.FindAnyWidget("settings_details_body_connectivity");
82  m_DetailsLabel = TextWidget.Cast( m_DetailsRoot.FindAnyWidget( "details_label" ) );
83  m_DetailsText = RichTextWidget.Cast( m_DetailsRoot.FindAnyWidget( "details_content" ) );
84  m_Keybindings = GridSpacerWidget.Cast( m_Root.FindAnyWidget( "keyboard_settings_content" ) );
85  if( m_Keybindings )
86  m_Keybindings.SetUserID( 777 );
87 
88  SetOptions( options );
89 
90  // mouse (PC & consoles)
91  Widget mouse_InvertSettingOption = m_Root.FindAnyWidget( "mouse_invert_setting_option" );
92  Widget mouse_VSensitivitySettingOption = m_Root.FindAnyWidget( "mouse_vsensitivity_setting_option" );
93  Widget mouse_HSensitivitySettingOption = m_Root.FindAnyWidget( "mouse_hsensitivity_setting_option" );
94  Widget mouse_AimMod_VSensitivitySettingOption = m_Root.FindAnyWidget( "mouse_aimmod_vsensitivity_setting_option" );
95  Widget mouse_AimMod_HSensitivitySettingOption = m_Root.FindAnyWidget( "mouse_aimmod_hsensitivity_setting_option" );
96 
97  mouse_InvertSettingOption.SetUserID( OptionAccessType.AT_OPTIONS_MOUSE_YAXIS_INVERTED );
98  mouse_VSensitivitySettingOption.SetUserID( OptionAccessType.AT_OPTIONS_MOUSE_YAXIS );
99  mouse_HSensitivitySettingOption.SetUserID( OptionAccessType.AT_OPTIONS_MOUSE_XAXIS );
100  mouse_AimMod_VSensitivitySettingOption.SetUserID( OptionAccessType.AT_OPTIONS_MOUSE_YAXIS_AIM_MOD );
101  mouse_AimMod_HSensitivitySettingOption.SetUserID( OptionAccessType.AT_OPTIONS_MOUSE_XAXIS_AIM_MOD );
102 
103  m_Mouse_InvertSelector = new OptionSelectorMultistate( mouse_InvertSettingOption, m_Mouse_InvertOption.GetIndex(), this, false, opt );
104  m_Mouse_VSensitivitySelector = new OptionSelectorSlider( mouse_VSensitivitySettingOption, m_Mouse_VSensitivityOption.ReadValue(), this, false, m_Mouse_VSensitivityOption.GetMin(), m_Mouse_VSensitivityOption.GetMax() );
105  m_Mouse_VSensitivitySelector.SetStep(SLIDER_STEP);
106  m_Mouse_HSensitivitySelector = new OptionSelectorSlider( mouse_HSensitivitySettingOption, m_Mouse_HSensitivityOption.ReadValue(), this, false, m_Mouse_HSensitivityOption.GetMin(), m_Mouse_HSensitivityOption.GetMax() );
107  m_Mouse_HSensitivitySelector.SetStep(SLIDER_STEP);
108  m_Mouse_AimMod_VSensitivitySelector = new OptionSelectorSlider( mouse_AimMod_VSensitivitySettingOption, m_Mouse_AimMod_VSensitivityOption.ReadValue(), this, false, m_Mouse_AimMod_VSensitivityOption.GetMin(), m_Mouse_AimMod_VSensitivityOption.GetMax() );
109  m_Mouse_AimMod_VSensitivitySelector.SetStep(SLIDER_STEP);
110  m_Mouse_AimMod_HSensitivitySelector = new OptionSelectorSlider( mouse_AimMod_HSensitivitySettingOption, m_Mouse_AimMod_HSensitivityOption.ReadValue(), this, false, m_Mouse_AimMod_HSensitivityOption.GetMin(), m_Mouse_AimMod_HSensitivityOption.GetMax() );
111  m_Mouse_AimMod_HSensitivitySelector.SetStep(SLIDER_STEP);
112 
113  m_Mouse_InvertSelector.m_OptionChanged.Insert( UpdateMouseInvertView );
114  m_Mouse_VSensitivitySelector.m_OptionChanged.Insert( UpdateMouseVSensitivity );
115  m_Mouse_HSensitivitySelector.m_OptionChanged.Insert( UpdateMouseHSensitivity );
116  m_Mouse_AimMod_VSensitivitySelector.m_OptionChanged.Insert( UpdateMouseAimModVSensitivity );
117  m_Mouse_AimMod_HSensitivitySelector.m_OptionChanged.Insert( UpdateMouseAimModHSensitivity );
118 
119  // controller (consoles only)
120  #ifdef PLATFORM_CONSOLE
121  m_MaKOptionAvailable = g_Game.GetGameState() != DayZGameState.IN_GAME || GetGame().GetWorld().IsMouseAndKeyboardEnabledOnServer();
122  m_ConsoleControllerSensitivityWidget = m_Root.FindAnyWidget( "controller_settings_root" );
123  m_ConsoleMouseSensitivityWidget = m_Root.FindAnyWidget( "mouse_settings_root" );
124 
125  Widget keyboardSettingOption = m_Root.FindAnyWidget( "keyboard_setting_option" );
126  Widget aimHelperSettingOption = m_Root.FindAnyWidget( "aimhelper_setting_option" );
127 
128  Widget controllerLS_VSensitivitySettingOption = m_Root.FindAnyWidget("controller_ls_vsensitivity_setting_option");
129  Widget controllerLS_HSensitivitySettingOption = m_Root.FindAnyWidget("controller_ls_hsensitivity_setting_option");
130  Widget controllerLS_VehicleMod_HSensitivitySettingOption = m_Root.FindAnyWidget("controller_ls_vehicle_sensitivity_setting_option");
131  Widget controllerRS_InvertSettingOption = m_Root.FindAnyWidget("controller_rs_invert_setting_option");
132  Widget controllerRS_VSensitivitySettingOption = m_Root.FindAnyWidget("controller_rs_vsensitivity_setting_option");
133  Widget controllerRS_HSensitivitySettingOption = m_Root.FindAnyWidget("controller_rs_hsensitivity_setting_option");
134  Widget controllerRS_CurvatureSettingOption = m_Root.FindAnyWidget("controller_rs_curvature_setting_option");
135  Widget controllerRS_AimMod_VSensitivitySettingOption = m_Root.FindAnyWidget("controller_rs_aimmod_vsensitivity_setting_option");
136  Widget controllerRS_AimMod_HSensitivitySettingOption = m_Root.FindAnyWidget("controller_rs_aimmod_hsensitivity_setting_option");
137  Widget controllerRS_AimMod_CurvatureSettingOption = m_Root.FindAnyWidget("controller_rs_aimmod_curvature_setting_option");
138 
139  keyboardSettingOption.SetUserID( OptionAccessType.AT_OPTIONS_MOUSE_AND_KEYBOARD );
140  aimHelperSettingOption.SetUserID( OptionAccessType.AT_OPTIONS_AIM_HELPER );
141 
142  controllerLS_VSensitivitySettingOption.SetUserID( OptionAccessType.AT_OPTIONS_CONTROLLER_LS_YAXIS );
143  controllerLS_HSensitivitySettingOption.SetUserID( OptionAccessType.AT_OPTIONS_CONTROLLER_LS_XAXIS );
144  controllerLS_VehicleMod_HSensitivitySettingOption.SetUserID( OptionAccessType.AT_OPTIONS_CONTROLLER_LS_XAXIS_VEHICLE_MOD );
145  controllerRS_InvertSettingOption.SetUserID( OptionAccessType.AT_OPTIONS_CONTROLLER_RS_YAXIS_INVERTED );
146  controllerRS_VSensitivitySettingOption.SetUserID( OptionAccessType.AT_OPTIONS_CONTROLLER_RS_YAXIS );
147  controllerRS_HSensitivitySettingOption.SetUserID( OptionAccessType.AT_OPTIONS_CONTROLLER_RS_XAXIS );
148  controllerRS_CurvatureSettingOption.SetUserID( OptionAccessType.AT_OPTIONS_CONTROLLER_RS_CURVATURE );
149  controllerRS_AimMod_VSensitivitySettingOption.SetUserID( OptionAccessType.AT_OPTIONS_CONTROLLER_RS_YAXIS_AIM_MOD );
150  controllerRS_AimMod_HSensitivitySettingOption.SetUserID( OptionAccessType.AT_OPTIONS_CONTROLLER_RS_XAXIS_AIM_MOD );
151  controllerRS_AimMod_CurvatureSettingOption.SetUserID( OptionAccessType.AT_OPTIONS_CONTROLLER_RS_CURVATURE_AIM_MOD );
152 
153  m_KeyboardSelector = new OptionSelectorMultistate( keyboardSettingOption, m_KeyboardOption.GetIndex(), this, !m_MaKOptionAvailable, opt );
154  m_AimHelperSelector = new OptionSelectorMultistate( aimHelperSettingOption, m_AimHelperOption.GetIndex(), this, false, opt );
155 
156  m_ControllerLS_VSensitivitySelector = new OptionSelectorSlider( controllerLS_VSensitivitySettingOption, m_ControllerLS_VSensitivityOption.ReadValue(), this, false, m_ControllerLS_VSensitivityOption.GetMin(), m_ControllerLS_VSensitivityOption.GetMax() );
157  m_ControllerLS_VSensitivitySelector.SetStep(SLIDER_STEP);
158  m_ControllerLS_HSensitivitySelector = new OptionSelectorSlider( controllerLS_HSensitivitySettingOption, m_ControllerLS_HSensitivityOption.ReadValue(), this, false, m_ControllerLS_HSensitivityOption.GetMin(), m_ControllerLS_HSensitivityOption.GetMax() );
159  m_ControllerLS_HSensitivitySelector.SetStep(SLIDER_STEP);
160  m_ControllerLS_VehicleMod_HSensitivitySelector = new OptionSelectorSlider( controllerLS_VehicleMod_HSensitivitySettingOption, m_ControllerLS_VehicleMod_HSensitivityOption.ReadValue(), this, false, m_ControllerLS_VehicleMod_HSensitivityOption.GetMin(), m_ControllerLS_VehicleMod_HSensitivityOption.GetMax() );
161  m_ControllerLS_VehicleMod_HSensitivitySelector.SetStep(SLIDER_STEP);
162  m_ControllerRS_InvertSelector = new OptionSelectorMultistate( controllerRS_InvertSettingOption, m_ControllerRS_InvertOption.GetIndex(), this, false, opt );
163  m_ControllerRS_VSensitivitySelector = new OptionSelectorSlider( controllerRS_VSensitivitySettingOption, m_ControllerRS_VSensitivityOption.ReadValue(), this, false, m_ControllerRS_VSensitivityOption.GetMin(), m_ControllerRS_VSensitivityOption.GetMax() );
164  m_ControllerRS_VSensitivitySelector.SetStep(SLIDER_STEP);
165  m_ControllerRS_HSensitivitySelector = new OptionSelectorSlider( controllerRS_HSensitivitySettingOption, m_ControllerRS_HSensitivityOption.ReadValue(), this, false, m_ControllerRS_HSensitivityOption.GetMin(), m_ControllerRS_HSensitivityOption.GetMax() );
166  m_ControllerRS_HSensitivitySelector.SetStep(SLIDER_STEP);
167  m_ControllerRS_CurvatureSelector = new OptionSelectorSlider( controllerRS_CurvatureSettingOption, m_ControllerRS_CurvatureOption.ReadValue(), this, false, m_ControllerRS_CurvatureOption.GetMin(), m_ControllerRS_CurvatureOption.GetMax() );
168  m_ControllerRS_CurvatureSelector.SetStep(SLIDER_STEP);
169  m_ControllerRS_AimMod_VSensitivitySelector = new OptionSelectorSlider( controllerRS_AimMod_VSensitivitySettingOption, m_ControllerRS_AimMod_VSensitivityOption.ReadValue(), this, false, m_ControllerRS_AimMod_VSensitivityOption.GetMin(), m_ControllerRS_AimMod_VSensitivityOption.GetMax() );
170  m_ControllerRS_AimMod_VSensitivitySelector.SetStep(SLIDER_STEP);
171  m_ControllerRS_AimMod_HSensitivitySelector = new OptionSelectorSlider( controllerRS_AimMod_HSensitivitySettingOption, m_ControllerRS_AimMod_HSensitivityOption.ReadValue(), this, false, m_ControllerRS_AimMod_HSensitivityOption.GetMin(), m_ControllerRS_AimMod_HSensitivityOption.GetMax() );
172  m_ControllerRS_AimMod_HSensitivitySelector.SetStep(SLIDER_STEP);
173  m_ControllerRS_AimMod_CurvatureSelector = new OptionSelectorSlider( controllerRS_AimMod_CurvatureSettingOption, m_ControllerRS_AimMod_CurvatureOption.ReadValue(), this, false, m_ControllerRS_AimMod_CurvatureOption.GetMin(), m_ControllerRS_AimMod_CurvatureOption.GetMax() );
174  m_ControllerRS_AimMod_CurvatureSelector.SetStep(SLIDER_STEP);
175 
176  m_KeyboardSelector.m_OptionChanged.Insert( UpdateKeyboard );
177  m_AimHelperSelector.m_OptionChanged.Insert( UpdateAimHelper );
178 
179  m_ControllerLS_VSensitivitySelector.m_OptionChanged.Insert( UpdateControllerLS_VSensitivity );
180  m_ControllerLS_HSensitivitySelector.m_OptionChanged.Insert( UpdateControllerLS_HSensitivity );
181  m_ControllerLS_VehicleMod_HSensitivitySelector.m_OptionChanged.Insert( UpdateControllerLS_VehicleMod_HSensitivity );
182  m_ControllerRS_InvertSelector.m_OptionChanged.Insert( UpdateControllerRS_InvertView );
183  m_ControllerRS_VSensitivitySelector.m_OptionChanged.Insert( UpdateControllerRS_VSensitivity );
184  m_ControllerRS_HSensitivitySelector.m_OptionChanged.Insert( UpdateControllerRS_HSensitivity );
185  m_ControllerRS_CurvatureSelector.m_OptionChanged.Insert( UpdateControllerRS_Curvature );
186  m_ControllerRS_AimMod_VSensitivitySelector.m_OptionChanged.Insert( UpdateControllerRS_AimMod_VSensitivity );
187  m_ControllerRS_AimMod_HSensitivitySelector.m_OptionChanged.Insert( UpdateControllerRS_AimMod_HSensitivity );
188  m_ControllerRS_AimMod_CurvatureSelector.m_OptionChanged.Insert( UpdateControllerRS_AimMod_Curvature );
189 
190  ShowConsoleSensitivityOptions(m_KeyboardOption.GetIndex());
191 
192  bool MaKState = m_KeyboardSelector.IsEnabled() && GetGame().GetInput().IsEnabledMouseAndKeyboardEvenOnServer();
193  GetGame().GetCallQueue(CALL_CATEGORY_GUI).Call(m_Menu.ToggleDependentOptions,EDependentOptions.MOUSEANDKEYBOARD_QUICKBAR,MaKState);
194  #endif
195 
196  FillTextMap();
197 
198  float x, y, y2;
199  m_Root.FindAnyWidget( "controls_settings_scroll" ).GetScreenSize( x, y );
200  m_Root.FindAnyWidget( "controls_settings_root" ).GetScreenSize( x, y2 );
201  int f = ( y2 > y );
202  m_Root.FindAnyWidget( "controls_settings_scroll" ).SetAlpha( f );
203 
204  m_Root.SetHandler( this );
205  }
206 
207  string GetLayoutName()
208  {
209  #ifdef PLATFORM_CONSOLE
210  return "gui/layouts/new_ui/options/xbox/controls_tab.layout";
211  #else
212  return "gui/layouts/new_ui/options/pc/controls_tab.layout";
213  #endif
214  }
215 
216  void EnterKeybindingMenu()
217  {
218  m_Menu.EnterScriptedMenu( MENU_KEYBINDINGS );
219  }
220 
222  void Focus()
223  {
224  #ifdef PLATFORM_CONSOLE
225  if (m_KeyboardSelector && m_KeyboardSelector.IsSelectorEnabled())
226  {
227  m_KeyboardSelector.Focus();
228  }
229  else if (m_AimHelperSelector)
230  {
231  m_AimHelperSelector.Focus();
232  }
233  #endif
234  }
235 
236  override bool OnMouseEnter( Widget w, int x, int y )
237  {
238  if ( w && w.IsInherited( ScrollWidget ) )
239  {
240  return false;
241  }
242 
243  m_Menu.ColorHighlight( w );
244 
245  return true;
246  }
247 
248  override bool OnMouseLeave( Widget w, Widget enterW, int x, int y )
249  {
250  if ( w && w.IsInherited( ScrollWidget ) )
251  {
252  return false;
253  }
254 
255  m_Menu.ColorNormal( w );
256  return true;
257  }
258 
259  override bool OnMouseButtonUp( Widget w, int x, int y, int button )
260  {
261  if( button == MouseState.LEFT )
262  {
263  #ifndef PLATFORM_CONSOLE
264  if( w == m_Keybindings )
265  {
266  EnterKeybindingMenu();
267  return true;
268  }
269  #endif
270  }
271  return false;
272  }
273 
274  override bool OnFocus( Widget w, int x, int y )
275  {
276  OptionsMenu menu = OptionsMenu.Cast( GetGame().GetUIManager().GetMenu() );
277  if( menu )
278  {
279  menu.OnFocus( w, x, y );
280  }
281 
282  if( w )
283  {
284  if (TextMapUpdateWidget(w.GetUserID()))
285  {
286  return true;
287  }
288 
289  if( w.IsInherited( SliderWidget ) )
290  {
291  ColorRed( w );
292  return true;
293  }
294 
295  if( IsFocusable( w ) )
296  {
297  ColorRed( w );
298  return true;
299  }
300  }
301  else
302  {
303  m_DetailsRoot.Show( false );
304  }
305  return ( w != null );
306  }
307 
308  override bool OnFocusLost( Widget w, int x, int y )
309  {
310  if( IsFocusable( w ) )
311  {
312  ColorWhite( w, null );
313  return true;
314  }
315  return false;
316  }
317 
318  bool IsFocusable( Widget w )
319  {
320  return w && (w.GetFlags() & ~WidgetFlags.NOFOCUS);
321  }
322 
323  bool TextMapUpdateWidget(int key)
324  {
325  bool connectivityInfoShown = key == OptionIDsScript.OPTION_CONNECTIVITY_INFO;
327  Param tmp = m_TextMap.Get(key);
328 
329  m_DetailsBodyDefault.Show(!connectivityInfoShown);
330  m_DetailsBodyConnectivity.Show(connectivityInfoShown);
331 
332  if (Class.CastTo(p,tmp))
333  {
334  m_DetailsRoot.Show(true);
335  m_DetailsText.Show(true);
336  m_DetailsLabel.SetText(p.param1);
337  m_DetailsText.SetText(p.param2);
338 
339  m_DetailsText.Update();
340  m_DetailsLabel.Update();
341  m_DetailsRoot.Update();
342  m_DetailsBodyConnectivity.Update(); //...
343  return true;
344  }
345  return false;
346  }
347 
348  bool IsChanged()
349  {
350  #ifdef PLATFORM_CONSOLE
351  return ( ( m_KeyboardSelector.IsEnabled() && m_KeyboardOption.GetIndex() == 0 ) || ( !m_KeyboardSelector.IsEnabled() && m_KeyboardOption.GetIndex() == 1 ) );
352  #else
353  return false;
354  #endif
355  }
356 
357  void Apply()
358  {
359  #ifdef PLATFORM_CONSOLE
360  bool changed = false;
361  if (m_MaKOptionAvailable)
362  {
363  //on change
364  if ((m_KeyboardSelector.IsEnabled() && m_KeyboardOption.GetIndex() == 0) || (!m_KeyboardSelector.IsEnabled() && m_KeyboardOption.GetIndex() == 1))
365  {
366  m_KeyboardOption.Switch();
367  changed = true;
368  }
369  }
370 
371  Focus();
372  GetGame().GetUIManager().ShowUICursor( m_MaKOptionAvailable && m_KeyboardOption.GetIndex() );
373  if (changed)
374  g_Game.UpdateInputDeviceDisconnectWarning();
375 
376  m_Menu.Refresh();
377  #endif
378  }
379 
380  void Revert()
381  {
382  if( m_Mouse_InvertSelector )
383  m_Mouse_InvertSelector.SetValue( m_Mouse_InvertOption.GetIndex(), true );
384  if( m_Mouse_VSensitivitySelector )
385  m_Mouse_VSensitivitySelector.SetValue( m_Mouse_VSensitivityOption.ReadValue(), true );
386  if( m_Mouse_HSensitivitySelector )
387  m_Mouse_HSensitivitySelector.SetValue( m_Mouse_HSensitivityOption.ReadValue(), true );
388  if( m_Mouse_AimMod_VSensitivitySelector )
389  m_Mouse_AimMod_VSensitivitySelector.SetValue( m_Mouse_AimMod_VSensitivityOption.ReadValue(), true );
390  if( m_Mouse_AimMod_HSensitivitySelector )
391  m_Mouse_AimMod_HSensitivitySelector.SetValue( m_Mouse_AimMod_HSensitivityOption.ReadValue(), true );
392 
393 
394  #ifdef PLATFORM_CONSOLE
395  if( m_KeyboardSelector )
396  m_KeyboardSelector.SetValue( m_KeyboardOption.GetIndex(), true );
397  if( m_AimHelperSelector )
398  m_AimHelperSelector.SetValue( m_AimHelperOption.GetIndex(), true );
399 
400  if( m_ControllerLS_VSensitivitySelector )
401  m_ControllerLS_VSensitivitySelector.SetValue( m_ControllerLS_VSensitivityOption.ReadValue(), true );
402  if( m_ControllerLS_HSensitivitySelector )
403  m_ControllerLS_HSensitivitySelector.SetValue( m_ControllerLS_HSensitivityOption.ReadValue(), true );
404  if( m_ControllerLS_VehicleMod_HSensitivitySelector )
405  m_ControllerLS_VehicleMod_HSensitivitySelector.SetValue( m_ControllerLS_VehicleMod_HSensitivityOption.ReadValue(), true );
406  if( m_ControllerRS_InvertSelector )
407  m_ControllerRS_InvertSelector.SetValue( m_ControllerRS_InvertOption.GetIndex(), true );
408  if( m_ControllerRS_VSensitivitySelector )
409  m_ControllerRS_VSensitivitySelector.SetValue( m_ControllerRS_VSensitivityOption.ReadValue(), true );
410  if( m_ControllerRS_HSensitivitySelector )
411  m_ControllerRS_HSensitivitySelector.SetValue( m_ControllerRS_HSensitivityOption.ReadValue(), true );
412  if( m_ControllerRS_CurvatureSelector )
413  m_ControllerRS_CurvatureSelector.SetValue( m_ControllerRS_CurvatureOption.ReadValue(), true );
414  if( m_ControllerRS_AimMod_VSensitivitySelector )
415  m_ControllerRS_AimMod_VSensitivitySelector.SetValue( m_ControllerRS_AimMod_VSensitivityOption.ReadValue(), true );
416  if( m_ControllerRS_AimMod_HSensitivitySelector )
417  m_ControllerRS_AimMod_HSensitivitySelector.SetValue( m_ControllerRS_AimMod_HSensitivityOption.ReadValue(), true );
418  if( m_ControllerRS_AimMod_CurvatureSelector )
419  m_ControllerRS_AimMod_CurvatureSelector.SetValue( m_ControllerRS_AimMod_CurvatureOption.ReadValue(), true );
420  #endif
421  }
422 
423  void SetToDefaults()
424  {
425  if( m_Mouse_InvertSelector )
426  m_Mouse_InvertSelector.SetValue( m_Mouse_InvertOption.GetDefaultIndex(), true );
427  if( m_Mouse_VSensitivitySelector )
428  m_Mouse_VSensitivitySelector.SetValue( m_Mouse_VSensitivityOption.GetDefault(), true );
429  if( m_Mouse_HSensitivitySelector )
430  m_Mouse_HSensitivitySelector.SetValue( m_Mouse_HSensitivityOption.GetDefault(), true );
431  if( m_Mouse_AimMod_VSensitivitySelector )
432  m_Mouse_AimMod_VSensitivitySelector.SetValue( m_Mouse_AimMod_VSensitivityOption.GetDefault(), true );
433  if( m_Mouse_AimMod_HSensitivitySelector )
434  m_Mouse_AimMod_HSensitivitySelector.SetValue( m_Mouse_AimMod_HSensitivityOption.GetDefault(), true );
435 
436  #ifdef PLATFORM_CONSOLE
437  if( m_KeyboardSelector )
438  m_KeyboardSelector.SetValue( m_KeyboardOption.GetDefaultIndex(), true );
439  if( m_AimHelperSelector )
440  m_AimHelperSelector.SetValue( m_AimHelperOption.GetDefaultIndex(), true );
441 
442  if( m_ControllerLS_VSensitivitySelector )
443  m_ControllerLS_VSensitivitySelector.SetValue( m_ControllerLS_VSensitivityOption.GetDefault(), true );
444  if( m_ControllerLS_HSensitivitySelector )
445  m_ControllerLS_HSensitivitySelector.SetValue( m_ControllerLS_HSensitivityOption.GetDefault(), true );
446  if( m_ControllerLS_VehicleMod_HSensitivitySelector )
447  m_ControllerLS_VehicleMod_HSensitivitySelector.SetValue( m_ControllerLS_VehicleMod_HSensitivityOption.GetDefault(), true );
448  if( m_ControllerRS_InvertSelector )
449  m_ControllerRS_InvertSelector.SetValue( m_ControllerRS_InvertOption.GetDefaultIndex(), true );
450  if( m_ControllerRS_VSensitivitySelector )
451  m_ControllerRS_VSensitivitySelector.SetValue( m_ControllerRS_VSensitivityOption.GetDefault(), true );
452  if( m_ControllerRS_HSensitivitySelector )
453  m_ControllerRS_HSensitivitySelector.SetValue( m_ControllerRS_HSensitivityOption.GetDefault(), true );
454  if( m_ControllerRS_CurvatureSelector )
455  m_ControllerRS_CurvatureSelector.SetValue( m_ControllerRS_CurvatureOption.GetDefault(), true );
456  if( m_ControllerRS_AimMod_VSensitivitySelector )
457  m_ControllerRS_AimMod_VSensitivitySelector.SetValue( m_ControllerRS_AimMod_VSensitivityOption.GetDefault(), true );
458  if( m_ControllerRS_AimMod_HSensitivitySelector )
459  m_ControllerRS_AimMod_HSensitivitySelector.SetValue( m_ControllerRS_AimMod_HSensitivityOption.GetDefault(), true );
460  if( m_ControllerRS_AimMod_CurvatureSelector )
461  m_ControllerRS_AimMod_CurvatureSelector.SetValue( m_ControllerRS_AimMod_CurvatureOption.GetDefault(), true );
462 
463  Focus();
464  #endif
465 
466  }
467 
468 #ifdef PLATFORM_CONSOLE
469  void ShowConsoleSensitivityOptions(int index)
470  {
471  m_ConsoleMouseSensitivityWidget.Show(index == 1 && m_MaKOptionAvailable);
472  }
473 
474  void UpdateKeyboard( int index )
475  {
476  Focus();
477  ShowConsoleSensitivityOptions(index);
478  m_Menu.OnChanged();
479  //m_Menu.ToggleDependentOptions(EDependentOptions.MOUSEANDKEYBOARD_QUICKBAR,index == 1 && GetGame().GetInput().IsEnabledMouseAndKeyboardEvenOnServer());
480  }
481 
482  void UpdateAimHelper( int index )
483  {
484  if ( m_AimHelperOption.GetIndex() != index )
485  {
486  m_AimHelperOption.Switch();
487  m_Menu.OnChanged();
488  }
489  }
490 
491  void UpdateControllerLS_VSensitivity( float value )
492  {
493  m_ControllerLS_VSensitivityOption.WriteValue( value );
494  m_Menu.OnChanged();
495  }
496 
497  void UpdateControllerLS_HSensitivity( float value )
498  {
499  m_ControllerLS_HSensitivityOption.WriteValue( value );
500  m_Menu.OnChanged();
501  }
502 
503  void UpdateControllerLS_VehicleMod_HSensitivity( float value )
504  {
505  m_ControllerLS_VehicleMod_HSensitivityOption.WriteValue( value );
506  m_Menu.OnChanged();
507  }
508 
509  void UpdateControllerRS_InvertView( int index )
510  {
511  if ( m_ControllerRS_InvertOption.GetIndex() != index )
512  {
513  m_ControllerRS_InvertOption.Switch();
514  m_Menu.OnChanged();
515  }
516  }
517 
518  void UpdateControllerRS_VSensitivity( float value )
519  {
520  m_ControllerRS_VSensitivityOption.WriteValue( value );
521  m_Menu.OnChanged();
522  }
523 
524  void UpdateControllerRS_HSensitivity( float value )
525  {
526  m_ControllerRS_HSensitivityOption.WriteValue( value );
527  m_Menu.OnChanged();
528  }
529 
530  void UpdateControllerRS_Curvature( float value )
531  {
532  m_ControllerRS_CurvatureOption.WriteValue( value );
533  m_Menu.OnChanged();
534  }
535 
536  void UpdateControllerRS_AimMod_VSensitivity( float value )
537  {
538  m_ControllerRS_AimMod_VSensitivityOption.WriteValue( value );
539  m_Menu.OnChanged();
540  }
541 
542  void UpdateControllerRS_AimMod_HSensitivity( float value )
543  {
544  m_ControllerRS_AimMod_HSensitivityOption.WriteValue( value );
545  m_Menu.OnChanged();
546  }
547 
548  void UpdateControllerRS_AimMod_Curvature( float value )
549  {
550  m_ControllerRS_AimMod_CurvatureOption.WriteValue( value );
551  m_Menu.OnChanged();
552  }
553 #endif
554 
555  void UpdateMouseInvertView( int index )
556  {
557  if ( m_Mouse_InvertOption.GetIndex() != index )
558  {
559  m_Mouse_InvertOption.Switch();
560  m_Menu.OnChanged();
561  }
562  }
563 
564  void UpdateMouseVSensitivity( float value )
565  {
566  m_Mouse_VSensitivityOption.WriteValue( value );
567  m_Menu.OnChanged();
568  }
569 
570  void UpdateMouseHSensitivity( float value )
571  {
572  m_Mouse_HSensitivityOption.WriteValue( value );
573  m_Menu.OnChanged();
574  }
575 
576  void UpdateMouseAimModVSensitivity( float value )
577  {
578  m_Mouse_AimMod_VSensitivityOption.WriteValue( value );
579  m_Menu.OnChanged();
580  }
581 
582  void UpdateMouseAimModHSensitivity( float value )
583  {
584  m_Mouse_AimMod_HSensitivityOption.WriteValue( value );
585  m_Menu.OnChanged();
586  }
587 
588  void ReloadOptions()
589  {
590  m_Menu.ReloadOptions();
591  }
592 
593  void SetOptions( GameOptions options )
594  {
595  m_Options = options;
596 
597  // mouse (PC & consoles)
598  m_Mouse_InvertOption = SwitchOptionsAccess.Cast( m_Options.GetOptionByType( OptionAccessType.AT_OPTIONS_MOUSE_YAXIS_INVERTED ) );
599  m_Mouse_VSensitivityOption = NumericOptionsAccess.Cast( m_Options.GetOptionByType( OptionAccessType.AT_OPTIONS_MOUSE_YAXIS ) );
600  m_Mouse_HSensitivityOption = NumericOptionsAccess.Cast( m_Options.GetOptionByType( OptionAccessType.AT_OPTIONS_MOUSE_XAXIS ) );
601  m_Mouse_AimMod_VSensitivityOption = NumericOptionsAccess.Cast( m_Options.GetOptionByType( OptionAccessType.AT_OPTIONS_MOUSE_YAXIS_AIM_MOD ) );
602  m_Mouse_AimMod_HSensitivityOption = NumericOptionsAccess.Cast( m_Options.GetOptionByType( OptionAccessType.AT_OPTIONS_MOUSE_XAXIS_AIM_MOD ) );
603 
604  // controller (consoles only)
605  #ifdef PLATFORM_CONSOLE
606  m_KeyboardOption = SwitchOptionsAccess.Cast( m_Options.GetOptionByType( OptionAccessType.AT_OPTIONS_MOUSE_AND_KEYBOARD ) );
607  m_AimHelperOption = SwitchOptionsAccess.Cast( m_Options.GetOptionByType( OptionAccessType.AT_OPTIONS_AIM_HELPER ) );
608 
609  m_ControllerLS_VSensitivityOption = NumericOptionsAccess.Cast( m_Options.GetOptionByType( OptionAccessType.AT_OPTIONS_CONTROLLER_LS_YAXIS ) );
610  m_ControllerLS_HSensitivityOption = NumericOptionsAccess.Cast( m_Options.GetOptionByType( OptionAccessType.AT_OPTIONS_CONTROLLER_LS_XAXIS ) );
611  m_ControllerLS_VehicleMod_HSensitivityOption = NumericOptionsAccess.Cast( m_Options.GetOptionByType( OptionAccessType.AT_OPTIONS_CONTROLLER_LS_XAXIS_VEHICLE_MOD ) );
612  m_ControllerRS_InvertOption = SwitchOptionsAccess.Cast( m_Options.GetOptionByType( OptionAccessType.AT_OPTIONS_CONTROLLER_RS_YAXIS_INVERTED ) );
613  m_ControllerRS_VSensitivityOption = NumericOptionsAccess.Cast( m_Options.GetOptionByType( OptionAccessType.AT_OPTIONS_CONTROLLER_RS_YAXIS ) );
614  m_ControllerRS_HSensitivityOption = NumericOptionsAccess.Cast( m_Options.GetOptionByType( OptionAccessType.AT_OPTIONS_CONTROLLER_RS_XAXIS ) );
615  m_ControllerRS_CurvatureOption = NumericOptionsAccess.Cast( m_Options.GetOptionByType( OptionAccessType.AT_OPTIONS_CONTROLLER_RS_CURVATURE ) );
616  m_ControllerRS_AimMod_VSensitivityOption = NumericOptionsAccess.Cast( m_Options.GetOptionByType( OptionAccessType.AT_OPTIONS_CONTROLLER_RS_YAXIS_AIM_MOD ) );
617  m_ControllerRS_AimMod_HSensitivityOption = NumericOptionsAccess.Cast( m_Options.GetOptionByType( OptionAccessType.AT_OPTIONS_CONTROLLER_RS_XAXIS_AIM_MOD ) );
618  m_ControllerRS_AimMod_CurvatureOption = NumericOptionsAccess.Cast( m_Options.GetOptionByType( OptionAccessType.AT_OPTIONS_CONTROLLER_RS_CURVATURE_AIM_MOD ) );
619  #endif
620 
621  Revert();
622  }
623 
624  void ToggleDependentOptions(int mode, bool state)
625  {
626  }
627 
628  void InitDependentOptionsVisibility()
629  {
630  }
631 
632  void FillTextMap()
633  {
634  m_TextMap = new map<int, ref Param2<string, string>>;
635  m_TextMap.Insert( OptionAccessType.AT_OPTIONS_MOUSE_YAXIS_INVERTED, new Param2<string, string>( "#STR_Invert_Vertical_tip_header", "#STR_Invert_Vertical_tip" ) );
636  m_TextMap.Insert( OptionAccessType.AT_OPTIONS_MOUSE_YAXIS, new Param2<string, string>( "#STR_Camera_V_Sensitivity_tip_header", "#STR_Camera_V_Sensitivity_tip" ) );
637  m_TextMap.Insert( OptionAccessType.AT_OPTIONS_MOUSE_XAXIS, new Param2<string, string>( "#STR_Camera_H_Sensitivity_tip_header", "#STR_Camera_H_Sensitivity_tip" ) );
638  m_TextMap.Insert( OptionAccessType.AT_OPTIONS_MOUSE_YAXIS_AIM_MOD, new Param2<string, string>( "#STR_Aiming_V_Sensitivity_tip_header", "#STR_Aiming_V_Sensitivity_tip" ) );
639  m_TextMap.Insert( OptionAccessType.AT_OPTIONS_MOUSE_XAXIS_AIM_MOD, new Param2<string, string>( "#STR_Aiming_H_Sensitivity_tip_header", "#STR_Aiming_H_Sensitivity_tip" ) );
640 
641  #ifdef PLATFORM_CONSOLE
642  m_TextMap.Insert( OptionAccessType.AT_OPTIONS_MOUSE_AND_KEYBOARD, new Param2<string, string>( "#xbox_options_controls_mandk_contr", "#xbox_options_controls_mandk_contr_desc" ) );
643  m_TextMap.Insert( OptionAccessType.AT_OPTIONS_AIM_HELPER, new Param2<string, string>( "#ps4_options_controls_aim_helper_contr", "#ps4_options_controls_aim_helper_contr_desc" ) );
644 
645  m_TextMap.Insert( OptionAccessType.AT_OPTIONS_CONTROLLER_LS_YAXIS, new Param2<string, string>( "#STR_Movement_V_Sensitivity_tip_header", "#STR_Movement_V_Sensitivity_tip" ) );
646  m_TextMap.Insert( OptionAccessType.AT_OPTIONS_CONTROLLER_LS_XAXIS, new Param2<string, string>( "#STR_Movement_H_Sensitivity_tip_header", "#STR_Movement_H_Sensitivity_tip" ) );
647  m_TextMap.Insert( OptionAccessType.AT_OPTIONS_CONTROLLER_LS_XAXIS_VEHICLE_MOD, new Param2<string, string>( "#STR_Movement_Vehicle_Sensitivity_tip_header", "#STR_Movement_Vehicle_Sensitivity_tip" ) );
648  m_TextMap.Insert( OptionAccessType.AT_OPTIONS_CONTROLLER_RS_YAXIS_INVERTED, new Param2<string, string>( "#STR_Invert_Vertical_tip_header", "#STR_Invert_Vertical_tip" ) );
649  m_TextMap.Insert( OptionAccessType.AT_OPTIONS_CONTROLLER_RS_YAXIS, new Param2<string, string>( "#STR_Camera_V_Sensitivity_tip_header", "#STR_Camera_V_Sensitivity_tip" ) );
650  m_TextMap.Insert( OptionAccessType.AT_OPTIONS_CONTROLLER_RS_XAXIS, new Param2<string, string>( "#STR_Camera_H_Sensitivity_tip_header", "#STR_Camera_H_Sensitivity_tip" ) );
651  m_TextMap.Insert( OptionAccessType.AT_OPTIONS_CONTROLLER_RS_CURVATURE, new Param2<string, string>( "#STR_Camera_Curvature_tip_header", "#STR_Camera_Curvature_tip" ) );
652  m_TextMap.Insert( OptionAccessType.AT_OPTIONS_CONTROLLER_RS_YAXIS_AIM_MOD, new Param2<string, string>( "#STR_Aiming_V_Sensitivity_tip_header", "#STR_Aiming_V_Sensitivity_tip" ) );
653  m_TextMap.Insert( OptionAccessType.AT_OPTIONS_CONTROLLER_RS_XAXIS_AIM_MOD, new Param2<string, string>( "#STR_Aiming_H_Sensitivity_tip_header", "#STR_Aiming_H_Sensitivity_tip" ) );
654  m_TextMap.Insert( OptionAccessType.AT_OPTIONS_CONTROLLER_RS_CURVATURE_AIM_MOD, new Param2<string, string>( "#STR_Aiming_Curvature_tip_header", "#STR_Camera_Curvature_tip" ) );
655  #endif
656  }
657 
658  //Coloring functions (Until WidgetStyles are useful)
659  void ColorRed( Widget w )
660  {
661  SetFocus( w );
662  ButtonWidget button;
663  if (Class.CastTo(button,w))
664  {
665  button.SetTextColor( ARGB( 255, 255, 0, 0 ) );
666  button.SetAlpha( 0.9 );
667  }
668  }
669 
670  void ColorWhite( Widget w, Widget enterW )
671  {
672  ButtonWidget button;
673  if (Class.CastTo(button,w))
674  {
675  button.SetTextColor( ARGB( 255, 255, 255, 255 ) );
676  button.SetAlpha( 0.0 );
677  }
678  }
679 }
Param2< string, string >
GetGame
proto native CGame GetGame()
OptionIDsScript
OptionIDsScript
Used for script-based game options. For anything C++ based, you would most likely use "Option Access ...
Definition: gameplay.c:1264
Focus
void Focus()
Definition: serverbrowsertab.c:181
Param
Base Param Class with no parameters. Used as general purpose parameter overloaded with Param1 to Para...
Definition: param.c:11
y
Icon y
GameOptions
Definition: gameplay.c:1420
m_Menu
protected ServerBrowserMenuNew m_Menu
Definition: serverbrowsertab.c:30
CALL_CATEGORY_GUI
const int CALL_CATEGORY_GUI
Definition: tools.c:9
OnMouseLeave
override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
Definition: uihintpanel.c:276
OnMouseButtonUp
override bool OnMouseButtonUp(Widget w, int x, int y, int button)
Definition: radialmenu.c:668
RichTextWidget
Definition: gameplay.c:315
map
map
Definition: controlsxboxnew.c:3
TextWidget
Definition: enwidgets.c:219
g_Game
DayZGame g_Game
Definition: dayzgame.c:3727
EDependentOptions
EDependentOptions
Definition: dependentoptions.c:1
OptionAccessType
OptionAccessType
C++ OptionAccessType.
Definition: gameplay.c:1200
MENU_KEYBINDINGS
const int MENU_KEYBINDINGS
Definition: constants.c:193
OnFocusLost
override bool OnFocusLost(Widget w, int x, int y)
Definition: serverbrowsertab.c:235
MouseState
MouseState
Definition: ensystem.c:310
array< string >
SetFocus
proto native void SetFocus(Widget w)
x
Icon x
WidgetFlags
WidgetFlags
Definition: enwidgets.c:57
OnFocus
override bool OnFocus(Widget w, int x, int y)
Definition: serverbrowsertab.c:217
Widget
Definition: enwidgets.c:189
m_Root
protected Widget m_Root
Definition: sizetochild.c:91
Class
Super root of all classes in Enforce script.
Definition: enscript.c:10
OnMouseEnter
override bool OnMouseEnter(Widget w, int x, int y)
Definition: uihintpanel.c:267
ScriptedWidgetEventHandler
map: item x vector(index, width, height)
Definition: enwidgets.c:650
ARGB
int ARGB(int a, int r, int g, int b)
Definition: proto.c:322
IsFocusable
bool IsFocusable(Widget w)
Definition: serverbrowsertab.c:284