Adds lobby music (#3620)

* Adds lobby music

* Add UI toggle for lobby music

* Pick the song serverside so everyone gets the same song

* Add more songs

* Fixes

* Catch-all end lobby music

* Rename it

* Catchall ambience cvar change

* Wait until we receive the lobby song to start playing one

* Fix toggling ready status resetting the song

* Comment

* Expend the last of my sanity fixing latejoin lobby music

* Update Content.Client/GameObjects/EntitySystems/BackgroundAudioSystem.cs

Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>

* Update Content.Client/GameObjects/EntitySystems/BackgroundAudioSystem.cs

Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>

* Update Content.Client/GameObjects/EntitySystems/BackgroundAudioSystem.cs

Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>

* Move the var

Co-authored-by: ike709 <sparebytes@protonmail.com>
Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
ike709
2021-03-12 16:40:28 -06:00
committed by GitHub
parent b87179cbef
commit 31f1cf9936
15 changed files with 239 additions and 96 deletions

View File

@@ -21,6 +21,7 @@ namespace Content.Client.UserInterface
private readonly Label MasterVolumeLabel;
private readonly Slider MasterVolumeSlider;
private readonly CheckBox AmbienceCheckBox;
private readonly CheckBox LobbyMusicCheckBox;
private readonly Button ResetButton;
public AudioControl(IConfigurationManager cfg, IClydeAudio clydeAudio)
@@ -70,6 +71,10 @@ namespace Content.Client.UserInterface
contents.AddChild(AmbienceCheckBox);
AmbienceCheckBox.Pressed = _cfg.GetCVar(CCVars.AmbienceBasicEnabled);
LobbyMusicCheckBox = new CheckBox {Text = Loc.GetString("ui-options-lobby-music")};
contents.AddChild(LobbyMusicCheckBox);
LobbyMusicCheckBox.Pressed = _cfg.GetCVar(CCVars.LobbyMusicEnabled);
ApplyButton = new Button
{
Text = Loc.GetString("ui-options-apply"), TextAlign = Label.AlignMode.Center,
@@ -118,6 +123,7 @@ namespace Content.Client.UserInterface
ResetButton.OnPressed += OnResetButtonPressed;
MasterVolumeSlider.OnValueChanged += OnMasterVolumeSliderChanged;
AmbienceCheckBox.OnToggled += OnAmbienceCheckToggled;
LobbyMusicCheckBox.OnToggled += OnLobbyMusicCheckToggled;
AddChild(vBox);
@@ -146,10 +152,16 @@ namespace Content.Client.UserInterface
UpdateChanges();
}
private void OnLobbyMusicCheckToggled(BaseButton.ButtonEventArgs args)
{
UpdateChanges();
}
private void OnApplyButtonPressed(BaseButton.ButtonEventArgs args)
{
_cfg.SetCVar(CVars.AudioMasterVolume, MasterVolumeSlider.Value / 100);
_cfg.SetCVar(CCVars.AmbienceBasicEnabled, AmbienceCheckBox.Pressed);
_cfg.SetCVar(CCVars.LobbyMusicEnabled, LobbyMusicCheckBox.Pressed);
_cfg.SaveToFile();
UpdateChanges();
}
@@ -165,6 +177,7 @@ namespace Content.Client.UserInterface
MasterVolumeLabel.Text =
Loc.GetString("ui-options-volume-percent", ("volume", MasterVolumeSlider.Value / 100));
AmbienceCheckBox.Pressed = _cfg.GetCVar(CCVars.AmbienceBasicEnabled);
LobbyMusicCheckBox.Pressed = _cfg.GetCVar(CCVars.LobbyMusicEnabled);
UpdateChanges();
}
@@ -173,7 +186,8 @@ namespace Content.Client.UserInterface
var isMasterVolumeSame =
System.Math.Abs(MasterVolumeSlider.Value - _cfg.GetCVar(CVars.AudioMasterVolume) * 100) < 0.01f;
var isAmbienceSame = AmbienceCheckBox.Pressed == _cfg.GetCVar(CCVars.AmbienceBasicEnabled);
var isEverythingSame = isMasterVolumeSame && isAmbienceSame;
var isLobbySame = LobbyMusicCheckBox.Pressed == _cfg.GetCVar(CCVars.LobbyMusicEnabled);
var isEverythingSame = isMasterVolumeSame && isAmbienceSame && isLobbySame;
ApplyButton.Disabled = isEverythingSame;
ResetButton.Disabled = isEverythingSame;
}