mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-09-03 02:27:08 +02:00
* 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.
46 lines
1.1 KiB
C#
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);
|
|
}
|
|
}
|
|
}
|