Extract tile overlays into a shp instead of rolling our own in code; Remove UIOverlay. Fixes #1061.
This commit is contained in:
@@ -22,8 +22,6 @@ namespace OpenRA.Graphics
|
|||||||
public readonly World world;
|
public readonly World world;
|
||||||
internal readonly TerrainRenderer terrainRenderer;
|
internal readonly TerrainRenderer terrainRenderer;
|
||||||
internal readonly ShroudRenderer shroudRenderer;
|
internal readonly ShroudRenderer shroudRenderer;
|
||||||
|
|
||||||
public readonly UiOverlay uiOverlay;
|
|
||||||
internal readonly HardwarePalette palette;
|
internal readonly HardwarePalette palette;
|
||||||
|
|
||||||
internal WorldRenderer(World world)
|
internal WorldRenderer(World world)
|
||||||
@@ -35,7 +33,6 @@ namespace OpenRA.Graphics
|
|||||||
|
|
||||||
terrainRenderer = new TerrainRenderer(world, this);
|
terrainRenderer = new TerrainRenderer(world, this);
|
||||||
shroudRenderer = new ShroudRenderer(world);
|
shroudRenderer = new ShroudRenderer(world);
|
||||||
uiOverlay = new UiOverlay();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int GetPaletteIndex(string name) { return palette.GetPaletteIndex(name); }
|
public int GetPaletteIndex(string name) { return palette.GetPaletteIndex(name); }
|
||||||
|
|||||||
@@ -137,7 +137,6 @@
|
|||||||
<Compile Include="Traits\TraitsInterfaces.cs" />
|
<Compile Include="Traits\TraitsInterfaces.cs" />
|
||||||
<Compile Include="Network\UnitOrders.cs" />
|
<Compile Include="Network\UnitOrders.cs" />
|
||||||
<Compile Include="Traits\Util.cs" />
|
<Compile Include="Traits\Util.cs" />
|
||||||
<Compile Include="UiOverlay.cs" />
|
|
||||||
<Compile Include="Graphics\Util.cs" />
|
<Compile Include="Graphics\Util.cs" />
|
||||||
<Compile Include="Graphics\Viewport.cs" />
|
<Compile Include="Graphics\Viewport.cs" />
|
||||||
<Compile Include="Orders\UnitOrderGenerator.cs" />
|
<Compile Include="Orders\UnitOrderGenerator.cs" />
|
||||||
|
|||||||
@@ -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" );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -23,6 +23,7 @@ namespace OpenRA.Mods.RA.Orders
|
|||||||
readonly string Building;
|
readonly string Building;
|
||||||
readonly IEnumerable<Renderable> Preview;
|
readonly IEnumerable<Renderable> Preview;
|
||||||
BuildingInfo BuildingInfo { get { return Rules.Info[ Building ].Traits.Get<BuildingInfo>(); } }
|
BuildingInfo BuildingInfo { get { return Rules.Info[ Building ].Traits.Get<BuildingInfo>(); } }
|
||||||
|
Sprite buildOk, buildBlocked;
|
||||||
|
|
||||||
public PlaceBuildingOrderGenerator(Actor producer, string name)
|
public PlaceBuildingOrderGenerator(Actor producer, string name)
|
||||||
{
|
{
|
||||||
@@ -31,6 +32,9 @@ namespace OpenRA.Mods.RA.Orders
|
|||||||
|
|
||||||
Preview = Rules.Info[Building].Traits.Get<RenderBuildingInfo>()
|
Preview = Rules.Info[Building].Traits.Get<RenderBuildingInfo>()
|
||||||
.RenderPreview(Rules.Info[Building], producer.Owner);
|
.RenderPreview(Rules.Info[Building], producer.Owner);
|
||||||
|
|
||||||
|
buildOk = SequenceProvider.GetSequence("overlay", "build-valid").GetSprite(0);
|
||||||
|
buildBlocked = SequenceProvider.GetSequence("overlay", "build-invalid").GetSprite(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<Order> Order(World world, int2 xy, MouseInput mi)
|
public IEnumerable<Order> Order(World world, int2 xy, MouseInput mi)
|
||||||
@@ -96,7 +100,8 @@ namespace OpenRA.Mods.RA.Orders
|
|||||||
cells.Add( t, isCloseEnough && world.IsCellBuildable(t, BuildingInfo.WaterBound) && res.GetResource(t) == null );
|
cells.Add( t, isCloseEnough && world.IsCellBuildable(t, BuildingInfo.WaterBound) && res.GetResource(t) == null );
|
||||||
}
|
}
|
||||||
|
|
||||||
wr.uiOverlay.DrawGrid( wr, cells );
|
foreach( var c in cells )
|
||||||
|
( c.Value ? buildOk : buildBlocked ).DrawAt( wr, Game.CellSize * c.Key, "terrain" );
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetCursor(World world, int2 xy, MouseInput mi) { return "default"; }
|
public string GetCursor(World world, int2 xy, MouseInput mi) { return "default"; }
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ namespace OpenRA.Mods.RA
|
|||||||
this.order = order;
|
this.order = order;
|
||||||
this.power = power;
|
this.power = power;
|
||||||
this.range = (power.Info as ChronoshiftPowerInfo).Range;
|
this.range = (power.Info as ChronoshiftPowerInfo).Range;
|
||||||
tile = UiOverlay.SynthesizeTile(0x04);
|
tile = SequenceProvider.GetSequence("overlay", "target-select").GetSprite(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<Order> Order(World world, int2 xy, MouseInput mi)
|
public IEnumerable<Order> Order(World world, int2 xy, MouseInput mi)
|
||||||
@@ -142,10 +142,9 @@ namespace OpenRA.Mods.RA
|
|||||||
this.sourceLocation = sourceLocation;
|
this.sourceLocation = sourceLocation;
|
||||||
this.range = (power.Info as ChronoshiftPowerInfo).Range;
|
this.range = (power.Info as ChronoshiftPowerInfo).Range;
|
||||||
|
|
||||||
// todo: this burns up more texture space every time someone uses chronoshift.
|
validTile = SequenceProvider.GetSequence("overlay", "target-valid").GetSprite(0);
|
||||||
validTile = UiOverlay.SynthesizeTile(0x0f);
|
invalidTile = SequenceProvider.GetSequence("overlay", "target-invalid").GetSprite(0);
|
||||||
invalidTile = UiOverlay.SynthesizeTile(0x08);
|
sourceTile = SequenceProvider.GetSequence("overlay", "target-select").GetSprite(0);
|
||||||
sourceTile = UiOverlay.SynthesizeTile(0x04);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<Order> Order(World world, int2 xy, MouseInput mi)
|
public IEnumerable<Order> Order(World world, int2 xy, MouseInput mi)
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ namespace OpenRA.Mods.RA
|
|||||||
this.order = order;
|
this.order = order;
|
||||||
this.power = power;
|
this.power = power;
|
||||||
this.range = (power.Info as IronCurtainPowerInfo).Range;
|
this.range = (power.Info as IronCurtainPowerInfo).Range;
|
||||||
tile = UiOverlay.SynthesizeTile(0x04);
|
tile = SequenceProvider.GetSequence("overlay", "target-select").GetSprite(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<Order> Order(World world, int2 xy, MouseInput mi)
|
public IEnumerable<Order> Order(World world, int2 xy, MouseInput mi)
|
||||||
|
|||||||
BIN
mods/cnc/bits/overlay.shp
Normal file
BIN
mods/cnc/bits/overlay.shp
Normal file
Binary file not shown.
@@ -212,3 +212,15 @@ pips:
|
|||||||
groups: pdigits
|
groups: pdigits
|
||||||
Start: 0
|
Start: 0
|
||||||
Length: *
|
Length: *
|
||||||
|
|
||||||
|
overlay:
|
||||||
|
build-valid:
|
||||||
|
Start: 0
|
||||||
|
build-invalid:
|
||||||
|
Start: 1
|
||||||
|
target-select:
|
||||||
|
Start: 2
|
||||||
|
target-valid:
|
||||||
|
Start: 0
|
||||||
|
target-invalid:
|
||||||
|
Start: 1
|
||||||
BIN
mods/ra/bits/overlay.shp
Normal file
BIN
mods/ra/bits/overlay.shp
Normal file
Binary file not shown.
@@ -1999,3 +1999,14 @@ gpsdot:
|
|||||||
Harvester:
|
Harvester:
|
||||||
Start: 5
|
Start: 5
|
||||||
|
|
||||||
|
overlay:
|
||||||
|
build-valid:
|
||||||
|
Start: 0
|
||||||
|
build-invalid:
|
||||||
|
Start: 1
|
||||||
|
target-select:
|
||||||
|
Start: 2
|
||||||
|
target-valid:
|
||||||
|
Start: 0
|
||||||
|
target-invalid:
|
||||||
|
Start: 1
|
||||||
Reference in New Issue
Block a user