diff --git a/Content.Client/Entry/EntryPoint.cs b/Content.Client/Entry/EntryPoint.cs index b9f0e0e8e6..2266b30c51 100644 --- a/Content.Client/Entry/EntryPoint.cs +++ b/Content.Client/Entry/EntryPoint.cs @@ -112,7 +112,6 @@ namespace Content.Client.Entry _prototypeManager.RegisterIgnore("htnPrimitive"); _prototypeManager.RegisterIgnore("gameMap"); _prototypeManager.RegisterIgnore("gameMapPool"); - _prototypeManager.RegisterIgnore("lobbyBackground"); _prototypeManager.RegisterIgnore("gamePreset"); _prototypeManager.RegisterIgnore("noiseChannel"); _prototypeManager.RegisterIgnore("playerConnectionWhitelist"); diff --git a/Content.Client/GameTicking/Managers/ClientGameTicker.cs b/Content.Client/GameTicking/Managers/ClientGameTicker.cs index 4bd91bd06c..443c6c20a8 100644 --- a/Content.Client/GameTicking/Managers/ClientGameTicker.cs +++ b/Content.Client/GameTicking/Managers/ClientGameTicker.cs @@ -11,6 +11,7 @@ using Robust.Client.State; using Robust.Client.UserInterface; using Robust.Shared.Prototypes; using Robust.Shared.Audio; +using Content.Shared.GameTicking.Prototypes; namespace Content.Client.GameTicking.Managers { @@ -28,7 +29,7 @@ namespace Content.Client.GameTicking.Managers [ViewVariables] public bool AreWeReady { get; private set; } [ViewVariables] public bool IsGameStarted { get; private set; } [ViewVariables] public ResolvedSoundSpecifier? RestartSound { get; private set; } - [ViewVariables] public string? LobbyBackground { get; private set; } + [ViewVariables] public ProtoId? LobbyBackground { get; private set; } [ViewVariables] public bool DisallowedLateJoin { get; private set; } [ViewVariables] public string? ServerInfoBlob { get; private set; } [ViewVariables] public TimeSpan StartTime { get; private set; } diff --git a/Content.Client/Lobby/LobbyState.cs b/Content.Client/Lobby/LobbyState.cs index 538266e1a2..9696da3bc2 100644 --- a/Content.Client/Lobby/LobbyState.cs +++ b/Content.Client/Lobby/LobbyState.cs @@ -13,6 +13,7 @@ using Robust.Client.ResourceManagement; using Robust.Client.UserInterface; using Robust.Client.UserInterface.Controls; using Robust.Shared.Configuration; +using Robust.Shared.Prototypes; using Robust.Shared.Timing; namespace Content.Client.Lobby @@ -28,6 +29,7 @@ namespace Content.Client.Lobby [Dependency] private readonly IGameTiming _gameTiming = default!; [Dependency] private readonly IVoteManager _voteManager = default!; [Dependency] private readonly ClientsidePlaytimeTrackingManager _playtimeTracking = default!; + [Dependency] private readonly IPrototypeManager _protoMan = default!; private ClientGameTicker _gameTicker = default!; private ContentAudioSystem _contentAudioSystem = default!; @@ -250,15 +252,22 @@ namespace Content.Client.Lobby private void UpdateLobbyBackground() { - if (_gameTicker.LobbyBackground != null) + if (_protoMan.TryIndex(_gameTicker.LobbyBackground, out var proto)) { - Lobby!.Background.Texture = _resourceCache.GetResource(_gameTicker.LobbyBackground ); + Lobby!.Background.Texture = _resourceCache.GetResource(proto.Background); + + var markup = Loc.GetString("lobby-state-background-text", + ("backgroundTitle", Loc.GetString(proto.Title)), + ("backgroundArtist", Loc.GetString(proto.Artist))); + + Lobby!.LobbyBackground.SetMarkup(markup); } else { Lobby!.Background.Texture = null; - } + Lobby!.LobbyBackground.SetMarkup(Loc.GetString("lobby-state-background-no-background-text")); + } } private void SetReady(bool newReady) diff --git a/Content.Client/Lobby/UI/LobbyGui.xaml b/Content.Client/Lobby/UI/LobbyGui.xaml index 9b5c761644..a716ae7c95 100644 --- a/Content.Client/Lobby/UI/LobbyGui.xaml +++ b/Content.Client/Lobby/UI/LobbyGui.xaml @@ -51,10 +51,13 @@ - + - - + + + + + diff --git a/Content.Server/GameTicking/GameTicker.LobbyBackground.cs b/Content.Server/GameTicking/GameTicker.LobbyBackground.cs index 2090e3e31f..82460572f7 100644 --- a/Content.Server/GameTicking/GameTicker.LobbyBackground.cs +++ b/Content.Server/GameTicking/GameTicker.LobbyBackground.cs @@ -1,4 +1,5 @@ -using Content.Server.GameTicking.Prototypes; +using Content.Shared.GameTicking.Prototypes; +using Robust.Shared.Prototypes; using Robust.Shared.Random; using Robust.Shared.Utility; using System.Linq; @@ -8,24 +9,37 @@ namespace Content.Server.GameTicking; public sealed partial class GameTicker { [ViewVariables] - public string? LobbyBackground { get; private set; } + public ProtoId? LobbyBackground { get; private set; } [ViewVariables] - private List? _lobbyBackgrounds; + private List>? _lobbyBackgrounds; private static readonly string[] WhitelistedBackgroundExtensions = new string[] {"png", "jpg", "jpeg", "webp"}; private void InitializeLobbyBackground() { - _lobbyBackgrounds = _prototypeManager.EnumeratePrototypes() - .Select(x => x.Background) - .Where(x => WhitelistedBackgroundExtensions.Contains(x.Extension)) - .ToList(); + var allprotos = _prototypeManager.EnumeratePrototypes().ToList(); + _lobbyBackgrounds ??= new List>(); + + //create protoids from them + foreach (var proto in allprotos) + { + var ext = proto.Background.Extension; + if (!WhitelistedBackgroundExtensions.Contains(ext)) + continue; + + //create a protoid and add it to the list + _lobbyBackgrounds.Add(new ProtoId(proto.ID)); + } RandomizeLobbyBackground(); } - private void RandomizeLobbyBackground() { - LobbyBackground = _lobbyBackgrounds!.Any() ? _robustRandom.Pick(_lobbyBackgrounds!).ToString() : null; + private void RandomizeLobbyBackground() + { + if (_lobbyBackgrounds != null && _lobbyBackgrounds.Count != 0) + LobbyBackground = _robustRandom.Pick(_lobbyBackgrounds); + else + LobbyBackground = null; } } diff --git a/Content.Server/GameTicking/Prototypes/LobbyBackgroundPrototype.cs b/Content.Server/GameTicking/Prototypes/LobbyBackgroundPrototype.cs deleted file mode 100644 index 5201fb389a..0000000000 --- a/Content.Server/GameTicking/Prototypes/LobbyBackgroundPrototype.cs +++ /dev/null @@ -1,21 +0,0 @@ -using Robust.Shared.Prototypes; -using Robust.Shared.Utility; - -namespace Content.Server.GameTicking.Prototypes; - -/// -/// Prototype for a lobby background the game can choose. -/// -[Prototype] -public sealed partial class LobbyBackgroundPrototype : IPrototype -{ - /// - [IdDataField] - public string ID { get; set; } = default!; - - /// - /// The sprite to use as the background. This should ideally be 1920x1080. - /// - [DataField("background", required: true)] - public ResPath Background = default!; -} diff --git a/Content.Shared/GameTicking/Prototypes/LobbyBackgroundPrototype.cs b/Content.Shared/GameTicking/Prototypes/LobbyBackgroundPrototype.cs new file mode 100644 index 0000000000..0f88d005a3 --- /dev/null +++ b/Content.Shared/GameTicking/Prototypes/LobbyBackgroundPrototype.cs @@ -0,0 +1,33 @@ +using Robust.Shared.Prototypes; +using Robust.Shared.Utility; + +namespace Content.Shared.GameTicking.Prototypes; + +/// +/// Prototype for a lobby background the game can choose. +/// +[Prototype] +public sealed partial class LobbyBackgroundPrototype : IPrototype +{ + /// + [IdDataField] + public string ID { get; set; } = default!; + + /// + /// The sprite to use as the background. This should ideally be 1920x1080. + /// + [DataField(required: true)] + public ResPath Background = default!; + + /// + /// The title of the background to be displayed in the lobby. + /// + [DataField] + public LocId Title = "lobby-state-background-unknown-title"; + + /// + /// The artist who made the art for the background. + /// + [DataField] + public LocId Artist = "lobby-state-background-unknown-artist"; +} diff --git a/Content.Shared/GameTicking/SharedGameTicker.cs b/Content.Shared/GameTicking/SharedGameTicker.cs index 877a849d07..57e69d1cf5 100644 --- a/Content.Shared/GameTicking/SharedGameTicker.cs +++ b/Content.Shared/GameTicking/SharedGameTicker.cs @@ -7,6 +7,7 @@ using Robust.Shared.Serialization.Markdown.Mapping; using Robust.Shared.Serialization.Markdown.Value; using Robust.Shared.Timing; using Robust.Shared.Audio; +using Content.Shared.GameTicking.Prototypes; namespace Content.Shared.GameTicking { @@ -95,14 +96,14 @@ namespace Content.Shared.GameTicking public sealed class TickerLobbyStatusEvent : EntityEventArgs { public bool IsRoundStarted { get; } - public string? LobbyBackground { get; } + public ProtoId? LobbyBackground { get; } public bool YouAreReady { get; } // UTC. public TimeSpan StartTime { get; } public TimeSpan RoundStartTimeSpan { get; } public bool Paused { get; } - public TickerLobbyStatusEvent(bool isRoundStarted, string? lobbyBackground, bool youAreReady, TimeSpan startTime, TimeSpan preloadTime, TimeSpan roundStartTimeSpan, bool paused) + public TickerLobbyStatusEvent(bool isRoundStarted, ProtoId? lobbyBackground, bool youAreReady, TimeSpan startTime, TimeSpan preloadTime, TimeSpan roundStartTimeSpan, bool paused) { IsRoundStarted = isRoundStarted; LobbyBackground = lobbyBackground; diff --git a/Resources/Locale/en-US/lobby/lobby-state-background.ftl b/Resources/Locale/en-US/lobby/lobby-state-background.ftl new file mode 100644 index 0000000000..c0046ca693 --- /dev/null +++ b/Resources/Locale/en-US/lobby/lobby-state-background.ftl @@ -0,0 +1,35 @@ +lobby-state-background-warden-title = Warden +lobby-state-background-warden-artist = Solbusaur + +lobby-state-background-pharmacy-title = Pharmacy +lobby-state-background-pharmacy-artist = Solbusaur + +lobby-state-background-SSXIV-title = SSXIV +lobby-state-background-SSXIV-artist = Abyssal + +lobby-state-background-susstation-title = Susstation +lobby-state-background-susstation-artist = Alekshhh + +lobby-state-background-skellyvstherev-title = Skelly Versus The Rev +lobby-state-background-skellyvstherev-artist = Hannah 'FairlySadPanda' Dawson + +lobby-state-background-doomed-title = Doomed +lobby-state-background-doomed-artist = brainfood1183 + +lobby-state-background-blueprint-title = Blueprint +lobby-state-background-blueprint-artist = data_redacted + +lobby-state-background-behonker-title = Behonker +lobby-state-background-behonker-artist = InCrah + +lobby-state-background-terminalstation-title = Terminal Station +lobby-state-background-terminalstation-artist = aserovich + +lobby-state-background-justaweekaway-title = Just a Week Away +lobby-state-background-justaweekaway-artist = plantyfern + +lobby-state-background-janishootout-title = Jani Shootout +lobby-state-background-janishootout-artist = psychpsyo + +lobby-state-background-reclaimernuke-title = Reclaimer Nuke +lobby-state-background-reclaimernuke-artist = GetOutMarutak diff --git a/Resources/Locale/en-US/lobby/lobby-state.ftl b/Resources/Locale/en-US/lobby/lobby-state.ftl index 0c92923b1c..1a9f4809de 100644 --- a/Resources/Locale/en-US/lobby/lobby-state.ftl +++ b/Resources/Locale/en-US/lobby/lobby-state.ftl @@ -21,6 +21,10 @@ lobby-state-song-text = Playing: [color=white]{$songTitle}[/color] by [color=whi lobby-state-song-no-song-text = No lobby song playing. lobby-state-song-unknown-title = [color=dimgray]Unknown title[/color] lobby-state-song-unknown-artist = [color=dimgray]Unknown artist[/color] +lobby-state-background-text = Menu art: [color=white]{$backgroundTitle}[/color] by [color=white]{$backgroundArtist}[/color] +lobby-state-background-no-background-text = No menu art loaded. +lobby-state-background-unknown-title = [color=dimgray]Unknown title[/color] +lobby-state-background-unknown-artist = [color=dimgray]Unknown artist[/color] lobby-state-playtime-comment-normal = You've spent {$hours} {$hours -> [1]hour diff --git a/Resources/Prototypes/lobbyscreens.yml b/Resources/Prototypes/lobbyscreens.yml index 8ffa580bc7..d0f6da99d5 100644 --- a/Resources/Prototypes/lobbyscreens.yml +++ b/Resources/Prototypes/lobbyscreens.yml @@ -1,48 +1,71 @@ - type: lobbyBackground id: Warden background: /Textures/LobbyScreens/warden.webp + title: lobby-state-background-warden-title + artist: lobby-state-background-warden-artist - type: lobbyBackground id: Pharmacy background: /Textures/LobbyScreens/pharmacy.webp + title: lobby-state-background-pharmacy-title + artist: lobby-state-background-pharmacy-artist - type: lobbyBackground id: SSXIV background: /Textures/LobbyScreens/ssxiv.webp + title: lobby-state-background-SSXIV-title + artist: lobby-state-background-SSXIV-artist - type: lobbyBackground id: Susstation background: /Textures/LobbyScreens/susstation.webp + title: lobby-state-background-susstation-title + artist: lobby-state-background-susstation-artist - type: lobbyBackground id: SkellyVsTheRev background: /Textures/LobbyScreens/skellyvstherev.webp + title: lobby-state-background-skellyvstherev-title + artist: lobby-state-background-skellyvstherev-artist - type: lobbyBackground id: Doomed background: /Textures/LobbyScreens/doomed.webp + title: lobby-state-background-doomed-title + artist: lobby-state-background-doomed-artist - type: lobbyBackground id: Blueprint background: /Textures/LobbyScreens/blueprint.webp + title: lobby-state-background-blueprint-title + artist: lobby-state-background-blueprint-artist - type: lobbyBackground id: Behonker background: /Textures/LobbyScreens/behonker.webp + title: lobby-state-background-behonker-title + artist: lobby-state-background-behonker-artist - type: lobbyBackground id: TerminalStation background: /Textures/LobbyScreens/terminalstation.webp + title: lobby-state-background-terminalstation-title + artist: lobby-state-background-terminalstation-artist - type: lobbyBackground id: JustAWeekAway background: /Textures/LobbyScreens/justaweekaway.webp + title: lobby-state-background-justaweekaway-title + artist: lobby-state-background-justaweekaway-artist - type: lobbyBackground id: JaniShootout background: /Textures/LobbyScreens/janishootout.webp + title: lobby-state-background-janishootout-title + artist: lobby-state-background-janishootout-artist - type: lobbyBackground id: ReclaimerNuke background: /Textures/LobbyScreens/reclaimer-nuke.webp - \ No newline at end of file + title: lobby-state-background-reclaimernuke-title + artist: lobby-state-background-reclaimernuke-artist