diff --git a/Barotrauma/BarotraumaClient/Source/GUI/GUIListBox.cs b/Barotrauma/BarotraumaClient/Source/GUI/GUIListBox.cs index be375920a..e12fe409c 100644 --- a/Barotrauma/BarotraumaClient/Source/GUI/GUIListBox.cs +++ b/Barotrauma/BarotraumaClient/Source/GUI/GUIListBox.cs @@ -184,6 +184,17 @@ namespace Barotrauma { base.SetDimensions(size, expandChildren); frame.SetDimensions(size, expandChildren); + + if (scrollBar.IsHorizontal) + { + scrollBar.Rect = new Rectangle(this.rect.X, this.rect.Bottom - 20, this.rect.Width, 20); + } + else + { + scrollBar.Rect = new Rectangle(this.rect.Right - 20, this.rect.Y, 20, this.rect.Height); + } + + UpdateScrollBarSize(); } private void UpdateChildrenRect(float deltaTime) @@ -340,9 +351,10 @@ namespace Barotrauma { if (child == frame) continue; totalSize += (scrollBar.IsHorizontal) ? child.Rect.Width : child.Rect.Height; - totalSize += spacing; } + totalSize += (children.Count - 1) * spacing; + scrollBar.BarSize = scrollBar.IsHorizontal ? Math.Max(Math.Min((float)rect.Width / (float)totalSize, 1.0f), 5.0f / rect.Width) : Math.Max(Math.Min((float)rect.Height / (float)totalSize, 1.0f), 5.0f / rect.Height); diff --git a/Barotrauma/BarotraumaClient/Source/Items/Item.cs b/Barotrauma/BarotraumaClient/Source/Items/Item.cs index d6b3cc93b..c942d2869 100644 --- a/Barotrauma/BarotraumaClient/Source/Items/Item.cs +++ b/Barotrauma/BarotraumaClient/Source/Items/Item.cs @@ -154,8 +154,9 @@ namespace Barotrauma int x = GameMain.GraphicsWidth / 2 - width / 2, y = 30; editingHUD = new GUIListBox(new Rectangle(x, y, width, height), ""); - ((GUIListBox)editingHUD).Spacing = 5; editingHUD.UserData = this; + GUIListBox listBox = (GUIListBox)editingHUD; + listBox.Spacing = 5; var itemEditor = new SerializableEntityEditor(this, inGame, editingHUD, true); @@ -166,6 +167,18 @@ namespace Barotrauma foreach (ItemComponent ic in components) { + if (ic.requiredItems.Count == 0) + { + if (inGame) + { + if (SerializableProperty.GetProperties(ic).Count == 0) continue; + } + else + { + if (SerializableProperty.GetProperties(ic).Count == 0) continue; + } + } + var componentEditor = new SerializableEntityEditor(ic, inGame, editingHUD, !inGame); if (inGame) continue; @@ -173,7 +186,7 @@ namespace Barotrauma foreach (RelatedItem relatedItem in ic.requiredItems) { var textBlock = new GUITextBlock(new Rectangle(0, 0, 0, 20), relatedItem.Type.ToString() + " required", "", Alignment.TopLeft, Alignment.CenterLeft, null, false, GUI.SmallFont); - textBlock.Padding = Vector4.Zero; + textBlock.Padding = new Vector4(10.0f, 0.0f, 10.0f, 0.0f); componentEditor.AddCustomContent(textBlock, 1); GUITextBox namesBox = new GUITextBox(new Rectangle(0, 0, 180, 20), Alignment.Right, "", textBlock); @@ -196,8 +209,10 @@ namespace Barotrauma y += 20; } } - - editingHUD.SetDimensions(new Point(editingHUD.Rect.Width, MathHelper.Clamp(editingHUD.children.Sum(c => c.Rect.Height), 50, editingHUD.Rect.Height))); + + int contentHeight = (int)(editingHUD.children.Sum(c => c.Rect.Height) + (listBox.children.Count - 1) * listBox.Spacing + listBox.Padding.Y + listBox.Padding.W); + + editingHUD.SetDimensions(new Point(editingHUD.Rect.Width, MathHelper.Clamp(contentHeight, 50, editingHUD.Rect.Height))); return editingHUD; } diff --git a/Barotrauma/BarotraumaClient/Source/Serialization/SerializableEntityEditor.cs b/Barotrauma/BarotraumaClient/Source/Serialization/SerializableEntityEditor.cs index 7c845ab01..a2d08c22b 100644 --- a/Barotrauma/BarotraumaClient/Source/Serialization/SerializableEntityEditor.cs +++ b/Barotrauma/BarotraumaClient/Source/Serialization/SerializableEntityEditor.cs @@ -87,7 +87,14 @@ namespace Barotrauma } } - SetDimensions(new Point(Rect.Width, children.Last().Rect.Bottom - Rect.Y + 10), false); + if (children.Count > 0) + { + SetDimensions(new Point(Rect.Width, children.Last().Rect.Bottom - Rect.Y + 10), false); + } + else + { + SetDimensions(new Point(Rect.Width, 0), false); + } } public void AddCustomContent(GUIComponent component, int childIndex) @@ -228,7 +235,7 @@ namespace Barotrauma propertyBox.Text = value; propertyBox.OnEnterPressed = (textBox, text) => { - if (property.TrySetValue(value)) + if (property.TrySetValue(text)) { TrySendNetworkUpdate(entity, property); }