Skip to content

Commit

Permalink
DebugDrawSelectionBuffer
Browse files Browse the repository at this point in the history
  • Loading branch information
kaczy93 committed Jan 21, 2024
1 parent f6877f7 commit dccb576
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
6 changes: 5 additions & 1 deletion CentrED/Map/MapManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class MapManager
private readonly SpriteBatch _spriteBatch;
private readonly Texture2D _background;

public bool DebugDrawSelectionBuffer;
private RenderTarget2D _selectionBuffer;

internal List<Tool> Tools = new();
Expand Down Expand Up @@ -757,6 +758,9 @@ public void Draw()
Metrics.Start("DrawSelection");
DrawSelectionBuffer();
Metrics.Stop("DrawSelection");
if (DebugDrawSelectionBuffer)
return;

_mapRenderer.SetRenderTarget(null);
Metrics.Start("DrawLand");
DrawLand();
Expand Down Expand Up @@ -790,7 +794,7 @@ private void DrawSelectionBuffer()
{
_mapEffect.WorldViewProj = Camera.WorldViewProj;
_mapEffect.CurrentTechnique = _mapEffect.Techniques["Selection"];
_mapRenderer.SetRenderTarget(_selectionBuffer);
_mapRenderer.SetRenderTarget(DebugDrawSelectionBuffer ? null : _selectionBuffer);
_mapRenderer.Begin
(
_mapEffect,
Expand Down
1 change: 1 addition & 0 deletions CentrED/UI/UIManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ public void Draw(GameTime gameTime)
{
Metrics.Start("DrawUI");
FramesPerSecond = 1 / gameTime.ElapsedGameTime.TotalSeconds;
_graphicsDevice.SetRenderTarget(null);
ImGui.NewFrame();
DrawUI();
ImGui.Render();
Expand Down
1 change: 1 addition & 0 deletions CentrED/UI/Windows/DebugWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ private void DrawGeneralTab()
{
mapManager.Reset();
}
ImGui.Checkbox("Draw SelectionBuffer", ref CEDGame.MapManager.DebugDrawSelectionBuffer);

ImGui.Separator();
if (ImGui.Button("Server Flush"))
Expand Down

0 comments on commit dccb576

Please sign in to comment.