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

fix ATLAS can`t breathe #617

Merged
merged 1 commit into from
Nov 13, 2024
Merged
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
5 changes: 3 additions & 2 deletions Content.Client/Lobby/UI/LobbyGui.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@
xmlns:widgets="clr-namespace:Content.Client.UserInterface.Systems.Chat.Widgets"
xmlns:serversHub="clr-namespace:Content.Client._Sunrise.ServersHub"
xmlns:changelog="clr-namespace:Content.Client.Changelog"
xmlns:userProfile="clr-namespace:Content.Client._Sunrise.UserProfile">
xmlns:userProfile="clr-namespace:Content.Client._Sunrise.UserProfile"
xmlns:texture="clr-namespace:Content.Client._Sunrise.Texture">
<!-- Background -->
<TextureRect Name="LobbyArt" Access="Public" VerticalExpand="True" HorizontalExpand="True"
Stretch="KeepAspectCovered" />
<AnimatedTextureRect Name="LobbyAnimation" HorizontalExpand="True" VerticalExpand="True" Access="Public" />
<texture:RawAnimatedTexture Name="LobbyAnimation" HorizontalExpand="True" VerticalExpand="True" Access="Public" />
<BoxContainer Name="MainContainer" VerticalExpand="True" HorizontalExpand="True" Orientation="Horizontal"
Margin="10 10 10 10" SeparationOverride="2">
<!-- LHS Controls -->
Expand Down
56 changes: 56 additions & 0 deletions Content.Client/_Sunrise/Texture/RawAnimatedTexture.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using Robust.Client.Graphics;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Client.Utility;
using Robust.Shared.Graphics.RSI;
using Robust.Shared.Timing;
using Robust.Shared.Utility;

namespace Content.Client._Sunrise.Texture;

public sealed class RawAnimatedTexture : Control
{
private IRsiStateLike? _state;
private int _curFrame;
private float _curFrameTime;

public TextureRect DisplayRect { get; }

public RsiDirection RsiDirection { get; } = RsiDirection.South;

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

DisplayRect = new TextureRect();
AddChild(DisplayRect);
}

public void SetFromSpriteSpecifier(SpriteSpecifier specifier)
{
_curFrame = 0;
_state = specifier.RsiStateLike();
_curFrameTime = _state.GetDelay(0);
DisplayRect.Texture = _state.GetFrame(RsiDirection, 0);
}

protected override void FrameUpdate(FrameEventArgs args)
{
if (!VisibleInTree || _state == null || !_state.IsAnimated)
return;

var oldFrame = _curFrame;

_curFrameTime -= args.DeltaSeconds;
while (_curFrameTime < _state.GetDelay(_curFrame))
{
_curFrame = (_curFrame + 1) % _state.AnimationFrameCount;
_curFrameTime += _state.GetDelay(_curFrame);
}

if (_curFrame != oldFrame)
{
DisplayRect.Texture = _state.GetFrame(RsiDirection, _curFrame);
}
}
}
Loading
Loading