1
0
mirror of https://github.com/k4zmu2a/SpaceCadetPinball.git synced 2024-11-02 00:42:53 +01:00

Added sprite positions to debug overlay.

This commit is contained in:
Muzychenko Andrey 2022-05-31 11:34:04 +03:00
parent 5d7d7c0822
commit c93e11ee6b
5 changed files with 27 additions and 0 deletions

View File

@ -101,6 +101,10 @@ void DebugOverlay::DrawOverlay()
if (options::Options.DebugOverlayGrid)
DrawBoxGrid();
// Draw bounding boxes around sprites
if (options::Options.DebugOverlaySprites)
DrawAllSprites();
// Draw all edges registered in TCollisionComponent.EdgeList + flippers
if (options::Options.DebugOverlayAllEdges)
DrawAllEdges();
@ -204,6 +208,23 @@ void DebugOverlay::DrawBallInfo()
}
}
void DebugOverlay::DrawAllSprites()
{
SDL_SetRenderDrawColor(winmain::Renderer, 200, 200, 0, 255);
for (auto cmp : pb::MainTable->ComponentList)
{
if (cmp->RenderSprite)
{
auto& bmpR = cmp->RenderSprite->BmpRect;
if (bmpR.Width != 0 && bmpR.Height != 0)
{
SDL_Rect rect{ bmpR.XPosition, bmpR.YPosition, bmpR.Width, bmpR.Height };
SDL_RenderDrawRect(winmain::Renderer, &rect);
}
}
}
}
void DebugOverlay::DrawCicleType(circle_type& circle)
{
vector2 linePt{ circle.Center.X + sqrt(circle.RadiusSq), circle.Center.Y };

View File

@ -19,4 +19,5 @@ private:
static void DrawBoxGrid();
static void DrawAllEdges();
static void DrawBallInfo();
static void DrawAllSprites();
};

View File

@ -111,6 +111,7 @@ void options::InitPrimary()
Options.DebugOverlayBallPosition = get_int("Debug Overlay Ball Position", true);
Options.DebugOverlayBallEdges = get_int("Debug Overlay Ball Edges", true);
Options.DebugOverlayCollisionMask = get_int("Debug Overlay Collision Mask", true);
Options.DebugOverlaySprites = get_int("Debug Overlay Sprites", true);
}
void options::InitSecondary()
@ -157,6 +158,7 @@ void options::uninit()
set_int("Debug Overlay Ball Position", Options.DebugOverlayBallPosition);
set_int("Debug Overlay Ball Edges", Options.DebugOverlayBallEdges);
set_int("Debug Overlay Collision Mask", Options.DebugOverlayCollisionMask);
set_int("Debug Overlay Sprites", Options.DebugOverlaySprites);
}

View File

@ -88,6 +88,7 @@ struct optionsStruct
bool DebugOverlayBallPosition;
bool DebugOverlayBallEdges;
bool DebugOverlayCollisionMask;
bool DebugOverlaySprites;
};
struct ControlRef

View File

@ -600,6 +600,8 @@ void winmain::RenderUi()
{
if (ImGui::MenuItem("Box Grid", nullptr, Options.DebugOverlayGrid))
Options.DebugOverlayGrid ^= true;
if (ImGui::MenuItem("Sprite Positions", nullptr, Options.DebugOverlaySprites))
Options.DebugOverlaySprites ^= true;
if (ImGui::MenuItem("All Edges", nullptr, Options.DebugOverlayAllEdges))
Options.DebugOverlayAllEdges ^= true;
if (ImGui::MenuItem("Ball Position", nullptr, Options.DebugOverlayBallPosition))