From b6d3c050a0f5cee58f9ea7772cb02c67c596420b Mon Sep 17 00:00:00 2001 From: Jabak <163307958+Jabaks@users.noreply.github.com> Date: Mon, 19 Aug 2024 21:11:35 +0300 Subject: [PATCH] Queue in JukeBox (#640) * Queue in JukeBox * Translation JukeBox --- .../Jukebox/JukeboxBoundUserInterface.cs | 23 +++- .../Audio/Jukebox/JukeboxEntry.xaml | 9 ++ .../Audio/Jukebox/JukeboxEntry.xaml.cs | 127 ++++++++++++++++++ Content.Client/Audio/Jukebox/JukeboxMenu.xaml | 29 ++-- .../Audio/Jukebox/JukeboxMenu.xaml.cs | 109 ++++++++------- Content.Client/Audio/Jukebox/JukeboxSystem.cs | 20 ++- Content.Server/Audio/Jukebox/JukeboxSystem.cs | 121 ++++++++++++++--- .../Audio/Jukebox/JukeboxComponent.cs | 18 +++ .../Locale/en-US/jukebox/jukebox-menu.ftl | 5 + .../Locale/ru-RU/jukebox/jukebox-menu.ftl | 10 ++ 10 files changed, 388 insertions(+), 83 deletions(-) create mode 100644 Content.Client/Audio/Jukebox/JukeboxEntry.xaml create mode 100644 Content.Client/Audio/Jukebox/JukeboxEntry.xaml.cs create mode 100644 Resources/Locale/ru-RU/jukebox/jukebox-menu.ftl diff --git a/Content.Client/Audio/Jukebox/JukeboxBoundUserInterface.cs b/Content.Client/Audio/Jukebox/JukeboxBoundUserInterface.cs index 072730d65d..f33d765c74 100644 --- a/Content.Client/Audio/Jukebox/JukeboxBoundUserInterface.cs +++ b/Content.Client/Audio/Jukebox/JukeboxBoundUserInterface.cs @@ -47,6 +47,16 @@ public sealed class JukeboxBoundUserInterface : BoundUserInterface _menu.OnSongSelected += SelectSong; + _menu.OnSongQueueAdd += songId => + { + SendMessage(new JukeboxAddQueueMessage(songId)); + }; + + _menu.OnQueueRemove += index => + { + SendMessage(new JukeboxRemoveQueueMessage(index)); + }; + _menu.SetTime += SetTime; PopulateMusic(); Reload(); @@ -65,17 +75,24 @@ public sealed class JukeboxBoundUserInterface : BoundUserInterface if (_protoManager.TryIndex(jukebox.SelectedSongId, out var songProto)) { var length = EntMan.System().GetAudioLength(songProto.Path.Path.ToString()); - _menu.SetSelectedSong(songProto.Name, (float) length.TotalSeconds); + _menu.SetSelectedSong(songProto.ID, (float) length.TotalSeconds); } else { - _menu.SetSelectedSong(string.Empty, 0f); + _menu.SetSelectedSong(null, 0f); } + + _menu.PopulateQueue(jukebox.SongIdQueue); + _menu.SetIsPlaying(EntMan.System().IsPlaying(jukebox.AudioStream)); } public void PopulateMusic() { - _menu?.Populate(_protoManager.EnumeratePrototypes()); + if (_menu == null || !EntMan.TryGetComponent(Owner, out JukeboxComponent? jukebox)) + return; + + _menu.Populate(_protoManager.EnumeratePrototypes()); + _menu.PopulateQueue(jukebox.SongIdQueue); } public void SelectSong(ProtoId songid) diff --git a/Content.Client/Audio/Jukebox/JukeboxEntry.xaml b/Content.Client/Audio/Jukebox/JukeboxEntry.xaml new file mode 100644 index 0000000000..143fc44d20 --- /dev/null +++ b/Content.Client/Audio/Jukebox/JukeboxEntry.xaml @@ -0,0 +1,9 @@ + +