fix: lobby music volume will be changed on options change without restart (also lobby music not looped anymore) (#25530)
* fix: lobby music volume will be changed on options change without restart (also lobby music not looped anymore) * refactor: now lobby music is part of ContentAudioSystem. Lobby playlist is used instead of single track. Client now selects next lobby soundtrack after previous finished. * refactor: incapsulated info on current lobby track in simple record * refactor: fixed inconsistent naming between song and soundtrack for lobbymusic * refactor: xml-doc for LobbyPlaylistChangedEvent * fix: inverted invalid _audio.PlayGlobal check to return only if lobby soundtrack play call failed --------- Co-authored-by: pa.pecherskij <pa.pecherskij@interfax.ru>
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using Content.Client.Audio;
|
||||
using Content.Client.GameTicking.Managers;
|
||||
using Content.Client.LateJoin;
|
||||
using Content.Client.Lobby.UI;
|
||||
@@ -34,6 +35,7 @@ namespace Content.Client.Lobby
|
||||
[ViewVariables] private CharacterSetupGui? _characterSetup;
|
||||
|
||||
private ClientGameTicker _gameTicker = default!;
|
||||
private ContentAudioSystem _contentAudioSystem = default!;
|
||||
|
||||
protected override Type? LinkedScreenType { get; } = typeof(LobbyGui);
|
||||
private LobbyGui? _lobby;
|
||||
@@ -49,6 +51,8 @@ namespace Content.Client.Lobby
|
||||
|
||||
var chatController = _userInterfaceManager.GetUIController<ChatUIController>();
|
||||
_gameTicker = _entityManager.System<ClientGameTicker>();
|
||||
_contentAudioSystem = _entityManager.System<ContentAudioSystem>();
|
||||
_contentAudioSystem.LobbySoundtrackChanged += UpdateLobbySoundtrackInfo;
|
||||
_characterSetup = new CharacterSetupGui(_entityManager, _resourceCache, _preferencesManager,
|
||||
_prototypeManager, _configurationManager);
|
||||
LayoutContainer.SetAnchorPreset(_characterSetup, LayoutContainer.LayoutPreset.Wide);
|
||||
@@ -93,6 +97,7 @@ namespace Content.Client.Lobby
|
||||
_gameTicker.InfoBlobUpdated -= UpdateLobbyUi;
|
||||
_gameTicker.LobbyStatusUpdated -= LobbyStatusUpdated;
|
||||
_gameTicker.LobbyLateJoinStatusUpdated -= LobbyLateJoinStatusUpdated;
|
||||
_contentAudioSystem.LobbySoundtrackChanged -= UpdateLobbySoundtrackInfo;
|
||||
|
||||
_voteManager.ClearPopupContainer();
|
||||
|
||||
@@ -207,22 +212,28 @@ namespace Content.Client.Lobby
|
||||
{
|
||||
_lobby!.ServerInfo.SetInfoBlob(_gameTicker.ServerInfoBlob);
|
||||
}
|
||||
}
|
||||
|
||||
if (_gameTicker.LobbySong == null)
|
||||
private void UpdateLobbySoundtrackInfo(LobbySoundtrackChangedEvent ev)
|
||||
{
|
||||
if (ev.SoundtrackFilename == null)
|
||||
{
|
||||
_lobby!.LobbySong.SetMarkup(Loc.GetString("lobby-state-song-no-song-text"));
|
||||
}
|
||||
else if (_resourceCache.TryGetResource<AudioResource>(_gameTicker.LobbySong, out var lobbySongResource))
|
||||
else if (
|
||||
ev.SoundtrackFilename != null
|
||||
&& _resourceCache.TryGetResource<AudioResource>(ev.SoundtrackFilename, out var lobbySongResource)
|
||||
)
|
||||
{
|
||||
var lobbyStream = lobbySongResource.AudioStream;
|
||||
|
||||
var title = string.IsNullOrEmpty(lobbyStream.Title) ?
|
||||
Loc.GetString("lobby-state-song-unknown-title") :
|
||||
lobbyStream.Title;
|
||||
var title = string.IsNullOrEmpty(lobbyStream.Title)
|
||||
? Loc.GetString("lobby-state-song-unknown-title")
|
||||
: lobbyStream.Title;
|
||||
|
||||
var artist = string.IsNullOrEmpty(lobbyStream.Artist) ?
|
||||
Loc.GetString("lobby-state-song-unknown-artist") :
|
||||
lobbyStream.Artist;
|
||||
var artist = string.IsNullOrEmpty(lobbyStream.Artist)
|
||||
? Loc.GetString("lobby-state-song-unknown-artist")
|
||||
: lobbyStream.Artist;
|
||||
|
||||
var markup = Loc.GetString("lobby-state-song-text",
|
||||
("songTitle", title),
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Content.Client.Chat.UI;
|
||||
using Content.Client.Info;
|
||||
using Content.Client.Message;
|
||||
using Content.Client.Preferences;
|
||||
using Content.Client.Preferences.UI;
|
||||
using Content.Client.UserInterface.Screens;
|
||||
@@ -33,6 +34,8 @@ namespace Content.Client.Lobby.UI
|
||||
SetAnchorPreset(MainContainer, LayoutPreset.Wide);
|
||||
SetAnchorPreset(Background, LayoutPreset.Wide);
|
||||
|
||||
LobbySong.SetMarkup(Loc.GetString("lobby-state-song-no-song-text"));
|
||||
|
||||
LeaveButton.OnPressed += _ => _consoleHost.ExecuteCommand("disconnect");
|
||||
OptionsButton.OnPressed += _ => _userInterfaceManager.GetUIController<OptionsUIController>().ToggleWindow();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user