Main menu art credit system (#41328)
* Main menu art credit system * change to center align in one box * left align * Update Resources/Prototypes/lobbyscreens.yml Co-authored-by: Hannah Giovanna Dawson <karakkaraz@gmail.com> * add margin * Update Resources/Prototypes/lobbyscreens.yml Co-authored-by: Hannah Giovanna Dawson <karakkaraz@gmail.com> * fix formatting * change to locale * FTL file * locid * handle null list properly * remove unneeded using * push * One more push --------- Co-authored-by: Hannah Giovanna Dawson <karakkaraz@gmail.com> Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com>
This commit is contained in:
@@ -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<LobbyBackgroundPrototype>? LobbyBackground { get; private set; }
|
||||
|
||||
[ViewVariables]
|
||||
private List<ResPath>? _lobbyBackgrounds;
|
||||
private List<ProtoId<LobbyBackgroundPrototype>>? _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();
|
||||
var allprotos = _prototypeManager.EnumeratePrototypes<LobbyBackgroundPrototype>().ToList();
|
||||
_lobbyBackgrounds ??= new List<ProtoId<LobbyBackgroundPrototype>>();
|
||||
|
||||
//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<LobbyBackgroundPrototype>(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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user