Extract tile overlays into a shp instead of rolling our own in code; Remove UIOverlay. Fixes #1061.

This commit is contained in:
Paul Chote
2011-07-27 21:17:24 +12:00
parent 08ed7f0316
commit c84f53c10d
10 changed files with 35 additions and 56 deletions

View File

@@ -22,8 +22,6 @@ namespace OpenRA.Graphics
public readonly World world;
internal readonly TerrainRenderer terrainRenderer;
internal readonly ShroudRenderer shroudRenderer;
public readonly UiOverlay uiOverlay;
internal readonly HardwarePalette palette;
internal WorldRenderer(World world)
@@ -35,7 +33,6 @@ namespace OpenRA.Graphics
terrainRenderer = new TerrainRenderer(world, this);
shroudRenderer = new ShroudRenderer(world);
uiOverlay = new UiOverlay();
}
public int GetPaletteIndex(string name) { return palette.GetPaletteIndex(name); }

View File

@@ -137,7 +137,6 @@
<Compile Include="Traits\TraitsInterfaces.cs" />
<Compile Include="Network\UnitOrders.cs" />
<Compile Include="Traits\Util.cs" />
<Compile Include="UiOverlay.cs" />
<Compile Include="Graphics\Util.cs" />
<Compile Include="Graphics\Viewport.cs" />
<Compile Include="Orders\UnitOrderGenerator.cs" />

View File

@@ -1,44 +0,0 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
*/
#endregion
using System.Collections.Generic;
using System.Drawing;
using OpenRA.Graphics;
namespace OpenRA
{
public class UiOverlay
{
Sprite buildOk, buildBlocked;
public UiOverlay()
{
buildOk = SynthesizeTile(0x0f);
buildBlocked = SynthesizeTile(0x08);
}
public static Sprite SynthesizeTile(byte paletteIndex)
{
byte[] data = new byte[Game.CellSize * Game.CellSize];
for (int i = 0; i < Game.CellSize; i++)
for (int j = 0; j < Game.CellSize; j++)
data[i * Game.CellSize + j] = ((i+j) % 4 != 0) ? (byte)0 : paletteIndex;
return Game.modData.SheetBuilder.Add(data, new Size(Game.CellSize, Game.CellSize));
}
public void DrawGrid( WorldRenderer wr, Dictionary<int2, bool> cells )
{
foreach( var c in cells )
( c.Value ? buildOk : buildBlocked ).DrawAt( wr, Game.CellSize * c.Key, "terrain" );
}
}
}