Skip to content

Commit

Permalink
Merge pull request #20 from gomozigota-metacoop/animated-lobby-screens
Browse files Browse the repository at this point in the history
Huge Update Epta
  • Loading branch information
ILLUZORR authored Feb 5, 2025
2 parents 1803a8d + 13c5713 commit 5490232
Show file tree
Hide file tree
Showing 29 changed files with 432 additions and 42 deletions.
2 changes: 1 addition & 1 deletion Content.Client/GameTicking/Managers/ClientGameTicker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,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 LobbyBackgroundPrototype? LobbyBackground { get; private set; }
[ViewVariables] public string? 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
18 changes: 1 addition & 17 deletions Content.Client/Lobby/LobbyState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -238,23 +238,7 @@ private void UpdateLobbyBackground()
{
if (_gameTicker.LobbyBackground != 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);
Lobby!.Background.SetRSI(_resourceCache.GetResource<RSIResource>(_gameTicker.LobbyBackground).RSI);

return;
}
Expand Down
7 changes: 4 additions & 3 deletions Content.Client/Lobby/UI/LobbyGui.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
xmlns:lobbyUi="clr-namespace:Content.Client.Lobby.UI"
xmlns:info="clr-namespace:Content.Client.Info"
xmlns:widgets="clr-namespace:Content.Client.UserInterface.Systems.Chat.Widgets"
xmlns:graphics="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client">
xmlns:graphics="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client"
xmlns:ui="clr-namespace:Content.Client._Kaif.UI">
<!-- Background -->
<TextureRect Access="Public" VerticalExpand="True" HorizontalExpand="True" Name="Background"
Stretch="KeepAspectCovered" />
<ui:AnimatedBackgroundControl Access="Public" Name="Background" VerticalExpand="True" HorizontalExpand="True"
Stretch="KeepAspectCovered" />
<BoxContainer Name="MainContainer" VerticalExpand="True" HorizontalExpand="True" Orientation="Horizontal"
Margin="10 10 10 10" SeparationOverride="2">
<SplitContainer State="Auto" ResizeMode="NotResizable" HorizontalExpand="True">
Expand Down
111 changes: 111 additions & 0 deletions Content.Client/_Kaif/UI/AnimatedBackgroundControl.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
using System.Linq;
using Content.Shared._Kaif;
using Robust.Client.Graphics;
using Robust.Client.ResourceManagement;
using Robust.Client.UserInterface.Controls;
using Robust.Shared.Graphics.RSI;
using Robust.Shared.Prototypes;
using Robust.Shared.Timing;

namespace Content.Client._Kaif.UI;

public sealed class AnimatedBackgroundControl : TextureRect
{
[Dependency] private readonly IResourceCache _resourceCache = default!;
[Dependency] private readonly IClyde _clyde = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;

private string _rsiPath = "/Textures/_Kaif/Lobby/Backgrounds/native.rsi";
public RSI? _RSI;
private const int States = 1;

private IRenderTexture? _buffer;

private readonly float[] _timer = new float[States];
private readonly float[][] _frameDelays = new float[States][];
private readonly int[] _frameCounter = new int[States];
private readonly Texture[][] _frames = new Texture[States][];

public AnimatedBackgroundControl()
{
IoCManager.InjectDependencies(this);

InitializeStates();
}

private void InitializeStates()
{
_RSI ??= _resourceCache.GetResource<RSIResource>(_rsiPath).RSI;

for (var i = 0; i < States; i++)
{
if (!_RSI.TryGetState((i + 1).ToString(), out var state))
continue;

_frames[i] = state.GetFrames(RsiDirection.South);
_frameDelays[i] = state.GetDelays();
_frameCounter[i] = 0;
}
}

public void SetRSI(RSI? rsi)
{
_RSI = rsi;
InitializeStates();
}

protected override void FrameUpdate(FrameEventArgs args)
{
base.FrameUpdate(args);

for (var i = 0; i < _frames.Length; i++)
{
var delays = _frameDelays[i];
if (delays.Length == 0)
continue;

_timer[i] += args.DeltaSeconds;

var currentFrameIndex = _frameCounter[i];

if (!(_timer[i] >= delays[currentFrameIndex]))
continue;

_timer[i] -= delays[currentFrameIndex];
_frameCounter[i] = (currentFrameIndex + 1) % _frames[i].Length;
Texture = _frames[i][_frameCounter[i]];
}
}

protected override void Draw(DrawingHandleScreen handle)
{
base.Draw(handle);

if (_buffer is null)
return;

handle.DrawTextureRect(_buffer.Texture, PixelSizeBox);
}

protected override void Resized()
{
base.Resized();
_buffer?.Dispose();
_buffer = _clyde.CreateRenderTarget(PixelSize, RenderTargetColorFormat.Rgba8Srgb);
}

protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
_buffer?.Dispose();
}

public void RandomizeBackground()
{
var backgroundsProto = _prototypeManager.EnumeratePrototypes<AnimatedLobbyScreenPrototype>().ToList();
var random = new Random();
var index = random.Next(backgroundsProto.Count);
_rsiPath = $"/Textures/{backgroundsProto[index].Path}";
InitializeStates();
}
}
2 changes: 1 addition & 1 deletion Content.Server/Administration/Commands/AdminWhoCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace Content.Server.Administration.Commands;

[AdminCommand(AdminFlags.AdminWho)]
[AnyCommand]
public sealed class AdminWhoCommand : IConsoleCommand
{
public string Command => "adminwho";
Expand Down
3 changes: 2 additions & 1 deletion Content.Server/Audio/ContentAudioSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ namespace Content.Server.Audio;
public sealed class ContentAudioSystem : SharedContentAudioSystem
{
[ValidatePrototypeId<SoundCollectionPrototype>]
private const string LobbyMusicCollection = "LobbyMusic";
// private const string LobbyMusicCollection = "LobbyMusic"; // Kaif Station edit
private const string LobbyMusicCollection = "LobbyMusicKaif";

[Dependency] private readonly AudioSystem _serverAudio = default!;
[Dependency] private readonly IRobustRandom _robustRandom = default!;
Expand Down
25 changes: 8 additions & 17 deletions Content.Server/GameTicking/GameTicker.LobbyBackground.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Content.Shared.GameTicking.Prototypes;
using Robust.Shared.Random;
using Robust.Shared.Utility;
using Content.Shared._Kaif;
using System.Linq;

namespace Content.Server.GameTicking;
Expand All @@ -9,30 +8,22 @@ namespace Content.Server.GameTicking;
public sealed partial class GameTicker
{
[ViewVariables]
public LobbyBackgroundPrototype? LobbyBackground { get; private set; }
public string? LobbyBackground { get; private set; }

[ViewVariables]
private List<LobbyBackgroundPrototype> _lobbyBackgrounds = [];

private static readonly string[] WhitelistedBackgroundExtensions = new string[] {"png", "jpg", "jpeg", "webp"};
private List<string>? _lobbyBackgrounds;

private void InitializeLobbyBackground()
{
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);
}
_lobbyBackgrounds = _prototypeManager.EnumeratePrototypes<AnimatedLobbyScreenPrototype>()
.Select(x => x.Path)
.ToList();

RandomizeLobbyBackground();
}

private void RandomizeLobbyBackground() {
private void RandomizeLobbyBackground()
{
LobbyBackground = _lobbyBackgrounds!.Any() ? _robustRandom.Pick(_lobbyBackgrounds!) : null;
}
}
5 changes: 3 additions & 2 deletions Content.Shared/GameTicking/SharedGameTicker.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Content.Shared._Kaif;
using Content.Shared.Roles;
using Content.Shared.GameTicking.Prototypes;
using Robust.Shared.Network;
Expand Down Expand Up @@ -87,15 +88,15 @@ public TickerConnectionStatusEvent(TimeSpan roundStartTimeSpan)
public sealed class TickerLobbyStatusEvent : EntityEventArgs
{
public bool IsRoundStarted { get; }
public LobbyBackgroundPrototype? LobbyBackground { get; } // Goobstation - Lobby Background Credits
public string? LobbyBackground { get; } // Goobstation - Lobby Background Credits
public bool YouAreReady { get; }
// UTC.
public TimeSpan StartTime { get; }
public TimeSpan RoundStartTimeSpan { get; }
public bool Paused { get; }

// Goobstation - Lobby Background Credits
public TickerLobbyStatusEvent(bool isRoundStarted, LobbyBackgroundPrototype? lobbyBackground, bool youAreReady, TimeSpan startTime, TimeSpan preloadTime, TimeSpan roundStartTimeSpan, bool paused)
public TickerLobbyStatusEvent(bool isRoundStarted, string? lobbyBackground, bool youAreReady, TimeSpan startTime, TimeSpan preloadTime, TimeSpan roundStartTimeSpan, bool paused)
{
IsRoundStarted = isRoundStarted;
LobbyBackground = lobbyBackground;
Expand Down
23 changes: 23 additions & 0 deletions Content.Shared/_Kaif/AnimatedLobbyScreenPrototype.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using Robust.Shared.Prototypes;

namespace Content.Shared._Kaif;

/// <summary>
/// This is a prototype for...
/// </summary>
[Prototype]
public sealed partial class AnimatedLobbyScreenPrototype : IPrototype
{
/// <inheritdoc/>
[IdDataField]
public string ID { get; } = default!;

[DataField(required: true)]
public string Path = default!;

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

[DataField("artist")]
public string? Artist;
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added Resources/Audio/_Kaif/Lobby/xs_project_yaica.ogg
Binary file not shown.
4 changes: 4 additions & 0 deletions Resources/Locale/ru-RU/_Kaif/purososal/mobs.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ent-MobMrProper = Мр. Проппер
.desc = Отмоет пол, проехавшись по вашему лицу.
ent-MobPoopsy = Какашонок
.desc = Маленький и злобный, враг скибиди туалетов.
19 changes: 19 additions & 0 deletions Resources/Prototypes/_Kaif/AnimatedLobbyScreens/lobbyscreens.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
- type: animatedLobbyScreen
id: Ultrazvuk
path: /Textures/_Kaif/Lobby/Backgrounds/ultrazvuk.rsi

- type: animatedLobbyScreen
id: Stena
path: /Textures/_Kaif/Lobby/Backgrounds/stena.rsi

- type: animatedLobbyScreen
id: Native
path: /Textures/_Kaif/Lobby/Backgrounds/native.rsi

- type: animatedLobbyScreen
id: Akula
path: /Textures/_Kaif/Lobby/Backgrounds/akula.rsi

- type: animatedLobbyScreen
id: Makaka
path: /Textures/_Kaif/Lobby/Backgrounds/makaka.rsi
8 changes: 8 additions & 0 deletions Resources/Prototypes/_Kaif/SoundCollections/lobbymusic.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
- type: soundCollection
id: LobbyMusicKaif
files:
- /Audio/_Kaif/Lobby/xs_project_skorostnaya_trassa.ogg
- /Audio/_Kaif/Lobby/xs_project_yaica.ogg
- /Audio/_Kaif/Lobby/xs_project_kayfushki.ogg
- /Audio/_Kaif/Lobby/xs_project_vodovorot.ogg
- /Audio/_Kaif/Lobby/xs_project_kolotushki.ogg
Binary file modified Resources/Textures/Kaif/Logo/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Resources/Textures/Kaif/Logo/logo2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions Resources/Textures/_Kaif/Lobby/Backgrounds/akula.rsi/meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"version": 1,
"license": "CC BY-ND",
"copyright": "By ILLUZORR, for Kaif Station only",
"size": {
"x": 1280,
"y": 720
},
"states": [
{
"name": "1",
"delays": [
[
1
]
]
}
]
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions Resources/Textures/_Kaif/Lobby/Backgrounds/makaka.rsi/meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"version": 1,
"license": "CC BY-ND",
"copyright": "By ILLUZORR, for Kaif Station only",
"size": {
"x": 1920,
"y": 1080
},
"states": [
{
"name": "1",
"delays": [
[
1
]
]
}
]
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions Resources/Textures/_Kaif/Lobby/Backgrounds/native.rsi/meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"version": 1,
"license": "CC BY-ND",
"copyright": "By ILLUZORR, for Kaif Station only",
"size": {
"x": 1920,
"y": 1080
},
"states": [
{
"name": "1",
"delays": [
[
1
]
]
}
]
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 5490232

Please sign in to comment.