Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
optionsmenugame.c
Go to the documentation of this file.
1 class OptionsMenuGame extends ScriptedWidgetEventHandler
2 {
3  private const float HUD_BRIGHTNESS_MIN = -1.0;
4  private const float HUD_BRIGHTNESS_MAX = 0.0;
5 
6  protected Widget m_Root;
7 
8  protected Widget m_SettingsRoot;
9  protected Widget m_DetailsRoot;
10  protected Widget m_DetailsBodyDefault;
11  protected Widget m_DetailsBodyConnectivity;
12  protected TextWidget m_DetailsLabel;
13  protected RichTextWidget m_DetailsText;
14  protected ButtonWidget m_QuickbarButton;
15 
16  protected ref NumericOptionsAccess m_FOVOption;
17  protected ref ListOptionsAccess m_LanguageOption;
18  protected ref ListOptionsAccess m_PauseOption;
19  #ifdef PLATFORM_CONSOLE
20  protected ref NumericOptionsAccess m_BrightnessOption;
21  protected ref OptionSelectorSlider m_BrightnessSelector;
22  #endif
23 
24  protected ref OptionSelectorMultistate m_LanguageSelector;
25  protected ref OptionSelectorSlider m_FOVSelector;
26  protected ref OptionSelectorMultistate m_ShowHUDSelector;
27  protected ref OptionSelectorMultistate m_ShowCrosshairSelector;
28  protected ref OptionSelectorMultistate m_ShowQuickbarSelector;
29  protected ref OptionSelectorMultistate m_ShowGameSelector;
30  protected ref OptionSelectorMultistate m_ShowAdminSelector;
31  protected ref OptionSelectorMultistate m_ShowPlayerSelector;
32  protected ref OptionSelectorMultistate m_ShowServerInfoSelector;
33  protected ref OptionSelectorMultistate m_BleedingIndication;
34  protected ref OptionSelectorMultistate m_ConnectivityInfo;
35  protected ref OptionSelectorSlider m_HUDBrightnessSelector;
36  protected ref OptionSelectorMultistate m_PauseSelector;
37 
38  protected GameOptions m_Options;
39  protected OptionsMenu m_Menu;
40 
41  protected ref map<int, ref Param2<string, string>> m_TextMap;
42 
43  void OptionsMenuGame(Widget parent, Widget details_root, GameOptions options, OptionsMenu menu)
44  {
45  m_Root = GetGame().GetWorkspace().CreateWidgets(GetLayoutName(), parent);
46 
47  m_DetailsRoot = details_root;
48  m_DetailsBodyDefault = m_DetailsRoot.FindAnyWidget("settings_details_body");
49  m_DetailsBodyConnectivity = m_DetailsRoot.FindAnyWidget("settings_details_body_connectivity");
50  m_DetailsLabel = TextWidget.Cast(m_DetailsRoot.FindAnyWidget("details_label"));
51  m_DetailsText = RichTextWidget.Cast(m_DetailsRoot.FindAnyWidget("details_content"));
52 
53  m_Options = options;
54  m_Menu = menu;
55 
56  m_FOVOption = NumericOptionsAccess.Cast(m_Options.GetOptionByType(OptionAccessType.AT_OPTIONS_FIELD_OF_VIEW));
57  m_LanguageOption = ListOptionsAccess.Cast(m_Options.GetOptionByType(OptionAccessType.AT_OPTIONS_LANGUAGE));
58  m_PauseOption = ListOptionsAccess.Cast(m_Options.GetOptionByType(OptionAccessType.AT_OPTIONS_PAUSE));
59 
60  m_Root.FindAnyWidget("fov_setting_option").SetUserID(OptionAccessType.AT_OPTIONS_FIELD_OF_VIEW);
61  m_Root.FindAnyWidget("hud_setting_option").SetUserID(OptionIDsScript.OPTION_HUD);
62  m_Root.FindAnyWidget("hud_brightness_setting_option").SetUserID(OptionIDsScript.OPTION_HUD_BRIGHTNESS);
63  m_Root.FindAnyWidget("crosshair_setting_option").SetUserID(OptionIDsScript.OPTION_CROSSHAIR);
64  m_Root.FindAnyWidget("game_setting_option").SetUserID(OptionIDsScript.OPTION_GAME_MESSAGES);
65  m_Root.FindAnyWidget("admin_setting_option").SetUserID(OptionIDsScript.OPTION_ADMIN_MESSAGES);
66  m_Root.FindAnyWidget("player_setting_option").SetUserID(OptionIDsScript.OPTION_PLAYER_MESSAGES);
67  m_Root.FindAnyWidget("language_setting_option").SetUserID(OptionAccessType.AT_OPTIONS_LANGUAGE);
68  m_Root.FindAnyWidget("bleeding_indication_setting_option").SetUserID(OptionIDsScript.OPTION_BLEEDINGINDICATION);
69  m_Root.FindAnyWidget("connectivity_setting_option").SetUserID(OptionIDsScript.OPTION_CONNECTIVITY_INFO);
70  m_Root.FindAnyWidget("quickbar_setting_option").SetUserID(OptionIDsScript.OPTION_QUICKBAR);
71 
72  #ifdef PLATFORM_CONSOLE
73  m_QuickbarButton = ButtonWidget.Cast(m_Root.FindAnyWidget("quickbar_button"));
74  m_Root.FindAnyWidget("brightness_setting_option").SetUserID(OptionAccessType.AT_OPTIONS_BRIGHT_SLIDER);
75  #else
76  m_Root.FindAnyWidget("serverinfo_setting_option").SetUserID(OptionIDsScript.OPTION_SERVER_INFO);
77  m_Root.FindAnyWidget("pause_setting_option").SetUserID(OptionAccessType.AT_OPTIONS_PAUSE);
78  #endif
79 
80  FillTextMap();
81 
82  array<string> opt = { "#options_controls_disabled", "#options_controls_enabled" };
83  array<string> opt2 = { "#options_controls_enabled", "#options_controls_disabled" };
84  array<string> opt3 = new array<string>;
85  for (int i = 0; i < m_LanguageOption.GetItemsCount(); ++i)
86  {
87  string text;
88  m_LanguageOption.GetItemText(i, text);
89  opt3.Insert(text);
90  }
91 
92  array<string> opt4 = { "#options_pc_nopause_0", "#options_pc_nopause_1", "#options_pc_nopause_2" }; // Pause options menu strings
93 
94  m_LanguageSelector = new OptionSelectorMultistate(m_Root.FindAnyWidget("language_setting_option"), m_LanguageOption.GetIndex(), this, false, opt3);
95  m_FOVSelector = new OptionSelectorSlider(m_Root.FindAnyWidget("fov_setting_option"), m_FOVOption.ReadValue(), this, false, m_FOVOption.GetMin(), m_FOVOption.GetMax());
96  m_ShowHUDSelector = new OptionSelectorMultistate(m_Root.FindAnyWidget("hud_setting_option"), g_Game.GetProfileOptionBool(EDayZProfilesOptions.HUD), this, false, opt);
97  m_HUDBrightnessSelector = new OptionSelectorSlider(m_Root.FindAnyWidget("hud_brightness_setting_option"), g_Game.GetProfileOptionFloat(EDayZProfilesOptions.HUD_BRIGHTNESS), this, false, HUD_BRIGHTNESS_MIN, HUD_BRIGHTNESS_MAX);
98  m_ShowCrosshairSelector = new OptionSelectorMultistate(m_Root.FindAnyWidget("crosshair_setting_option"), g_Game.GetProfileOptionBool(EDayZProfilesOptions.CROSSHAIR), this, false, opt);
99  m_ShowGameSelector = new OptionSelectorMultistate(m_Root.FindAnyWidget("game_setting_option"), g_Game.GetProfileOptionBool(EDayZProfilesOptions.GAME_MESSAGES), this, false, opt2);
100  m_ShowAdminSelector = new OptionSelectorMultistate(m_Root.FindAnyWidget("admin_setting_option"), g_Game.GetProfileOptionBool(EDayZProfilesOptions.ADMIN_MESSAGES), this, false, opt2);
101  m_ShowPlayerSelector = new OptionSelectorMultistate(m_Root.FindAnyWidget("player_setting_option"), g_Game.GetProfileOptionBool(EDayZProfilesOptions.PLAYER_MESSAGES), this, false, opt2);
102  m_BleedingIndication = new OptionSelectorMultistate(m_Root.FindAnyWidget("bleeding_indication_setting_option"), g_Game.GetProfileOptionBool(EDayZProfilesOptions.BLEEDINGINDICATION), this, false, opt);
103  m_ConnectivityInfo = new OptionSelectorMultistate(m_Root.FindAnyWidget("connectivity_setting_option"), g_Game.GetProfileOptionBool(EDayZProfilesOptions.CONNECTIVITY_INFO), this, false, opt);
104  m_ShowQuickbarSelector = new OptionSelectorMultistate(m_Root.FindAnyWidget("quickbar_setting_option"), g_Game.GetProfileOptionBool(EDayZProfilesOptions.QUICKBAR), this, false, opt);
105 
106  m_LanguageSelector.m_OptionChanged.Insert(UpdateLanguageOption);
107  m_FOVSelector.m_OptionChanged.Insert(UpdateFOVOption);
108  m_ShowHUDSelector.m_OptionChanged.Insert(UpdateHUDOption);
109  m_HUDBrightnessSelector.m_OptionChanged.Insert(UpdateHUDBrightnessOption);
110  m_ShowCrosshairSelector.m_OptionChanged.Insert(UpdateCrosshairOption);
111  m_ShowGameSelector.m_OptionChanged.Insert(UpdateGameOption);
112  m_ShowAdminSelector.m_OptionChanged.Insert(UpdateAdminOption);
113  m_ShowPlayerSelector.m_OptionChanged.Insert(UpdatePlayerOption);
114  m_BleedingIndication.m_OptionChanged.Insert(UpdateBleedingIndication);
115  m_ConnectivityInfo.m_OptionChanged.Insert(UpdateConnectivityInfo);
116  m_ShowQuickbarSelector.m_OptionChanged.Insert(UpdateQuickbarOption);
117 
118  #ifdef PLATFORM_CONSOLE
119  m_BrightnessOption = NumericOptionsAccess.Cast(m_Options.GetOptionByType(OptionAccessType.AT_OPTIONS_BRIGHT_SLIDER));
120  m_BrightnessSelector = new OptionSelectorSlider(m_Root.FindAnyWidget("brightness_setting_option"), m_BrightnessOption.ReadValue(), this, false, m_BrightnessOption.GetMin(), m_BrightnessOption.GetMax());
121  m_BrightnessSelector.m_OptionChanged.Insert(UpdateBrightnessOption);
122  #else
123  m_ShowServerInfoSelector = new OptionSelectorMultistate(m_Root.FindAnyWidget("serverinfo_setting_option"), g_Game.GetProfileOptionBool(EDayZProfilesOptions.SERVERINFO_DISPLAY), this, false, opt);
124  m_PauseSelector = new OptionSelectorMultistate(m_Root.FindAnyWidget("pause_setting_option"), m_PauseOption.GetIndex(), this, false, opt4);
125 
126  m_ShowServerInfoSelector.m_OptionChanged.Insert(UpdateServerInfoOption);
127  m_PauseSelector.m_OptionChanged.Insert(UpdatePauseOption);
128  #endif
129 
130  float x, y, y2;
131  m_Root.FindAnyWidget("game_settings_scroll").GetScreenSize(x, y);
132  m_Root.FindAnyWidget("game_settings_root").GetScreenSize(x, y2);
133  int f = (y2 > y);
134  m_Root.FindAnyWidget("game_settings_scroll").SetAlpha(f);
135 
136  m_Root.SetHandler(this);
137  m_DetailsRoot.Show(false);
138 
139  InitDependentOptionsVisibility();
140  }
141 
142  void ~OptionsMenuGame()
143  {
144  if (m_FOVOption)
145  {
146  m_FOVOption.Revert();
147  g_Game.SetUserFOV(m_FOVOption.ReadValue());
148  }
149 
150  RevertHUDBrightness();
151  }
152 
153  string GetLayoutName()
154  {
155  #ifdef PLATFORM_CONSOLE
156  return "gui/layouts/new_ui/options/xbox/game_tab.layout";
157  #else
158  return "gui/layouts/new_ui/options/pc/game_tab.layout";
159  #endif
160  }
161 
162  void Focus()
163  {
164  #ifdef PLATFORM_CONSOLE
165  SetFocus(m_LanguageSelector.GetParent());
166  #endif
167  }
168 
169  bool IsChanged()
170  {
171  bool universal = (m_ShowHUDSelector.GetValue() != g_Game.GetProfileOptionBool(EDayZProfilesOptions.HUD) || m_ShowCrosshairSelector.GetValue() != g_Game.GetProfileOptionBool(EDayZProfilesOptions.CROSSHAIR));
172  universal = universal || m_HUDBrightnessSelector.GetValue() != g_Game.GetProfileOptionFloat(EDayZProfilesOptions.HUD_BRIGHTNESS);
173  universal = universal || (m_ShowGameSelector.GetValue() != g_Game.GetProfileOptionBool(EDayZProfilesOptions.GAME_MESSAGES) || m_ShowAdminSelector.GetValue() != g_Game.GetProfileOptionBool(EDayZProfilesOptions.ADMIN_MESSAGES));
174  universal = universal || m_ShowPlayerSelector.GetValue() != g_Game.GetProfileOptionBool(EDayZProfilesOptions.PLAYER_MESSAGES);
175  universal = universal || m_BleedingIndication.GetValue() != g_Game.GetProfileOptionBool(EDayZProfilesOptions.BLEEDINGINDICATION);
176  universal = universal || m_ConnectivityInfo.GetValue() != g_Game.GetProfileOptionBool(EDayZProfilesOptions.CONNECTIVITY_INFO);
177  universal = universal || m_LanguageOption.IsChanged();
178 
179  #ifdef PLATFORM_CONSOLE
180  return universal;
181  #else
182  return (universal || m_ShowQuickbarSelector.GetValue() != g_Game.GetProfileOptionBool(EDayZProfilesOptions.QUICKBAR) || m_ShowServerInfoSelector.GetValue() != g_Game.GetProfileOptionBool(EDayZProfilesOptions.SERVERINFO_DISPLAY));
183  #endif
184  }
185 
186  void Apply()
187  {
188  IngameHud hud = GetHud();
189  InGameMenu menu = InGameMenu.Cast(GetGame().GetUIManager().FindMenu(MENU_INGAME));
190  MissionGameplay mission = MissionGameplay.Cast(GetGame().GetMission());
191 
192  g_Game.SetProfileOptionBool(EDayZProfilesOptions.HUD, m_ShowHUDSelector.GetValue());
193  g_Game.SetProfileOptionBool(EDayZProfilesOptions.CROSSHAIR, m_ShowCrosshairSelector.GetValue());
194  g_Game.SetProfileOptionBool(EDayZProfilesOptions.GAME_MESSAGES, m_ShowGameSelector.GetValue());
195  g_Game.SetProfileOptionBool(EDayZProfilesOptions.ADMIN_MESSAGES, m_ShowAdminSelector.GetValue());
196  g_Game.SetProfileOptionBool(EDayZProfilesOptions.PLAYER_MESSAGES, m_ShowPlayerSelector.GetValue());
197  g_Game.SetProfileOptionFloat(EDayZProfilesOptions.HUD_BRIGHTNESS, m_HUDBrightnessSelector.GetValue());
198 
199  #ifndef PLATFORM_CONSOLE
200  g_Game.SetProfileOptionBool(EDayZProfilesOptions.QUICKBAR, m_ShowQuickbarSelector.GetValue());
201  g_Game.SetProfileOptionBool(EDayZProfilesOptions.SERVERINFO_DISPLAY, m_ShowServerInfoSelector.GetValue());
202  #endif
203 
204  if (hud)
205  {
206  #ifndef PLATFORM_CONSOLE
207  hud.ShowQuickBar(m_ShowQuickbarSelector.GetValue());
208  #else
209  hud.ShowQuickBar(GetGame().GetInput().IsEnabledMouseAndKeyboardEvenOnServer());
210  #endif
211  hud.ShowHud(m_ShowHUDSelector.GetValue());
212  }
213 
214  bool bleedingIndicationOld = g_Game.GetProfileOptionBool(EDayZProfilesOptions.BLEEDINGINDICATION);
215  bool bleedingIndicationNew = m_BleedingIndication.GetValue();
216  bool connectivityOld = g_Game.GetProfileOptionBool(EDayZProfilesOptions.CONNECTIVITY_INFO);
217  bool connectivityNew = m_ConnectivityInfo.GetValue();
218 
219  g_Game.SetProfileOptionBool(EDayZProfilesOptions.BLEEDINGINDICATION, bleedingIndicationNew);
220  g_Game.SetProfileOptionBool(EDayZProfilesOptions.CONNECTIVITY_INFO, connectivityNew);
221 
222  if (mission)
223  {
224  //BLEEDINGINDICATION changed
225  if (bleedingIndicationOld != bleedingIndicationNew)
226  {
227  OnBleedingIndicationChanged(bleedingIndicationNew);
228  }
229 
230  //CONNECTIVITY_INFO changed
231  if (connectivityOld != connectivityNew)
232  {
233  mission.GetConnectivityInvoker().Invoke(connectivityNew);
234  }
235  }
236 
237  #ifndef PLATFORM_CONSOLE
238  if (menu)
239  {
240  menu.SetServerInfoVisibility(m_ShowServerInfoSelector.GetValue());
241  }
242  #endif
243 
244  if (m_LanguageOption.IsChanged()) //language changed
245  {
246  if (mission)
247  {
248  mission.ResetGUI();
249  }
250  else
251  {
252  ErrorEx("mission not found!", ErrorExSeverity.INFO);
253  }
254  }
255  }
256 
257  void Revert()
258  {
259  if (m_ShowHUDSelector)
260  m_ShowHUDSelector.SetValue(g_Game.GetProfileOptionBool(EDayZProfilesOptions.HUD), false);
261 
262  RevertHUDBrightness();
263 
264  if (m_ShowCrosshairSelector)
265  m_ShowCrosshairSelector.SetValue(g_Game.GetProfileOptionBool(EDayZProfilesOptions.CROSSHAIR), false);
266  if (m_FOVOption)
267  {
268  m_FOVSelector.SetValue(m_FOVOption.ReadValue(), false);
269  g_Game.SetUserFOV(m_FOVOption.ReadValue());
270  }
271  if (m_LanguageOption)
272  m_LanguageSelector.SetValue(m_LanguageOption.GetIndex(), false);
273  if (m_ShowGameSelector)
274  m_ShowGameSelector.SetValue(g_Game.GetProfileOptionBool(EDayZProfilesOptions.GAME_MESSAGES), false);
275  if (m_ShowAdminSelector)
276  m_ShowAdminSelector.SetValue(g_Game.GetProfileOptionBool(EDayZProfilesOptions.ADMIN_MESSAGES), false);
277  if (m_ShowPlayerSelector)
278  m_ShowPlayerSelector.SetValue(g_Game.GetProfileOptionBool(EDayZProfilesOptions.PLAYER_MESSAGES), false);
279  if (m_BleedingIndication)
280  m_BleedingIndication.SetValue(g_Game.GetProfileOptionBool(EDayZProfilesOptions.BLEEDINGINDICATION), false);
281  if (m_ConnectivityInfo)
282  m_ConnectivityInfo.SetValue(g_Game.GetProfileOptionBool(EDayZProfilesOptions.CONNECTIVITY_INFO), false);
283 
284  #ifdef PLATFORM_CONSOLE
285  if (m_BrightnessSelector)
286  m_BrightnessSelector.SetValue(m_BrightnessOption.ReadValue(), false);
287  #else
288  if (m_ShowQuickbarSelector)
289  m_ShowQuickbarSelector.SetValue(g_Game.GetProfileOptionBool(EDayZProfilesOptions.QUICKBAR), false);
290  if (m_ShowServerInfoSelector)
291  m_ShowServerInfoSelector.SetValue(g_Game.GetProfileOptionBool(EDayZProfilesOptions.SERVERINFO_DISPLAY), false);
292  if (m_PauseOption)
293  {
294  m_PauseSelector.SetValue(m_PauseOption.GetIndex(), false);
295  }
296  #endif
297  }
298 
299  void SetToDefaults()
300  {
301  g_Game.ResetProfileOptions();
302 
303  if (m_ShowHUDSelector)
304  m_ShowHUDSelector.SetValue(g_Game.GetProfileOptionDefaultBool(EDayZProfilesOptions.HUD), false);
305 
306  if (m_HUDBrightnessSelector)
307  {
308  m_HUDBrightnessSelector.SetValue(g_Game.GetProfileOptionDefaultFloat(EDayZProfilesOptions.HUD_BRIGHTNESS), false);
309  g_Game.SetHudBrightness(m_HUDBrightnessSelector.GetValue());
310  }
311 
312  if (m_ShowCrosshairSelector)
313  m_ShowCrosshairSelector.SetValue(g_Game.GetProfileOptionDefaultBool(EDayZProfilesOptions.CROSSHAIR), false);
314 
315  if (m_FOVOption)
316  {
317  m_FOVOption.WriteValue(m_FOVOption.GetDefault());
318  m_FOVSelector.SetValue(m_FOVOption.ReadValue(), false);
319  g_Game.SetUserFOV(m_FOVOption.GetDefault());
320  }
321  if (m_ShowGameSelector)
322  m_ShowGameSelector.SetValue(g_Game.GetProfileOptionDefaultBool(EDayZProfilesOptions.GAME_MESSAGES), false);
323  if (m_ShowAdminSelector)
324  m_ShowAdminSelector.SetValue(g_Game.GetProfileOptionDefaultBool(EDayZProfilesOptions.ADMIN_MESSAGES), false);
325  if (m_ShowPlayerSelector)
326  m_ShowPlayerSelector.SetValue(g_Game.GetProfileOptionDefaultBool(EDayZProfilesOptions.PLAYER_MESSAGES), false);
327  if (m_BleedingIndication)
328  m_BleedingIndication.SetValue(g_Game.GetProfileOptionDefaultBool(EDayZProfilesOptions.BLEEDINGINDICATION), false);
329  if (m_ConnectivityInfo)
330  m_ConnectivityInfo.SetValue(g_Game.GetProfileOptionDefaultBool(EDayZProfilesOptions.CONNECTIVITY_INFO), false);
331 
332  #ifdef PLATFORM_CONSOLE
333  if (m_BrightnessSelector)
334  {
335  m_BrightnessOption.WriteValue(m_BrightnessOption.GetDefault());
336  m_BrightnessSelector.SetValue(m_BrightnessOption.GetDefault(), false);
337  }
338  #else
339  if (m_ShowQuickbarSelector)
340  m_ShowQuickbarSelector.SetValue(g_Game.GetProfileOptionDefaultBool(EDayZProfilesOptions.QUICKBAR), false);
341  if (m_ShowServerInfoSelector)
342  m_ShowServerInfoSelector.SetValue(g_Game.GetProfileOptionDefaultBool(EDayZProfilesOptions.SERVERINFO_DISPLAY), false);
343  if (m_PauseOption)
344  {
345  m_PauseOption.SetIndex(m_PauseOption.GetDefaultIndex());
346  m_PauseSelector.SetValue(m_PauseOption.GetIndex(), false);
347  }
348  #endif
349  }
350 
351  void ReloadOptions()
352  {
353  m_Menu.ReloadOptions();
354  }
355 
356  void SetOptions(GameOptions options)
357  {
358  m_Options = options;
359 
360  m_FOVOption = NumericOptionsAccess.Cast(m_Options.GetOptionByType(OptionAccessType.AT_OPTIONS_FIELD_OF_VIEW));
361  m_LanguageOption = ListOptionsAccess.Cast(m_Options.GetOptionByType(OptionAccessType.AT_OPTIONS_LANGUAGE));
362 
363  if (m_FOVSelector)
364  m_FOVSelector.SetValue(m_FOVOption.ReadValue(), false);
365 
366  if (m_LanguageOption)
367  m_LanguageSelector.SetValue(m_LanguageOption.GetIndex(), false);
368 
369  #ifdef PLATFORM_CONSOLE
370  m_BrightnessOption = NumericOptionsAccess.Cast(m_Options.GetOptionByType(OptionAccessType.AT_OPTIONS_BRIGHT_SLIDER));
371  if (m_BrightnessOption)
372  m_BrightnessSelector.SetValue(m_BrightnessOption.ReadValue(), false);
373  #endif
374  }
375 
376  void ToggleDependentOptions(int mode, bool state)
377  {
378  }
379 
380  void InitDependentOptionsVisibility()
381  {
382  #ifdef PLATFORM_CONSOLE
383  m_QuickbarButton.Show(false);
384  #endif
385  }
386 
387  protected void UpdateLanguageOption(int new_index)
388  {
389  m_LanguageOption.SetIndex(new_index);
390  m_Menu.OnChanged();
391 
392  TextMapUpdateWidget(OptionAccessType.AT_OPTIONS_LANGUAGE);
393  }
394 
395  protected void UpdatePauseOption(int new_index)
396  {
397  m_PauseOption.SetIndex(new_index);
398  m_Menu.OnChanged();
399  }
400 
401  protected void UpdateFOVOption(float new_value)
402  {
403  m_FOVOption.WriteValue(new_value);
404  g_Game.SetUserFOV(new_value);
405  m_Menu.OnChanged();
406  }
407 
408  protected void UpdateHUDBrightnessOption(float newValue)
409  {
410  g_Game.SetHudBrightness(newValue);
411  m_Menu.OnChanged();
412  }
413 
414  protected void UpdateHUDOption(int new_index)
415  {
416  m_Menu.OnChanged();
417  }
418 
419  protected void UpdateBleedingIndication(int new_index)
420  {
421  m_Menu.OnChanged();
422  }
423 
424  protected void UpdateConnectivityInfo(int newIndex)
425  {
426  m_Menu.OnChanged();
427  }
428 
429  protected void UpdateCrosshairOption(int new_index)
430  {
431  m_Menu.OnChanged();
432  }
433 
434  protected void UpdateQuickbarOption(int new_index)
435  {
436  m_Menu.OnChanged();
437  }
438 
439  protected void UpdateGameOption(int new_index)
440  {
441  m_Menu.OnChanged();
442  }
443 
444  protected void UpdateAdminOption(int new_index)
445  {
446  m_Menu.OnChanged();
447  }
448 
449  protected void UpdatePlayerOption(int new_index)
450  {
451  m_Menu.OnChanged();
452  }
453 
454  protected void UpdateServerInfoOption(int new_index)
455  {
456  m_Menu.OnChanged();
457  }
458 
459  IngameHud GetHud()
460  {
461  Mission mission = GetGame().GetMission();
462  if (mission)
463  {
464  IngameHud hud = IngameHud.Cast(mission.GetHud());
465  return hud;
466  }
467  return null;
468  }
469 
470 #ifdef PLATFORM_CONSOLE
471  void UpdateBrightnessOption(float value)
472  {
473  m_BrightnessOption.WriteValue(value);
474  m_Menu.OnChanged();
475  }
476 #endif
477 
478  override bool OnMouseEnter(Widget w, int x, int y)
479  {
480  if (w && w.IsInherited(ScrollWidget))
481  {
482  return false;
483  }
484 
485  if (w && w.IsInherited(SliderWidget))
486  {
487  return false;
488  }
489 
490  m_Menu.ColorHighlight(w);
491 
492  return true;
493  }
494 
495  override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
496  {
497  if (w && w.IsInherited(ScrollWidget))
498  {
499  return false;
500  }
501 
502  m_Menu.ColorNormal(w);
503  return true;
504  }
505 
506  override bool OnFocus(Widget w, int x, int y)
507  {
508  if (m_Menu)
509  {
510  m_Menu.OnFocus(w, x, y);
511  }
512 
513  if (w)
514  {
515  if (TextMapUpdateWidget(w.GetUserID()))
516  {
517  return true;
518  }
519 
520  if (w.IsInherited(SliderWidget))
521  {
522  return true;
523  }
524  }
525  m_DetailsRoot.Show(false);
526  return (w != null);
527  }
528 
529  protected void OnBleedingIndicationChanged(bool state)
530  {
531  MissionGameplay mission = MissionGameplay.Cast(GetGame().GetMission());
532  if (mission)
533  {
534  Param1<bool> par = new Param1<bool>(state);
535  mission.GetEffectWidgets().UpdateWidgets(EffectWidgetsTypes.BLEEDING_LAYER,0,par);
536  }
537  }
538 
539  bool TextMapUpdateWidget(int key)
540  {
541  bool connectivityInfoShown = key == OptionIDsScript.OPTION_CONNECTIVITY_INFO;
543  Param tmp = m_TextMap.Get(key);
544 
545  m_DetailsBodyDefault.Show(!connectivityInfoShown);
546  m_DetailsBodyConnectivity.Show(connectivityInfoShown);
547 
548  if (Class.CastTo(p,tmp))
549  {
550  m_DetailsRoot.Show(true);
551  m_DetailsText.Show(true);
552  m_DetailsLabel.SetText(p.param1);
553  m_DetailsText.SetText(p.param2);
554 
555  m_DetailsText.Update();
556  m_DetailsLabel.Update();
557  m_DetailsRoot.Update();
558  m_DetailsBodyConnectivity.Update(); //...
559  return true;
560  }
561  return false;
562  }
563 
564  void FillTextMap()
565  {
566  m_TextMap = new map<int, ref Param2<string, string>>;
567  m_TextMap.Insert(OptionAccessType.AT_OPTIONS_LANGUAGE, new Param2<string, string>("#options_game_select_language", "#options_game_select_language_desc"));
568  m_TextMap.Insert(OptionAccessType.AT_OPTIONS_FIELD_OF_VIEW, new Param2<string, string>("#options_game_field_of_view", "#options_game_field_of_view_desc"));
569  m_TextMap.Insert(OptionIDsScript.OPTION_HUD, new Param2<string, string>("#options_game_show_HUD", "#options_game_show_HUD_desc"));
570  m_TextMap.Insert(OptionIDsScript.OPTION_HUD_BRIGHTNESS, new Param2<string, string>("#options_game_hud_brightness", "#options_game_hud_brightness_desc"));
571  m_TextMap.Insert(OptionIDsScript.OPTION_CROSSHAIR, new Param2<string, string>("#options_game_show_crosshair", "#options_game_show_crosshair_desc"));
572  m_TextMap.Insert(OptionIDsScript.OPTION_QUICKBAR, new Param2<string, string>("#options_game_show_quickbar", "#options_game_show_quickbar_desc"));
573  m_TextMap.Insert(OptionIDsScript.OPTION_SERVER_INFO, new Param2<string, string>("#options_game_show_serverinfo", "#options_game_show_serverinfo_desc"));
574  m_TextMap.Insert(OptionIDsScript.OPTION_BLEEDINGINDICATION, new Param2<string, string>("#options_game_show_bleedingindication", "#options_game_show_bleedingindication_desc"));
575  m_TextMap.Insert(OptionIDsScript.OPTION_CONNECTIVITY_INFO, new Param2<string, string>("#options_game_connectivity", ""));
576 
577  #ifdef PLATFORM_WINDOWS
578  m_TextMap.Insert(OptionAccessType.AT_OPTIONS_PAUSE, new Param2<string, string>("#layout_options_pc_nopause_title", "#layout_options_pc_nopause_tooltip"));
579  m_TextMap.Insert(OptionIDsScript.OPTION_GAME_MESSAGES, new Param2<string, string>("#options_pc_game_messages", "#options_game_show_game_msg"));
580  m_TextMap.Insert(OptionIDsScript.OPTION_ADMIN_MESSAGES, new Param2<string, string>("#options_pc_admin_mes", "#options_game_show_admin_msg"));
581  m_TextMap.Insert(OptionIDsScript.OPTION_PLAYER_MESSAGES, new Param2<string, string>("#options_pc_player_messages", "#options_game_show_player_msg"));
582  #else
583  #ifdef PLATFORM_XBOX
584  m_TextMap.Insert(OptionAccessType.AT_OPTIONS_BRIGHT_SLIDER, new Param2<string, string>("#options_video_brightness", "#options_video_brightness_desc"));
585  m_TextMap.Insert(OptionIDsScript.OPTION_GAME_MESSAGES, new Param2<string, string>("#options_xbox_game_messages", "#options_game_show_game_msg"));
586  m_TextMap.Insert(OptionIDsScript.OPTION_ADMIN_MESSAGES, new Param2<string, string>("#options_xbox_admin_mes", "#options_game_show_admin_msg"));
587  m_TextMap.Insert(OptionIDsScript.OPTION_PLAYER_MESSAGES, new Param2<string, string>("#options_xbox_player_messages","#options_game_show_player_msg"));
588  #else
589  #ifdef PLATFORM_PS4
590  m_TextMap.Insert(OptionAccessType.AT_OPTIONS_BRIGHT_SLIDER, new Param2<string, string>("#ps4_options_video_brightness", "#ps4_options_video_brightness_desc"));
591  m_TextMap.Insert(OptionIDsScript.OPTION_GAME_MESSAGES, new Param2<string, string>("#ps4_options_game_messages", "#ps4_options_game_show_game_msg"));
592  m_TextMap.Insert(OptionIDsScript.OPTION_ADMIN_MESSAGES, new Param2<string, string>("#ps4_options_admin_mes", "#ps4_options_game_show_admin_msg"));
593  m_TextMap.Insert(OptionIDsScript.OPTION_PLAYER_MESSAGES, new Param2<string, string>("#ps4_options_player_messages","#ps4_options_game_show_player_msg"));
594  #endif
595  #endif
596  #endif
597  }
598 
599  private void RevertHUDBrightness()
600  {
601  if (m_HUDBrightnessSelector)
602  {
603  m_HUDBrightnessSelector.SetValue(g_Game.GetProfileOptionFloat(EDayZProfilesOptions.HUD_BRIGHTNESS), false);
604  g_Game.SetHudBrightness(m_HUDBrightnessSelector.GetValue());
605  }
606  }
607 }
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
mission
Mission mission
Definition: displaystatus.c:28
EDayZProfilesOptions
EDayZProfilesOptions
Definition: edayzprofilesoptions.c:1
Focus
void Focus()
Definition: serverbrowsertab.c:181
Mission
Mission class.
Definition: gameplay.c:670
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
ErrorEx
enum ShapeType ErrorEx
OnMouseLeave
override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
Definition: uihintpanel.c:276
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
ErrorExSeverity
ErrorExSeverity
Definition: endebug.c:61
OptionAccessType
OptionAccessType
C++ OptionAccessType.
Definition: gameplay.c:1200
array< string >
MENU_INGAME
const int MENU_INGAME
Definition: constants.c:168
SetFocus
proto native void SetFocus(Widget w)
x
Icon x
OnFocus
override bool OnFocus(Widget w, int x, int y)
Definition: serverbrowsertab.c:217
Widget
Definition: enwidgets.c:189
GetInput
ActionInput GetInput()
Definition: actionbase.c:1066
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