diff --git a/Barotrauma/BarotraumaClient/Source/GUI/GUIDropDown.cs b/Barotrauma/BarotraumaClient/Source/GUI/GUIDropDown.cs index 8516d994c..1ba9d78c8 100644 --- a/Barotrauma/BarotraumaClient/Source/GUI/GUIDropDown.cs +++ b/Barotrauma/BarotraumaClient/Source/GUI/GUIDropDown.cs @@ -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); } } diff --git a/Barotrauma/BarotraumaClient/Source/GUI/GUIListBox.cs b/Barotrauma/BarotraumaClient/Source/GUI/GUIListBox.cs index 541f5376a..772fdc661 100644 --- a/Barotrauma/BarotraumaClient/Source/GUI/GUIListBox.cs +++ b/Barotrauma/BarotraumaClient/Source/GUI/GUIListBox.cs @@ -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 diff --git a/Barotrauma/BarotraumaClient/Source/Screens/SubEditorScreen.cs b/Barotrauma/BarotraumaClient/Source/Screens/SubEditorScreen.cs index 5e87310c0..84f067902 100644 --- a/Barotrauma/BarotraumaClient/Source/Screens/SubEditorScreen.cs +++ b/Barotrauma/BarotraumaClient/Source/Screens/SubEditorScreen.cs @@ -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);