diff --git a/OpenRA.Game/FieldLoader.cs b/OpenRA.Game/FieldLoader.cs
index 9b2dcb920c..616bc1af34 100644
--- a/OpenRA.Game/FieldLoader.cs
+++ b/OpenRA.Game/FieldLoader.cs
@@ -188,6 +188,27 @@ namespace OpenRA
return InvalidValueAction(value, fieldType, fieldName);
}
+ else if (fieldType == typeof(Color[]))
+ {
+ var parts = value.Split(',');
+
+ if (parts.Length % 4 != 0)
+ return InvalidValueAction(value, fieldType, fieldName);
+
+ var colors = new Color[parts.Length / 4];
+
+ for (var i = 0; i < colors.Length; i++)
+ {
+ colors[i] = Color.FromArgb(
+ Exts.ParseIntegerInvariant(parts[4 * i]).Clamp(0, 255),
+ Exts.ParseIntegerInvariant(parts[4 * i + 1]).Clamp(0, 255),
+ Exts.ParseIntegerInvariant(parts[4 * i + 2]).Clamp(0, 255),
+ Exts.ParseIntegerInvariant(parts[4 * i + 3]).Clamp(0, 255));
+ }
+
+ return colors;
+ }
+
else if (fieldType == typeof(HSLColor))
{
var parts = value.Split(',');
diff --git a/OpenRA.Game/Map/TileSet.cs b/OpenRA.Game/Map/TileSet.cs
index b1934a64b7..2c1769808f 100644
--- a/OpenRA.Game/Map/TileSet.cs
+++ b/OpenRA.Game/Map/TileSet.cs
@@ -158,6 +158,7 @@ namespace OpenRA
public readonly string[] Extensions;
public readonly int WaterPaletteRotationBase = 0x60;
public readonly byte MaxGroundHeight = 0;
+ public readonly Color[] HeightDebugColors = new[] { Color.Red };
public readonly string[] EditorTemplateOrder;
public readonly bool IgnoreTileSpriteOffsets;
diff --git a/OpenRA.Game/Traits/Player/DeveloperMode.cs b/OpenRA.Game/Traits/Player/DeveloperMode.cs
index 66b9656ca7..af18664c41 100644
--- a/OpenRA.Game/Traits/Player/DeveloperMode.cs
+++ b/OpenRA.Game/Traits/Player/DeveloperMode.cs
@@ -23,6 +23,7 @@ namespace OpenRA.Traits
public bool BuildAnywhere;
public bool ShowCombatGeometry;
public bool ShowDebugGeometry;
+ public bool ShowTerrainGeometry;
public object Create(ActorInitializer init) { return new DeveloperMode(this); }
}
@@ -41,6 +42,7 @@ namespace OpenRA.Traits
// Client side only
public bool ShowCombatGeometry;
public bool ShowDebugGeometry;
+ public bool ShowTerrainGeometry;
public DeveloperMode(DeveloperModeInfo info)
{
@@ -53,6 +55,7 @@ namespace OpenRA.Traits
BuildAnywhere = info.BuildAnywhere;
ShowCombatGeometry = info.ShowCombatGeometry;
ShowDebugGeometry = info.ShowDebugGeometry;
+ ShowTerrainGeometry = info.ShowTerrainGeometry;
}
public void ResolveOrder(Actor self, Order order)
diff --git a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj
index cde0c6f705..da17f71218 100644
--- a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj
+++ b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj
@@ -147,6 +147,7 @@
+
diff --git a/OpenRA.Mods.Common/World/TerrainGeometryOverlay.cs b/OpenRA.Mods.Common/World/TerrainGeometryOverlay.cs
new file mode 100644
index 0000000000..f68b7d22c3
--- /dev/null
+++ b/OpenRA.Mods.Common/World/TerrainGeometryOverlay.cs
@@ -0,0 +1,127 @@
+#region Copyright & License Information
+ /*
+ * Copyright 2007-2014 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;
+using System.Drawing;
+using System.Collections.Generic;
+using System.Linq;
+using OpenRA.Traits;
+using OpenRA.Graphics;
+
+namespace OpenRA.Mods.Common
+{
+ [Desc("Renders a debug overlay showing the terrain cells. Attach this to the world actor.")]
+ public class TerrainGeometryOverlayInfo : ITraitInfo
+ {
+ public object Create(ActorInitializer init) { return new TerrainGeometryOverlay(init.self); }
+ }
+
+ public class TerrainGeometryOverlay : IRenderOverlay
+ {
+ readonly int[][] vertices = new int[][]
+ {
+ // Flat
+ new[] { 0, 0, 0, 0 },
+
+ // Slopes (two corners high)
+ new[] { 0, 0, 1, 1 },
+ new[] { 1, 0, 0, 1 },
+ new[] { 1, 1, 0, 0 },
+ new[] { 0, 1, 1, 0 },
+
+ // Slopes (one corner high)
+ new[] { 0, 0, 0, 1 },
+ new[] { 1, 0, 0, 0 },
+ new[] { 0, 1, 0, 0 },
+ new[] { 0, 0, 1, 0 },
+
+ // Slopes (three corners high)
+ new[] { 1, 0, 1, 1 },
+ new[] { 1, 1, 0, 1 },
+ new[] { 1, 1, 1, 0 },
+ new[] { 0, 1, 1, 1 },
+
+ // Slopes (two corners high, one corner double high)
+ new[] { 1, 0, 1, 2 },
+ new[] { 2, 1, 0, 1 },
+ new[] { 1, 2, 1, 0 },
+ new[] { 0, 1, 2, 1 },
+
+ // Slopes (two corners high, alternating)
+ new[] { 1, 0, 1, 0 },
+ new[] { 0, 1, 0, 1 },
+ new[] { 1, 0, 1, 0 },
+ new[] { 0, 1, 0, 1 }
+ };
+
+ readonly Lazy devMode;
+
+ public TerrainGeometryOverlay(Actor self)
+ {
+ devMode = Exts.Lazy(() => self.World.LocalPlayer != null ? self.World.LocalPlayer.PlayerActor.Trait() : null);
+ }
+
+ public void Render(WorldRenderer wr)
+ {
+ if (devMode.Value == null || !devMode.Value.ShowTerrainGeometry)
+ return;
+
+ var ts = wr.world.Map.TileShape;
+ var colors = wr.world.TileSet.HeightDebugColors;
+
+ var leftDelta = ts == TileShape.Diamond ? new WVec(-512, 0, 0) : new WVec(-512, -512, 0);
+ var topDelta = ts == TileShape.Diamond ? new WVec(0, -512, 0) : new WVec(512, -512, 0);
+ var rightDelta = ts == TileShape.Diamond ? new WVec(512, 0, 0) : new WVec(512, 512, 0);
+ var bottomDelta = ts == TileShape.Diamond ? new WVec(0, 512, 0) : new WVec(-512, 512, 0);
+
+ foreach (var cell in wr.Viewport.VisibleCells)
+ {
+ var lr = Game.Renderer.WorldLineRenderer;
+ var pos = wr.world.Map.CenterOfCell(cell);
+
+ var height = (int)wr.world.Map.MapHeight.Value[cell];
+ var tile = wr.world.Map.MapTiles.Value[cell];
+
+ TerrainTileInfo tileInfo = null;
+
+ // TODO: This is a temporary workaround for our sloppy tileset definitions
+ // (ra/td templates omit Clear tiles from templates)
+ try
+ {
+ tileInfo = wr.world.TileSet.Templates[tile.Type][tile.Index];
+ }
+ catch (Exception) { }
+
+ if (tileInfo == null)
+ continue;
+
+ var leftHeight = vertices[tileInfo.RampType][0];
+ var topHeight = vertices[tileInfo.RampType][1];
+ var rightHeight = vertices[tileInfo.RampType][2];
+ var bottomHeight = vertices[tileInfo.RampType][3];
+
+ var leftColor = colors[height + leftHeight];
+ var topColor = colors[height + topHeight];
+ var rightColor = colors[height + rightHeight];
+ var bottomColor = colors[height + bottomHeight];
+
+ var left = wr.ScreenPxPosition(pos + leftDelta + new WVec(0, 0, 512 * leftHeight)).ToFloat2();
+ var top = wr.ScreenPxPosition(pos + topDelta + new WVec(0, 0, 512 * topHeight)).ToFloat2();
+ var right = wr.ScreenPxPosition(pos + rightDelta + new WVec(0, 0, 512 * rightHeight)).ToFloat2();
+ var bottom = wr.ScreenPxPosition(pos + bottomDelta + new WVec(0, 0, 512 * bottomHeight)).ToFloat2();
+
+ lr.DrawLine(left, top, leftColor, topColor);
+ lr.DrawLine(top, right, topColor, rightColor);
+ lr.DrawLine(right, bottom, rightColor, bottomColor);
+ lr.DrawLine(bottom, left, bottomColor, leftColor);
+ }
+ }
+ }
+}
diff --git a/OpenRA.Mods.RA/Widgets/Logic/DebugMenuLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/DebugMenuLogic.cs
index 1011d75816..2e6cd763ff 100644
--- a/OpenRA.Mods.RA/Widgets/Logic/DebugMenuLogic.cs
+++ b/OpenRA.Mods.RA/Widgets/Logic/DebugMenuLogic.cs
@@ -74,6 +74,13 @@ namespace OpenRA.Mods.RA.Widgets.Logic
showGeometryCheckbox.OnClick = () => devTrait.ShowDebugGeometry ^= true;
}
+ var showTerrainGeometryCheckbox = widget.GetOrNull("SHOW_TERRAIN_OVERLAY");
+ if (showTerrainGeometryCheckbox != null)
+ {
+ showTerrainGeometryCheckbox.IsChecked = () => devTrait.ShowTerrainGeometry;
+ showTerrainGeometryCheckbox.OnClick = () => devTrait.ShowTerrainGeometry ^= true;
+ }
+
var allTechCheckbox = widget.GetOrNull("ENABLE_TECH");
if (allTechCheckbox != null)
{
diff --git a/mods/cnc/chrome/ingame-debug.yaml b/mods/cnc/chrome/ingame-debug.yaml
index 148e0ec559..9e1dc992bc 100644
--- a/mods/cnc/chrome/ingame-debug.yaml
+++ b/mods/cnc/chrome/ingame-debug.yaml
@@ -83,30 +83,36 @@ Container@DEBUG_PANEL:
Width: PARENT_RIGHT
Checkbox@SHOW_UNIT_PATHS:
X: 45
- Y: 285
+ Y: 275
Width: 200
Height: 20
Font: Regular
Text: Show Unit Paths
Checkbox@SHOW_ASTAR:
X: 45
- Y: 315
+ Y: 305
Height: 20
Width: 200
Font: Regular
Text: Show A* Cost
Checkbox@SHOW_COMBATOVERLAY:
X: 290
- Y: 285
+ Y: 275
Height: 20
Width: 200
Font: Regular
Text: Show Combat Geometry
Checkbox@SHOW_GEOMETRY:
X: 290
- Y: 315
+ Y: 305
Height: 20
Width: 200
Font: Regular
Text: Show Render Geometry
-
+ Checkbox@SHOW_TERRAIN_OVERLAY:
+ X: 290
+ Y: 335
+ Height: 20
+ Width: 200
+ Font: Regular
+ Text: Show Terrain Geometry
diff --git a/mods/cnc/rules/world.yaml b/mods/cnc/rules/world.yaml
index 9410aca729..a26240673b 100644
--- a/mods/cnc/rules/world.yaml
+++ b/mods/cnc/rules/world.yaml
@@ -125,6 +125,7 @@ World:
AllowedTerrainTypes: Clear,Road
AllowUnderActors: false
PathfinderDebugOverlay:
+ TerrainGeometryOverlay:
SpawnMapActors:
MPStartLocations:
CreateMPPlayers:
diff --git a/mods/d2k/rules/world.yaml b/mods/d2k/rules/world.yaml
index e3d091e8b1..26dd5e7d75 100644
--- a/mods/d2k/rules/world.yaml
+++ b/mods/d2k/rules/world.yaml
@@ -104,6 +104,7 @@ World:
Race: ordos
DomainIndex:
PathfinderDebugOverlay:
+ TerrainGeometryOverlay:
BuildableTerrainLayer:
D2kResourceLayer:
ResourceClaimLayer:
diff --git a/mods/ra/chrome/ingame-debug.yaml b/mods/ra/chrome/ingame-debug.yaml
index b2e20db205..e6cf64c0ae 100644
--- a/mods/ra/chrome/ingame-debug.yaml
+++ b/mods/ra/chrome/ingame-debug.yaml
@@ -1,6 +1,6 @@
Container@DEBUG_PANEL:
Logic: DebugMenuLogic
- Y: 20
+ Y: 10
Width: PARENT_RIGHT
Height: PARENT_BOTTOM
Children:
@@ -88,30 +88,36 @@ Container@DEBUG_PANEL:
Width: PARENT_RIGHT
Checkbox@SHOW_UNIT_PATHS:
X: 45
- Y: 285
+ Y: 275
Width: 200
Height: 20
Font: Regular
Text: Show Unit Paths
Checkbox@SHOW_ASTAR:
X: 45
- Y: 315
+ Y: 305
Height: 20
Width: 200
Font: Regular
Text: Show A* Cost
Checkbox@SHOW_COMBATOVERLAY:
X: 290
- Y: 285
+ Y: 275
Height: 20
Width: 200
Font: Regular
Text: Show Combat Geometry
Checkbox@SHOW_GEOMETRY:
X: 290
- Y: 315
+ Y: 305
Height: 20
Width: 200
Font: Regular
Text: Show Render Geometry
-
+ Checkbox@SHOW_TERRAIN_OVERLAY:
+ X: 290
+ Y: 335
+ Height: 20
+ Width: 200
+ Font: Regular
+ Text: Show Terrain Geometry
diff --git a/mods/ra/rules/world.yaml b/mods/ra/rules/world.yaml
index 7e6fda39aa..a5094986a2 100644
--- a/mods/ra/rules/world.yaml
+++ b/mods/ra/rules/world.yaml
@@ -133,6 +133,7 @@ World:
AllowUnderActors: false
TerrainType: Gems
PathfinderDebugOverlay:
+ TerrainGeometryOverlay:
SpawnMapActors:
CreateMPPlayers:
MPStartUnits@mcvonly:
diff --git a/mods/ts/rules/world.yaml b/mods/ts/rules/world.yaml
index 4c7f48d9cf..4badd21f11 100644
--- a/mods/ts/rules/world.yaml
+++ b/mods/ts/rules/world.yaml
@@ -148,6 +148,7 @@ World:
AllowUnderActors: false
TerrainType: BlueTiberium
PathfinderDebugOverlay:
+ TerrainGeometryOverlay:
SpawnMapActors:
CreateMPPlayers:
MPStartUnits@MCV:
diff --git a/mods/ts/tilesets/temperat.yaml b/mods/ts/tilesets/temperat.yaml
index 9048ae413d..024ce8afc4 100644
--- a/mods/ts/tilesets/temperat.yaml
+++ b/mods/ts/tilesets/temperat.yaml
@@ -4,6 +4,7 @@ General:
Extensions: .tem, .shp
Palette: isotem.pal
MaxGroundHeight: 16
+ HeightDebugColors: 128,0,0,0, 128,0,0,68, 128,0,0,136, 128,0,0,204, 128,0,0,255, 128,68,0,204, 128,136,0,136, 128,204,0,68, 128,255,17,0, 128,255,85,0, 128,255,153,0, 128,255,221,0, 128,221,255,0, 128,153,255,0, 128,85,255,0, 128,17,255,0
EditorTemplateOrder: Misc Buildings, Clear, Cliff Pieces, Ice Flow, House, Blank, Ice Ramps, Cliff Set, Civilian Buildings, Shore Pieces, Rough LAT tile, Clear/Rough LAT, Cliff/Water pieces, Bendy Dirt Roads, Dirt Road Junctions, Straight Dirt Roads, Bridges, Paved Roads, Water, Dirt Road Slopes, Slope Set Pieces, Dead Oil Tanker, Ruins, Waterfalls, Ground 01, Ground 02, Sand, Sand/Clear LAT, Rough ground, Paved Road Ends, TrainBridges, Pavement, Pavement/Clear LAT, Paved road bits, Green, Green/Clear LAT, Ramp edge fixup, Water slopes, Pavement (Use for LAT), Paved Road Slopes, Monorail Slopes, Waterfalls-B, Waterfalls-C, Waterfalls-D, Tunnel Floor, Tunnel Side, TrackTunnel Floor, Destroyable Cliffs, Water Caves, Scrin Wreckage, DirtTrackTunnel Floor, DirtTunnel Floor
SheetSize: 2048