GUI elements now respect render order + some minor distance comparison optimization

This commit is contained in:
juanjp600
2016-11-15 22:26:36 -03:00
parent 3c57b9d945
commit d2c17274fe
39 changed files with 441 additions and 47 deletions
+11 -5
View File
@@ -55,6 +55,11 @@ namespace Barotrauma
}
}
public override Rectangle MouseRect
{
get { return box.Rect; }
}
public GUITickBox(Rectangle rect, string label, Alignment alignment, GUIComponent parent)
: this(rect, label, alignment, GUI.Font, parent)
{
@@ -69,6 +74,7 @@ namespace Barotrauma
box = new GUIFrame(rect, Color.DarkGray, null, this);
box.HoverColor = Color.Gray;
box.SelectedColor = Color.DarkGray;
box.CanBeFocused = false;
text = new GUITextBlock(new Rectangle(rect.Right + 10, rect.Y+2, 20, rect.Height), label, GUI.Style, this, font);
@@ -76,19 +82,19 @@ namespace Barotrauma
Enabled = true;
}
public override void Update(float deltaTime)
{
if (!Visible || !Enabled) return;
if (MouseOn != null && MouseOn != this && !MouseOn.IsParentOf(this)) return;
//if (MouseOn != null && MouseOn != this && !MouseOn.IsParentOf(this)) return;
if (text.Rect.Contains(PlayerInput.MousePosition)) MouseOn = this;
//if (text.Rect.Contains(PlayerInput.MousePosition)) MouseOn = this;
if (box.Rect.Contains(PlayerInput.MousePosition))
if (MouseOn==this)//box.Rect.Contains(PlayerInput.MousePosition))
{
//ToolTip = this.ToolTip;
MouseOn = this;
//MouseOn = this;
box.State = ComponentState.Hover;