DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
OptionsMenuSounds.c
См. документацию.
1class OptionsMenuSounds 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 protected TextWidget m_DetailsLabel;
10 protected RichTextWidget m_DetailsText;
11
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;
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 protected ref OptionSelectorMultistate m_AmbientMusicSelector;
26
27 protected ref Timer m_AudioLevelTimer;
28 protected GameOptions m_Options;
29 protected OptionsMenu m_Menu;
30 protected MissionGameplay m_MissionGameplay;
32
34
35 private bool m_WasMicCapturing;
36
37 void OptionsMenuSounds(Widget parent, Widget details_root, GameOptions options, OptionsMenu menu)
38 {
40 m_DetailsRoot = details_root;
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"));
45 m_Options = options;
46 m_Menu = menu;
47
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));
54
55 m_MissionGameplay = MissionGameplay.Cast(GetGame().GetMission());
58 m_AudioLevelTimer.Run(0.1, this, "UpdateAudioLevel", null, true);
59
60 m_Root.FindAnyWidget( "master_setting_option" ).SetUserID(OptionAccessType.AT_OPTIONS_MASTER_VOLUME);
61 m_Root.FindAnyWidget( "effects_setting_option" ).SetUserID(OptionAccessType.AT_OPTIONS_EFFECTS_SLIDER);
62 m_Root.FindAnyWidget( "music_setting_option" ).SetUserID(OptionAccessType.AT_OPTIONS_MUSIC_SLIDER);
63 m_Root.FindAnyWidget( "voip_output_setting_option" ).SetUserID(OptionAccessType.AT_OPTIONS_VON_SLIDER);
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);
67
69
70 array<string> inputModeValues = {
71 "#STR_Controls_PushToTalk",
72 "#STR_USRACT_UAVOICEOVERNETTOGGLE",
73 };
74 array<string> ambientMusicModeValues = {
75 "#STR_Ambient_Music_Enabled",
76 "#STR_Ambient_Music_Menu_Only",
77 };
78
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);
86
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);
93 m_InputModeSelector.m_OptionChanged.Insert(UpdateInputMode);
94
96 {
97 // event to monitor when options get reverted directly from C++
98 m_VOIPThresholdOption.GetEvents().Event_OnRevert.Insert(m_VonManager.OnVOIPThresholdChanged);
99 m_VonManager.m_OnVonStateEvent.Insert(OnVonStateEvent);
100 m_VonManager.m_OnPartyChatChangedEvent.Insert(OnPartyChatChangedEvent);
101 m_VOIPThresholdSelector.m_OptionChanged.Insert(m_VonManager.OnVOIPThresholdChanged);
102 }
103
104 float x, y, y2;
105 m_Root.FindAnyWidget("sound_settings_scroll").GetScreenSize(x, y);
106 m_Root.FindAnyWidget("sound_settings_root").GetScreenSize(x, y2);
107 int f = (y2 > y);
108 m_Root.FindAnyWidget("sound_settings_scroll").SetAlpha(f);
109
110 m_Root.SetHandler(this);
111
112 CGame game = GetGame();
114
115 // do not enable mic capture if user in party chat
116 if (!game.IsInPartyChat())
117 {
118 game.EnableMicCapture(true);
119 }
120 }
121
123 {
124 m_VonManager.m_OnVonStateEvent.Remove(OnVonStateEvent);
125 m_VonManager.m_OnPartyChatChangedEvent.Remove(OnPartyChatChangedEvent);
126
128 {
129 // reset mic to previous capturing state
131 }
132
133 m_AudioLevelTimer.Stop();
134 }
135
137 {
138 #ifdef PLATFORM_CONSOLE
139 return "gui/layouts/new_ui/options/xbox/sound_tab.layout";
140 #else
141 #ifdef PLATFORM_WINDOWS
142 return "gui/layouts/new_ui/options/pc/sound_tab.layout";
143 #endif
144 #endif
145 }
146
147 void Focus()
148 {
149 #ifdef PLATFORM_CONSOLE
150 SetFocus(m_MasterSelector.GetParent());
151 #endif
152 }
153
154 override bool OnMouseEnter(Widget w, int x, int y)
155 {
156 if ( w && w.IsInherited(ScrollWidget))
157 {
158 return false;
159 }
160
161 m_Menu.ColorHighlight(w);
162
163 return true;
164 }
165
166 override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
167 {
168 if ( w && w.IsInherited(ScrollWidget))
169 {
170 return false;
171 }
172
173 m_Menu.ColorNormal(w);
174 return true;
175 }
176
177 override bool OnFocus(Widget w, int x, int y)
178 {
179 OptionsMenu menu = OptionsMenu.Cast(GetGame().GetUIManager().GetMenu());
180 if (menu)
181 {
182 menu.OnFocus(w, x, y);
183 }
184 if (w)
185 {
186 if (TextMapUpdateWidget(w.GetUserID()))
187 {
188 return true;
189 }
190
191 if (w.IsInherited(SliderWidget))
192 {
193 return true;
194 }
195 }
196 m_DetailsRoot.Show(false);
197 return (w != null);
198 }
199
201 {
202 bool connectivityInfoShown = key == OptionIDsScript.OPTION_CONNECTIVITY_INFO;
204 Param tmp = m_TextMap.Get(key);
205
206 m_DetailsBodyDefault.Show(!connectivityInfoShown);
207 m_DetailsBodyConnectivity.Show(connectivityInfoShown);
208
209 if (Class.CastTo(p,tmp))
210 {
211 m_DetailsRoot.Show(true);
212 m_DetailsText.Show(true);
213 m_DetailsLabel.SetText(p.param1);
214 m_DetailsText.SetText(p.param2);
215
216 m_DetailsText.Update();
217 m_DetailsLabel.Update();
218 m_DetailsRoot.Update();
219 m_DetailsBodyConnectivity.Update(); //...
220 return true;
221 }
222 return false;
223 }
224
226 {
227 // changing VON mode may disable mic capture,
228 // but mic should capture the entire time this menu is open (unless user in party chat)
229 if (!GetGame().IsInPartyChat())
230 {
231 // force enable mic capture
233 }
234
236 }
237
239 {
240 auto game = GetGame();
241 if (!game.IsInPartyChat())
242 {
243 game.EnableMicCapture(true);
244 }
245
247 }
248
249 // updates the mic capture state to reset to, when this menu closes
251 {
252 // if user is in party chat, then mic should not capture
253 if (GetGame().IsInPartyChat())
254 {
255 m_WasMicCapturing = false;
256 }
257
258 // otherwise, mic should capture ONLY if Voice Activation is enabled
259 else
260 {
261 m_WasMicCapturing = m_MissionGameplay.IsVoNActive();
262 }
263 }
264
266 {
267 bool universal = (m_AmbientMusicSelector.GetValue() != g_Game.GetProfileOptionInt(EDayZProfilesOptions.AMBIENT_MUSIC_MODE));
268
269 return universal;
270 }
271
272 void Apply()
273 {
274 g_Game.SetProfileOptionInt(EDayZProfilesOptions.AMBIENT_MUSIC_MODE, m_AmbientMusicSelector.GetValue());
275 }
276
277 void Revert()
278 {
279 if (m_MasterOption)
280 {
281 m_MasterSelector.SetValue(m_MasterOption.ReadValue(), true);
282 }
283 if (m_EffectsOption)
284 {
285 m_EffectsSelector.SetValue(m_EffectsOption.ReadValue(),true);
286 }
287 if (m_VOIPOption)
288 {
289 m_VOIPSelector.SetValue(m_VOIPOption.ReadValue(), true);
290 }
292 {
293 m_VOIPThresholdSelector.SetValue(m_VOIPThresholdOption.ReadValue(), true);
294 }
295 if (m_MusicOption)
296 {
297 m_MusicSelector.SetValue(m_MusicOption.ReadValue(), true);
298 }
300 {
301 m_InputModeSelector.SetValue(m_InputModeOption.GetIndex(), false);
302 }
303
305 m_AmbientMusicSelector.SetValue(g_Game.GetProfileOptionInt(EDayZProfilesOptions.AMBIENT_MUSIC_MODE), false);
306 }
307
309 {
310 if (m_MasterOption)
311 {
312 m_MasterSelector.SetValue(m_MasterOption.GetDefault(), true);
313 }
314 if (m_EffectsOption)
315 {
316 m_EffectsSelector.SetValue(m_EffectsOption.GetDefault(), true);
317 }
318 if (m_VOIPOption)
319 {
320 m_VOIPSelector.SetValue(m_VOIPOption.GetDefault(), true);
321 }
323 {
324 m_VOIPThresholdSelector.SetValue(m_VOIPThresholdOption.GetDefault(), true);
325 }
326 if (m_MusicOption)
327 {
328 m_MusicSelector.SetValue(m_MusicOption.GetDefault(), true);
329 }
331 {
332 m_InputModeOption.SetIndex(m_InputModeOption.GetDefaultIndex());
333 m_InputModeSelector.SetValue( m_InputModeOption.GetIndex(), false );
334 }
335
337 m_AmbientMusicSelector.SetValue(g_Game.GetProfileOptionDefaultInt(EDayZProfilesOptions.AMBIENT_MUSIC_MODE), false);
338 }
339
341 {
342 m_Menu.ReloadOptions();
343 }
344
346 {
347 m_Options = options;
348
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));
355
356 Revert();
357 }
358
359 void ToggleDependentOptions(int mode, bool state)
360 {
361 }
362
366
367 void UpdateMaster(float value)
368 {
369 m_MasterOption.WriteValue(value);
370 m_Menu.OnChanged();
371 }
372
373 void UpdateEffects(float value)
374 {
375 m_EffectsOption.WriteValue(value);
376 m_Menu.OnChanged();
377 }
378
379 void UpdateVOIP(float value)
380 {
381 m_VOIPOption.WriteValue(value);
382 m_Menu.OnChanged();
383 }
384
385 void UpdateVOIPThreshold(float value)
386 {
387 m_VOIPThresholdOption.WriteValue(value);
388 m_Menu.OnChanged();
389 }
390
391 void UpdateMusic(float value)
392 {
393 m_MusicOption.WriteValue(value);
394 m_Menu.OnChanged();
395 }
396
398 {
399 m_Menu.OnChanged();
400 }
401
402 void UpdateInputMode(int newIndex)
403 {
404 m_InputModeOption.SetIndex(newIndex);
405 m_Menu.OnChanged();
406 }
407
409 {
410 m_VOIPThresholdSelector.SetSlider2Value(GetGame().GetSoundScene().GetAudioLevel());
411 }
412
413
415 {
417
418 m_TextMap.Insert(OptionAccessType.AT_OPTIONS_MASTER_VOLUME, new Param2<string, string>("#STR_sound_tab_master_tip_header", "#STR_sound_tab_master_tip"));
419 m_TextMap.Insert(OptionAccessType.AT_OPTIONS_EFFECTS_SLIDER, new Param2<string, string>("#STR_sound_tab_effects_tip_header", "#STR_sound_tab_effects_tip"));
420 m_TextMap.Insert(OptionAccessType.AT_OPTIONS_MUSIC_SLIDER, new Param2<string, string>("#STR_sound_tab_music_tip_header", "#STR_sound_tab_music_tip"));
421 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"));
422
423 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"));
424 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"));
425 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"));
426 }
427}
map
Определения ControlsXboxNew.c:4
DayZGame g_Game
Определения DayZGame.c:3868
EDayZProfilesOptions
Определения EDayZProfilesOptions.c:2
Icon x
Icon y
Widget m_DetailsRoot
Определения ServerBrowserTab.c:84
Widget m_Root
Определения SizeToChild.c:91
proto native bool IsMicCapturing()
Returns whether mic is currently capturing audio from user.
proto native bool IsInPartyChat()
Returns whether user is currently in a voice party (currently only supported on xbox)
proto native WorkspaceWidget GetWorkspace()
proto native void EnableMicCapture(bool enable)
Enable microphone to locally capture audio from user. Audio heard does NOT automatically get transmit...
Определения DayZGame.c:890
Super root of all classes in Enforce script.
Определения EnScript.c:11
Определения gameplay.c:1461
Определения PPEConstants.c:68
Base Param Class with no parameters. Used as general purpose parameter overloaded with Param1 to Para...
Определения param.c:12
Определения gameplay.c:317
ref NumericOptionsAccess m_MusicOption
Определения OptionsMenuSounds.c:16
ref OptionSelectorMultistate m_AmbientMusicSelector
Определения OptionsMenuSounds.c:25
GameOptions m_Options
Определения OptionsMenuControls.c:18
bool m_WasMicCapturing
Определения OptionsMenuSounds.c:35
VONManagerBase m_VonManager
Определения OptionsMenuSounds.c:31
void UpdateAmbientSoundModeOption(int value)
Определения OptionsMenuSounds.c:397
void UpdateVOIP(float value)
Определения OptionsMenuSounds.c:379
void SetToDefaults()
Определения OptionsMenuSounds.c:308
ref NumericOptionsAccess m_MasterOption
Определения OptionsMenuSounds.c:12
ref NumericOptionsAccess m_VOIPThresholdOption
Определения OptionsMenuSounds.c:15
void OnPartyChatChangedEvent()
Определения OptionsMenuSounds.c:238
Widget m_Root
Определения SizeToChild.c:9
void ToggleDependentOptions(int mode, bool state)
Определения OptionsMenuSounds.c:359
void UpdateWasMicCapturing()
Определения OptionsMenuSounds.c:250
ref NumericOptionsAccess m_VOIPOption
Определения OptionsMenuSounds.c:14
ref OptionSelectorSlider m_VOIPSelector
Определения OptionsMenuSounds.c:21
void SetOptions(GameOptions options)
Определения OptionsMenuSounds.c:345
ref OptionSelectorLevelMarker m_VOIPThresholdSelector
Определения OptionsMenuSounds.c:22
ref Timer m_AudioLevelTimer
Определения OptionsMenuSounds.c:27
CameraToolsMenu m_Menu
Определения CTEvent.c:8
ref OptionSelectorSlider m_MusicSelector
Определения OptionsMenuSounds.c:23
RichTextWidget m_DetailsText
Определения OptionsMenuControls.c:15
ref NumericOptionsAccess m_EffectsOption
Определения OptionsMenuSounds.c:13
void UpdateInputMode(int newIndex)
Определения OptionsMenuSounds.c:402
ref OptionSelectorMultistate m_InputModeSelector
Определения OptionsMenuSounds.c:24
void UpdateEffects(float value)
Определения OptionsMenuSounds.c:373
Widget m_DetailsBodyConnectivity
Определения OptionsMenuControls.c:8
void ReloadOptions()
Определения OptionsMenuSounds.c:340
void UpdateVOIPThreshold(float value)
Определения OptionsMenuSounds.c:385
override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
Определения OptionsMenuSounds.c:166
Widget m_DetailsBodyDefault
Определения OptionsMenuControls.c:7
bool TextMapUpdateWidget(int key)
Определения OptionsMenuControls.c:360
ref OptionSelectorSlider m_EffectsSelector
Определения OptionsMenuSounds.c:20
ref map< int, ref Param2< string, string > > m_TextMap
Определения OptionsMenuControls.c:71
MissionGameplay m_MissionGameplay
Определения OptionsMenuSounds.c:30
void UpdateMusic(float value)
Определения OptionsMenuSounds.c:391
ref ListOptionsAccess m_InputModeOption
Определения OptionsMenuSounds.c:17
void UpdateAudioLevel()
Определения OptionsMenuSounds.c:408
override bool OnFocus(Widget w, int x, int y)
Определения OptionsMenuSounds.c:177
override bool OnMouseEnter(Widget w, int x, int y)
Определения OptionsMenuSounds.c:154
void UpdateMaster(float value)
Определения OptionsMenuSounds.c:367
void OptionsMenuSounds(Widget parent, Widget details_root, GameOptions options, OptionsMenu menu)
Определения OptionsMenuSounds.c:37
void ~OptionsMenuSounds()
Определения OptionsMenuSounds.c:122
void OnVonStateEvent()
Определения OptionsMenuSounds.c:225
ref OptionSelectorSlider m_MasterSelector
Определения OptionsMenuSounds.c:19
TextWidget m_DetailsLabel
Определения OptionsMenuControls.c:14
void InitDependentOptionsVisibility()
Определения OptionsMenuSounds.c:363
map: item x vector(index, width, height)
Определения EnWidgets.c:651
Определения EnWidgets.c:220
Определения DayZPlayerImplement.c:63
static VONManagerBase GetInstance()
Main way to access VONManager functionality from script.
Определения VONManager.c:292
Определения VONManager.c:2
Manager class which handles Voice-over-network functionality while player is connected to a server.
Определения VONManager.c:285
Определения EnWidgets.c:190
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 ...
Определения gameplay.c:1293
proto native CGame GetGame()
OptionAccessType
C++ OptionAccessType.
Определения gameplay.c:1224
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
proto native float GetAudioLevel()
proto native external Widget CreateWidgets(string layout, Widget parentWidget=NULL, bool immedUpdate=true)
Create widgets from *.layout file.
proto native void SetFocus(Widget w)
WorkspaceWidget Widget
Defined in code.