diff --git a/OpenRA.Editor/Form1.cs b/OpenRA.Editor/Form1.cs index 9745ca53d4..b3ffb39b5e 100644 --- a/OpenRA.Editor/Form1.cs +++ b/OpenRA.Editor/Form1.cs @@ -145,7 +145,7 @@ namespace OpenRA.Editor { Rules.LoadRules(manifest, map); tileset = Rules.TileSets[map.Tileset]; - tilesetRenderer = new TileSetRenderer(tileset, new Size(manifest.TileSize, manifest.TileSize)); + tilesetRenderer = new TileSetRenderer(tileset, manifest.TileSize); var shadowIndex = new int[] { 3, 4 }; var palette = new Palette(FileSystem.Open(tileset.Palette), shadowIndex); diff --git a/OpenRA.Editor/Surface.cs b/OpenRA.Editor/Surface.cs index 793d84145a..5f6f907458 100644 --- a/OpenRA.Editor/Surface.cs +++ b/OpenRA.Editor/Surface.cs @@ -303,14 +303,16 @@ namespace OpenRA.Editor bitmap.UnlockBits(data); if (ShowGrid) + { using (var g = SGraphics.FromImage(bitmap)) { + var ts = Game.modData.Manifest.TileSize; var rect = new Rectangle(0, 0, bitmap.Width, bitmap.Height); - ControlPaint.DrawGrid(g, rect, new Size(2, Game.CellSize), Color.DarkRed); - ControlPaint.DrawGrid(g, rect, new Size(Game.CellSize, 2), Color.DarkRed); - ControlPaint.DrawGrid(g, rect, new Size(Game.CellSize, Game.CellSize), Color.Red); + ControlPaint.DrawGrid(g, rect, new Size(2, ts.Height), Color.DarkRed); + ControlPaint.DrawGrid(g, rect, new Size(ts.Width, 2), Color.DarkRed); + ControlPaint.DrawGrid(g, rect, new Size(ts.Width, ts.Height), Color.Red); } - + } return bitmap; } diff --git a/OpenRA.FileFormats/Manifest.cs b/OpenRA.FileFormats/Manifest.cs index df1f8f7428..6ac3067248 100644 --- a/OpenRA.FileFormats/Manifest.cs +++ b/OpenRA.FileFormats/Manifest.cs @@ -9,6 +9,7 @@ #endregion using System.Collections.Generic; +using System.Drawing; using System.IO; using System.Linq; @@ -28,7 +29,7 @@ namespace OpenRA.FileFormats public readonly MiniYaml LoadScreen; public readonly MiniYaml LobbyDefaults; public readonly Dictionary> Fonts; - public readonly int TileSize = 24; + public readonly Size TileSize = new Size(24, 24); public Manifest(string mod) { @@ -68,7 +69,7 @@ namespace OpenRA.FileFormats int.Parse(x.Value.NodesDict["Size"].Value))); if (yaml.ContainsKey("TileSize")) - TileSize = int.Parse(yaml["TileSize"].Value); + TileSize = FieldLoader.GetValue("TileSize", yaml["TileSize"].Value); // Allow inherited mods to import parent maps. var compat = new List(); diff --git a/OpenRA.Game/Game.cs b/OpenRA.Game/Game.cs index f15c436cac..7b2ee2870e 100644 --- a/OpenRA.Game/Game.cs +++ b/OpenRA.Game/Game.cs @@ -27,8 +27,6 @@ namespace OpenRA { public static class Game { - public static int CellSize { get { return modData.Manifest.TileSize; } } - public static MouseButtonPreference mouseButtonPreference = new MouseButtonPreference(); public static ModData modData; diff --git a/OpenRA.Game/Graphics/WorldRenderer.cs b/OpenRA.Game/Graphics/WorldRenderer.cs index 61f4389544..6085f8d3ad 100644 --- a/OpenRA.Game/Graphics/WorldRenderer.cs +++ b/OpenRA.Game/Graphics/WorldRenderer.cs @@ -235,8 +235,8 @@ namespace OpenRA.Graphics // Conversion between world and screen coordinates public float2 ScreenPosition(WPos pos) { - var c = Game.CellSize / 1024f; - return new float2(c * pos.X, c * (pos.Y - pos.Z)); + var ts = Game.modData.Manifest.TileSize; + return new float2(ts.Width * pos.X / 1024f, ts.Height * (pos.Y - pos.Z) / 1024f); } public int2 ScreenPxPosition(WPos pos) @@ -249,8 +249,8 @@ namespace OpenRA.Graphics // For scaling vectors to pixel sizes in the voxel renderer public float[] ScreenVector(WVec vec) { - var c = Game.CellSize / 1024f; - return new float[] { c * vec.X, c * vec.Y, c * vec.Z, 1 }; + var ts = Game.modData.Manifest.TileSize; + return new float[] { ts.Width * vec.X / 1024f, ts.Height * vec.Y / 1024f, ts.Height * vec.Z / 1024f, 1 }; } public int2 ScreenPxOffset(WVec vec) @@ -262,12 +262,14 @@ namespace OpenRA.Graphics public float ScreenZPosition(WPos pos, int offset) { - return (pos.Y + pos.Z + offset) * Game.CellSize / 1024f; + var ts = Game.modData.Manifest.TileSize; + return (pos.Y + pos.Z + offset) * ts.Height / 1024f; } public WPos Position(int2 screenPx) { - return new WPos(1024 * screenPx.X / Game.CellSize, 1024 * screenPx.Y / Game.CellSize, 0); + var ts = Game.modData.Manifest.TileSize; + return new WPos(1024 * screenPx.X / ts.Width, 1024 * screenPx.Y / ts.Height, 0); } } } diff --git a/OpenRA.Game/Traits/World/ScreenMap.cs b/OpenRA.Game/Traits/World/ScreenMap.cs index 2e7c676cbf..f0d8007bf3 100755 --- a/OpenRA.Game/Traits/World/ScreenMap.cs +++ b/OpenRA.Game/Traits/World/ScreenMap.cs @@ -36,8 +36,9 @@ namespace OpenRA.Traits public ScreenMap(World world, ScreenMapInfo info) { this.info = info; - cols = world.Map.MapSize.X * Game.CellSize / info.BinSize + 1; - rows = world.Map.MapSize.Y * Game.CellSize / info.BinSize + 1; + var ts = Game.modData.Manifest.TileSize; + cols = world.Map.MapSize.X * ts.Width / info.BinSize + 1; + rows = world.Map.MapSize.Y * ts.Height / info.BinSize + 1; frozen = new Cache[]>(InitializeFrozenActors); actors = new Dictionary[rows * cols]; diff --git a/OpenRA.Mods.RA/ShroudRenderer.cs b/OpenRA.Mods.RA/ShroudRenderer.cs index de9c9190e1..bbfaabb782 100644 --- a/OpenRA.Mods.RA/ShroudRenderer.cs +++ b/OpenRA.Mods.RA/ShroudRenderer.cs @@ -95,9 +95,9 @@ namespace OpenRA.Mods.RA // Synthesize unexplored tile if it isn't defined if (!info.Index.Contains(0)) { - var size = new Size(Game.modData.Manifest.TileSize, Game.modData.Manifest.TileSize); - var data = Exts.MakeArray(size.Width * size.Height, _ => (byte)info.ShroudColor); - var s = Game.modData.SheetBuilder.Add(data, size); + var ts = Game.modData.Manifest.TileSize; + var data = Exts.MakeArray(ts.Width * ts.Height, _ => (byte)info.ShroudColor); + var s = Game.modData.SheetBuilder.Add(data, ts); unexploredTile = new Sprite(s.sheet, s.bounds, s.offset, s.channel, info.ShroudBlend); } else diff --git a/OpenRA.Utility/UpgradeRules.cs b/OpenRA.Utility/UpgradeRules.cs index 811f7577de..b05cd084d9 100644 --- a/OpenRA.Utility/UpgradeRules.cs +++ b/OpenRA.Utility/UpgradeRules.cs @@ -43,7 +43,8 @@ namespace OpenRA.Utility static void ConvertPxToRange(ref string input, int scaleMult, int scaleDiv) { var value = int.Parse(input); - var world = value * 1024 * scaleMult / (scaleDiv * Game.CellSize); + var ts = Game.modData.Manifest.TileSize; + var world = value * 1024 * scaleMult / (scaleDiv * ts.Height); var cells = world / 1024; var subcells = world - 1024 * cells; @@ -59,7 +60,8 @@ namespace OpenRA.Utility static void ConvertInt2ToWVec(ref string input) { var offset = FieldLoader.GetValue("(value)", input); - var world = new WVec(offset.X * 1024 / Game.CellSize, offset.Y * 1024 / Game.CellSize, 0); + var ts = Game.modData.Manifest.TileSize; + var world = new WVec(offset.X * 1024 / ts.Width, offset.Y * 1024 / ts.Height, 0); input = world.ToString(); } diff --git a/mods/d2k/mod.yaml b/mods/d2k/mod.yaml index f445a4a54d..cf13825927 100644 --- a/mods/d2k/mod.yaml +++ b/mods/d2k/mod.yaml @@ -91,7 +91,7 @@ Notifications: TileSets: mods/d2k/tilesets/arrakis.yaml -TileSize: 32 +TileSize: 32,32 Music: mods/d2k/music.yaml diff --git a/mods/ts/mod.yaml b/mods/ts/mod.yaml index 251fbe2b23..afa2033382 100644 --- a/mods/ts/mod.yaml +++ b/mods/ts/mod.yaml @@ -134,6 +134,8 @@ Notifications: TileSets: mods/ra/tilesets/interior.yaml +TileSize: 48,24 + Music: mods/ts/music.yaml