Merge pull request #9526 from penev92/tileShapes
Rename TileShape to fit its role better
This commit is contained in:
@@ -42,7 +42,7 @@ namespace OpenRA.Mods.Common.Pathfinder
|
||||
layer = pool.Pop();
|
||||
|
||||
if (layer == null)
|
||||
layer = new CellLayer<CellInfo>(defaultLayer.Shape, defaultLayer.Size);
|
||||
layer = new CellLayer<CellInfo>(defaultLayer.GridType, defaultLayer.Size);
|
||||
layer.CopyValuesFrom(defaultLayer);
|
||||
return layer;
|
||||
}
|
||||
|
||||
@@ -130,11 +130,11 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
tooltipContainer.Value.RemoveTooltip();
|
||||
}
|
||||
|
||||
public int2 ConvertToPreview(CPos cell, TileShape gridType)
|
||||
public int2 ConvertToPreview(CPos cell, MapGridType gridType)
|
||||
{
|
||||
var preview = Preview();
|
||||
var point = cell.ToMPos(gridType);
|
||||
var cellWidth = gridType == TileShape.Diamond ? 2 : 1;
|
||||
var cellWidth = gridType == MapGridType.RectangularIsometric ? 2 : 1;
|
||||
var dx = (int)(previewScale * cellWidth * (point.U - preview.Bounds.Left));
|
||||
var dy = (int)(previewScale * (point.V - preview.Bounds.Top));
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
readonly World world;
|
||||
readonly WorldRenderer worldRenderer;
|
||||
readonly RadarPings radarPings;
|
||||
readonly bool isDiamond;
|
||||
readonly bool isRectangularIsometric;
|
||||
readonly int cellWidth;
|
||||
readonly int previewWidth;
|
||||
readonly int previewHeight;
|
||||
@@ -64,11 +64,11 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
this.worldRenderer = worldRenderer;
|
||||
radarPings = world.WorldActor.TraitOrDefault<RadarPings>();
|
||||
|
||||
isDiamond = world.Map.Grid.Type == TileShape.Diamond;
|
||||
cellWidth = isDiamond ? 2 : 1;
|
||||
isRectangularIsometric = world.Map.Grid.Type == MapGridType.RectangularIsometric;
|
||||
cellWidth = isRectangularIsometric ? 2 : 1;
|
||||
previewWidth = world.Map.MapSize.X;
|
||||
previewHeight = world.Map.MapSize.Y;
|
||||
if (isDiamond)
|
||||
if (isRectangularIsometric)
|
||||
previewWidth = 2 * previewWidth - 1;
|
||||
}
|
||||
|
||||
@@ -153,7 +153,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
fixed (byte* colorBytes = &radarData[0])
|
||||
{
|
||||
var colors = (int*)colorBytes;
|
||||
if (isDiamond)
|
||||
if (isRectangularIsometric)
|
||||
{
|
||||
// Odd rows are shifted right by 1px
|
||||
var dx = uv.V & 1;
|
||||
@@ -189,7 +189,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
var colors = (int*)colorBytes;
|
||||
foreach (var uv in world.Map.Unproject(puv))
|
||||
{
|
||||
if (isDiamond)
|
||||
if (isRectangularIsometric)
|
||||
{
|
||||
// Odd rows are shifted right by 1px
|
||||
var dx = uv.V & 1;
|
||||
@@ -381,7 +381,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
|
||||
var uv = cell.First.ToMPos(world.Map.Grid.Type);
|
||||
var color = cell.Second.ToArgb();
|
||||
if (isDiamond)
|
||||
if (isRectangularIsometric)
|
||||
{
|
||||
// Odd rows are shifted right by 1px
|
||||
var dx = uv.V & 1;
|
||||
@@ -430,7 +430,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
var dy = (int)(previewScale * (uv.V - world.Map.Bounds.Top));
|
||||
|
||||
// Odd rows are shifted right by 1px
|
||||
if (isDiamond && (uv.V & 1) == 1)
|
||||
if (isRectangularIsometric && (uv.V & 1) == 1)
|
||||
dx += 1;
|
||||
|
||||
return new int2(mapRect.X + dx, mapRect.Y + dy);
|
||||
|
||||
@@ -10,8 +10,6 @@
|
||||
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using OpenRA.FileFormats;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Widgets;
|
||||
|
||||
@@ -42,9 +40,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
return;
|
||||
|
||||
var grid = Game.ModData.Manifest.Get<MapGrid>();
|
||||
var ts = grid.TileSize;
|
||||
var shape = grid.Type;
|
||||
bounds = worldRenderer.Theater.TemplateBounds(template, ts, shape);
|
||||
bounds = worldRenderer.Theater.TemplateBounds(template, grid.TileSize, grid.Type);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,7 +69,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
|
||||
var grid = Game.ModData.Manifest.Get<MapGrid>();
|
||||
var ts = grid.TileSize;
|
||||
var shape = grid.Type;
|
||||
var gridType = grid.Type;
|
||||
var scale = GetScale();
|
||||
|
||||
var sb = new Rectangle((int)(scale * bounds.X), (int)(scale * bounds.Y), (int)(scale * bounds.Width), (int)(scale * bounds.Height));
|
||||
@@ -94,8 +90,8 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
var sprite = worldRenderer.Theater.TileSprite(tile, 0);
|
||||
var size = new float2(sprite.Size.X * scale, sprite.Size.Y * scale);
|
||||
|
||||
var u = shape == TileShape.Rectangle ? x : (x - y) / 2f;
|
||||
var v = shape == TileShape.Rectangle ? y : (x + y) / 2f;
|
||||
var u = gridType == MapGridType.Rectangular ? x : (x - y) / 2f;
|
||||
var v = gridType == MapGridType.Rectangular ? y : (x + y) / 2f;
|
||||
var pos = origin + scale * (new float2(u * ts.Width, (v - 0.5f * tileInfo.Height) * ts.Height) - 0.5f * sprite.Size);
|
||||
Game.Renderer.SpriteRenderer.DrawSprite(sprite, pos, worldRenderer.Palette(Palette), size);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user