Files
tbd-station-14/Content.Server/GameTicking/GameTicker.LobbyBackground.cs
Pieter-Jan Briers 773d02f694 WebP lobby images (#25184)
* Allow webp in lobby background files

* Make lobby art webp images

Reduces folder from 10 MB to 2.5 MB without only slight quality loss.

* Update PutLobbyScreensHere.txt
2024-02-16 16:55:57 -07:00

32 lines
959 B
C#

using Content.Server.GameTicking.Prototypes;
using Robust.Shared.Random;
using Robust.Shared.Utility;
using System.Linq;
namespace Content.Server.GameTicking;
public sealed partial class GameTicker
{
[ViewVariables]
public string? LobbyBackground { get; private set; }
[ViewVariables]
private List<ResPath>? _lobbyBackgrounds;
private static readonly string[] WhitelistedBackgroundExtensions = new string[] {"png", "jpg", "jpeg", "webp"};
private void InitializeLobbyBackground()
{
_lobbyBackgrounds = _prototypeManager.EnumeratePrototypes<LobbyBackgroundPrototype>()
.Select(x => x.Background)
.Where(x => WhitelistedBackgroundExtensions.Contains(x.Extension))
.ToList();
RandomizeLobbyBackground();
}
private void RandomizeLobbyBackground() {
LobbyBackground = _lobbyBackgrounds!.Any() ? _robustRandom.Pick(_lobbyBackgrounds!).ToString() : null;
}
}