mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-09-02 10:07:15 +02:00
Not quite perfect, but quite usable. Adds the ability to scale the UI. Scaling is controlled via a cvar, and can be changed at runtime. Fractional scaling is supported. Some controls could be better (SpriteView, TextureRect), but for now it's a good start.
70 lines
1.7 KiB
C#
70 lines
1.7 KiB
C#
using Robust.Client.Graphics.Drawing;
|
|
using Robust.Client.Utility;
|
|
using Robust.Shared.Maths;
|
|
|
|
namespace Robust.Client.UserInterface.Controls
|
|
{
|
|
[ControlWrap("Panel")]
|
|
public class Panel : Control
|
|
{
|
|
public const string StylePropertyPanel = "panel";
|
|
|
|
public Panel(string name) : base(name)
|
|
{
|
|
}
|
|
|
|
public Panel()
|
|
{
|
|
}
|
|
|
|
private StyleBox _panelOverride;
|
|
|
|
public StyleBox PanelOverride
|
|
{
|
|
get => _panelOverride;
|
|
set => _panelOverride = value;
|
|
}
|
|
|
|
private StyleBox ActualPanel
|
|
{
|
|
get
|
|
{
|
|
if (_panelOverride != null)
|
|
{
|
|
return _panelOverride;
|
|
}
|
|
|
|
if (TryGetStyleProperty(StylePropertyPanel, out StyleBox panel))
|
|
{
|
|
return panel;
|
|
}
|
|
|
|
return UserInterfaceManager.ThemeDefaults.PanelPanel;
|
|
}
|
|
}
|
|
|
|
protected internal override void Draw(DrawingHandleScreen handle)
|
|
{
|
|
base.Draw(handle);
|
|
|
|
var panel = ActualPanel;
|
|
panel.Draw(handle, PixelSizeBox);
|
|
}
|
|
|
|
private protected override void SetGodotProperty(string property, object value, GodotAssetScene context)
|
|
{
|
|
base.SetGodotProperty(property, value, context);
|
|
|
|
if (property == "custom_styles/panel")
|
|
{
|
|
PanelOverride = GetGodotResource<StyleBox>(context, value);
|
|
}
|
|
}
|
|
|
|
protected override Vector2 CalculateMinimumSize()
|
|
{
|
|
return ActualPanel.MinimumSize/UIScale;
|
|
}
|
|
}
|
|
}
|