Use Manifest.TileSize everywhere.
This commit is contained in:
@@ -63,8 +63,8 @@ namespace OpenRA.Editor
|
|||||||
public void Preview(Surface surface, SGraphics g)
|
public void Preview(Surface surface, SGraphics g)
|
||||||
{
|
{
|
||||||
g.DrawImage(brushTemplate.Bitmap,
|
g.DrawImage(brushTemplate.Bitmap,
|
||||||
surface.TileSet.TileSize * surface.GetBrushLocation().X * surface.Zoom + surface.GetOffset().X,
|
surface.TileSetRenderer.TileSize.Width * surface.GetBrushLocation().X * surface.Zoom + surface.GetOffset().X,
|
||||||
surface.TileSet.TileSize * surface.GetBrushLocation().Y * surface.Zoom + surface.GetOffset().Y,
|
surface.TileSetRenderer.TileSize.Height * surface.GetBrushLocation().Y * surface.Zoom + surface.GetOffset().Y,
|
||||||
brushTemplate.Bitmap.Width * surface.Zoom,
|
brushTemplate.Bitmap.Width * surface.Zoom,
|
||||||
brushTemplate.Bitmap.Height * surface.Zoom);
|
brushTemplate.Bitmap.Height * surface.Zoom);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -258,7 +258,7 @@ namespace OpenRA.Editor
|
|||||||
|
|
||||||
Bitmap RenderChunk(int u, int v)
|
Bitmap RenderChunk(int u, int v)
|
||||||
{
|
{
|
||||||
var bitmap = new Bitmap(ChunkSize * TileSet.TileSize, ChunkSize * TileSet.TileSize);
|
var bitmap = new Bitmap(ChunkSize * TileSetRenderer.TileSize.Width, ChunkSize * TileSetRenderer.TileSize.Height);
|
||||||
|
|
||||||
var data = bitmap.LockBits(bitmap.Bounds(),
|
var data = bitmap.LockBits(bitmap.Bounds(),
|
||||||
ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
|
ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
|
||||||
@@ -275,9 +275,9 @@ namespace OpenRA.Editor
|
|||||||
var tile = TileSetRenderer.Data(tr.type);
|
var tile = TileSetRenderer.Data(tr.type);
|
||||||
var index = (tr.index < tile.Count) ? tr.index : (byte)0;
|
var index = (tr.index < tile.Count) ? tr.index : (byte)0;
|
||||||
var rawImage = tile[index];
|
var rawImage = tile[index];
|
||||||
for (var x = 0; x < TileSet.TileSize; x++)
|
for (var x = 0; x < TileSetRenderer.TileSize.Width; x++)
|
||||||
for (var y = 0; y < TileSet.TileSize; y++)
|
for (var y = 0; y < TileSetRenderer.TileSize.Height; y++)
|
||||||
p[(j * TileSet.TileSize + y) * stride + i * TileSet.TileSize + x] = Palette.GetColor(rawImage[x + TileSet.TileSize * y]).ToArgb();
|
p[(j * TileSetRenderer.TileSize.Width + y) * stride + i * TileSetRenderer.TileSize.Width + x] = Palette.GetColor(rawImage[x + TileSetRenderer.TileSize.Width * y]).ToArgb();
|
||||||
|
|
||||||
if (Map.MapResources.Value[u * ChunkSize + i, v * ChunkSize + j].type != 0)
|
if (Map.MapResources.Value[u * ChunkSize + i, v * ChunkSize + j].type != 0)
|
||||||
{
|
{
|
||||||
@@ -288,12 +288,12 @@ namespace OpenRA.Editor
|
|||||||
int* q = (int*)srcdata.Scan0.ToPointer();
|
int* q = (int*)srcdata.Scan0.ToPointer();
|
||||||
var srcstride = srcdata.Stride >> 2;
|
var srcstride = srcdata.Stride >> 2;
|
||||||
|
|
||||||
for (var x = 0; x < TileSet.TileSize; x++)
|
for (var x = 0; x < TileSetRenderer.TileSize.Width; x++)
|
||||||
for (var y = 0; y < TileSet.TileSize; y++)
|
for (var y = 0; y < TileSetRenderer.TileSize.Height; y++)
|
||||||
{
|
{
|
||||||
var c = q[y * srcstride + x];
|
var c = q[y * srcstride + x];
|
||||||
if ((c & 0xff000000) != 0) /* quick & dirty, i cbf doing real alpha */
|
if ((c & 0xff000000) != 0) /* quick & dirty, i cbf doing real alpha */
|
||||||
p[(j * TileSet.TileSize + y) * stride + i * TileSet.TileSize + x] = c;
|
p[(j * TileSetRenderer.TileSize.Width + y) * stride + i * TileSetRenderer.TileSize.Width + x] = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
resourceImage.UnlockBits(srcdata);
|
resourceImage.UnlockBits(srcdata);
|
||||||
@@ -319,15 +319,15 @@ namespace OpenRA.Editor
|
|||||||
{
|
{
|
||||||
var vX = (int)Math.Floor((mousePos.X - Offset.X) / Zoom);
|
var vX = (int)Math.Floor((mousePos.X - Offset.X) / Zoom);
|
||||||
var vY = (int)Math.Floor((mousePos.Y - Offset.Y) / Zoom);
|
var vY = (int)Math.Floor((mousePos.Y - Offset.Y) / Zoom);
|
||||||
return new CPos(vX / TileSet.TileSize, vY / TileSet.TileSize);
|
return new CPos(vX / TileSetRenderer.TileSize.Width, vY / TileSetRenderer.TileSize.Height);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CPos GetBrushLocationBR()
|
public CPos GetBrushLocationBR()
|
||||||
{
|
{
|
||||||
var vX = (int)Math.Floor((mousePos.X - Offset.X) / Zoom);
|
var vX = (int)Math.Floor((mousePos.X - Offset.X) / Zoom);
|
||||||
var vY = (int)Math.Floor((mousePos.Y - Offset.Y) / Zoom);
|
var vY = (int)Math.Floor((mousePos.Y - Offset.Y) / Zoom);
|
||||||
return new CPos((vX + TileSet.TileSize - 1) / TileSet.TileSize,
|
return new CPos((vX + TileSetRenderer.TileSize.Width - 1) / TileSetRenderer.TileSize.Width,
|
||||||
(vY + TileSet.TileSize - 1) / TileSet.TileSize);
|
(vY + TileSetRenderer.TileSize.Height - 1) / TileSetRenderer.TileSize.Height);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DrawActor(SGraphics g, CPos p, ActorTemplate t, ColorPalette cp)
|
public void DrawActor(SGraphics g, CPos p, ActorTemplate t, ColorPalette cp)
|
||||||
@@ -341,11 +341,11 @@ namespace OpenRA.Editor
|
|||||||
|
|
||||||
float2 GetDrawPosition(CPos location, Bitmap bmp, bool centered)
|
float2 GetDrawPosition(CPos location, Bitmap bmp, bool centered)
|
||||||
{
|
{
|
||||||
float offsetX = centered ? bmp.Width / 2 - TileSet.TileSize / 2 : 0;
|
float offsetX = centered ? bmp.Width / 2 - TileSetRenderer.TileSize.Width / 2 : 0;
|
||||||
float drawX = TileSet.TileSize * location.X * Zoom + Offset.X - offsetX;
|
float drawX = TileSetRenderer.TileSize.Width * location.X * Zoom + Offset.X - offsetX;
|
||||||
|
|
||||||
float offsetY = centered ? bmp.Height / 2 - TileSet.TileSize / 2 : 0;
|
float offsetY = centered ? bmp.Height / 2 - TileSetRenderer.TileSize.Height / 2 : 0;
|
||||||
float drawY = TileSet.TileSize * location.Y * Zoom + Offset.Y - offsetY;
|
float drawY = TileSetRenderer.TileSize.Height * location.Y * Zoom + Offset.Y - offsetY;
|
||||||
|
|
||||||
return new float2(drawX, drawY);
|
return new float2(drawX, drawY);
|
||||||
}
|
}
|
||||||
@@ -413,24 +413,24 @@ namespace OpenRA.Editor
|
|||||||
|
|
||||||
var bmp = Chunks[x];
|
var bmp = Chunks[x];
|
||||||
|
|
||||||
var drawX = TileSet.TileSize * (float)ChunkSize * (float)x.X * Zoom + Offset.X;
|
var drawX = TileSetRenderer.TileSize.Width * (float)ChunkSize * (float)x.X * Zoom + Offset.X;
|
||||||
var drawY = TileSet.TileSize * (float)ChunkSize * (float)x.Y * Zoom + Offset.Y;
|
var drawY = TileSetRenderer.TileSize.Height * (float)ChunkSize * (float)x.Y * Zoom + Offset.Y;
|
||||||
RectangleF sourceRect = new RectangleF(0, 0, bmp.Width, bmp.Height);
|
RectangleF sourceRect = new RectangleF(0, 0, bmp.Width, bmp.Height);
|
||||||
RectangleF destRect = new RectangleF(drawX, drawY, bmp.Width * Zoom, bmp.Height * Zoom);
|
RectangleF destRect = new RectangleF(drawX, drawY, bmp.Width * Zoom, bmp.Height * Zoom);
|
||||||
e.Graphics.DrawImage(bmp, destRect, sourceRect, GraphicsUnit.Pixel);
|
e.Graphics.DrawImage(bmp, destRect, sourceRect, GraphicsUnit.Pixel);
|
||||||
}
|
}
|
||||||
|
|
||||||
e.Graphics.DrawRectangle(CordonPen,
|
e.Graphics.DrawRectangle(CordonPen,
|
||||||
Map.Bounds.Left * TileSet.TileSize * Zoom + Offset.X,
|
Map.Bounds.Left * TileSetRenderer.TileSize.Width * Zoom + Offset.X,
|
||||||
Map.Bounds.Top * TileSet.TileSize * Zoom + Offset.Y,
|
Map.Bounds.Top * TileSetRenderer.TileSize.Height * Zoom + Offset.Y,
|
||||||
Map.Bounds.Width * TileSet.TileSize * Zoom,
|
Map.Bounds.Width * TileSetRenderer.TileSize.Width * Zoom,
|
||||||
Map.Bounds.Height * TileSet.TileSize * Zoom);
|
Map.Bounds.Height * TileSetRenderer.TileSize.Height * Zoom);
|
||||||
|
|
||||||
e.Graphics.DrawRectangle(SelectionPen,
|
e.Graphics.DrawRectangle(SelectionPen,
|
||||||
(SelectionStart.X * TileSet.TileSize * Zoom) + Offset.X,
|
(SelectionStart.X * TileSetRenderer.TileSize.Width * Zoom) + Offset.X,
|
||||||
(SelectionStart.Y * TileSet.TileSize * Zoom) + Offset.Y,
|
(SelectionStart.Y * TileSetRenderer.TileSize.Height * Zoom) + Offset.Y,
|
||||||
(SelectionEnd - SelectionStart).X * TileSet.TileSize * Zoom,
|
(SelectionEnd - SelectionStart).X * TileSetRenderer.TileSize.Width * Zoom,
|
||||||
(SelectionEnd - SelectionStart).Y * TileSet.TileSize * Zoom);
|
(SelectionEnd - SelectionStart).Y * TileSetRenderer.TileSize.Height * Zoom);
|
||||||
|
|
||||||
if (IsPaste)
|
if (IsPaste)
|
||||||
{
|
{
|
||||||
@@ -439,10 +439,10 @@ namespace OpenRA.Editor
|
|||||||
var height = Math.Abs((SelectionStart - SelectionEnd).Y);
|
var height = Math.Abs((SelectionStart - SelectionEnd).Y);
|
||||||
|
|
||||||
e.Graphics.DrawRectangle(PastePen,
|
e.Graphics.DrawRectangle(PastePen,
|
||||||
(loc.X * TileSet.TileSize * Zoom) + Offset.X,
|
(loc.X * TileSetRenderer.TileSize.Width * Zoom) + Offset.X,
|
||||||
(loc.Y * TileSet.TileSize * Zoom) + Offset.Y,
|
(loc.Y * TileSetRenderer.TileSize.Height * Zoom) + Offset.Y,
|
||||||
width * (TileSet.TileSize * Zoom),
|
width * (TileSetRenderer.TileSize.Width * Zoom),
|
||||||
height * (TileSet.TileSize * Zoom));
|
height * (TileSetRenderer.TileSize.Height * Zoom));
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var ar in Map.Actors.Value)
|
foreach (var ar in Map.Actors.Value)
|
||||||
@@ -458,8 +458,8 @@ namespace OpenRA.Editor
|
|||||||
foreach (var ar in Map.Actors.Value)
|
foreach (var ar in Map.Actors.Value)
|
||||||
if (!ar.Key.StartsWith("Actor")) // if it has a custom name
|
if (!ar.Key.StartsWith("Actor")) // if it has a custom name
|
||||||
e.Graphics.DrawStringContrast(Font, ar.Key,
|
e.Graphics.DrawStringContrast(Font, ar.Key,
|
||||||
(int)(ar.Value.Location().X * TileSet.TileSize * Zoom + Offset.X),
|
(int)(ar.Value.Location().X * TileSetRenderer.TileSize.Width * Zoom + Offset.X),
|
||||||
(int)(ar.Value.Location().Y * TileSet.TileSize * Zoom + Offset.Y),
|
(int)(ar.Value.Location().Y * TileSetRenderer.TileSize.Height * Zoom + Offset.Y),
|
||||||
Brushes.White,
|
Brushes.White,
|
||||||
Brushes.Black);
|
Brushes.Black);
|
||||||
|
|
||||||
@@ -469,7 +469,7 @@ namespace OpenRA.Editor
|
|||||||
{
|
{
|
||||||
if (i % 8 == 0)
|
if (i % 8 == 0)
|
||||||
{
|
{
|
||||||
PointF point = new PointF(i * TileSet.TileSize * Zoom + Offset.X, (Map.Bounds.Top - 8) * TileSet.TileSize * Zoom + Offset.Y);
|
PointF point = new PointF(i * TileSetRenderer.TileSize.Width * Zoom + Offset.X, (Map.Bounds.Top - 8) * TileSetRenderer.TileSize.Height * Zoom + Offset.Y);
|
||||||
e.Graphics.DrawString((i - Map.Bounds.Left).ToString(), MarkerFont, TextBrush, point);
|
e.Graphics.DrawString((i - Map.Bounds.Left).ToString(), MarkerFont, TextBrush, point);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -478,7 +478,7 @@ namespace OpenRA.Editor
|
|||||||
{
|
{
|
||||||
if (i % 8 == 0)
|
if (i % 8 == 0)
|
||||||
{
|
{
|
||||||
PointF point = new PointF((Map.Bounds.Left - 8) * TileSet.TileSize * Zoom + Offset.X, i * TileSet.TileSize * Zoom + Offset.Y);
|
PointF point = new PointF((Map.Bounds.Left - 8) * TileSetRenderer.TileSize.Width * Zoom + Offset.X, i * TileSetRenderer.TileSize.Height * Zoom + Offset.Y);
|
||||||
e.Graphics.DrawString((i - Map.Bounds.Left).ToString(), MarkerFont, TextBrush, point);
|
e.Graphics.DrawString((i - Map.Bounds.Left).ToString(), MarkerFont, TextBrush, point);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,12 +21,12 @@ namespace OpenRA.FileFormats
|
|||||||
{
|
{
|
||||||
public TileSet TileSet;
|
public TileSet TileSet;
|
||||||
Dictionary<ushort, List<byte[]>> templates;
|
Dictionary<ushort, List<byte[]>> templates;
|
||||||
Size tileSize;
|
public Size TileSize;
|
||||||
|
|
||||||
public TileSetRenderer(TileSet tileset, Size tileSize)
|
public TileSetRenderer(TileSet tileset, Size tileSize)
|
||||||
{
|
{
|
||||||
this.TileSet = tileset;
|
this.TileSet = tileset;
|
||||||
this.tileSize = tileSize;
|
this.TileSize = tileSize;
|
||||||
|
|
||||||
templates = new Dictionary<ushort, List<byte[]>>();
|
templates = new Dictionary<ushort, List<byte[]>>();
|
||||||
|
|
||||||
@@ -40,7 +40,7 @@ namespace OpenRA.FileFormats
|
|||||||
var template = TileSet.Templates[id];
|
var template = TileSet.Templates[id];
|
||||||
var templateData = templates[id];
|
var templateData = templates[id];
|
||||||
|
|
||||||
var bitmap = new Bitmap(tileSize.Width * template.Size.X, tileSize.Height * template.Size.Y,
|
var bitmap = new Bitmap(TileSize.Width * template.Size.X, TileSize.Height * template.Size.Y,
|
||||||
PixelFormat.Format8bppIndexed);
|
PixelFormat.Format8bppIndexed);
|
||||||
|
|
||||||
bitmap.Palette = p.AsSystemPalette();
|
bitmap.Palette = p.AsSystemPalette();
|
||||||
@@ -58,15 +58,15 @@ namespace OpenRA.FileFormats
|
|||||||
if (templateData[u + v * template.Size.X] != null)
|
if (templateData[u + v * template.Size.X] != null)
|
||||||
{
|
{
|
||||||
var rawImage = templateData[u + v * template.Size.X];
|
var rawImage = templateData[u + v * template.Size.X];
|
||||||
for (var i = 0; i < tileSize.Width; i++)
|
for (var i = 0; i < TileSize.Width; i++)
|
||||||
for (var j = 0; j < tileSize.Height; j++)
|
for (var j = 0; j < TileSize.Height; j++)
|
||||||
q[(v * tileSize.Width + j) * stride + u * tileSize.Width + i] = rawImage[i + tileSize.Width * j];
|
q[(v * TileSize.Width + j) * stride + u * TileSize.Width + i] = rawImage[i + TileSize.Width * j];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (var i = 0; i < tileSize.Width; i++)
|
for (var i = 0; i < TileSize.Width; i++)
|
||||||
for (var j = 0; j < tileSize.Height; j++)
|
for (var j = 0; j < TileSize.Height; j++)
|
||||||
q[(v * tileSize.Width + j) * stride + u * tileSize.Width + i] = 0;
|
q[(v * TileSize.Width + j) * stride + u * TileSize.Width + i] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -79,7 +79,6 @@ namespace OpenRA.FileFormats
|
|||||||
public string Id;
|
public string Id;
|
||||||
public string Palette;
|
public string Palette;
|
||||||
public string PlayerPalette;
|
public string PlayerPalette;
|
||||||
public int TileSize = 24;
|
|
||||||
public string[] Extensions;
|
public string[] Extensions;
|
||||||
public int WaterPaletteRotationBase = 0x60;
|
public int WaterPaletteRotationBase = 0x60;
|
||||||
public Dictionary<string, TerrainTypeInfo> Terrain = new Dictionary<string, TerrainTypeInfo>();
|
public Dictionary<string, TerrainTypeInfo> Terrain = new Dictionary<string, TerrainTypeInfo>();
|
||||||
|
|||||||
@@ -366,7 +366,6 @@ namespace OpenRA.TilesetBuilder
|
|||||||
{
|
{
|
||||||
Name = tilesetName,
|
Name = tilesetName,
|
||||||
Id = tilesetID.ToUpper(),
|
Id = tilesetID.ToUpper(),
|
||||||
TileSize = size,
|
|
||||||
Palette = tilesetPalette.ToLower(),
|
Palette = tilesetPalette.ToLower(),
|
||||||
Extensions = new string[] { ext[0], ext[1] }
|
Extensions = new string[] { ext[0], ext[1] }
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
General:
|
General:
|
||||||
Name: Arrakis
|
Name: Arrakis
|
||||||
TileSize: 32
|
|
||||||
Id: ARRAKIS
|
Id: ARRAKIS
|
||||||
Palette: d2k.pal
|
Palette: d2k.pal
|
||||||
Extensions: .bas,.bat,.bgb,.ice,.tre,.was,.ext,.shp
|
Extensions: .bas,.bat,.bgb,.ice,.tre,.was,.ext,.shp
|
||||||
|
|||||||
Reference in New Issue
Block a user