Fixed monster spawn & extra cargo settings being impossible to select due to the menus being outside of their parent GUIComponent

This commit is contained in:
Joonas Rikkonen
2018-01-10 14:21:37 +02:00
parent 37217db7cb
commit f9500fa6e1
4 changed files with 12 additions and 5 deletions

View File

@@ -132,7 +132,7 @@ namespace Barotrauma
protected Rectangle ClampRect(Rectangle r)
{
if (parent == null) return r;
if (parent == null || !ClampMouseRectToParent) return r;
Rectangle parentRect = parent.ClampRect(parent.rect);
if (parentRect.Width <= 0 || parentRect.Height <= 0) return Rectangle.Empty;
if (parentRect.X > r.X)
@@ -190,10 +190,15 @@ namespace Barotrauma
}
}
}
public bool ClampMouseRectToParent = true;
public virtual Rectangle MouseRect
{
get { return CanBeFocused ? ClampRect(rect) : Rectangle.Empty; }
get
{
if (!CanBeFocused) return Rectangle.Empty;
return ClampMouseRectToParent ? ClampRect(rect) : rect;
}
}
public Dictionary<ComponentState, List<UISprite>> sprites;

View File

@@ -296,7 +296,7 @@ namespace Barotrauma
{
get
{
return ClampRect(rect);
return ClampMouseRectToParent ? ClampRect(rect) : rect;
}
}

View File

@@ -63,7 +63,7 @@ namespace Barotrauma
public override Rectangle MouseRect
{
get { return ClampRect(box.Rect); }
get { return ClampMouseRectToParent ? ClampRect(box.Rect) : box.Rect; }
}
public override ScalableFont Font

View File

@@ -187,6 +187,7 @@ namespace Barotrauma.Networking
monsterButton.Enabled = !GameStarted;
var monsterFrame = new GUIListBox(new Rectangle(-290, 60, 280, 250), "", settingsTabs[0]);
monsterFrame.Visible = false;
monsterFrame.ClampMouseRectToParent = false;
monsterButton.UserData = monsterFrame;
monsterButton.OnClicked = (button, obj) =>
{
@@ -231,6 +232,7 @@ namespace Barotrauma.Networking
var cargoFrame = new GUIListBox(new Rectangle(300, 60, 280, 250), "", settingsTabs[0]);
cargoFrame.Visible = false;
cargoFrame.ClampMouseRectToParent = false;
cargoButton.UserData = cargoFrame;
cargoButton.OnClicked = (button, obj) =>
{