Drop TopLeft and BottomRight from MapFormat 5. Use Bounds directly.
This commit is contained in:
@@ -132,8 +132,7 @@ namespace OpenRA.Editor
|
|||||||
Map.Tileset = Truncate(map.GetValue("Theater", "TEMPERAT"), 8);
|
Map.Tileset = Truncate(map.GetValue("Theater", "TEMPERAT"), 8);
|
||||||
Map.MapSize.X = MapSize;
|
Map.MapSize.X = MapSize;
|
||||||
Map.MapSize.Y = MapSize;
|
Map.MapSize.Y = MapSize;
|
||||||
Map.TopLeft = new int2(XOffset, YOffset);
|
Map.Bounds = Rectangle.FromLTRB(XOffset, YOffset, XOffset + Width, YOffset + Height);
|
||||||
Map.BottomRight = new int2(XOffset + Width, YOffset + Height);
|
|
||||||
Map.Selectable = true;
|
Map.Selectable = true;
|
||||||
|
|
||||||
if (legacyMapFormat == IniMapFormat.RedAlert)
|
if (legacyMapFormat == IniMapFormat.RedAlert)
|
||||||
|
|||||||
@@ -178,7 +178,12 @@ namespace OpenRA.FileFormats
|
|||||||
yy = res * (parts[1].Contains('%') ? 0.01f : 1f);
|
yy = res * (parts[1].Contains('%') ? 0.01f : 1f);
|
||||||
return new float2(xx, yy);
|
return new float2(xx, yy);
|
||||||
}
|
}
|
||||||
|
else if (fieldType == typeof(Rectangle))
|
||||||
|
{
|
||||||
|
var parts = x.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
return new Rectangle(int.Parse(parts[0]), int.Parse(parts[1]), int.Parse(parts[2]), int.Parse(parts[3]));
|
||||||
|
}
|
||||||
|
|
||||||
UnknownFieldAction("[Type] {0}".F(x),fieldType);
|
UnknownFieldAction("[Type] {0}".F(x),fieldType);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -295,7 +300,12 @@ namespace OpenRA.FileFormats
|
|||||||
((int)c.G).Clamp(0, 255),
|
((int)c.G).Clamp(0, 255),
|
||||||
((int)c.B).Clamp(0, 255));
|
((int)c.B).Clamp(0, 255));
|
||||||
}
|
}
|
||||||
|
else if (f.FieldType == typeof(Rectangle))
|
||||||
|
{
|
||||||
|
var r = (Rectangle)v;
|
||||||
|
return "{0},{1},{2},{3}".F(r.X, r.Y, r.Width, r.Height);
|
||||||
|
}
|
||||||
|
|
||||||
return f.FieldType.IsArray
|
return f.FieldType.IsArray
|
||||||
? string.Join(",", ((Array)v).OfType<object>().Select(a => a.ToString()).ToArray())
|
? string.Join(",", ((Array)v).OfType<object>().Select(a => a.ToString()).ToArray())
|
||||||
: v.ToString();
|
: v.ToString();
|
||||||
|
|||||||
@@ -37,14 +37,14 @@ namespace OpenRA.FileFormats
|
|||||||
[FieldLoader.Load] public string[] StartPoints;
|
[FieldLoader.Load] public string[] StartPoints;
|
||||||
public int PlayerCount { get { return StartPoints.Count(); } }
|
public int PlayerCount { get { return StartPoints.Count(); } }
|
||||||
[FieldLoader.LoadUsing( "LoadWaypoints" )]
|
[FieldLoader.LoadUsing( "LoadWaypoints" )]
|
||||||
public Dictionary<string, int2> Waypoints = new Dictionary<string, int2>();
|
public Dictionary<string, int2> Waypoints = new Dictionary<string, int2>();
|
||||||
|
public IEnumerable<int2> SpawnPoints{ get { return Waypoints.Where(kv => StartPoints.Contains(kv.Key)).Select(kv => kv.Value); } }
|
||||||
|
|
||||||
public IEnumerable<int2> SpawnPoints{ get { return Waypoints.Where(kv => StartPoints.Contains(kv.Key)).Select(kv => kv.Value); } }
|
|
||||||
|
|
||||||
|
[FieldLoader.Load] public Rectangle Bounds;
|
||||||
|
|
||||||
|
// TODO: Remove these once we stop supporting MapFormat < 5
|
||||||
[FieldLoader.Load] public int2 TopLeft;
|
[FieldLoader.Load] public int2 TopLeft;
|
||||||
[FieldLoader.Load] public int2 BottomRight;
|
[FieldLoader.Load] public int2 BottomRight;
|
||||||
public Rectangle Bounds;
|
|
||||||
|
|
||||||
public MapStub() {} // Hack for the editor - not used for anything important
|
public MapStub() {} // Hack for the editor - not used for anything important
|
||||||
|
|
||||||
@@ -55,12 +55,14 @@ namespace OpenRA.FileFormats
|
|||||||
var yaml = MiniYaml.FromStream(Container.GetContent("map.yaml"));
|
var yaml = MiniYaml.FromStream(Container.GetContent("map.yaml"));
|
||||||
FieldLoader.Load( this, new MiniYaml( null, yaml ) );
|
FieldLoader.Load( this, new MiniYaml( null, yaml ) );
|
||||||
|
|
||||||
Bounds = Rectangle.FromLTRB(TopLeft.X, TopLeft.Y, BottomRight.X, BottomRight.Y);
|
|
||||||
Uid = ComputeHash();
|
Uid = ComputeHash();
|
||||||
|
|
||||||
// Upgrade maps to define StartPoints
|
// Upgrade maps to define StartPoints
|
||||||
if (MapFormat < 5)
|
if (MapFormat < 5)
|
||||||
|
{
|
||||||
StartPoints = Waypoints.Select(kv => kv.Key).ToArray();
|
StartPoints = Waypoints.Select(kv => kv.Key).ToArray();
|
||||||
|
Bounds = Rectangle.FromLTRB(TopLeft.X, TopLeft.Y, BottomRight.X, BottomRight.Y);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
string ComputeHash()
|
string ComputeHash()
|
||||||
|
|||||||
@@ -236,8 +236,7 @@ namespace OpenRA
|
|||||||
"Author",
|
"Author",
|
||||||
"Tileset",
|
"Tileset",
|
||||||
"MapSize",
|
"MapSize",
|
||||||
"TopLeft",
|
"Bounds",
|
||||||
"BottomRight",
|
|
||||||
"UseAsShellmap",
|
"UseAsShellmap",
|
||||||
"Type",
|
"Type",
|
||||||
"StartPoints"
|
"StartPoints"
|
||||||
@@ -394,9 +393,7 @@ namespace OpenRA
|
|||||||
|
|
||||||
public void ResizeCordon(int left, int top, int right, int bottom)
|
public void ResizeCordon(int left, int top, int right, int bottom)
|
||||||
{
|
{
|
||||||
TopLeft = new int2(left, top);
|
Bounds = Rectangle.FromLTRB(left, top, right, bottom);
|
||||||
BottomRight = new int2(right, bottom);
|
|
||||||
Bounds = Rectangle.FromLTRB(TopLeft.X, TopLeft.Y, BottomRight.X, BottomRight.Y);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user