- 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)
This commit is contained in:
@@ -155,41 +155,30 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
public GUIButton(Rectangle rect, string text, Color? color, Alignment alignment, Alignment textAlignment, string style = "", GUIComponent parent = null)
|
||||
: base (style)
|
||||
: base(style)
|
||||
{
|
||||
this.rect = rect;
|
||||
if (color!=null) this.color = (Color)color;
|
||||
if (color != null) this.color = (Color)color;
|
||||
this.alignment = alignment;
|
||||
|
||||
if (parent != null) parent.AddChild(this);
|
||||
|
||||
frame = new GUIFrame(Rectangle.Empty, style, this);
|
||||
GUI.Style.Apply(frame, style, this);
|
||||
GUI.Style.Apply(frame, style == "" ? "GUIButton" : style);
|
||||
|
||||
textBlock = new GUITextBlock(Rectangle.Empty, text,
|
||||
Color.Transparent, (this.style == null) ? Color.Black : this.style.textColor,
|
||||
textAlignment, style, this);
|
||||
textAlignment, null, this);
|
||||
GUI.Style.Apply(textBlock, style, this);
|
||||
|
||||
Enabled = true;
|
||||
}
|
||||
|
||||
|
||||
public override void Draw(SpriteBatch spriteBatch)
|
||||
{
|
||||
if (!Visible) return;
|
||||
|
||||
//Color currColor = color;
|
||||
//if (state == ComponentState.Hover) currColor = hoverColor;
|
||||
//if (state == ComponentState.Selected) currColor = selectedColor;
|
||||
|
||||
//GUI.DrawRectangle(spriteBatch, rect, currColor * alpha, true);
|
||||
|
||||
////spriteBatch.DrawString(HUD.font, text, new Vector2(rect.X+rect.Width/2, rect.Y+rect.Height/2), Color.Black, 0.0f, new Vector2(0.5f,0.5f), 1.0f, SpriteEffects.None, 0.0f);
|
||||
|
||||
//GUI.DrawRectangle(spriteBatch, rect, Color.Black * alpha, false);
|
||||
|
||||
|
||||
DrawChildren(spriteBatch);
|
||||
|
||||
//if (!Enabled) GUI.DrawRectangle(spriteBatch, rect, Color.Gray*0.5f, true);
|
||||
}
|
||||
|
||||
public override void Update(float deltaTime)
|
||||
@@ -203,7 +192,7 @@ namespace Barotrauma
|
||||
{
|
||||
if (OnPressed != null)
|
||||
{
|
||||
if (OnPressed()) state = ComponentState.Selected;
|
||||
if (OnPressed()) state = ComponentState.Pressed;
|
||||
}
|
||||
}
|
||||
else if (PlayerInput.LeftButtonClicked())
|
||||
|
||||
Reference in New Issue
Block a user