From 37217db7cb187ac242ae6d736cf05db35b9e4088 Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Wed, 10 Jan 2018 12:24:30 +0200 Subject: [PATCH] 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. --- .../BarotraumaClient/Source/GUI/GUIDropDown.cs | 15 +++++++++------ .../BarotraumaClient/Source/GUI/GUIListBox.cs | 13 +++++++++++++ .../Source/Screens/SubEditorScreen.cs | 5 +++++ 3 files changed, 27 insertions(+), 6 deletions(-) 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);