2023-12-09 15:18:15 +11:00
|
|
|
using Content.Client.Audio;
|
2021-07-20 21:36:28 +02:00
|
|
|
using Content.Shared.CCVar;
|
2023-11-27 22:12:34 +11:00
|
|
|
using Robust.Client.Audio;
|
2021-07-20 21:36:28 +02:00
|
|
|
using Robust.Client.AutoGenerated;
|
|
|
|
|
using Robust.Client.UserInterface;
|
|
|
|
|
using Robust.Client.UserInterface.XAML;
|
|
|
|
|
using Robust.Shared;
|
|
|
|
|
using Robust.Shared.Configuration;
|
|
|
|
|
|
2024-06-22 06:11:14 +02:00
|
|
|
namespace Content.Client.Options.UI.Tabs;
|
2022-03-19 23:45:51 -05:00
|
|
|
|
2024-06-22 06:11:14 +02:00
|
|
|
[GenerateTypedNameReferences]
|
|
|
|
|
public sealed partial class AudioTab : Control
|
|
|
|
|
{
|
|
|
|
|
[Dependency] private readonly IConfigurationManager _cfg = default!;
|
|
|
|
|
[Dependency] private readonly IAudioManager _audio = default!;
|
2021-07-20 21:36:28 +02:00
|
|
|
|
2024-06-22 06:11:14 +02:00
|
|
|
public AudioTab()
|
|
|
|
|
{
|
|
|
|
|
RobustXamlLoader.Load(this);
|
|
|
|
|
IoCManager.InjectDependencies(this);
|
|
|
|
|
|
|
|
|
|
var masterVolume = Control.AddOptionPercentSlider(
|
|
|
|
|
CVars.AudioMasterVolume,
|
|
|
|
|
SliderVolumeMaster,
|
|
|
|
|
scale: ContentAudioSystem.MasterVolumeMultiplier);
|
|
|
|
|
masterVolume.ImmediateValueChanged += OnMasterVolumeSliderChanged;
|
|
|
|
|
|
|
|
|
|
Control.AddOptionPercentSlider(
|
|
|
|
|
CVars.MidiVolume,
|
|
|
|
|
SliderVolumeMidi,
|
|
|
|
|
scale: ContentAudioSystem.MidiVolumeMultiplier);
|
|
|
|
|
|
|
|
|
|
Control.AddOptionPercentSlider(
|
|
|
|
|
CCVars.AmbientMusicVolume,
|
|
|
|
|
SliderVolumeAmbientMusic,
|
|
|
|
|
scale: ContentAudioSystem.AmbientMusicMultiplier);
|
|
|
|
|
|
|
|
|
|
Control.AddOptionPercentSlider(
|
|
|
|
|
CCVars.AmbienceVolume,
|
|
|
|
|
SliderVolumeAmbience,
|
|
|
|
|
scale: ContentAudioSystem.AmbienceMultiplier);
|
|
|
|
|
|
|
|
|
|
Control.AddOptionPercentSlider(
|
|
|
|
|
CCVars.LobbyMusicVolume,
|
|
|
|
|
SliderVolumeLobby,
|
|
|
|
|
scale: ContentAudioSystem.LobbyMultiplier);
|
|
|
|
|
|
|
|
|
|
Control.AddOptionPercentSlider(
|
|
|
|
|
CCVars.InterfaceVolume,
|
|
|
|
|
SliderVolumeInterface,
|
|
|
|
|
scale: ContentAudioSystem.InterfaceMultiplier);
|
|
|
|
|
|
|
|
|
|
Control.AddOptionSlider(
|
|
|
|
|
CCVars.MaxAmbientSources,
|
|
|
|
|
SliderMaxAmbienceSounds,
|
|
|
|
|
_cfg.GetCVar(CCVars.MinMaxAmbientSourcesConfigured),
|
|
|
|
|
_cfg.GetCVar(CCVars.MaxMaxAmbientSourcesConfigured));
|
|
|
|
|
|
|
|
|
|
Control.AddOptionCheckBox(CCVars.LobbyMusicEnabled, LobbyMusicCheckBox);
|
|
|
|
|
Control.AddOptionCheckBox(CCVars.RestartSoundsEnabled, RestartSoundsCheckBox);
|
|
|
|
|
Control.AddOptionCheckBox(CCVars.EventMusicEnabled, EventMusicCheckBox);
|
|
|
|
|
Control.AddOptionCheckBox(CCVars.AdminSoundsEnabled, AdminSoundsCheckBox);
|
|
|
|
|
|
|
|
|
|
Control.Initialize();
|
|
|
|
|
}
|
2023-12-09 14:03:08 +11:00
|
|
|
|
2024-06-22 06:11:14 +02:00
|
|
|
private void OnMasterVolumeSliderChanged(float value)
|
|
|
|
|
{
|
|
|
|
|
// TODO: I was thinking of giving OptionsTabControlRow a flag to "set CVar immediately", but I'm deferring that
|
|
|
|
|
// until there's a proper system for enforcing people don't close the window with pending changes.
|
|
|
|
|
_audio.SetMasterGain(value);
|
2021-07-20 21:36:28 +02:00
|
|
|
}
|
|
|
|
|
}
|