Fixed GUIListBox background frame not moving when the listbox is moved (dropdowns inside listboxes work correctly now), opening the "add submarine" dropdown menu in sub editor deselects all entities to prevent the entity editing panel from overlapping with the dropdown.

This commit is contained in:
Joonas Rikkonen
2018-01-10 12:24:30 +02:00
parent 5f2227489b
commit 37217db7cb
3 changed files with 27 additions and 6 deletions
@@ -6,9 +6,9 @@ namespace Barotrauma
{ {
public class GUIDropDown : GUIComponent public class GUIDropDown : GUIComponent
{ {
public delegate bool OnSelectedHandler(GUIComponent selected, object obj = null); public delegate bool OnSelectedHandler(GUIComponent selected, object obj = null);
public OnSelectedHandler OnSelected; public OnSelectedHandler OnSelected;
public OnSelectedHandler OnDropped;
private GUIButton button; private GUIButton button;
private GUIListBox listBox; private GUIListBox listBox;
@@ -135,7 +135,7 @@ namespace Barotrauma
private bool SelectItem(GUIComponent component, object obj) private bool SelectItem(GUIComponent component, object obj)
{ {
GUITextBlock textBlock = component as GUITextBlock; GUITextBlock textBlock = component as GUITextBlock;
if (textBlock==null) return false; if (textBlock == null) return false;
button.Text = textBlock.Text; button.Text = textBlock.Text;
Dropped = false; Dropped = false;
@@ -171,10 +171,14 @@ namespace Barotrauma
wasOpened = true; wasOpened = true;
Dropped = !Dropped; Dropped = !Dropped;
if (Dropped && parent.children[parent.children.Count-1]!=this) if (Dropped)
{ {
parent.children.Remove(this); OnDropped?.Invoke(this, userData);
parent.children.Add(this); if (parent.children[parent.children.Count - 1] != this)
{
parent.children.Remove(this);
parent.children.Add(this);
}
} }
return true; return true;
@@ -219,7 +223,6 @@ namespace Barotrauma
button.Draw(spriteBatch); button.Draw(spriteBatch);
if (!Dropped) return; if (!Dropped) return;
listBox.Draw(spriteBatch); listBox.Draw(spriteBatch);
} }
} }
@@ -87,6 +87,19 @@ namespace Barotrauma
} }
} }
public override Rectangle Rect
{
get
{
return rect;
}
set
{
base.Rect = value;
frame.Rect = value;
}
}
public override Color Color public override Color Color
{ {
get get
@@ -177,6 +177,11 @@ namespace Barotrauma
linkedSubBox.AddItem(sub.Name, sub); linkedSubBox.AddItem(sub.Name, sub);
} }
linkedSubBox.OnSelected += SelectLinkedSub; linkedSubBox.OnSelected += SelectLinkedSub;
linkedSubBox.OnDropped += (component, obj) =>
{
MapEntity.SelectedList.Clear();
return true;
};
leftPanel = new GUIFrame(new Rectangle(0, 0, 150, GameMain.GraphicsHeight), "GUIFrameLeft"); leftPanel = new GUIFrame(new Rectangle(0, 0, 150, GameMain.GraphicsHeight), "GUIFrameLeft");
leftPanel.Padding = new Vector4(10.0f, 10.0f, 10.0f, 10.0f); leftPanel.Padding = new Vector4(10.0f, 10.0f, 10.0f, 10.0f);