commit 7245c721339885d062567befc052a592391b3b4a Author: Joonas Rikkonen <poe.regalis@gmail.com> Date: Sun Mar 10 15:22:31 2019 +0200 Fixed StatusEffects only applying afflictions to one limb even if the target is "Character" instead of "Limb", added a subtle screen distortion effect to heavy radiation sickness. Closes #1256 commit e0db27e62ec9546fd4b182a0cc97f7e5830645ae Author: Joonas Rikkonen <poe.regalis@gmail.com> Date: Sat Mar 9 21:53:51 2019 +0200 Fixed WrapText adding unnecessary spaces after every line break. Closes #1215 commit 988bc58d51c195ad9265b84a1e97e0101cd3f808 Author: Joonas Rikkonen <poe.regalis@gmail.com> Date: Sat Mar 9 21:12:50 2019 +0200 Fixed crashing when attempting to create a body for a wall section that's less than 1 unit long (e.g. if a wall that's just slightly longer than the wall section size receives damage). commit 8c31157425a9e2ec02312618d1bfa359ab3ee87d Author: Joonas Rikkonen <poe.regalis@gmail.com> Date: Sat Mar 9 20:30:44 2019 +0200 Fixed clients being unable to toggle the respawn shuttle on/off commit a4ccb039219830efe9cd305c26942dda1bd04e9c Author: Joonas Rikkonen <poe.regalis@gmail.com> Date: Sat Mar 9 19:33:22 2019 +0200 Fixed inability to select the respawn shuttle as a client host commit b89b2d2c282d8c74d7ccd37b3f29dcab51eff680 Author: Joonas Rikkonen <poe.regalis@gmail.com> Date: Sat Mar 9 19:32:41 2019 +0200 Made it possible to edit the style of the ListBox under GUIDropDowns, increased the opacity of the listbox to make the contents more readable when there's text behind it commit 8f6d9aef3d637fe37a18c78f4b15ef8fd266374e Author: Joonas Rikkonen <poe.regalis@gmail.com> Date: Sat Mar 9 18:11:23 2019 +0200 Fixed NetLobbyScreen not showing the names of the submarines the client doesn't have
224 lines
6.2 KiB
C#
224 lines
6.2 KiB
C#
using Microsoft.Xna.Framework;
|
|
using Microsoft.Xna.Framework.Graphics;
|
|
|
|
namespace Barotrauma
|
|
{
|
|
public class GUIButton : GUIComponent
|
|
{
|
|
protected GUITextBlock textBlock;
|
|
public GUITextBlock TextBlock { get { return textBlock; } }
|
|
protected GUIFrame frame;
|
|
public GUIFrame Frame { get { return frame; } }
|
|
|
|
public delegate bool OnClickedHandler(GUIButton button, object obj);
|
|
public OnClickedHandler OnClicked;
|
|
|
|
public delegate bool OnPressedHandler();
|
|
public OnPressedHandler OnPressed;
|
|
|
|
public delegate bool OnButtonDownHandler();
|
|
public OnButtonDownHandler OnButtonDown;
|
|
|
|
public bool CanBeSelected = true;
|
|
|
|
public override bool Enabled
|
|
{
|
|
get
|
|
{
|
|
return enabled;
|
|
}
|
|
|
|
set
|
|
{
|
|
if (value == enabled) return;
|
|
enabled = value;
|
|
frame.Color = enabled ? color : Color.Gray * 0.7f;
|
|
}
|
|
}
|
|
|
|
public override Color Color
|
|
{
|
|
get { return base.Color; }
|
|
set
|
|
{
|
|
base.Color = value;
|
|
frame.Color = value;
|
|
}
|
|
}
|
|
|
|
public override Color HoverColor
|
|
{
|
|
get { return base.HoverColor; }
|
|
set
|
|
{
|
|
base.HoverColor = value;
|
|
frame.HoverColor = value;
|
|
}
|
|
}
|
|
|
|
public override Color SelectedColor
|
|
{
|
|
get
|
|
{
|
|
return base.SelectedColor;
|
|
}
|
|
set
|
|
{
|
|
base.SelectedColor = value;
|
|
frame.SelectedColor = value;
|
|
}
|
|
}
|
|
|
|
public override Color PressedColor
|
|
{
|
|
get
|
|
{
|
|
return base.PressedColor;
|
|
}
|
|
set
|
|
{
|
|
base.PressedColor = value;
|
|
frame.PressedColor = value;
|
|
}
|
|
}
|
|
|
|
public override Color OutlineColor
|
|
{
|
|
get { return base.OutlineColor; }
|
|
set
|
|
{
|
|
base.OutlineColor = value;
|
|
if (frame != null) frame.OutlineColor = value;
|
|
}
|
|
}
|
|
|
|
public Color TextColor
|
|
{
|
|
get { return textBlock.TextColor; }
|
|
set { textBlock.TextColor = value; }
|
|
}
|
|
|
|
public override ScalableFont Font
|
|
{
|
|
get
|
|
{
|
|
return (textBlock==null) ? GUI.Font : textBlock.Font;
|
|
}
|
|
set
|
|
{
|
|
base.Font = value;
|
|
if (textBlock != null) textBlock.Font = value;
|
|
}
|
|
}
|
|
|
|
public string Text
|
|
{
|
|
get { return textBlock.Text; }
|
|
set { textBlock.Text = value; }
|
|
}
|
|
|
|
public bool ForceUpperCase
|
|
{
|
|
get { return textBlock.ForceUpperCase; }
|
|
set { textBlock.ForceUpperCase = value; }
|
|
}
|
|
|
|
public override string ToolTip
|
|
{
|
|
get
|
|
{
|
|
return base.ToolTip;
|
|
}
|
|
set
|
|
{
|
|
textBlock.ToolTip = value;
|
|
base.ToolTip = value;
|
|
}
|
|
}
|
|
|
|
public bool Selected { get; set; }
|
|
|
|
public GUIButton(RectTransform rectT, string text = "", Alignment textAlignment = Alignment.Center, string style = "", Color? color = null) : base(style, rectT)
|
|
{
|
|
if (color.HasValue)
|
|
{
|
|
this.color = color.Value;
|
|
}
|
|
frame = new GUIFrame(new RectTransform(Vector2.One, rectT), style);
|
|
if (style != null) GUI.Style.Apply(frame, style == "" ? "GUIButton" : style);
|
|
textBlock = new GUITextBlock(new RectTransform(Vector2.One, rectT), text, textAlignment: textAlignment, style: null)
|
|
{
|
|
TextColor = this.style == null ? Color.Black : this.style.textColor
|
|
};
|
|
GUI.Style.Apply(textBlock, "", this);
|
|
Enabled = true;
|
|
}
|
|
|
|
public override void ApplyStyle(GUIComponentStyle style)
|
|
{
|
|
base.ApplyStyle(style);
|
|
|
|
if (frame != null) frame.ApplyStyle(style);
|
|
}
|
|
|
|
protected override void Draw(SpriteBatch spriteBatch)
|
|
{
|
|
//do nothing
|
|
}
|
|
|
|
protected override void Update(float deltaTime)
|
|
{
|
|
if (!Visible) return;
|
|
base.Update(deltaTime);
|
|
if (Rect.Contains(PlayerInput.MousePosition) && CanBeSelected && Enabled && GUI.IsMouseOn(this))
|
|
{
|
|
state = ComponentState.Hover;
|
|
if (PlayerInput.LeftButtonDown())
|
|
{
|
|
OnButtonDown?.Invoke();
|
|
}
|
|
if (PlayerInput.LeftButtonHeld())
|
|
{
|
|
if (OnPressed != null)
|
|
{
|
|
if (OnPressed())
|
|
{
|
|
state = ComponentState.Pressed;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
state = ComponentState.Pressed;
|
|
}
|
|
}
|
|
else if (PlayerInput.LeftButtonClicked())
|
|
{
|
|
GUI.PlayUISound(GUISoundType.Click);
|
|
if (OnClicked != null)
|
|
{
|
|
if (OnClicked(this, UserData) && CanBeSelected)
|
|
{
|
|
state = ComponentState.Selected;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Selected = !Selected;
|
|
// state = state == ComponentState.Selected ? ComponentState.None : ComponentState.Selected;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
state = Selected ? ComponentState.Selected : ComponentState.None;
|
|
}
|
|
|
|
foreach (GUIComponent child in Children)
|
|
{
|
|
child.State = state;
|
|
}
|
|
//frame.State = state;
|
|
}
|
|
}
|
|
}
|