Unstable 0.1400.7.0 (Coronavirus edition)
This commit is contained in:
@@ -10,10 +10,10 @@ namespace Barotrauma
|
||||
{
|
||||
class SerializableEntityEditor : GUIComponent
|
||||
{
|
||||
private int elementHeight;
|
||||
private GUILayoutGroup layoutGroup;
|
||||
private float inputFieldWidth = 0.5f;
|
||||
private float largeInputFieldWidth = 0.8f;
|
||||
private readonly int elementHeight;
|
||||
private readonly GUILayoutGroup layoutGroup;
|
||||
private readonly float inputFieldWidth = 0.5f;
|
||||
private readonly float largeInputFieldWidth = 0.8f;
|
||||
#if DEBUG
|
||||
public static List<string> MissingLocalizations = new List<string>();
|
||||
#endif
|
||||
@@ -23,6 +23,8 @@ namespace Barotrauma
|
||||
public static DateTime NextCommandPush;
|
||||
public static Tuple<SerializableProperty, PropertyCommand> CommandBuffer;
|
||||
|
||||
private Action refresh;
|
||||
|
||||
public int ContentHeight
|
||||
{
|
||||
get
|
||||
@@ -312,6 +314,11 @@ namespace Barotrauma
|
||||
Recalculate();
|
||||
}
|
||||
|
||||
public void RefreshValues()
|
||||
{
|
||||
refresh?.Invoke();
|
||||
}
|
||||
|
||||
public void Recalculate() => RectTransform.Resize(new Point(RectTransform.NonScaledSize.X, ContentHeight));
|
||||
|
||||
public GUIComponent CreateNewField(SerializableProperty property, ISerializableEntity entity)
|
||||
@@ -459,6 +466,10 @@ namespace Barotrauma
|
||||
return true;
|
||||
}
|
||||
};
|
||||
refresh += () =>
|
||||
{
|
||||
propertyTickBox.Selected = (bool)property.GetValue(entity);
|
||||
};
|
||||
if (!Fields.ContainsKey(property.Name)) { Fields.Add(property.Name, new GUIComponent[] { propertyTickBox }); }
|
||||
return propertyTickBox;
|
||||
}
|
||||
@@ -480,7 +491,7 @@ namespace Barotrauma
|
||||
ToolTip = toolTip,
|
||||
Font = GUI.SmallFont
|
||||
};
|
||||
field = numberInput as GUIComponent;
|
||||
field = numberInput;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -499,7 +510,11 @@ namespace Barotrauma
|
||||
TrySendNetworkUpdate(entity, property);
|
||||
}
|
||||
};
|
||||
field = numberInput as GUIComponent;
|
||||
refresh += () =>
|
||||
{
|
||||
if (!numberInput.TextBox.Selected) { numberInput.IntValue = (int)property.GetValue(entity); }
|
||||
};
|
||||
field = numberInput;
|
||||
}
|
||||
if (!Fields.ContainsKey(property.Name)) { Fields.Add(property.Name, new GUIComponent[] { field }); }
|
||||
return frame;
|
||||
@@ -538,6 +553,10 @@ namespace Barotrauma
|
||||
TrySendNetworkUpdate(entity, property);
|
||||
}
|
||||
};
|
||||
refresh += () =>
|
||||
{
|
||||
if (!numberInput.TextBox.Selected) { numberInput.FloatValue = (float)property.GetValue(entity); }
|
||||
};
|
||||
if (!Fields.ContainsKey(property.Name)) { Fields.Add(property.Name, new GUIComponent[] { numberInput }); }
|
||||
return frame;
|
||||
}
|
||||
@@ -567,6 +586,10 @@ namespace Barotrauma
|
||||
}
|
||||
return true;
|
||||
};
|
||||
refresh += () =>
|
||||
{
|
||||
if (!enumDropDown.Dropped) { enumDropDown.SelectItem(property.GetValue(entity)); }
|
||||
};
|
||||
if (!Fields.ContainsKey(property.Name)) { Fields.Add(property.Name, new GUIComponent[] { enumDropDown }); }
|
||||
return frame;
|
||||
}
|
||||
@@ -635,6 +658,10 @@ namespace Barotrauma
|
||||
|
||||
propertyBox.OnDeselected += (textBox, keys) => OnApply(textBox);
|
||||
propertyBox.OnEnterPressed += (box, text) => OnApply(box);
|
||||
refresh += () =>
|
||||
{
|
||||
if (!propertyBox.Selected) { propertyBox.Text = (string)property.GetValue(entity); }
|
||||
};
|
||||
|
||||
bool OnApply(GUITextBox textBox)
|
||||
{
|
||||
@@ -730,6 +757,15 @@ namespace Barotrauma
|
||||
};
|
||||
fields[i] = numberInput;
|
||||
}
|
||||
refresh += () =>
|
||||
{
|
||||
if (!fields.Any(f => ((GUINumberInput)f).TextBox.Selected))
|
||||
{
|
||||
Point value = (Point)property.GetValue(entity);
|
||||
((GUINumberInput)fields[0]).IntValue = value.X;
|
||||
((GUINumberInput)fields[1]).IntValue = value.Y;
|
||||
}
|
||||
};
|
||||
frame.RectTransform.MinSize = new Point(0, frame.RectTransform.Children.Max(c => c.MinSize.Y));
|
||||
if (!Fields.ContainsKey(property.Name)) { Fields.Add(property.Name, fields); }
|
||||
return frame;
|
||||
@@ -791,6 +827,15 @@ namespace Barotrauma
|
||||
};
|
||||
fields[i] = numberInput;
|
||||
}
|
||||
refresh += () =>
|
||||
{
|
||||
if (!fields.Any(f => ((GUINumberInput)f).TextBox.Selected))
|
||||
{
|
||||
Vector2 value = (Vector2)property.GetValue(entity);
|
||||
((GUINumberInput)fields[0]).FloatValue = value.X;
|
||||
((GUINumberInput)fields[1]).FloatValue = value.Y;
|
||||
}
|
||||
};
|
||||
frame.RectTransform.MinSize = new Point(0, frame.RectTransform.Children.Max(c => c.MinSize.Y));
|
||||
if (!Fields.ContainsKey(property.Name)) { Fields.Add(property.Name, fields); }
|
||||
return frame;
|
||||
@@ -857,6 +902,16 @@ namespace Barotrauma
|
||||
};
|
||||
fields[i] = numberInput;
|
||||
}
|
||||
refresh += () =>
|
||||
{
|
||||
if (!fields.Any(f => ((GUINumberInput)f).TextBox.Selected))
|
||||
{
|
||||
Vector3 value = (Vector3)property.GetValue(entity);
|
||||
((GUINumberInput)fields[0]).FloatValue = value.X;
|
||||
((GUINumberInput)fields[1]).FloatValue = value.Y;
|
||||
((GUINumberInput)fields[2]).FloatValue = value.Z;
|
||||
}
|
||||
};
|
||||
frame.RectTransform.MinSize = new Point(0, frame.RectTransform.Children.Max(c => c.MinSize.Y));
|
||||
if (!Fields.ContainsKey(property.Name)) { Fields.Add(property.Name, fields); }
|
||||
return frame;
|
||||
@@ -927,6 +982,17 @@ namespace Barotrauma
|
||||
};
|
||||
fields[i] = numberInput;
|
||||
}
|
||||
refresh += () =>
|
||||
{
|
||||
if (!fields.Any(f => ((GUINumberInput)f).TextBox.Selected))
|
||||
{
|
||||
Vector4 value = (Vector4)property.GetValue(entity);
|
||||
((GUINumberInput)fields[0]).FloatValue = value.X;
|
||||
((GUINumberInput)fields[1]).FloatValue = value.Y;
|
||||
((GUINumberInput)fields[2]).FloatValue = value.Z;
|
||||
((GUINumberInput)fields[3]).FloatValue = value.W;
|
||||
}
|
||||
};
|
||||
frame.RectTransform.MinSize = new Point(0, frame.RectTransform.Children.Max(c => c.MinSize.Y));
|
||||
if (!Fields.ContainsKey(property.Name)) { Fields.Add(property.Name, fields); }
|
||||
return frame;
|
||||
@@ -993,13 +1059,13 @@ namespace Barotrauma
|
||||
{
|
||||
Color newVal = (Color)property.GetValue(entity);
|
||||
if (comp == 0)
|
||||
newVal.R = (byte)(numInput.IntValue);
|
||||
newVal.R = (byte)numInput.IntValue;
|
||||
else if (comp == 1)
|
||||
newVal.G = (byte)(numInput.IntValue);
|
||||
newVal.G = (byte)numInput.IntValue;
|
||||
else if (comp == 2)
|
||||
newVal.B = (byte)(numInput.IntValue);
|
||||
newVal.B = (byte)numInput.IntValue;
|
||||
else
|
||||
newVal.A = (byte)(numInput.IntValue);
|
||||
newVal.A = (byte)numInput.IntValue;
|
||||
|
||||
if (SetPropertyValue(property, entity, newVal))
|
||||
{
|
||||
@@ -1010,6 +1076,17 @@ namespace Barotrauma
|
||||
colorBox.Color = colorBox.HoverColor = colorBox.PressedColor = colorBox.SelectedTextColor = (Color)property.GetValue(entity);
|
||||
fields[i] = numberInput;
|
||||
}
|
||||
refresh += () =>
|
||||
{
|
||||
if (!fields.Any(f => ((GUINumberInput)f).TextBox.Selected))
|
||||
{
|
||||
Color value = (Color)property.GetValue(entity);
|
||||
((GUINumberInput)fields[0]).IntValue = value.R;
|
||||
((GUINumberInput)fields[1]).IntValue = value.G;
|
||||
((GUINumberInput)fields[2]).IntValue = value.B;
|
||||
((GUINumberInput)fields[3]).IntValue = value.A;
|
||||
}
|
||||
};
|
||||
frame.RectTransform.MinSize = new Point(0, frame.RectTransform.Children.Max(c => c.MinSize.Y));
|
||||
if (!Fields.ContainsKey(property.Name)) { Fields.Add(property.Name, fields); }
|
||||
return frame;
|
||||
@@ -1072,6 +1149,17 @@ namespace Barotrauma
|
||||
};
|
||||
fields[i] = numberInput;
|
||||
}
|
||||
refresh += () =>
|
||||
{
|
||||
if (!fields.Any(f => ((GUINumberInput)f).TextBox.Selected))
|
||||
{
|
||||
Rectangle value = (Rectangle)property.GetValue(entity);
|
||||
((GUINumberInput)fields[0]).IntValue = value.X;
|
||||
((GUINumberInput)fields[1]).IntValue = value.Y;
|
||||
((GUINumberInput)fields[2]).IntValue = value.Width;
|
||||
((GUINumberInput)fields[3]).IntValue = value.Height;
|
||||
}
|
||||
};
|
||||
if (!Fields.ContainsKey(property.Name)) { Fields.Add(property.Name, fields); }
|
||||
return frame;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user