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:
@@ -169,7 +169,7 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
protected Color spriteColor;
|
||||
[Editable, HasDefaultValue("1.0,1.0,1.0,1.0", true)]
|
||||
[Editable, SerializableProperty("1.0,1.0,1.0,1.0", true)]
|
||||
public string SpriteColor
|
||||
{
|
||||
get { return XMLExtensions.Vector4ToString(spriteColor.ToVector4()); }
|
||||
@@ -220,7 +220,7 @@ namespace Barotrauma
|
||||
get { return condition; }
|
||||
}
|
||||
|
||||
[Editable, HasDefaultValue("", true)]
|
||||
[Editable, SerializableProperty("", true)]
|
||||
public string Tags
|
||||
{
|
||||
get { return string.Join(",",tags); }
|
||||
@@ -359,7 +359,7 @@ namespace Barotrauma
|
||||
XElement element = prefab.ConfigElement;
|
||||
if (element == null) return;
|
||||
|
||||
properties = ObjectProperty.InitProperties(this, element);
|
||||
properties = ObjectProperty.DeserializeProperties(this, element);
|
||||
|
||||
if (submarine == null || !submarine.Loading) FindHull();
|
||||
|
||||
@@ -1400,7 +1400,7 @@ namespace Barotrauma
|
||||
|
||||
ObjectProperty objectProperty = allProperties[propertyIndex];
|
||||
|
||||
Type type = objectProperty.GetType();
|
||||
Type type = objectProperty.PropertyType;
|
||||
if (type == typeof(string))
|
||||
{
|
||||
objectProperty.TrySetValue(msg.ReadString());
|
||||
@@ -1643,7 +1643,7 @@ namespace Barotrauma
|
||||
|
||||
bool shouldBeLoaded = false;
|
||||
|
||||
foreach (var propertyAttribute in property.Attributes.OfType<HasDefaultValue>())
|
||||
foreach (var propertyAttribute in property.Attributes.OfType<SerializableProperty>())
|
||||
{
|
||||
if (propertyAttribute.isSaveable)
|
||||
{
|
||||
@@ -1713,7 +1713,7 @@ namespace Barotrauma
|
||||
element.Add(new XAttribute("linked", string.Join(",", linkedToIDs)));
|
||||
}
|
||||
|
||||
ObjectProperty.SaveProperties(this, element);
|
||||
ObjectProperty.SerializeProperties(this, element);
|
||||
|
||||
foreach (ItemComponent ic in components)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user