SerializableEntityEditor layout tweaking
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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<InGameEditable>(ic).Count == 0) continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (SerializableProperty.GetProperties<Editable>(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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user