diff --git a/Content.Client/Entry/EntryPoint.cs b/Content.Client/Entry/EntryPoint.cs index 7106985492..0c76a94800 100644 --- a/Content.Client/Entry/EntryPoint.cs +++ b/Content.Client/Entry/EntryPoint.cs @@ -95,6 +95,7 @@ namespace Content.Client.Entry prototypes.RegisterIgnore("aiFaction"); prototypes.RegisterIgnore("gameMap"); prototypes.RegisterIgnore("behaviorSet"); + prototypes.RegisterIgnore("lobbyBackground"); prototypes.RegisterIgnore("advertisementsPack"); prototypes.RegisterIgnore("metabolizerType"); prototypes.RegisterIgnore("metabolismGroup"); diff --git a/Content.Server/GameTicking/GameTicker.LobbyBackground.cs b/Content.Server/GameTicking/GameTicker.LobbyBackground.cs index f0d2614b4d..d701db91c8 100644 --- a/Content.Server/GameTicking/GameTicker.LobbyBackground.cs +++ b/Content.Server/GameTicking/GameTicker.LobbyBackground.cs @@ -1,5 +1,6 @@ using System.IO; using System.Linq; +using Content.Server.GameTicking.Prototypes; using Content.Shared.Audio; using Robust.Shared.ContentPack; using Robust.Shared.Random; @@ -25,8 +26,11 @@ public sealed partial class GameTicker private void InitializeLobbyBackground() { - _lobbyBackgrounds = _resourceManager.ContentFindFiles(new ResourcePath(LobbyScreenPath)).ToList(); - _lobbyBackgrounds = _lobbyBackgrounds.FindAll(path => WhitelistedBackgroundExtensions.Contains((path.Extension))); + _lobbyBackgrounds = _prototypeManager.EnumeratePrototypes() + .Select(x => x.Background) + .Where(x => WhitelistedBackgroundExtensions.Contains(x.Extension)) + .ToList(); + LobbyBackground = _lobbyBackgrounds.Any() ? _robustRandom.Pick(_lobbyBackgrounds).ToString() : null; } diff --git a/Content.Server/GameTicking/Prototypes/LobbyBackgroundPrototype.cs b/Content.Server/GameTicking/Prototypes/LobbyBackgroundPrototype.cs new file mode 100644 index 0000000000..29b84b9f3f --- /dev/null +++ b/Content.Server/GameTicking/Prototypes/LobbyBackgroundPrototype.cs @@ -0,0 +1,22 @@ +using JetBrains.Annotations; +using Robust.Shared.Prototypes; +using Robust.Shared.Utility; + +namespace Content.Server.GameTicking.Prototypes; + +/// +/// Prototype for a lobby background the game can choose. +/// +[Prototype("lobbyBackground")] +public sealed 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 ResourcePath Background = default!; +} diff --git a/Resources/Prototypes/lobbyscreens.yml b/Resources/Prototypes/lobbyscreens.yml new file mode 100644 index 0000000000..c6a7c7a822 --- /dev/null +++ b/Resources/Prototypes/lobbyscreens.yml @@ -0,0 +1,7 @@ +- type: lobbyBackground + id: Robotics + background: /Textures/LobbyScreens/robotics.png + +- type: lobbyBackground + id: Supermatter + background: /Textures/LobbyScreens/supermatter.png diff --git a/Resources/Textures/LobbyScreens/PutLobbyScreensHere.txt b/Resources/Textures/LobbyScreens/PutLobbyScreensHere.txt index d2cc2b8325..52cb3f1dc9 100644 --- a/Resources/Textures/LobbyScreens/PutLobbyScreensHere.txt +++ b/Resources/Textures/LobbyScreens/PutLobbyScreensHere.txt @@ -1,2 +1,2 @@ Note: -Only png and jpgs files are supported \ No newline at end of file +Only png and jpgs files are supported, and you need a prototype in Resources/Prototypes/lobbyscreens.yml