Files
RobustToolbox/Robust.Client/UserInterface/Controls/SpriteView.cs
T
Pieter-Jan BriersandGitHub cb5f2ffae1 Refactor UI system. (#843)
* Refactor UI system.

Deferred updating is used for styling & layout. This fixes the awful time complexity of containers.
Removed SetDefaults and Initialize. They were a bad idea alright.

* Fix build on .NET Framework.
2019-08-14 22:03:51 +02:00

46 lines
1.1 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()
{
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);
}
}
}