1class OptionsMenuSounds
extends ScriptedWidgetEventHandler
5 protected Widget m_SettingsRoot;
7 protected Widget m_DetailsBodyDefault;
8 protected Widget m_DetailsBodyConnectivity;
9 protected TextWidget m_DetailsLabel;
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;
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 =
GetGame().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"));
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(
GetGame().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);
71 "#STR_Controls_PushToTalk",
72 "#STR_USRACT_UAVOICEOVERNETTOGGLE",
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);
113 m_WasMicCapturing = game.IsMicCapturing();
116 if (!game.IsInPartyChat())
118 game.EnableMicCapture(
true);
122 void ~OptionsMenuSounds()
127 if (m_MissionGameplay)
130 GetGame().EnableMicCapture(m_WasMicCapturing);
133 m_AudioLevelTimer.Stop();
136 string GetLayoutName()
138 #ifdef PLATFORM_CONSOLE
139 return "gui/layouts/new_ui/options/xbox/sound_tab.layout";
141 #ifdef PLATFORM_WINDOWS
142 return "gui/layouts/new_ui/options/pc/sound_tab.layout";
149 #ifdef PLATFORM_CONSOLE
150 SetFocus(m_MasterSelector.GetParent());
156 if ( w && w.IsInherited(ScrollWidget))
168 if ( w && w.IsInherited(ScrollWidget))
177 override bool OnFocus(Widget w,
int x,
int y)
179 OptionsMenu menu = OptionsMenu.Cast(
GetGame().GetUIManager().GetMenu());
182 menu.OnFocus(w,
x,
y);
186 if (TextMapUpdateWidget(w.GetUserID()))
191 if (w.IsInherited(SliderWidget))
200 bool TextMapUpdateWidget(
int key)
202 bool connectivityInfoShown = key ==
OptionIDsScript.OPTION_CONNECTIVITY_INFO;
204 Param tmp = m_TextMap.Get(key);
206 m_DetailsBodyDefault.Show(!connectivityInfoShown);
207 m_DetailsBodyConnectivity.Show(connectivityInfoShown);
209 if (
Class.CastTo(p,tmp))
212 m_DetailsText.Show(
true);
213 m_DetailsLabel.SetText(p.param1);
214 m_DetailsText.SetText(p.param2);
216 m_DetailsText.Update();
217 m_DetailsLabel.Update();
219 m_DetailsBodyConnectivity.Update();
225 void OnVonStateEvent()
229 if (!
GetGame().IsInPartyChat())
232 GetGame().EnableMicCapture(
true);
235 UpdateWasMicCapturing();
238 void OnPartyChatChangedEvent()
241 if (!game.IsInPartyChat())
243 game.EnableMicCapture(
true);
246 UpdateWasMicCapturing();
250 void UpdateWasMicCapturing()
255 m_WasMicCapturing =
false;
261 m_WasMicCapturing = m_MissionGameplay.IsVoNActive();
281 m_MasterSelector.SetValue(m_MasterOption.ReadValue(),
true);
285 m_EffectsSelector.SetValue(m_EffectsOption.ReadValue(),
true);
289 m_VOIPSelector.SetValue(m_VOIPOption.ReadValue(),
true);
291 if (m_VOIPThresholdOption)
293 m_VOIPThresholdSelector.SetValue(m_VOIPThresholdOption.ReadValue(),
true);
297 m_MusicSelector.SetValue(m_MusicOption.ReadValue(),
true);
299 if (m_InputModeOption)
301 m_InputModeSelector.SetValue(m_InputModeOption.GetIndex(),
false);
304 if (m_AmbientMusicSelector)
312 m_MasterSelector.SetValue(m_MasterOption.GetDefault(),
true);
316 m_EffectsSelector.SetValue(m_EffectsOption.GetDefault(),
true);
320 m_VOIPSelector.SetValue(m_VOIPOption.GetDefault(),
true);
322 if (m_VOIPThresholdOption)
324 m_VOIPThresholdSelector.SetValue(m_VOIPThresholdOption.GetDefault(),
true);
328 m_MusicSelector.SetValue(m_MusicOption.GetDefault(),
true);
330 if (m_InputModeOption)
332 m_InputModeOption.SetIndex(m_InputModeOption.GetDefaultIndex());
333 m_InputModeSelector.SetValue( m_InputModeOption.GetIndex(),
false );
336 if (m_AmbientMusicSelector)
349 m_MasterOption = NumericOptionsAccess.Cast(m_Options.GetOptionByType(
OptionAccessType.AT_OPTIONS_MASTER_VOLUME));
350 m_EffectsOption = NumericOptionsAccess.Cast(m_Options.GetOptionByType(
OptionAccessType.AT_OPTIONS_EFFECTS_SLIDER));
351 m_MusicOption = NumericOptionsAccess.Cast(m_Options.GetOptionByType(
OptionAccessType.AT_OPTIONS_MUSIC_SLIDER));
352 m_VOIPOption = NumericOptionsAccess.Cast(m_Options.GetOptionByType(
OptionAccessType.AT_OPTIONS_VON_SLIDER));
353 m_InputModeOption = ListOptionsAccess.Cast(m_Options.GetOptionByType(
OptionAccessType.AT_OPTIONS_VON_INPUT_MODE));
354 m_VOIPThresholdOption = NumericOptionsAccess.Cast(m_Options.GetOptionByType(
OptionAccessType.AT_OPTIONS_VON_THRESHOLD_SLIDER));
359 void ToggleDependentOptions(
int mode,
bool state)
363 void InitDependentOptionsVisibility()
367 void UpdateMaster(
float value)
369 m_MasterOption.WriteValue(value);
373 void UpdateEffects(
float value)
375 m_EffectsOption.WriteValue(value);
379 void UpdateVOIP(
float value)
381 m_VOIPOption.WriteValue(value);
385 void UpdateVOIPThreshold(
float value)
387 m_VOIPThresholdOption.WriteValue(value);
393 m_MusicOption.WriteValue(value);
397 void UpdateAmbientSoundModeOption(
int value)
402 void UpdateInputMode(
int newIndex)
404 m_InputModeOption.SetIndex(newIndex);
408 void UpdateAudioLevel()
410 m_VOIPThresholdSelector.SetSlider2Value(
GetGame().GetSoundScene().GetAudioLevel());
override bool OnMouseEnter(Widget w, int x, int y)
override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
Super root of all classes in Enforce script.
Base Param Class with no parameters. Used as general purpose parameter overloaded with Param1 to Para...
void OnVOIPThresholdChanged()
ref ScriptInvoker m_OnVonStateEvent
ref ScriptInvoker m_OnPartyChatChangedEvent
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
OptionIDsScript
Used for script-based game options. For anything C++ based, you would most likely use "Option Access ...
proto native CGame GetGame()
OptionAccessType
C++ OptionAccessType.
ServerBrowserMenuNew m_Menu
override bool OnFocus(Widget w, int x, int y)