Merge pull request #11211 from Mailaender/debugcustomterrain
Added a CustomTerrainDebugOverlay
This commit is contained in:
@@ -408,6 +408,7 @@
|
|||||||
<Compile Include="Traits\BodyOrientation.cs" />
|
<Compile Include="Traits\BodyOrientation.cs" />
|
||||||
<Compile Include="Traits\QuantizeFacingsFromSequence.cs" />
|
<Compile Include="Traits\QuantizeFacingsFromSequence.cs" />
|
||||||
<Compile Include="Traits\Render\AutoSelectionSize.cs" />
|
<Compile Include="Traits\Render\AutoSelectionSize.cs" />
|
||||||
|
<Compile Include="Traits\Render\CustomTerrainDebugOverlay.cs" />
|
||||||
<Compile Include="Traits\Render\Hovers.cs" />
|
<Compile Include="Traits\Render\Hovers.cs" />
|
||||||
<Compile Include="Traits\Render\LeavesTrails.cs" />
|
<Compile Include="Traits\Render\LeavesTrails.cs" />
|
||||||
<Compile Include="Traits\Render\RenderSpritesEditorOnly.cs" />
|
<Compile Include="Traits\Render\RenderSpritesEditorOnly.cs" />
|
||||||
|
|||||||
@@ -0,0 +1,79 @@
|
|||||||
|
#region Copyright & License Information
|
||||||
|
/*
|
||||||
|
* Copyright 2007-2016 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, either version 3 of
|
||||||
|
* the License, or (at your option) any later version. For more
|
||||||
|
* information, see COPYING.
|
||||||
|
*/
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Drawing;
|
||||||
|
using OpenRA.Graphics;
|
||||||
|
using OpenRA.Mods.Common.Commands;
|
||||||
|
using OpenRA.Mods.Common.Graphics;
|
||||||
|
using OpenRA.Traits;
|
||||||
|
|
||||||
|
namespace OpenRA.Mods.Common.Traits
|
||||||
|
{
|
||||||
|
[Desc("Displays custom terrain types.")]
|
||||||
|
class CustomTerrainDebugOverlayInfo : ITraitInfo
|
||||||
|
{
|
||||||
|
public readonly string Font = "TinyBold";
|
||||||
|
|
||||||
|
public object Create(ActorInitializer init) { return new CustomTerrainDebugOverlay(init.Self, this); }
|
||||||
|
}
|
||||||
|
|
||||||
|
class CustomTerrainDebugOverlay : IWorldLoaded, IChatCommand, IRender
|
||||||
|
{
|
||||||
|
const string CommandName = "debugcustomterrain";
|
||||||
|
const string CommandDesc = "Toggles the custom terrain debug overlay.";
|
||||||
|
|
||||||
|
public bool Enabled;
|
||||||
|
|
||||||
|
readonly SpriteFont font;
|
||||||
|
|
||||||
|
public CustomTerrainDebugOverlay(Actor self, CustomTerrainDebugOverlayInfo info)
|
||||||
|
{
|
||||||
|
font = Game.Renderer.Fonts[info.Font];
|
||||||
|
}
|
||||||
|
|
||||||
|
void IWorldLoaded.WorldLoaded(World w, WorldRenderer wr)
|
||||||
|
{
|
||||||
|
var console = w.WorldActor.TraitOrDefault<ChatCommands>();
|
||||||
|
var help = w.WorldActor.TraitOrDefault<HelpCommand>();
|
||||||
|
|
||||||
|
if (console == null || help == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
console.RegisterCommand(CommandName, this);
|
||||||
|
help.RegisterHelp(CommandName, CommandDesc);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IChatCommand.InvokeCommand(string name, string arg)
|
||||||
|
{
|
||||||
|
if (name == CommandName)
|
||||||
|
Enabled ^= true;
|
||||||
|
}
|
||||||
|
|
||||||
|
IEnumerable<IRenderable> IRender.Render(Actor self, WorldRenderer wr)
|
||||||
|
{
|
||||||
|
if (!Enabled)
|
||||||
|
yield break;
|
||||||
|
|
||||||
|
foreach (var uv in wr.Viewport.VisibleCellsInsideBounds.CandidateMapCoords)
|
||||||
|
{
|
||||||
|
var cell = uv.ToCPos(wr.World.Map);
|
||||||
|
var center = wr.World.Map.CenterOfCell(cell);
|
||||||
|
var terrainType = self.World.Map.CustomTerrain[cell];
|
||||||
|
if (terrainType == byte.MaxValue)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
var info = wr.World.Map.GetTerrainInfo(cell);
|
||||||
|
yield return new TextRenderable(font, center, 0, info.Color, info.Type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -134,6 +134,18 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
showActorTagsCheckbox.IsChecked = () => devTrait.ShowActorTags;
|
showActorTagsCheckbox.IsChecked = () => devTrait.ShowActorTags;
|
||||||
showActorTagsCheckbox.OnClick = () => devTrait.ShowActorTags ^= true;
|
showActorTagsCheckbox.OnClick = () => devTrait.ShowActorTags ^= true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var showCustomTerrainCheckbox = widget.GetOrNull<CheckboxWidget>("SHOW_CUSTOMTERRAIN_OVERLAY");
|
||||||
|
if (showCustomTerrainCheckbox != null)
|
||||||
|
{
|
||||||
|
var customTerrainDebugTrait = world.WorldActor.TraitOrDefault<CustomTerrainDebugOverlay>();
|
||||||
|
showCustomTerrainCheckbox.Disabled = customTerrainDebugTrait == null;
|
||||||
|
if (customTerrainDebugTrait != null)
|
||||||
|
{
|
||||||
|
showCustomTerrainCheckbox.IsChecked = () => customTerrainDebugTrait.Enabled;
|
||||||
|
showCustomTerrainCheckbox.OnClick = () => customTerrainDebugTrait.Enabled ^= true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Order(World world, string order)
|
public void Order(World world, string order)
|
||||||
|
|||||||
@@ -123,3 +123,10 @@ Container@DEBUG_PANEL:
|
|||||||
Width: 200
|
Width: 200
|
||||||
Font: Regular
|
Font: Regular
|
||||||
Text: Show Actor Tags
|
Text: Show Actor Tags
|
||||||
|
Checkbox@SHOW_CUSTOMTERRAIN_OVERLAY:
|
||||||
|
X: 290
|
||||||
|
Y: 365
|
||||||
|
Height: 20
|
||||||
|
Width: 200
|
||||||
|
Font: Regular
|
||||||
|
Text: Show Custom Terrain
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ Container@GAME_INFO_PANEL:
|
|||||||
X: (WINDOW_RIGHT - WIDTH) / 2
|
X: (WINDOW_RIGHT - WIDTH) / 2
|
||||||
Y: (WINDOW_BOTTOM - HEIGHT) / 2
|
Y: (WINDOW_BOTTOM - HEIGHT) / 2
|
||||||
Width: 512
|
Width: 512
|
||||||
Height: 375
|
Height: 405
|
||||||
Logic: GameInfoLogic
|
Logic: GameInfoLogic
|
||||||
Visible: False
|
Visible: False
|
||||||
Children:
|
Children:
|
||||||
|
|||||||
@@ -72,6 +72,7 @@ World:
|
|||||||
ResourceClaimLayer:
|
ResourceClaimLayer:
|
||||||
PathfinderDebugOverlay:
|
PathfinderDebugOverlay:
|
||||||
WarheadDebugOverlay:
|
WarheadDebugOverlay:
|
||||||
|
CustomTerrainDebugOverlay:
|
||||||
MapCreeps:
|
MapCreeps:
|
||||||
SpawnMapActors:
|
SpawnMapActors:
|
||||||
MapBuildRadius:
|
MapBuildRadius:
|
||||||
|
|||||||
@@ -79,6 +79,7 @@ World:
|
|||||||
BuildableTerrainLayer:
|
BuildableTerrainLayer:
|
||||||
D2kResourceLayer:
|
D2kResourceLayer:
|
||||||
ResourceClaimLayer:
|
ResourceClaimLayer:
|
||||||
|
CustomTerrainDebugOverlay:
|
||||||
SmudgeLayer@Rock:
|
SmudgeLayer@Rock:
|
||||||
Type: RockCrater
|
Type: RockCrater
|
||||||
Sequence: rockcraters
|
Sequence: rockcraters
|
||||||
|
|||||||
@@ -128,3 +128,10 @@ Container@DEBUG_PANEL:
|
|||||||
Width: 200
|
Width: 200
|
||||||
Font: Regular
|
Font: Regular
|
||||||
Text: Show Actor Tags
|
Text: Show Actor Tags
|
||||||
|
Checkbox@SHOW_CUSTOMTERRAIN_OVERLAY:
|
||||||
|
X: 290
|
||||||
|
Y: 365
|
||||||
|
Height: 20
|
||||||
|
Width: 200
|
||||||
|
Font: Regular
|
||||||
|
Text: Show Custom Terrain
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ Container@GAME_INFO_PANEL:
|
|||||||
X: (WINDOW_RIGHT - WIDTH) / 2
|
X: (WINDOW_RIGHT - WIDTH) / 2
|
||||||
Y: (WINDOW_BOTTOM - HEIGHT) / 2
|
Y: (WINDOW_BOTTOM - HEIGHT) / 2
|
||||||
Width: 522
|
Width: 522
|
||||||
Height: 455
|
Height: 485
|
||||||
Logic: GameInfoLogic
|
Logic: GameInfoLogic
|
||||||
Visible: False
|
Visible: False
|
||||||
Children:
|
Children:
|
||||||
|
|||||||
@@ -99,6 +99,7 @@ World:
|
|||||||
ProductionPaletteWidget: PRODUCTION_PALETTE
|
ProductionPaletteWidget: PRODUCTION_PALETTE
|
||||||
BridgeLayer:
|
BridgeLayer:
|
||||||
Bridges: bridge1, bridge2, br1, br2, br3, sbridge1, sbridge2, sbridge3, sbridge4
|
Bridges: bridge1, bridge2, br1, br2, br3, sbridge1, sbridge2, sbridge3, sbridge4
|
||||||
|
CustomTerrainDebugOverlay:
|
||||||
CrateSpawner:
|
CrateSpawner:
|
||||||
DeliveryAircraft: badr
|
DeliveryAircraft: badr
|
||||||
QuantizedFacings: 16
|
QuantizedFacings: 16
|
||||||
|
|||||||
@@ -135,3 +135,10 @@ Container@DEBUG_PANEL:
|
|||||||
Width: 200
|
Width: 200
|
||||||
Font: Regular
|
Font: Regular
|
||||||
Text: Show Actor Tags
|
Text: Show Actor Tags
|
||||||
|
Checkbox@SHOW_CUSTOMTERRAIN_OVERLAY:
|
||||||
|
X: 290
|
||||||
|
Y: 365
|
||||||
|
Height: 20
|
||||||
|
Width: 200
|
||||||
|
Font: Regular
|
||||||
|
Text: Show Custom Terrain
|
||||||
|
|||||||
@@ -94,6 +94,7 @@ World:
|
|||||||
SmokeType: largesmoke
|
SmokeType: largesmoke
|
||||||
Sequence: largecraters
|
Sequence: largecraters
|
||||||
ResourceLayer:
|
ResourceLayer:
|
||||||
|
CustomTerrainDebugOverlay:
|
||||||
ResourceClaimLayer:
|
ResourceClaimLayer:
|
||||||
PathfinderDebugOverlay:
|
PathfinderDebugOverlay:
|
||||||
WarheadDebugOverlay:
|
WarheadDebugOverlay:
|
||||||
|
|||||||
@@ -596,19 +596,10 @@ tuntop01:
|
|||||||
ShadowStart: 1
|
ShadowStart: 1
|
||||||
|
|
||||||
tuntop02:
|
tuntop02:
|
||||||
idle:
|
Inherits: tuntop01
|
||||||
Offset: 0, -13
|
|
||||||
UseTilesetExtension: true
|
|
||||||
ShadowStart: 1
|
|
||||||
|
|
||||||
tuntop03:
|
tuntop03:
|
||||||
idle:
|
Inherits: tuntop01
|
||||||
Offset: 0, -13
|
|
||||||
UseTilesetExtension: true
|
|
||||||
ShadowStart: 1
|
|
||||||
|
|
||||||
tuntop04:
|
tuntop04:
|
||||||
idle:
|
Inherits: tuntop01
|
||||||
Offset: 0, -13
|
|
||||||
UseTilesetExtension: true
|
|
||||||
ShadowStart: 1
|
|
||||||
|
|||||||
Reference in New Issue
Block a user