-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from gomozigota-metacoop/animated-lobby-screens
Huge Update Epta
- Loading branch information
Showing
29 changed files
with
432 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
19
Resources/Prototypes/_Kaif/AnimatedLobbyScreens/lobbyscreens.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
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.
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
19
Resources/Textures/_Kaif/Lobby/Backgrounds/akula.rsi/meta.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
19
Resources/Textures/_Kaif/Lobby/Backgrounds/makaka.rsi/meta.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
19
Resources/Textures/_Kaif/Lobby/Backgrounds/native.rsi/meta.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
Oops, something went wrong.