(667564ff6) Fixed item scale not being saved and item rect not being scaled according to the item's scale. Closes #1547
This commit is contained in:
@@ -71,6 +71,8 @@ namespace Barotrauma
|
|||||||
private Inventory parentInventory;
|
private Inventory parentInventory;
|
||||||
private Inventory ownInventory;
|
private Inventory ownInventory;
|
||||||
|
|
||||||
|
private Rectangle defaultRect;
|
||||||
|
|
||||||
private Dictionary<string, Connection> connections;
|
private Dictionary<string, Connection> connections;
|
||||||
|
|
||||||
private List<Repairable> repairables;
|
private List<Repairable> repairables;
|
||||||
@@ -198,6 +200,26 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private float scale = 1.0f;
|
||||||
|
public override float Scale
|
||||||
|
{
|
||||||
|
get { return scale; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (scale == value) { return; }
|
||||||
|
scale = MathHelper.Clamp(value, 0.1f, 10.0f);
|
||||||
|
|
||||||
|
float relativeScale = scale / prefab.Scale;
|
||||||
|
|
||||||
|
if (!ResizeHorizontal || !ResizeVertical)
|
||||||
|
{
|
||||||
|
int newWidth = ResizeHorizontal ? rect.Width : (int)(defaultRect.Width * relativeScale);
|
||||||
|
int newHeight = ResizeVertical ? rect.Height : (int)(defaultRect.Height * relativeScale);
|
||||||
|
Rect = new Rectangle(rect.X, rect.Y, newWidth, newHeight);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public float PositionUpdateInterval
|
public float PositionUpdateInterval
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
@@ -500,6 +522,7 @@ namespace Barotrauma
|
|||||||
tags = new HashSet<string>();
|
tags = new HashSet<string>();
|
||||||
repairables = new List<Repairable>();
|
repairables = new List<Repairable>();
|
||||||
|
|
||||||
|
defaultRect = newRect;
|
||||||
rect = newRect;
|
rect = newRect;
|
||||||
|
|
||||||
condition = itemPrefab.Health;
|
condition = itemPrefab.Health;
|
||||||
@@ -634,7 +657,10 @@ namespace Barotrauma
|
|||||||
|
|
||||||
public override MapEntity Clone()
|
public override MapEntity Clone()
|
||||||
{
|
{
|
||||||
Item clone = new Item(rect, Prefab, Submarine, callOnItemLoaded: false);
|
Item clone = new Item(rect, Prefab, Submarine, callOnItemLoaded: false)
|
||||||
|
{
|
||||||
|
defaultRect = defaultRect
|
||||||
|
};
|
||||||
foreach (KeyValuePair<string, SerializableProperty> property in SerializableProperties)
|
foreach (KeyValuePair<string, SerializableProperty> property in SerializableProperties)
|
||||||
{
|
{
|
||||||
if (!property.Value.Attributes.OfType<Editable>().Any()) continue;
|
if (!property.Value.Attributes.OfType<Editable>().Any()) continue;
|
||||||
@@ -2056,7 +2082,7 @@ namespace Barotrauma
|
|||||||
element.Add(new XAttribute("rect",
|
element.Add(new XAttribute("rect",
|
||||||
(int)(rect.X - subPosition.X) + "," +
|
(int)(rect.X - subPosition.X) + "," +
|
||||||
(int)(rect.Y - subPosition.Y) + "," +
|
(int)(rect.Y - subPosition.Y) + "," +
|
||||||
rect.Width + "," + rect.Height));
|
defaultRect.Width + "," + defaultRect.Height));
|
||||||
|
|
||||||
if (linkedTo != null && linkedTo.Count > 0)
|
if (linkedTo != null && linkedTo.Count > 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -555,7 +555,7 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[Serialize(1f, false), Editable(0.1f, 10f, DecimalCount = 3, ValueStep = 0.1f)]
|
[Serialize(1f, true), Editable(0.1f, 10f, DecimalCount = 3, ValueStep = 0.1f)]
|
||||||
public virtual float Scale { get; set; } = 1;
|
public virtual float Scale { get; set; } = 1;
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user