Working on improving the serialization system and ObjectProperty/IPropertyObject (TODO: come up with better names). The plan is to:

- Add support for some of the most common types (vectors, colors, rects) so there's no need to parse the values in the setters of the serializable properties (see Holdable.HoldPos for example).
- Make a generic version of the item editing HUD that can be used on any IPropertyObject. Should make it easier to implement things like the character editor, editing structure properties, particle editor, etc.
- Improve the interface of the editing HUD. Instead of having to type in a string value into a textbox, there should be number input fields for numeric properties, sliders for properties that only accept a range of values, a color picker, etc. And tooltips.
This commit is contained in:
Joonas Rikkonen
2017-11-03 19:41:21 +02:00
parent 8b9be55135
commit a0d606ef5f
41 changed files with 345 additions and 263 deletions
@@ -47,7 +47,7 @@ namespace Barotrauma.Items.Components
private string msg;
[HasDefaultValue(0.0f, false)]
[SerializableProperty(0.0f, false)]
public float PickingTime
{
get;
@@ -103,21 +103,21 @@ namespace Barotrauma.Items.Components
}
}
[HasDefaultValue(false, false)]
[SerializableProperty(false, false)]
public bool CanBePicked
{
get { return canBePicked; }
set { canBePicked = value; }
}
[HasDefaultValue(false, false)]
[SerializableProperty(false, false)]
public bool DrawHudWhenEquipped
{
get;
private set;
}
[HasDefaultValue(false, false)]
[SerializableProperty(false, false)]
public bool CanBeSelected
{
get { return canBeSelected; }
@@ -136,7 +136,7 @@ namespace Barotrauma.Items.Components
protected set;
}
[HasDefaultValue(false, false)]
[SerializableProperty(false, false)]
public bool DeleteOnUse
{
get;
@@ -153,7 +153,7 @@ namespace Barotrauma.Items.Components
get { return name; }
}
[HasDefaultValue("", false)]
[SerializableProperty("", false)]
public string Msg
{
get { return msg; }
@@ -205,7 +205,7 @@ namespace Barotrauma.Items.Components
DebugConsole.ThrowError("Invalid pick key in " + element + "!", e);
}
properties = ObjectProperty.InitProperties(this, element);
properties = ObjectProperty.DeserializeProperties(this, element);
foreach (XElement subElement in element.Elements())
{
@@ -586,7 +586,7 @@ namespace Barotrauma.Items.Components
componentElement.Add(newElement);
}
ObjectProperty.SaveProperties(this, componentElement);
ObjectProperty.SerializeProperties(this, componentElement);
parentElement.Add(componentElement);
return componentElement;