(d9829ac) v0.9.4.0
This commit is contained in:
@@ -8,7 +8,6 @@ using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Xml.Linq;
|
||||
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Property)]
|
||||
@@ -21,10 +20,13 @@ namespace Barotrauma
|
||||
public float MinValueFloat = float.MinValue, MaxValueFloat = float.MaxValue;
|
||||
public float ValueStep;
|
||||
|
||||
public string ToolTip;
|
||||
|
||||
public string DisplayName;
|
||||
|
||||
/// <summary>
|
||||
/// Currently implemented only for int fields. TODO: implement the remaining types (SerializableEntityEditor)
|
||||
/// </summary>
|
||||
public bool ReadOnly;
|
||||
|
||||
public Editable(int maxLength = 20)
|
||||
{
|
||||
MaxLength = maxLength;
|
||||
@@ -57,6 +59,8 @@ namespace Barotrauma
|
||||
public bool isSaveable;
|
||||
public string translationTextTag;
|
||||
|
||||
public string Description;
|
||||
|
||||
/// <summary>
|
||||
/// Makes the property serializable to/from XML
|
||||
/// </summary>
|
||||
@@ -64,11 +68,12 @@ namespace Barotrauma
|
||||
/// <param name="isSaveable">Is the value saved to XML when serializing.</param>
|
||||
/// <param name="translationTextTag">If set to anything else than null, SerializableEntityEditors will show what the text gets translated to or warn if the text is not found in the language files.
|
||||
/// Setting the value to a non-empty string will let the user select the text from one whose tag starts with the given string (e.g. RoomName. would show all texts with a RoomName.* tag)</param>
|
||||
public Serialize(object defaultValue, bool isSaveable, string translationTextTag = null)
|
||||
public Serialize(object defaultValue, bool isSaveable, string description = "", string translationTextTag = null)
|
||||
{
|
||||
this.defaultValue = defaultValue;
|
||||
this.isSaveable = isSaveable;
|
||||
this.translationTextTag = translationTextTag;
|
||||
this.Description = description;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -684,18 +689,26 @@ namespace Barotrauma
|
||||
{
|
||||
if (subElement.Name.ToString().ToLowerInvariant() != "upgrade") { continue; }
|
||||
var upgradeVersion = new Version(subElement.GetAttributeString("gameversion", "0.0.0.0"));
|
||||
if (savedVersion < upgradeVersion)
|
||||
if (savedVersion >= upgradeVersion) { continue; }
|
||||
foreach (XAttribute attribute in subElement.Attributes())
|
||||
{
|
||||
foreach (XAttribute attribute in subElement.Attributes())
|
||||
string attributeName = attribute.Name.ToString().ToLowerInvariant();
|
||||
if (attributeName == "gameversion") { continue; }
|
||||
if (entity.SerializableProperties.TryGetValue(attributeName, out SerializableProperty property))
|
||||
{
|
||||
string attributeName = attribute.Name.ToString().ToLowerInvariant();
|
||||
if (attributeName == "gameversion") { continue; }
|
||||
if (entity.SerializableProperties.TryGetValue(attributeName, out SerializableProperty property))
|
||||
property.TrySetValue(entity, attribute.Value);
|
||||
}
|
||||
else if (entity is Item item)
|
||||
{
|
||||
foreach (ISerializableEntity component in item.AllPropertyObjects)
|
||||
{
|
||||
property.TrySetValue(entity, attribute.Value);
|
||||
if (component.SerializableProperties.TryGetValue(attributeName, out SerializableProperty componentProperty))
|
||||
{
|
||||
componentProperty.TrySetValue(component, attribute.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user