Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lobby Background Credits #1558

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Content.Client/GameTicking/Managers/ClientGameTicker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Content.Client.Lobby;
using Content.Client.RoundEnd;
using Content.Shared.GameTicking;
using Content.Shared.GameTicking.Prototypes;
using Content.Shared.GameWindow;
using JetBrains.Annotations;
using Robust.Client.Graphics;
Expand All @@ -26,7 +27,7 @@ public sealed class ClientGameTicker : SharedGameTicker
[ViewVariables] public bool AreWeReady { get; private set; }
[ViewVariables] public bool IsGameStarted { get; private set; }
[ViewVariables] public string? RestartSound { get; private set; }
[ViewVariables] public string? LobbyBackground { get; private set; }
[ViewVariables] public LobbyBackgroundPrototype? 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; }
Expand Down
34 changes: 28 additions & 6 deletions Content.Client/Lobby/LobbyState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
using Robust.Client.UserInterface.Controls;
using Robust.Shared.Timing;


namespace Content.Client.Lobby
{
public sealed class LobbyState : Robust.Client.State.State
Expand All @@ -25,6 +24,7 @@ public sealed class LobbyState : Robust.Client.State.State
[Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly IVoteManager _voteManager = default!;

private ISawmill _sawmill = default!;
private ClientGameTicker _gameTicker = default!;
private ContentAudioSystem _contentAudioSystem = default!;

Expand All @@ -42,6 +42,7 @@ protected override void Startup()
_gameTicker = _entityManager.System<ClientGameTicker>();
_contentAudioSystem = _entityManager.System<ContentAudioSystem>();
_contentAudioSystem.LobbySoundtrackChanged += UpdateLobbySoundtrackInfo;
_sawmill = Logger.GetSawmill("lobby");

chatController.SetMainChat(true);

Expand Down Expand Up @@ -113,7 +114,7 @@ public override void FrameUpdate(FrameEventArgs e)
return;
}

Lobby!.StationTime.Text = Loc.GetString("lobby-state-player-status-round-not-started");
Lobby!.StationTime.Text = Loc.GetString("lobby-state-player-status-round-not-started");
string text;

if (_gameTicker.Paused)
Expand Down Expand Up @@ -161,7 +162,7 @@ private void UpdateLobbyUi()
else
{
Lobby!.StartTime.Text = string.Empty;
Lobby!.ReadyButton.Text = Loc.GetString(Lobby!.ReadyButton.Pressed ? "lobby-state-player-status-ready": "lobby-state-player-status-not-ready");
Lobby!.ReadyButton.Text = Loc.GetString(Lobby!.ReadyButton.Pressed ? "lobby-state-player-status-ready" : "lobby-state-player-status-not-ready");
Lobby!.ReadyButton.ToggleMode = true;
Lobby!.ReadyButton.Disabled = false;
Lobby!.ReadyButton.Pressed = _gameTicker.AreWeReady;
Expand Down Expand Up @@ -200,10 +201,31 @@ private void UpdateLobbySoundtrackInfo(LobbySoundtrackChangedEvent ev)
private void UpdateLobbyBackground()
{
if (_gameTicker.LobbyBackground != null)
Lobby!.Background.Texture = _resourceCache.GetResource<TextureResource>(_gameTicker.LobbyBackground);
else
Lobby!.Background.Texture = null;
{
Lobby!.Background.Texture = _resourceCache.GetResource<TextureResource>(_gameTicker.LobbyBackground.Background);

var lobbyBackground = _gameTicker.LobbyBackground;

var name = string.IsNullOrEmpty(lobbyBackground.Name)
? Loc.GetString("lobby-state-background-unknown-title")
: lobbyBackground.Name;

var artist = string.IsNullOrEmpty(lobbyBackground.Artist)
? Loc.GetString("lobby-state-background-unknown-artist")
: lobbyBackground.Artist;

var markup = Loc.GetString("lobby-state-background-text",
("backgroundName", name),
("backgroundArtist", artist));

Lobby!.LobbyBackground.SetMarkup(markup);

return;
}

_sawmill.Warning("_gameTicker.LobbyBackground was null! No lobby background selected.");
Lobby!.Background.Texture = null;
Lobby!.LobbyBackground.SetMarkup(Loc.GetString("lobby-state-background-no-background-text"));
}

private void SetReady(bool newReady)
Expand Down
5 changes: 4 additions & 1 deletion Content.Client/Lobby/UI/LobbyGui.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,14 @@
<!-- Vertical Padding-->
<Control VerticalExpand="True" />
<!-- Left Bot Panel -->
<BoxContainer Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Bottom">
<BoxContainer Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Bottom" SeparationOverride="4">
<info:DevInfoBanner Name="DevInfoBanner" VerticalExpand="false" Margin="3 3 3 3" />
<PanelContainer StyleClasses="AngleRect">
<RichTextLabel Name="LobbySong" Access="Public" HorizontalAlignment="Center" />
</PanelContainer>
<PanelContainer StyleClasses="AngleRect">
<RichTextLabel Name="LobbyBackground" Access="Public" HorizontalAlignment="Center" />
</PanelContainer>
</BoxContainer>
</Control>
<!-- Character setup state -->
Expand Down
1 change: 1 addition & 0 deletions Content.Client/Lobby/UI/LobbyGui.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public LobbyGui()
SetAnchorPreset(Background, LayoutPreset.Wide);

LobbySong.SetMarkup(Loc.GetString("lobby-state-song-no-song-text"));
LobbyBackground.SetMarkup(Loc.GetString("lobby-state-background-no-background-text"));

LeaveButton.OnPressed += _ => _consoleHost.ExecuteCommand("disconnect");
OptionsButton.OnPressed += _ => UserInterfaceManager.GetUIController<OptionsUIController>().ToggleWindow();
Expand Down
22 changes: 14 additions & 8 deletions Content.Server/GameTicking/GameTicker.LobbyBackground.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Content.Server.GameTicking.Prototypes;
using Content.Shared.GameTicking.Prototypes;
using Robust.Shared.Random;
using Robust.Shared.Utility;
using System.Linq;
Expand All @@ -8,24 +8,30 @@ namespace Content.Server.GameTicking;
public sealed partial class GameTicker
{
[ViewVariables]
public string? LobbyBackground { get; private set; }
public LobbyBackgroundPrototype? LobbyBackground { get; private set; }

[ViewVariables]
private List<ResPath>? _lobbyBackgrounds;
private List<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();
foreach (var prototype in _prototypeManager.EnumeratePrototypes<LobbyBackgroundPrototype>())
{
if (!WhitelistedBackgroundExtensions.Contains(prototype.Background.Extension))
{
_sawmill.Warning($"Lobby background '{prototype.ID}' has an invalid extension '{prototype.Background.Extension}' and will be ignored.");
continue;
}

_lobbyBackgrounds.Add(prototype);
}

RandomizeLobbyBackground();
}

private void RandomizeLobbyBackground() {
LobbyBackground = _lobbyBackgrounds!.Any() ? _robustRandom.Pick(_lobbyBackgrounds!).ToString() : null;
LobbyBackground = _lobbyBackgrounds!.Any() ? _robustRandom.Pick(_lobbyBackgrounds!) : null;
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
using Robust.Shared.Prototypes;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using Robust.Shared.Utility;

namespace Content.Server.GameTicking.Prototypes;
namespace Content.Shared.GameTicking.Prototypes;

/// <summary>
/// Prototype for a lobby background the game can choose.
/// </summary>
[Prototype("lobbyBackground")]
[NetSerializable, Serializable]
public sealed partial class LobbyBackgroundPrototype : IPrototype
{
/// <inheritdoc/>
Expand All @@ -18,4 +20,10 @@ public sealed partial class LobbyBackgroundPrototype : IPrototype
/// </summary>
[DataField("background", required: true)]
public ResPath Background = default!;

[DataField("name")]
public string? Name;

[DataField("artist")]
public string? Artist;
}
5 changes: 3 additions & 2 deletions Content.Shared/GameTicking/SharedGameTicker.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Content.Shared.Roles;
using Content.Shared.GameTicking.Prototypes;
using Robust.Shared.Network;
using Robust.Shared.Replays;
using Robust.Shared.Serialization;
Expand Down Expand Up @@ -78,14 +79,14 @@ public TickerConnectionStatusEvent(TimeSpan roundStartTimeSpan)
public sealed class TickerLobbyStatusEvent : EntityEventArgs
{
public bool IsRoundStarted { get; }
public string? LobbyBackground { get; }
public LobbyBackgroundPrototype? 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, LobbyBackgroundPrototype? lobbyBackground, bool youAreReady, TimeSpan startTime, TimeSpan preloadTime, TimeSpan roundStartTimeSpan, bool paused)
{
IsRoundStarted = isRoundStarted;
LobbyBackground = lobbyBackground;
Expand Down
4 changes: 4 additions & 0 deletions Resources/Locale/en-US/_Goobstation/lobby/lobby-state.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
lobby-state-background-text = Background: [color=white]{$backgroundName}[/color] by [color=white]{$backgroundArtist}[/color]
lobby-state-background-no-background-text = No background selected.
lobby-state-background-unknown-title = [color=dimgray]Unknown lobby background[/color]
lobby-state-background-unknown-artist = [color=dimgray]Unknown artist[/color]
24 changes: 23 additions & 1 deletion Resources/Prototypes/lobbyscreens.yml
Original file line number Diff line number Diff line change
@@ -1,43 +1,65 @@
- type: lobbyBackground
id: Robotics
background: /Textures/LobbyScreens/robotics.webp
name: Robotics
artist: Veritius

- type: lobbyBackground
id: Supermatter
background: /Textures/LobbyScreens/supermatter.webp
name: Supermatter
artist: Vertitius

- type: lobbyBackground
id: Warden
background: /Textures/LobbyScreens/warden.webp
name: Warden
artist: Solbusaur

- type: lobbyBackground
id: Pharmacy
background: /Textures/LobbyScreens/pharmacy.webp
name: Pharmacy
artist: Solbusaur

- type: lobbyBackground
id: SSXIV
background: /Textures/LobbyScreens/ssxiv.webp
name: SSXIV
artist: Abyssal

- type: lobbyBackground
id: Susstation
background: /Textures/LobbyScreens/susstation.webp
name: Sus Station
artist: Alekshhh

- type: lobbyBackground
id: SkellyVsTheRev
background: /Textures/LobbyScreens/skellyvstherev.webp
name: Skelly Vs The Rev
artist: Hannah 'FairlySadPanda' Dawson

- type: lobbyBackground
id: Doomed
background: /Textures/LobbyScreens/doomed.webp
name: Doomed
artist: brainfood1183

- type: lobbyBackground
id: Blueprint
background: /Textures/LobbyScreens/blueprint.webp
name: Blueprint
artist: data_redacted

- type: lobbyBackground
id: TerminalStation
background: /Textures/LobbyScreens/terminalstation.webp
name: Terminal Station
artist: aserovich

- type: lobbyBackground
id: JustAWeekAway
background: /Textures/LobbyScreens/justaweekaway.webp
background: /Textures/LobbyScreens/justaweekaway.webp
name: Just A Week Away
artist: plantyfern
2 changes: 1 addition & 1 deletion Resources/Textures/LobbyScreens/attributions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@
- files: ["justaweekaway.webp"]
license: "CC-BY-SA-3.0"
copyright: "plantyfern on discord"
source: "https://github.com/space-wizards/space-station-14"
source: "https://github.com/space-wizards/space-station-14"
Loading