Add Visualization chat commands

This commit is contained in:
rob-v
2017-05-21 09:17:31 +02:00
committed by Oliver Brakmann
parent 8403adba37
commit d4e9e0e069
18 changed files with 145 additions and 71 deletions

View File

@@ -34,7 +34,7 @@ namespace OpenRA.Graphics
readonly HardwarePalette palette = new HardwarePalette();
readonly Dictionary<string, PaletteReference> palettes = new Dictionary<string, PaletteReference>();
readonly TerrainRenderer terrainRenderer;
readonly Lazy<DeveloperMode> devTrait;
readonly Lazy<DebugVisualizations> debugVis;
readonly Func<string, PaletteReference> createPaletteReference;
readonly bool enableDepthBuffer;
@@ -61,7 +61,7 @@ namespace OpenRA.Graphics
Theater = new Theater(world.Map.Rules.TileSet);
terrainRenderer = new TerrainRenderer(world, this);
devTrait = Exts.Lazy(() => world.LocalPlayer != null ? world.LocalPlayer.PlayerActor.Trait<DeveloperMode>() : null);
debugVis = Exts.Lazy(() => world.WorldActor.TraitOrDefault<DebugVisualizations>());
}
public void UpdatePalettesForPlayer(string internalName, HSLColor color, bool replaceExisting)
@@ -125,11 +125,11 @@ namespace OpenRA.Graphics
if (World.WorldActor.Disposed)
return;
if (devTrait.Value != null)
if (debugVis.Value != null)
{
Game.Renderer.WorldSpriteRenderer.SetDepthPreviewEnabled(devTrait.Value.ShowDepthPreview);
Game.Renderer.WorldRgbaSpriteRenderer.SetDepthPreviewEnabled(devTrait.Value.ShowDepthPreview);
Game.Renderer.WorldRgbaColorRenderer.SetDepthPreviewEnabled(devTrait.Value.ShowDepthPreview);
Game.Renderer.WorldSpriteRenderer.SetDepthPreviewEnabled(debugVis.Value.DepthBuffer);
Game.Renderer.WorldRgbaSpriteRenderer.SetDepthPreviewEnabled(debugVis.Value.DepthBuffer);
Game.Renderer.WorldRgbaColorRenderer.SetDepthPreviewEnabled(debugVis.Value.DepthBuffer);
}
RefreshPalette();
@@ -196,7 +196,7 @@ namespace OpenRA.Graphics
foreach (var r in g)
r.Render(this);
if (devTrait.Value != null && devTrait.Value.ShowDebugGeometry)
if (debugVis.Value != null && debugVis.Value.RenderGeometry)
{
for (var i = 0; i < renderables.Count; i++)
renderables[i].RenderDebugGeometry(this);

View File

@@ -190,6 +190,7 @@
<Compile Include="Traits\World\ResourceType.cs" />
<Compile Include="Traits\World\ScreenShaker.cs" />
<Compile Include="Traits\World\Shroud.cs" />
<Compile Include="Traits\World\DebugVisualizations.cs" />
<Compile Include="World.cs" />
<Compile Include="WorldUtils.cs" />
<Compile Include="VoiceExts.cs" />

View File

@@ -47,18 +47,6 @@ namespace OpenRA.Traits
[Desc("Enable the path debug overlay by default.")]
public bool PathDebug;
[Desc("Enable the combat geometry overlay by default.")]
public bool ShowCombatGeometry;
[Desc("Enable the debug geometry overlay by default.")]
public bool ShowDebugGeometry;
[Desc("Enable the depth buffer overlay by default.")]
public bool ShowDepthPreview;
[Desc("Enable the actor tags overlay by default.")]
public bool ShowActorTags;
IEnumerable<LobbyOption> ILobbyOptions.LobbyOptions(Ruleset rules)
{
yield return new LobbyBooleanOption("cheats", "Debug Menu", Enabled, Locked);
@@ -88,12 +76,6 @@ namespace OpenRA.Traits
public bool UnlimitedPower { get { return Enabled && unlimitedPower; } }
public bool BuildAnywhere { get { return Enabled && buildAnywhere; } }
// Client side only
public bool ShowCombatGeometry;
public bool ShowDebugGeometry;
public bool ShowDepthPreview;
public bool ShowActorTags;
bool enableAll;
public DeveloperMode(DeveloperModeInfo info)
@@ -105,11 +87,6 @@ namespace OpenRA.Traits
pathDebug = info.PathDebug;
unlimitedPower = info.UnlimitedPower;
buildAnywhere = info.BuildAnywhere;
ShowCombatGeometry = info.ShowCombatGeometry;
ShowDebugGeometry = info.ShowDebugGeometry;
ShowDepthPreview = info.ShowDepthPreview;
ShowActorTags = info.ShowActorTags;
}
void INotifyCreated.Created(Actor self)

View File

@@ -0,0 +1,24 @@
#region Copyright & License Information
/*
* Copyright 2007-2017 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
namespace OpenRA.Traits
{
[Desc("Enables visualization commands. Attach this to the world actor.")]
public class DebugVisualizationsInfo : TraitInfo<DebugVisualizations> { }
public class DebugVisualizations
{
public bool CombatGeometry;
public bool RenderGeometry;
public bool DepthBuffer;
public bool ActorTags;
}
}