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

View File

@@ -6,9 +6,9 @@ namespace Barotrauma
{
public class GUIDropDown : GUIComponent
{
public delegate bool OnSelectedHandler(GUIComponent selected, object obj = null);
public OnSelectedHandler OnSelected;
public OnSelectedHandler OnDropped;
private GUIButton button;
private GUIListBox listBox;
@@ -135,7 +135,7 @@ namespace Barotrauma
private bool SelectItem(GUIComponent component, object obj)
{
GUITextBlock textBlock = component as GUITextBlock;
if (textBlock==null) return false;
if (textBlock == null) return false;
button.Text = textBlock.Text;
Dropped = false;
@@ -171,10 +171,14 @@ namespace Barotrauma
wasOpened = true;
Dropped = !Dropped;
if (Dropped && parent.children[parent.children.Count-1]!=this)
if (Dropped)
{
parent.children.Remove(this);
parent.children.Add(this);
OnDropped?.Invoke(this, userData);
if (parent.children[parent.children.Count - 1] != this)
{
parent.children.Remove(this);
parent.children.Add(this);
}
}
return true;
@@ -219,7 +223,6 @@ namespace Barotrauma
button.Draw(spriteBatch);
if (!Dropped) return;
listBox.Draw(spriteBatch);
}
}

View File

@@ -87,6 +87,19 @@ namespace Barotrauma
}
}
public override Rectangle Rect
{
get
{
return rect;
}
set
{
base.Rect = value;
frame.Rect = value;
}
}
public override Color Color
{
get

View File

@@ -177,6 +177,11 @@ namespace Barotrauma
linkedSubBox.AddItem(sub.Name, sub);
}
linkedSubBox.OnSelected += SelectLinkedSub;
linkedSubBox.OnDropped += (component, obj) =>
{
MapEntity.SelectedList.Clear();
return true;
};
leftPanel = new GUIFrame(new Rectangle(0, 0, 150, GameMain.GraphicsHeight), "GUIFrameLeft");
leftPanel.Padding = new Vector4(10.0f, 10.0f, 10.0f, 10.0f);