Files
LuaCsForBarotraumaEP/Subsurface/Source/GUI/GUIFrame.cs
Regalis 34f0ae39b6 - Sliced sprites are scaled instead of tiling (so they work properly even if the UI element is smaller than the sprite)
- Option to use separate sprites for different states of a GUIComponent (e.g. hovered/pressed button)
- Option to configure "child styles" for the individual elements of a GUIComponent (e.g. the background frame and the handle of a scroll bar)
2017-04-09 21:26:35 +03:00

62 lines
1.8 KiB
C#

using Microsoft.Xna.Framework;
using System.Linq;
namespace Barotrauma
{
public class GUIFrame : GUIComponent
{
public GUIFrame(Rectangle rect, string style = "", GUIComponent parent = null)
: this(rect, null, (Alignment.Left | Alignment.Top), style, parent)
{
}
public GUIFrame(Rectangle rect, Color color, string style = "", GUIComponent parent = null)
: this(rect, color, (Alignment.Left | Alignment.Top), style, parent)
{
}
public GUIFrame(Rectangle rect, Color? color, Alignment alignment, string style = "", GUIComponent parent = null)
: base(style)
{
this.rect = rect;
this.alignment = alignment;
if (color != null) this.color = (Color)color;
if (parent != null)
{
parent.AddChild(this);
}
else
{
UpdateDimensions();
}
//if (style != null) ApplyStyle(style);
}
public override void Draw(Microsoft.Xna.Framework.Graphics.SpriteBatch spriteBatch)
{
if (!Visible) return;
Color currColor = color;
if (state == ComponentState.Selected) currColor = selectedColor;
if (state == ComponentState.Hover) currColor = hoverColor;
if (sprites == null || !sprites.Any()) GUI.DrawRectangle(spriteBatch, rect, currColor * (currColor.A/255.0f), true);
base.Draw(spriteBatch);
if (OutlineColor != Color.Transparent)
{
GUI.DrawRectangle(spriteBatch, rect, OutlineColor * (OutlineColor.A/255.0f), false);
}
DrawChildren(spriteBatch);
}
}
}