mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-09-02 10:07:15 +02:00
56 lines
1.2 KiB
C#
56 lines
1.2 KiB
C#
using Robust.Client.Interfaces.GameObjects.Components;
|
|
using Robust.Client.Interfaces.Graphics;
|
|
using Robust.Shared.Maths;
|
|
|
|
namespace Robust.Client.UserInterface.Controls
|
|
{
|
|
public class SpriteView : Control
|
|
{
|
|
private Vector2 _scale = (1, 1);
|
|
|
|
public Vector2 Scale
|
|
{
|
|
get => _scale;
|
|
set
|
|
{
|
|
_scale = value;
|
|
MinimumSizeChanged();
|
|
}
|
|
}
|
|
|
|
public ISpriteComponent Sprite { get; set; }
|
|
|
|
public SpriteView()
|
|
{
|
|
}
|
|
|
|
public SpriteView(string name) : base(name)
|
|
{
|
|
}
|
|
|
|
protected override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
RectClipContent = true;
|
|
}
|
|
|
|
protected override Vector2 CalculateMinimumSize()
|
|
{
|
|
// TODO: make this not hardcoded.
|
|
// It'll break on larger things.
|
|
return (32, 32) * Scale;
|
|
}
|
|
|
|
internal override void DrawInternal(IRenderHandle renderHandle)
|
|
{
|
|
if (Sprite == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
renderHandle.DrawEntity(Sprite.Owner, GlobalPixelPosition + PixelSize / 2, Scale);
|
|
}
|
|
}
|
|
}
|