DayZ 1.29
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 {
39 m_Root = g_Game.GetWorkspace().CreateWidgets(GetLayoutName(), parent);
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(g_Game.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 m_WasMicCapturing = g_Game.IsMicCapturing();
113
114 // do not enable mic capture if user in party chat
115 if (!g_Game.IsInPartyChat())
116 {
117 g_Game.EnableMicCapture(true);
118 }
119 }
120
122 {
123 m_VonManager.m_OnVonStateEvent.Remove(OnVonStateEvent);
124 m_VonManager.m_OnPartyChatChangedEvent.Remove(OnPartyChatChangedEvent);
125
127 {
128 // reset mic to previous capturing state
129 g_Game.EnableMicCapture(m_WasMicCapturing);
130 }
131
132 m_AudioLevelTimer.Stop();
133 }
134
136 {
137 #ifdef PLATFORM_CONSOLE
138 return "gui/layouts/new_ui/options/xbox/sound_tab.layout";
139 #else
140 #ifdef PLATFORM_WINDOWS
141 return "gui/layouts/new_ui/options/pc/sound_tab.layout";
142 #endif
143 #endif
144 }
145
146 void Focus()
147 {
148 #ifdef PLATFORM_CONSOLE
149 SetFocus(m_MasterSelector.GetParent());
150 #endif
151 }
152
153 override bool OnMouseEnter(Widget w, int x, int y)
154 {
155 if ( w && w.IsInherited(ScrollWidget))
156 {
157 return false;
158 }
159
160 m_Menu.ColorHighlight(w);
161
162 return true;
163 }
164
165 override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
166 {
167 if ( w && w.IsInherited(ScrollWidget))
168 {
169 return false;
170 }
171
172 m_Menu.ColorNormal(w);
173 return true;
174 }
175
176 override bool OnFocus(Widget w, int x, int y)
177 {
178 OptionsMenu menu = OptionsMenu.Cast(g_Game.GetUIManager().GetMenu());
179 if (menu)
180 {
181 menu.OnFocus(w, x, y);
182 }
183 if (w)
184 {
185 if (TextMapUpdateWidget(w.GetUserID()))
186 {
187 return true;
188 }
189
190 if (w.IsInherited(SliderWidget))
191 {
192 return true;
193 }
194 }
195 m_DetailsRoot.Show(false);
196 return (w != null);
197 }
198
200 {
201 bool connectivityInfoShown = key == OptionIDsScript.OPTION_CONNECTIVITY_INFO;
203 Param tmp = m_TextMap.Get(key);
204
205 m_DetailsBodyDefault.Show(!connectivityInfoShown);
206 m_DetailsBodyConnectivity.Show(connectivityInfoShown);
207
208 if (Class.CastTo(p,tmp))
209 {
210 m_DetailsRoot.Show(true);
211 m_DetailsText.Show(true);
212 m_DetailsLabel.SetText(p.param1);
213 m_DetailsText.SetText(p.param2);
214
215 m_DetailsText.Update();
216 m_DetailsLabel.Update();
217 m_DetailsRoot.Update();
218 m_DetailsBodyConnectivity.Update(); //...
219 return true;
220 }
221 return false;
222 }
223
225 {
226 // changing VON mode may disable mic capture,
227 // but mic should capture the entire time this menu is open (unless user in party chat)
228 if (!g_Game.IsInPartyChat())
229 {
230 // force enable mic capture
231 g_Game.EnableMicCapture(true);
232 }
233
235 }
236
238 {
239 if (!g_Game.IsInPartyChat())
240 {
241 g_Game.EnableMicCapture(true);
242 }
243
245 }
246
247 // updates the mic capture state to reset to, when this menu closes
249 {
250 // if user is in party chat, then mic should not capture
251 if (g_Game.IsInPartyChat())
252 {
253 m_WasMicCapturing = false;
254 }
255
256 // otherwise, mic should capture ONLY if Voice Activation is enabled
257 else
258 {
259 m_WasMicCapturing = m_MissionGameplay.IsVoNActive();
260 }
261 }
262
264 {
265 bool universal = (m_AmbientMusicSelector.GetValue() != g_Game.GetProfileOptionInt(EDayZProfilesOptions.AMBIENT_MUSIC_MODE));
266
267 return universal;
268 }
269
270 void Apply()
271 {
272 g_Game.SetProfileOptionInt(EDayZProfilesOptions.AMBIENT_MUSIC_MODE, m_AmbientMusicSelector.GetValue());
273 }
274
275 void Revert()
276 {
277 if (m_MasterOption)
278 {
279 m_MasterSelector.SetValue(m_MasterOption.ReadValue(), true);
280 }
281 if (m_EffectsOption)
282 {
283 m_EffectsSelector.SetValue(m_EffectsOption.ReadValue(),true);
284 }
285 if (m_VOIPOption)
286 {
287 m_VOIPSelector.SetValue(m_VOIPOption.ReadValue(), true);
288 }
290 {
291 m_VOIPThresholdSelector.SetValue(m_VOIPThresholdOption.ReadValue(), true);
292 }
293 if (m_MusicOption)
294 {
295 m_MusicSelector.SetValue(m_MusicOption.ReadValue(), true);
296 }
298 {
299 m_InputModeSelector.SetValue(m_InputModeOption.GetIndex(), false);
300 }
301
303 m_AmbientMusicSelector.SetValue(g_Game.GetProfileOptionInt(EDayZProfilesOptions.AMBIENT_MUSIC_MODE), false);
304 }
305
307 {
308 if (m_MasterOption)
309 {
310 m_MasterSelector.SetValue(m_MasterOption.GetDefault(), true);
311 }
312 if (m_EffectsOption)
313 {
314 m_EffectsSelector.SetValue(m_EffectsOption.GetDefault(), true);
315 }
316 if (m_VOIPOption)
317 {
318 m_VOIPSelector.SetValue(m_VOIPOption.GetDefault(), true);
319 }
321 {
322 m_VOIPThresholdSelector.SetValue(m_VOIPThresholdOption.GetDefault(), true);
323 }
324 if (m_MusicOption)
325 {
326 m_MusicSelector.SetValue(m_MusicOption.GetDefault(), true);
327 }
329 {
330 m_InputModeOption.SetIndex(m_InputModeOption.GetDefaultIndex());
331 m_InputModeSelector.SetValue( m_InputModeOption.GetIndex(), false );
332 }
333
335 m_AmbientMusicSelector.SetValue(g_Game.GetProfileOptionDefaultInt(EDayZProfilesOptions.AMBIENT_MUSIC_MODE), false);
336 }
337
339 {
340 m_Menu.ReloadOptions();
341 }
342
344 {
345 m_Options = options;
346
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));
353
354 Revert();
355 }
356
357 void ToggleDependentOptions(int mode, bool state)
358 {
359 }
360
364
365 void UpdateMaster(float value)
366 {
367 m_MasterOption.WriteValue(value);
368 m_Menu.OnChanged();
369 }
370
371 void UpdateEffects(float value)
372 {
373 m_EffectsOption.WriteValue(value);
374 m_Menu.OnChanged();
375 }
376
377 void UpdateVOIP(float value)
378 {
379 m_VOIPOption.WriteValue(value);
380 m_Menu.OnChanged();
381 }
382
383 void UpdateVOIPThreshold(float value)
384 {
385 m_VOIPThresholdOption.WriteValue(value);
386 m_Menu.OnChanged();
387 }
388
389 void UpdateMusic(float value)
390 {
391 m_MusicOption.WriteValue(value);
392 m_Menu.OnChanged();
393 }
394
396 {
397 m_Menu.OnChanged();
398 }
399
400 void UpdateInputMode(int newIndex)
401 {
402 m_InputModeOption.SetIndex(newIndex);
403 m_Menu.OnChanged();
404 }
405
407 {
408 m_VOIPThresholdSelector.SetSlider2Value(g_Game.GetSoundScene().GetAudioLevel());
409 }
410
411
413 {
415
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"));
420
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"));
424 }
425}
DayZGame g_Game
Определения DayZGame.c:3942
EDayZProfilesOptions
Определения EDayZProfilesOptions.c:2
Icon x
Icon y
Widget m_DetailsRoot
Определения ServerBrowserTab.c:84
Widget m_Root
Определения SizeToChild.c:91
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:395
void UpdateVOIP(float value)
Определения OptionsMenuSounds.c:377
void SetToDefaults()
Определения OptionsMenuSounds.c:306
ref NumericOptionsAccess m_MasterOption
Определения OptionsMenuSounds.c:12
ref NumericOptionsAccess m_VOIPThresholdOption
Определения OptionsMenuSounds.c:15
void OnPartyChatChangedEvent()
Определения OptionsMenuSounds.c:237
Widget m_Root
Определения SizeToChild.c:9
void ToggleDependentOptions(int mode, bool state)
Определения OptionsMenuSounds.c:357
void UpdateWasMicCapturing()
Определения OptionsMenuSounds.c:248
ref NumericOptionsAccess m_VOIPOption
Определения OptionsMenuSounds.c:14
ref OptionSelectorSlider m_VOIPSelector
Определения OptionsMenuSounds.c:21
void SetOptions(GameOptions options)
Определения OptionsMenuSounds.c:343
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:400
ref OptionSelectorMultistate m_InputModeSelector
Определения OptionsMenuSounds.c:24
void UpdateEffects(float value)
Определения OptionsMenuSounds.c:371
Widget m_DetailsBodyConnectivity
Определения OptionsMenuControls.c:8
void ReloadOptions()
Определения OptionsMenuSounds.c:338
void UpdateVOIPThreshold(float value)
Определения OptionsMenuSounds.c:383
override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
Определения OptionsMenuSounds.c:165
Widget m_DetailsBodyDefault
Определения OptionsMenuControls.c:7
bool TextMapUpdateWidget(int key)
Определения OptionsMenuControls.c:371
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:389
ref ListOptionsAccess m_InputModeOption
Определения OptionsMenuSounds.c:17
void UpdateAudioLevel()
Определения OptionsMenuSounds.c:406
override bool OnFocus(Widget w, int x, int y)
Определения OptionsMenuSounds.c:176
override bool OnMouseEnter(Widget w, int x, int y)
Определения OptionsMenuSounds.c:153
void UpdateMaster(float value)
Определения OptionsMenuSounds.c:365
void OptionsMenuSounds(Widget parent, Widget details_root, GameOptions options, OptionsMenu menu)
Определения OptionsMenuSounds.c:37
void ~OptionsMenuSounds()
Определения OptionsMenuSounds.c:121
void OnVonStateEvent()
Определения OptionsMenuSounds.c:224
ref OptionSelectorSlider m_MasterSelector
Определения OptionsMenuSounds.c:19
TextWidget m_DetailsLabel
Определения OptionsMenuControls.c:14
void InitDependentOptionsVisibility()
Определения OptionsMenuSounds.c:361
map: item x vector(index, width, height)
Определения EnWidgets.c:657
Определения EnWidgets.c:220
Определения DayZPlayerImplement.c:39
static VONManagerBase GetInstance()
Main way to access VONManager functionality from script.
Определения VONManager.c:306
Определения VONManager.c:2
Manager class which handles Voice-over-network functionality while player is connected to a server.
Определения VONManager.c:299
Определения EnWidgets.c:190
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
Определения CachedEquipmentStorage.c:4
OptionIDsScript
Used for script-based game options. For anything C++ based, you would most likely use "Option Access ...
Определения gameplay.c:1293
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 void SetFocus(Widget w)
WorkspaceWidget Widget
Defined in code.