diff --git a/OpenRA.Game/Graphics/WorldRenderer.cs b/OpenRA.Game/Graphics/WorldRenderer.cs index bea22d0c79..d88b3c78cb 100644 --- a/OpenRA.Game/Graphics/WorldRenderer.cs +++ b/OpenRA.Game/Graphics/WorldRenderer.cs @@ -212,6 +212,13 @@ namespace OpenRA.Graphics r.RenderDebugGeometry(this); } + if (debugVis.Value != null && debugVis.Value.ScreenMap) + foreach (var r in World.ScreenMap.ItemBounds(World.RenderPlayer)) + Game.Renderer.WorldRgbaColorRenderer.DrawRect( + new float3(r.Left, r.Top, r.Bottom), + new float3(r.Right, r.Bottom, r.Bottom), + 1 / Viewport.Zoom, Color.MediumSpringGreen); + Game.Renderer.Flush(); } diff --git a/OpenRA.Game/Primitives/SpatiallyPartitioned.cs b/OpenRA.Game/Primitives/SpatiallyPartitioned.cs index 3e6683b485..debe06edc4 100644 --- a/OpenRA.Game/Primitives/SpatiallyPartitioned.cs +++ b/OpenRA.Game/Primitives/SpatiallyPartitioned.cs @@ -133,5 +133,7 @@ namespace OpenRA.Primitives } } } + + public IEnumerable ItemBounds { get { return itemBounds.Values; } } } } diff --git a/OpenRA.Game/Traits/World/DebugVisualizations.cs b/OpenRA.Game/Traits/World/DebugVisualizations.cs index 46f8fc520d..7f9ecc606e 100644 --- a/OpenRA.Game/Traits/World/DebugVisualizations.cs +++ b/OpenRA.Game/Traits/World/DebugVisualizations.cs @@ -18,6 +18,7 @@ namespace OpenRA.Traits { public bool CombatGeometry; public bool RenderGeometry; + public bool ScreenMap; public bool DepthBuffer; public bool ActorTags; } diff --git a/OpenRA.Game/Traits/World/ScreenMap.cs b/OpenRA.Game/Traits/World/ScreenMap.cs index e3a2672d51..7b0f48e905 100644 --- a/OpenRA.Game/Traits/World/ScreenMap.cs +++ b/OpenRA.Game/Traits/World/ScreenMap.cs @@ -187,5 +187,13 @@ namespace OpenRA.Traits return NoFrozenActors; return partitionedFrozenActors[p].InBox(r).Where(frozenActorIsValid); } + + public IEnumerable ItemBounds(Player viewer) + { + var bounds = partitionedActors.ItemBounds + .Concat(partitionedEffects.ItemBounds); + + return viewer != null ? bounds.Concat(partitionedFrozenActors[viewer].ItemBounds) : bounds; + } } } diff --git a/OpenRA.Mods.Common/Commands/DebugVisualizationCommands.cs b/OpenRA.Mods.Common/Commands/DebugVisualizationCommands.cs index 2752393822..e8b03202e9 100644 --- a/OpenRA.Mods.Common/Commands/DebugVisualizationCommands.cs +++ b/OpenRA.Mods.Common/Commands/DebugVisualizationCommands.cs @@ -11,6 +11,7 @@ using System; using OpenRA.Graphics; +using OpenRA.Mods.Common.Traits; using OpenRA.Traits; namespace OpenRA.Mods.Common.Commands @@ -21,12 +22,16 @@ namespace OpenRA.Mods.Common.Commands public class DebugVisualizationCommands : IChatCommand, IWorldLoaded { DebugVisualizations debugVis; + DeveloperMode devMode; public void WorldLoaded(World w, WorldRenderer wr) { var world = w; debugVis = world.WorldActor.TraitOrDefault(); + if (world.LocalPlayer != null) + devMode = world.LocalPlayer.PlayerActor.Trait(); + if (debugVis == null) return; @@ -41,6 +46,7 @@ namespace OpenRA.Mods.Common.Commands register("showcombatgeometry", "toggles combat geometry overlay."); register("showrendergeometry", "toggles render geometry overlay."); + register("showscreenmap", "toggles screen map overlay."); register("showdepthbuffer", "toggles depth buffer overlay."); register("showactortags", "toggles actor tags overlay."); } @@ -57,6 +63,11 @@ namespace OpenRA.Mods.Common.Commands debugVis.RenderGeometry ^= true; break; + case "showscreenmap": + if (devMode == null || devMode.Enabled) + debugVis.ScreenMap ^= true; + break; + case "showdepthbuffer": debugVis.DepthBuffer ^= true; break; diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/DebugMenuLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/DebugMenuLogic.cs index fec7f54513..ec6213ca7a 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/DebugMenuLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Ingame/DebugMenuLogic.cs @@ -77,6 +77,14 @@ namespace OpenRA.Mods.Common.Widgets.Logic showGeometryCheckbox.OnClick = () => debugVis.RenderGeometry ^= true; } + var showScreenMapCheckbox = widget.GetOrNull("SHOW_SCREENMAP"); + if (showScreenMapCheckbox != null) + { + showScreenMapCheckbox.Disabled = debugVis == null; + showScreenMapCheckbox.IsChecked = () => debugVis != null && debugVis.ScreenMap; + showScreenMapCheckbox.OnClick = () => debugVis.ScreenMap ^= true; + } + var terrainGeometryTrait = world.WorldActor.Trait(); var showTerrainGeometryCheckbox = widget.GetOrNull("SHOW_TERRAIN_OVERLAY"); if (showTerrainGeometryCheckbox != null && terrainGeometryTrait != null) diff --git a/mods/cnc/chrome/ingame-debug.yaml b/mods/cnc/chrome/ingame-debug.yaml index c4043339bb..4cbb94d018 100644 --- a/mods/cnc/chrome/ingame-debug.yaml +++ b/mods/cnc/chrome/ingame-debug.yaml @@ -122,4 +122,11 @@ Container@DEBUG_PANEL: Height: 20 Width: 200 Font: Regular - Text: Show Terrain Geometry \ No newline at end of file + Text: Show Terrain Geometry + Checkbox@SHOW_SCREENMAP: + X: 290 + Y: 365 + Height: 20 + Width: 200 + Font: Regular + Text: Show Screen Map diff --git a/mods/common/chrome/ingame-debug.yaml b/mods/common/chrome/ingame-debug.yaml index 4b096d34ea..fc6c283100 100644 --- a/mods/common/chrome/ingame-debug.yaml +++ b/mods/common/chrome/ingame-debug.yaml @@ -128,3 +128,10 @@ Container@DEBUG_PANEL: Width: 200 Font: Regular Text: Show Terrain Geometry + Checkbox@SHOW_SCREENMAP: + X: 290 + Y: 365 + Height: 20 + Width: 200 + Font: Regular + Text: Show Screen Map diff --git a/mods/ts/chrome/ingame-debug.yaml b/mods/ts/chrome/ingame-debug.yaml index 77383063e6..89c31a83b9 100644 --- a/mods/ts/chrome/ingame-debug.yaml +++ b/mods/ts/chrome/ingame-debug.yaml @@ -135,3 +135,10 @@ Container@DEBUG_PANEL: Width: 200 Font: Regular Text: Show Terrain Geometry + Checkbox@SHOW_SCREENMAP: + X: 290 + Y: 365 + Height: 20 + Width: 200 + Font: Regular + Text: Show Screen Map