Merge pull request #9526 from penev92/tileShapes

Rename TileShape to fit its role better
This commit is contained in:
reaperrr
2015-10-26 15:41:09 +01:00
21 changed files with 87 additions and 97 deletions

View File

@@ -20,7 +20,7 @@ namespace OpenRA.Graphics
{
public static Bitmap TerrainBitmap(TileSet tileset, Map map, bool actualSize = false)
{
var isDiamond = map.Grid.Type == TileShape.Diamond;
var isRectangularIsometric = map.Grid.Type == MapGridType.RectangularIsometric;
var b = map.Bounds;
// Fudge the heightmap offset by adding as much extra as we need / can.
@@ -30,7 +30,7 @@ namespace OpenRA.Graphics
var height = b.Height + heightOffset;
var bitmapWidth = width;
if (isDiamond)
if (isRectangularIsometric)
bitmapWidth = 2 * bitmapWidth - 1;
if (!actualSize)
@@ -55,7 +55,7 @@ namespace OpenRA.Graphics
var type = tileset.GetTileInfo(mapTiles[uv]);
var leftColor = type != null ? type.LeftColor : Color.Black;
if (isDiamond)
if (isRectangularIsometric)
{
// Odd rows are shifted right by 1px
var dx = uv.V & 1;
@@ -81,7 +81,7 @@ namespace OpenRA.Graphics
static Bitmap AddStaticResources(TileSet tileset, Map map, Ruleset resourceRules, Bitmap terrainBitmap)
{
var terrain = new Bitmap(terrainBitmap);
var isDiamond = map.Grid.Type == TileShape.Diamond;
var isRectangularIsometric = map.Grid.Type == MapGridType.RectangularIsometric;
var b = map.Bounds;
// Fudge the heightmap offset by adding as much extra as we need / can
@@ -113,7 +113,7 @@ namespace OpenRA.Graphics
continue;
var color = tileset[tileset.GetTerrainIndex(res)].Color.ToArgb();
if (isDiamond)
if (isRectangularIsometric)
{
// Odd rows are shifted right by 1px
var dx = uv.V & 1;

View File

@@ -108,7 +108,7 @@ namespace OpenRA.Graphics
return template.Sprites[start * template.Stride + r.Index];
}
public Rectangle TemplateBounds(TerrainTemplateInfo template, Size tileSize, TileShape tileShape)
public Rectangle TemplateBounds(TerrainTemplateInfo template, Size tileSize, MapGridType mapGrid)
{
Rectangle? templateRect = null;
@@ -125,8 +125,8 @@ namespace OpenRA.Graphics
continue;
var sprite = TileSprite(tile);
var u = tileShape == TileShape.Rectangle ? x : (x - y) / 2f;
var v = tileShape == TileShape.Rectangle ? y : (x + y) / 2f;
var u = mapGrid == MapGridType.Rectangular ? x : (x - y) / 2f;
var v = mapGrid == MapGridType.Rectangular ? y : (x + y) / 2f;
var tl = new float2(u * tileSize.Width, (v - 0.5f * tileInfo.Height) * tileSize.Height) - 0.5f * sprite.Size;
var rect = new Rectangle((int)(tl.X + sprite.Offset.X), (int)(tl.Y + sprite.Offset.Y), (int)sprite.Size.X, (int)sprite.Size.Y);

View File

@@ -9,7 +9,6 @@
#endregion
using System;
using System.Collections;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
@@ -100,7 +99,7 @@ namespace OpenRA.Graphics
// The full map is visible in the editor
var width = map.MapSize.X * grid.TileSize.Width;
var height = map.MapSize.Y * grid.TileSize.Height;
if (wr.World.Map.Grid.Type == TileShape.Diamond)
if (wr.World.Map.Grid.Type == MapGridType.RectangularIsometric)
height /= 2;
mapBounds = new Rectangle(0, 0, width, height);
@@ -240,10 +239,9 @@ namespace OpenRA.Graphics
var tl = (PPos)map.CellContaining(worldRenderer.ProjectedPosition(TopLeft)).ToMPos(map);
var br = (PPos)map.CellContaining(worldRenderer.ProjectedPosition(BottomRight)).ToMPos(map);
// Diamond tile shapes don't have straight edges, and so we need
// an additional cell margin to include the cells that are half
// visible on each edge.
if (map.Grid.Type == TileShape.Diamond)
// RectangularIsometric maps don't have straight edges, and so we need an additional
// cell margin to include the cells that are half visible on each edge.
if (map.Grid.Type == MapGridType.RectangularIsometric)
{
tl = new PPos(tl.U - 1, tl.V - 1);
br = new PPos(br.U + 1, br.V + 1);