1class OptionsMenuSounds
extends ScriptedWidgetEventHandler
5 protected Widget m_SettingsRoot;
7 protected Widget m_DetailsBodyDefault;
8 protected Widget m_DetailsBodyConnectivity;
9 protected TextWidget m_DetailsLabel;
10 protected RichTextWidget m_DetailsText;
12 protected ref NumericOptionsAccess m_MasterOption;
13 protected ref NumericOptionsAccess m_EffectsOption;
14 protected ref NumericOptionsAccess m_VOIPOption;
15 protected ref NumericOptionsAccess m_VOIPThresholdOption;
16 protected ref NumericOptionsAccess m_MusicOption;
17 protected ref ListOptionsAccess m_InputModeOption;
19 protected ref OptionSelectorSlider m_MasterSelector;
20 protected ref OptionSelectorSlider m_EffectsSelector;
21 protected ref OptionSelectorSlider m_VOIPSelector;
22 protected ref OptionSelectorLevelMarker m_VOIPThresholdSelector;
23 protected ref OptionSelectorSlider m_MusicSelector;
24 protected ref OptionSelectorMultistate m_InputModeSelector;
25 protected ref OptionSelectorMultistate m_AmbientMusicSelector;
27 protected ref Timer m_AudioLevelTimer;
28 protected GameOptions m_Options;
29 protected OptionsMenu
m_Menu;
30 protected MissionGameplay m_MissionGameplay;
35 private bool m_WasMicCapturing;
37 void OptionsMenuSounds(Widget parent, Widget details_root, GameOptions options, OptionsMenu menu)
39 m_Root =
g_Game.GetWorkspace().CreateWidgets(GetLayoutName(), parent);
41 m_DetailsBodyDefault =
m_DetailsRoot.FindAnyWidget(
"settings_details_body");
42 m_DetailsBodyConnectivity =
m_DetailsRoot.FindAnyWidget(
"settings_details_body_connectivity");
43 m_DetailsLabel = TextWidget.Cast(
m_DetailsRoot.FindAnyWidget(
"details_label"));
44 m_DetailsText = RichTextWidget.Cast(
m_DetailsRoot.FindAnyWidget(
"details_content"));
48 m_MasterOption = NumericOptionsAccess.Cast(m_Options.GetOptionByType(
OptionAccessType.AT_OPTIONS_MASTER_VOLUME));
49 m_EffectsOption = NumericOptionsAccess.Cast(m_Options.GetOptionByType(
OptionAccessType.AT_OPTIONS_EFFECTS_SLIDER));
50 m_MusicOption = NumericOptionsAccess.Cast(m_Options.GetOptionByType(
OptionAccessType.AT_OPTIONS_MUSIC_SLIDER));
51 m_VOIPOption = NumericOptionsAccess.Cast(m_Options.GetOptionByType(
OptionAccessType.AT_OPTIONS_VON_SLIDER));
52 m_VOIPThresholdOption = NumericOptionsAccess.Cast(m_Options.GetOptionByType(
OptionAccessType.AT_OPTIONS_VON_THRESHOLD_SLIDER));
53 m_InputModeOption = ListOptionsAccess.Cast(m_Options.GetOptionByType(
OptionAccessType.AT_OPTIONS_VON_INPUT_MODE));
55 m_MissionGameplay = MissionGameplay.Cast(
g_Game.GetMission());
56 m_VonManager = VONManager.GetInstance();
57 m_AudioLevelTimer =
new Timer();
58 m_AudioLevelTimer.Run(0.1,
this,
"UpdateAudioLevel", null,
true);
64 m_Root.FindAnyWidget(
"voip_threshold_setting_option" ).SetUserID(
OptionAccessType.AT_OPTIONS_VON_THRESHOLD_SLIDER);
65 m_Root.FindAnyWidget(
"voip_selection_setting_option" ).SetUserID(
OptionAccessType.AT_OPTIONS_VON_INPUT_MODE);
66 m_Root.FindAnyWidget(
"ambient_music_mode_option" ).SetUserID(
OptionIDsScript.OPTION_AMBIENT_MUSIC_MODE);
70 array<string> inputModeValues = {
71 "#STR_Controls_PushToTalk",
72 "#STR_USRACT_UAVOICEOVERNETTOGGLE",
74 array<string> ambientMusicModeValues = {
75 "#STR_Ambient_Music_Enabled",
76 "#STR_Ambient_Music_Menu_Only",
79 m_MasterSelector =
new OptionSelectorSlider(
m_Root.FindAnyWidget(
"master_setting_option" ), m_MasterOption.ReadValue(),
this,
false, m_MasterOption.GetMin(), m_MasterOption.GetMax());
80 m_EffectsSelector =
new OptionSelectorSlider(
m_Root.FindAnyWidget(
"effects_setting_option" ), m_EffectsOption.ReadValue(),
this,
false, m_EffectsOption.GetMin(), m_EffectsOption.GetMax());
81 m_VOIPSelector =
new OptionSelectorSlider(
m_Root.FindAnyWidget(
"voip_output_setting_option" ), m_VOIPOption.ReadValue(),
this,
false, m_VOIPOption.GetMin(), m_VOIPOption.GetMax());
82 m_VOIPThresholdSelector =
new OptionSelectorLevelMarker(
m_Root.FindAnyWidget(
"voip_threshold_setting_option" ), m_VOIPThresholdOption.ReadValue(),
this,
false, m_VOIPThresholdOption.GetMin(), m_VOIPThresholdOption.GetMax());
83 m_MusicSelector =
new OptionSelectorSlider(
m_Root.FindAnyWidget(
"music_setting_option" ), m_MusicOption.ReadValue(),
this,
false, m_MusicOption.GetMin(), m_MusicOption.GetMax());
84 m_InputModeSelector =
new OptionSelectorMultistate(
m_Root.FindAnyWidget(
"voip_selection_setting_option" ), m_InputModeOption.GetIndex(),
this,
false, inputModeValues);
85 m_AmbientMusicSelector =
new OptionSelectorMultistate(
m_Root.FindAnyWidget(
"ambient_music_mode_option" ),
g_Game.GetProfileOptionInt(
EDayZProfilesOptions.AMBIENT_MUSIC_MODE),
this,
false, ambientMusicModeValues);
87 m_MasterSelector.m_OptionChanged.Insert(UpdateMaster);
88 m_EffectsSelector.m_OptionChanged.Insert(UpdateEffects);
89 m_VOIPSelector.m_OptionChanged.Insert(UpdateVOIP);
90 m_VOIPThresholdSelector.m_OptionChanged.Insert(UpdateVOIPThreshold);
91 m_MusicSelector.m_OptionChanged.Insert(
UpdateMusic);
92 m_AmbientMusicSelector.m_OptionChanged.Insert(UpdateAmbientSoundModeOption);
93 m_InputModeSelector.m_OptionChanged.Insert(UpdateInputMode);
95 if (m_MissionGameplay)
105 m_Root.FindAnyWidget(
"sound_settings_scroll").GetScreenSize(
x,
y);
106 m_Root.FindAnyWidget(
"sound_settings_root").GetScreenSize(
x, y2);
108 m_Root.FindAnyWidget(
"sound_settings_scroll").SetAlpha(f);
112 m_WasMicCapturing =
g_Game.IsMicCapturing();
115 if (!
g_Game.IsInPartyChat())
117 g_Game.EnableMicCapture(
true);
121 void ~OptionsMenuSounds()
126 if (m_MissionGameplay)
129 g_Game.EnableMicCapture(m_WasMicCapturing);
132 m_AudioLevelTimer.Stop();
135 string GetLayoutName()
137 #ifdef PLATFORM_CONSOLE
138 return "gui/layouts/new_ui/options/xbox/sound_tab.layout";
140 #ifdef PLATFORM_WINDOWS
141 return "gui/layouts/new_ui/options/pc/sound_tab.layout";
148 #ifdef PLATFORM_CONSOLE
149 SetFocus(m_MasterSelector.GetParent());
155 if ( w && w.IsInherited(ScrollWidget))
167 if ( w && w.IsInherited(ScrollWidget))
176 override bool OnFocus(Widget w,
int x,
int y)
178 OptionsMenu menu = OptionsMenu.Cast(
g_Game.GetUIManager().GetMenu());
181 menu.OnFocus(w,
x,
y);
185 if (TextMapUpdateWidget(w.GetUserID()))
190 if (w.IsInherited(SliderWidget))
199 bool TextMapUpdateWidget(
int key)
201 bool connectivityInfoShown = key ==
OptionIDsScript.OPTION_CONNECTIVITY_INFO;
202 Param2<string, string> p;
203 Param tmp = m_TextMap.Get(key);
205 m_DetailsBodyDefault.Show(!connectivityInfoShown);
206 m_DetailsBodyConnectivity.Show(connectivityInfoShown);
208 if (Class.CastTo(p,tmp))
211 m_DetailsText.Show(
true);
212 m_DetailsLabel.SetText(p.param1);
213 m_DetailsText.SetText(p.param2);
215 m_DetailsText.Update();
216 m_DetailsLabel.Update();
218 m_DetailsBodyConnectivity.Update();
224 void OnVonStateEvent()
228 if (!
g_Game.IsInPartyChat())
231 g_Game.EnableMicCapture(
true);
234 UpdateWasMicCapturing();
237 void OnPartyChatChangedEvent()
239 if (!
g_Game.IsInPartyChat())
241 g_Game.EnableMicCapture(
true);
244 UpdateWasMicCapturing();
248 void UpdateWasMicCapturing()
251 if (
g_Game.IsInPartyChat())
253 m_WasMicCapturing =
false;
259 m_WasMicCapturing = m_MissionGameplay.IsVoNActive();
279 m_MasterSelector.SetValue(m_MasterOption.ReadValue(),
true);
283 m_EffectsSelector.SetValue(m_EffectsOption.ReadValue(),
true);
287 m_VOIPSelector.SetValue(m_VOIPOption.ReadValue(),
true);
289 if (m_VOIPThresholdOption)
291 m_VOIPThresholdSelector.SetValue(m_VOIPThresholdOption.ReadValue(),
true);
295 m_MusicSelector.SetValue(m_MusicOption.ReadValue(),
true);
297 if (m_InputModeOption)
299 m_InputModeSelector.SetValue(m_InputModeOption.GetIndex(),
false);
302 if (m_AmbientMusicSelector)
310 m_MasterSelector.SetValue(m_MasterOption.GetDefault(),
true);
314 m_EffectsSelector.SetValue(m_EffectsOption.GetDefault(),
true);
318 m_VOIPSelector.SetValue(m_VOIPOption.GetDefault(),
true);
320 if (m_VOIPThresholdOption)
322 m_VOIPThresholdSelector.SetValue(m_VOIPThresholdOption.GetDefault(),
true);
326 m_MusicSelector.SetValue(m_MusicOption.GetDefault(),
true);
328 if (m_InputModeOption)
330 m_InputModeOption.SetIndex(m_InputModeOption.GetDefaultIndex());
331 m_InputModeSelector.SetValue( m_InputModeOption.GetIndex(),
false );
334 if (m_AmbientMusicSelector)
343 void SetOptions(GameOptions options)
347 m_MasterOption = NumericOptionsAccess.Cast(m_Options.GetOptionByType(
OptionAccessType.AT_OPTIONS_MASTER_VOLUME));
348 m_EffectsOption = NumericOptionsAccess.Cast(m_Options.GetOptionByType(
OptionAccessType.AT_OPTIONS_EFFECTS_SLIDER));
349 m_MusicOption = NumericOptionsAccess.Cast(m_Options.GetOptionByType(
OptionAccessType.AT_OPTIONS_MUSIC_SLIDER));
350 m_VOIPOption = NumericOptionsAccess.Cast(m_Options.GetOptionByType(
OptionAccessType.AT_OPTIONS_VON_SLIDER));
351 m_InputModeOption = ListOptionsAccess.Cast(m_Options.GetOptionByType(
OptionAccessType.AT_OPTIONS_VON_INPUT_MODE));
352 m_VOIPThresholdOption = NumericOptionsAccess.Cast(m_Options.GetOptionByType(
OptionAccessType.AT_OPTIONS_VON_THRESHOLD_SLIDER));
357 void ToggleDependentOptions(
int mode,
bool state)
361 void InitDependentOptionsVisibility()
365 void UpdateMaster(
float value)
367 m_MasterOption.WriteValue(value);
371 void UpdateEffects(
float value)
373 m_EffectsOption.WriteValue(value);
377 void UpdateVOIP(
float value)
379 m_VOIPOption.WriteValue(value);
383 void UpdateVOIPThreshold(
float value)
385 m_VOIPThresholdOption.WriteValue(value);
391 m_MusicOption.WriteValue(value);
395 void UpdateAmbientSoundModeOption(
int value)
400 void UpdateInputMode(
int newIndex)
402 m_InputModeOption.SetIndex(newIndex);
406 void UpdateAudioLevel()
408 m_VOIPThresholdSelector.SetSlider2Value(
g_Game.GetSoundScene().GetAudioLevel());
416 m_TextMap.Insert(
OptionAccessType.AT_OPTIONS_MASTER_VOLUME,
new Param2<string, string>(
"#STR_sound_tab_master_tip_header",
"#STR_sound_tab_master_tip"));
417 m_TextMap.Insert(
OptionAccessType.AT_OPTIONS_EFFECTS_SLIDER,
new Param2<string, string>(
"#STR_sound_tab_effects_tip_header",
"#STR_sound_tab_effects_tip"));
418 m_TextMap.Insert(
OptionAccessType.AT_OPTIONS_MUSIC_SLIDER,
new Param2<string, string>(
"#STR_sound_tab_music_tip_header",
"#STR_sound_tab_music_tip"));
419 m_TextMap.Insert(
OptionIDsScript.OPTION_AMBIENT_MUSIC_MODE,
new Param2<string, string>(
"#STR_sound_tab_ambient_mode_tip_header",
"#STR_sound_tab_ambient_mode_tip"));
421 m_TextMap.Insert(
OptionAccessType.AT_OPTIONS_VON_SLIDER,
new Param2<string, string>(
"#STR_sound_tab_voice_output_tip_header",
"#STR_sound_tab_voice_output_tip"));
422 m_TextMap.Insert(
OptionAccessType.AT_OPTIONS_VON_THRESHOLD_SLIDER,
new Param2<string, string>(
"#STR_sound_tab_voice_threshold_tip_header",
"#STR_sound_tab_voice_threshold_tip"));
423 m_TextMap.Insert(
OptionAccessType.AT_OPTIONS_VON_INPUT_MODE,
new Param2<string, string>(
"#STR_sound_tab_voice_mode_tip_header",
"#STR_sound_tab_voice_mode_tip"));
void OnVOIPThresholdChanged()
ref ScriptInvoker m_OnVonStateEvent
ref ScriptInvoker m_OnPartyChatChangedEvent
OptionIDsScript
Used for script-based game options. For anything C++ based, you would most likely use "Option Access ...
OptionAccessType
C++ OptionAccessType.
ServerBrowserMenuNew m_Menu
override bool OnFocus(Widget w, int x, int y)
override bool OnMouseEnter(Widget w, int x, int y)
override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)