DayZ 1.24
Loading...
Searching...
No Matches
OptionsMenuSounds.c
Go to the documentation of this file.
1class OptionsMenuSounds extends ScriptedWidgetEventHandler
2{
3 protected Widget m_Root;
4
5 protected Widget m_SettingsRoot;
6 protected Widget m_DetailsRoot;
11
18
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
27 protected GameOptions m_Options;
28 protected OptionsMenu m_Menu;
29 protected MissionGameplay m_MissionGameplay;
31
33
34 private bool m_WasMicCapturing;
35
37 {
38 m_Root = GetGame().GetWorkspace().CreateWidgets(GetLayoutName(), parent);
39 m_DetailsRoot = details_root;
40 m_DetailsBodyDefault = m_DetailsRoot.FindAnyWidget("settings_details_body");
41 m_DetailsBodyConnectivity = m_DetailsRoot.FindAnyWidget("settings_details_body_connectivity");
42 m_DetailsLabel = TextWidget.Cast(m_DetailsRoot.FindAnyWidget("details_label"));
43 m_DetailsText = RichTextWidget.Cast(m_DetailsRoot.FindAnyWidget("details_content"));
44 m_Options = options;
45 m_Menu = menu;
46
47 m_MasterOption = NumericOptionsAccess.Cast(m_Options.GetOptionByType(OptionAccessType.AT_OPTIONS_MASTER_VOLUME));
48 m_EffectsOption = NumericOptionsAccess.Cast(m_Options.GetOptionByType(OptionAccessType.AT_OPTIONS_EFFECTS_SLIDER));
49 m_MusicOption = NumericOptionsAccess.Cast(m_Options.GetOptionByType(OptionAccessType.AT_OPTIONS_MUSIC_SLIDER));
50 m_VOIPOption = NumericOptionsAccess.Cast(m_Options.GetOptionByType(OptionAccessType.AT_OPTIONS_VON_SLIDER));
51 m_VOIPThresholdOption = NumericOptionsAccess.Cast(m_Options.GetOptionByType(OptionAccessType.AT_OPTIONS_VON_THRESHOLD_SLIDER));
52 m_InputModeOption = ListOptionsAccess.Cast(m_Options.GetOptionByType(OptionAccessType.AT_OPTIONS_VON_INPUT_MODE));
53
54 m_MissionGameplay = MissionGameplay.Cast(GetGame().GetMission());
55 m_VonManager = VONManager.GetInstance();
56 m_AudioLevelTimer = new Timer();
57 m_AudioLevelTimer.Run(0.1, this, "UpdateAudioLevel", NULL, true);
58
59 m_Root.FindAnyWidget("master_setting_option").SetUserID(OptionAccessType.AT_OPTIONS_MASTER_VOLUME);
60 m_Root.FindAnyWidget("effects_setting_option").SetUserID(OptionAccessType.AT_OPTIONS_EFFECTS_SLIDER);
61 m_Root.FindAnyWidget("music_setting_option").SetUserID(OptionAccessType.AT_OPTIONS_MUSIC_SLIDER);
62 m_Root.FindAnyWidget("voip_output_setting_option").SetUserID(OptionAccessType.AT_OPTIONS_VON_SLIDER);
63 m_Root.FindAnyWidget("voip_threshold_setting_option").SetUserID(OptionAccessType.AT_OPTIONS_VON_THRESHOLD_SLIDER);
64 m_Root.FindAnyWidget("voip_selection_setting_option").SetUserID(OptionAccessType.AT_OPTIONS_VON_INPUT_MODE);
65
67
68 array<string> inputModeValues = { "#STR_Controls_PushToTalk", "#STR_USRACT_UAVOICEOVERNETTOGGLE" };
69
70 m_MasterSelector = new OptionSelectorSlider(m_Root.FindAnyWidget("master_setting_option"), m_MasterOption.ReadValue(), this, false, m_MasterOption.GetMin(), m_MasterOption.GetMax());
71 m_EffectsSelector = new OptionSelectorSlider(m_Root.FindAnyWidget("effects_setting_option"), m_EffectsOption.ReadValue(), this, false, m_EffectsOption.GetMin(), m_EffectsOption.GetMax());
72 m_VOIPSelector = new OptionSelectorSlider(m_Root.FindAnyWidget("voip_output_setting_option"), m_VOIPOption.ReadValue(), this, false, m_VOIPOption.GetMin(), m_VOIPOption.GetMax());
73 m_VOIPThresholdSelector = new OptionSelectorLevelMarker(m_Root.FindAnyWidget("voip_threshold_setting_option"), m_VOIPThresholdOption.ReadValue(), this, false, m_VOIPThresholdOption.GetMin(), m_VOIPThresholdOption.GetMax());
74 m_MusicSelector = new OptionSelectorSlider(m_Root.FindAnyWidget("music_setting_option"), m_MusicOption.ReadValue(), this, false, m_MusicOption.GetMin(), m_MusicOption.GetMax());
75 m_InputModeSelector = new OptionSelectorMultistate(m_Root.FindAnyWidget("voip_selection_setting_option"), m_InputModeOption.GetIndex(), this, false, inputModeValues);
76
77 m_MasterSelector.m_OptionChanged.Insert(UpdateMaster);
78 m_EffectsSelector.m_OptionChanged.Insert(UpdateEffects);
79 m_VOIPSelector.m_OptionChanged.Insert(UpdateVOIP);
80 m_VOIPThresholdSelector.m_OptionChanged.Insert(UpdateVOIPThreshold);
81 m_MusicSelector.m_OptionChanged.Insert(UpdateMusic);
82 m_InputModeSelector.m_OptionChanged.Insert(UpdateInputMode);
83
84 if (m_MissionGameplay)
85 {
86 // event to monitor when options get reverted directly from C++
87 m_VOIPThresholdOption.GetEvents().Event_OnRevert.Insert(m_VonManager.OnVOIPThresholdChanged);
88 m_VonManager.m_OnVonStateEvent.Insert(OnVonStateEvent);
89 m_VonManager.m_OnPartyChatChangedEvent.Insert(OnPartyChatChangedEvent);
90 m_VOIPThresholdSelector.m_OptionChanged.Insert(m_VonManager.OnVOIPThresholdChanged);
91 }
92
93 float x, y, y2;
94 m_Root.FindAnyWidget("sound_settings_scroll").GetScreenSize(x, y);
95 m_Root.FindAnyWidget("sound_settings_root").GetScreenSize(x, y2);
96 int f = (y2 > y);
97 m_Root.FindAnyWidget("sound_settings_scroll").SetAlpha(f);
98
99 m_Root.SetHandler(this);
100
101 CGame game = GetGame();
102 m_WasMicCapturing = game.IsMicCapturing();
103
104 // do not enable mic capture if user in party chat
105 if (!game.IsInPartyChat())
106 game.EnableMicCapture(true);
107 }
108
110 {
111 m_VonManager.m_OnVonStateEvent.Remove(OnVonStateEvent);
112 m_VonManager.m_OnPartyChatChangedEvent.Remove(OnPartyChatChangedEvent);
113
114 if (m_MissionGameplay)
115 {
116 // reset mic to previous capturing state
117 GetGame().EnableMicCapture(m_WasMicCapturing);
118 }
119
120 m_AudioLevelTimer.Stop();
121 }
122
124 {
125#ifdef PLATFORM_CONSOLE
126 return "gui/layouts/new_ui/options/xbox/sound_tab.layout";
127#else
128#ifdef PLATFORM_WINDOWS
129 return "gui/layouts/new_ui/options/pc/sound_tab.layout";
130#endif
131#endif
132 }
133
134 void Focus()
135 {
136#ifdef PLATFORM_CONSOLE
137 SetFocus(m_MasterSelector.GetParent());
138#endif
139 }
140
141 override bool OnMouseEnter(Widget w, int x, int y)
142 {
143 if (w && w.IsInherited(ScrollWidget))
144 return false;
145
146 m_Menu.ColorHighlight(w);
147
148 return true;
149 }
150
151 override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
152 {
153 if (w && w.IsInherited(ScrollWidget))
154 return false;
155
156 m_Menu.ColorNormal(w);
157 return true;
158 }
159
160 override bool OnFocus(Widget w, int x, int y)
161 {
162 OptionsMenu menu = OptionsMenu.Cast(GetGame().GetUIManager().GetMenu());
163 if (menu)
164 menu.OnFocus(w, x, y);
165 if (w)
166 {
167 if (TextMapUpdateWidget(w.GetUserID()))
168 return true;
169
170 if (w.IsInherited(SliderWidget))
171 return true;
172 }
173 m_DetailsRoot.Show(false);
174 return (w != null);
175 }
176
178 {
179 bool connectivityInfoShown = key == OptionIDsScript.OPTION_CONNECTIVITY_INFO;
181 Param tmp = m_TextMap.Get(key);
182
183 m_DetailsBodyDefault.Show(!connectivityInfoShown);
184 m_DetailsBodyConnectivity.Show(connectivityInfoShown);
185
186 if (Class.CastTo(p, tmp))
187 {
188 m_DetailsRoot.Show(true);
189 m_DetailsText.Show(true);
190 m_DetailsLabel.SetText(p.param1);
191 m_DetailsText.SetText(p.param2);
192
193 m_DetailsText.Update();
194 m_DetailsLabel.Update();
195 m_DetailsRoot.Update();
196 m_DetailsBodyConnectivity.Update(); //...
197 return true;
198 }
199 return false;
200 }
201
203 {
204 // changing VON mode may disable mic capture,
205 // but mic should capture the entire time this menu is open (unless user in party chat)
206 if (!GetGame().IsInPartyChat())
207 {
208 // force enable mic capture
209 GetGame().EnableMicCapture(true);
210 }
211
213 }
214
216 {
217 auto game = GetGame();
218 if (!game.IsInPartyChat())
219 game.EnableMicCapture(true);
220
222 }
223
224 // updates the mic capture state to reset to, when this menu closes
226 {
227 // if user is in party chat, then mic should not capture
228 if (GetGame().IsInPartyChat())
229 m_WasMicCapturing = false;
230
231 // otherwise, mic should capture ONLY if Voice Activation is enabled
232 else
233 m_WasMicCapturing = m_MissionGameplay.IsVoNActive();
234 }
235
237 {
238 return false;
239 }
240
241 void Apply()
242 {
243
244 }
245
246 void Revert()
247 {
248 if (m_MasterOption)
249 m_MasterSelector.SetValue(m_MasterOption.ReadValue(), true);
250 if (m_EffectsOption)
251 m_EffectsSelector.SetValue(m_EffectsOption.ReadValue(), true);
252 if (m_VOIPOption)
253 m_VOIPSelector.SetValue(m_VOIPOption.ReadValue(), true);
254 if (m_VOIPThresholdOption)
255 m_VOIPThresholdSelector.SetValue(m_VOIPThresholdOption.ReadValue(), true);
256 if (m_MusicOption)
257 m_MusicSelector.SetValue(m_MusicOption.ReadValue(), true);
258 if (m_InputModeOption)
259 m_InputModeSelector.SetValue(m_InputModeOption.GetIndex(), false);
260 }
261
263 {
264 if (m_MasterOption)
265 m_MasterSelector.SetValue(m_MasterOption.GetDefault(), true);
266 if (m_EffectsOption)
267 m_EffectsSelector.SetValue(m_EffectsOption.GetDefault(), true);
268 if (m_VOIPOption)
269 m_VOIPSelector.SetValue(m_VOIPOption.GetDefault(), true);
270 if (m_VOIPThresholdOption)
271 m_VOIPThresholdSelector.SetValue(m_VOIPThresholdOption.GetDefault(), true);
272 if (m_MusicOption)
273 m_MusicSelector.SetValue(m_MusicOption.GetDefault(), true);
274 if (m_InputModeOption)
275 {
276 m_InputModeOption.SetIndex(m_InputModeOption.GetDefaultIndex());
277 m_InputModeSelector.SetValue(m_InputModeOption.GetIndex(), false);
278 }
279 }
280
282 {
283 m_Menu.ReloadOptions();
284 }
285
287 {
288 m_Options = options;
289
290 m_MasterOption = NumericOptionsAccess.Cast(m_Options.GetOptionByType(OptionAccessType.AT_OPTIONS_MASTER_VOLUME));
291 m_EffectsOption = NumericOptionsAccess.Cast(m_Options.GetOptionByType(OptionAccessType.AT_OPTIONS_EFFECTS_SLIDER));
292 m_MusicOption = NumericOptionsAccess.Cast(m_Options.GetOptionByType(OptionAccessType.AT_OPTIONS_MUSIC_SLIDER));
293 m_VOIPOption = NumericOptionsAccess.Cast(m_Options.GetOptionByType(OptionAccessType.AT_OPTIONS_VON_SLIDER));
294 m_InputModeOption = ListOptionsAccess.Cast(m_Options.GetOptionByType(OptionAccessType.AT_OPTIONS_VON_INPUT_MODE));
295 m_VOIPThresholdOption = NumericOptionsAccess.Cast(m_Options.GetOptionByType(OptionAccessType.AT_OPTIONS_VON_THRESHOLD_SLIDER));
296
297 Revert();
298 }
299
301 {
302 }
303
307
308 void UpdateMaster(float value)
309 {
310 m_MasterOption.WriteValue(value);
311 m_Menu.OnChanged();
312 }
313
315 {
316 m_EffectsOption.WriteValue(value);
317 m_Menu.OnChanged();
318 }
319
320 void UpdateVOIP(float value)
321 {
322 m_VOIPOption.WriteValue(value);
323 m_Menu.OnChanged();
324 }
325
327 {
328 m_VOIPThresholdOption.WriteValue(value);
329 m_Menu.OnChanged();
330 }
331
332 void UpdateMusic(float value)
333 {
334 m_MusicOption.WriteValue(value);
335 m_Menu.OnChanged();
336 }
337
339 {
340 m_InputModeOption.SetIndex(newIndex);
341 m_Menu.OnChanged();
342 }
343
345 {
346 m_VOIPThresholdSelector.SetSlider2Value(GetGame().GetSoundScene().GetAudioLevel());
347 }
348
349
351 {
353
354 m_TextMap.Insert(OptionAccessType.AT_OPTIONS_MASTER_VOLUME, new Param2<string, string>("#STR_sound_tab_master_tip_header", "#STR_sound_tab_master_tip"));
355 m_TextMap.Insert(OptionAccessType.AT_OPTIONS_EFFECTS_SLIDER, new Param2<string, string>("#STR_sound_tab_effects_tip_header", "#STR_sound_tab_effects_tip"));
356 m_TextMap.Insert(OptionAccessType.AT_OPTIONS_MUSIC_SLIDER, new Param2<string, string>("#STR_sound_tab_music_tip_header", "#STR_sound_tab_music_tip"));
357
358 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"));
359 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"));
360 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"));
361 }
362}
void UpdateMusic()
Icon x
Icon y
ServerBrowserMenuNew m_Menu
Widget m_Root
Definition SizeToChild.c:85
proto native float GetAudioLevel()
Super root of all classes in Enforce script.
Definition EnScript.c:11
proto native OptionsAccess GetOptionByType(int accessType)
Get option by AccessType.
Base Param Class with no parameters. Used as general purpose parameter overloaded with Param1 to Para...
Definition param.c:12
map: item x vector(index, width, height)
Definition EnWidgets.c:651
ref NumericOptionsAccess m_MusicOption
ref NumericOptionsAccess m_MasterOption
ref NumericOptionsAccess m_VOIPThresholdOption
void ToggleDependentOptions(int mode, bool state)
ref NumericOptionsAccess m_VOIPOption
ref OptionSelectorSlider m_VOIPSelector
void SetOptions(GameOptions options)
ref OptionSelectorLevelMarker m_VOIPThresholdSelector
CameraToolsMenu m_Menu
Definition CTEvent.c:8
ref OptionSelectorSlider m_MusicSelector
ref NumericOptionsAccess m_EffectsOption
void UpdateInputMode(int newIndex)
ref OptionSelectorMultistate m_InputModeSelector
void UpdateVOIPThreshold(float value)
override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
ref OptionSelectorSlider m_EffectsSelector
ref map< int, ref Param2< string, string > > m_TextMap
ref ListOptionsAccess m_InputModeOption
override bool OnFocus(Widget w, int x, int y)
override bool OnMouseEnter(Widget w, int x, int y)
void OptionsMenuSounds(Widget parent, Widget details_root, GameOptions options, OptionsMenu menu)
ref OptionSelectorSlider m_MasterSelector
void OnVOIPThresholdChanged()
ref ScriptInvoker m_OnVonStateEvent
Definition VONManager.c:4
ref ScriptInvoker m_OnPartyChatChangedEvent
Definition VONManager.c:5
Manager class which handles Voice-over-network functionality while player is connected to a server.
Definition VONManager.c:242
static VONManagerBase GetInstance()
Main way to access VONManager functionality from script.
Definition VONManager.c:249
OptionIDsScript
Used for script-based game options. For anything C++ based, you would most likely use "Option Access ...
Definition gameplay.c:1246
proto native CGame GetGame()
OptionAccessType
C++ OptionAccessType.
Definition gameplay.c:1182
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
proto native void SetFocus(Widget w)