64 lines
1.9 KiB
C
64 lines
1.9 KiB
C
#include <Debug/DebugTopBar.h>
|
|
|
|
#if JULIET_DEBUG
|
|
#include <game.h>
|
|
#include <dcimgui.h>
|
|
#include <stdio.h>
|
|
|
|
internal String GetGameModeName(GameMode gameMode)
|
|
{
|
|
String result = WrapString("Unknown ERROR");
|
|
if (gameMode == GameMode_Editor)
|
|
{
|
|
result = WrapString("Editor");
|
|
}
|
|
else if (gameMode == GameMode_Play)
|
|
{
|
|
result = WrapString("Play");
|
|
}
|
|
else if (gameMode == GameMode_Debug)
|
|
{
|
|
result = WrapString("Debug");
|
|
}
|
|
return result;
|
|
}
|
|
|
|
void DrawTopBar(void)
|
|
{
|
|
GameState* gameState = GetGameState();
|
|
|
|
ImVec2_c viewportPos = ImGui_GetMainViewportPos();
|
|
ImVec2_c viewportSize = ImGui_GetMainViewportSize();
|
|
ImGui_SetNextWindowPos(viewportPos);
|
|
ImVec2_c barSize = { viewportSize.x, 10.0f };
|
|
ImGui_SetNextWindowSize(barSize);
|
|
|
|
ImGuiWindowFlags_c flags = ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoMove |
|
|
ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing |
|
|
ImGuiWindowFlags_NoNav;
|
|
|
|
ImVec4_c bgCol = { 0.0f, 0.0f, 0.0f, 0.6f };
|
|
ImVec2_c padding = { 10.0f, 5.0f };
|
|
ImGui_PushStyleColor(ImGuiCol_WindowBg, bgCol);
|
|
ImGui_PushStyleVarVec2(ImGuiStyleVar_WindowPadding, padding);
|
|
|
|
if (ImGui_Begin("TopBarOverlay", NULL, flags))
|
|
{
|
|
ImGui_Text("Game Mode: %s", CStr(GetGameModeName(gameState->Mode)));
|
|
|
|
float framerate = ImGuiIO_GetFramerate();
|
|
char fps_text[32];
|
|
snprintf(fps_text, sizeof(fps_text), "FPS: %.1f (%.2f ms)", (double)framerate, (double)(1000.0f / framerate));
|
|
float text_width = ImGui_CalcTextSize(fps_text, NULL).x;
|
|
ImGui_SameLine(viewportSize.x - text_width - 15.0f, -1.0f); // 15px right padding
|
|
// Render FPS text
|
|
ImGui_Text("%s", fps_text);
|
|
}
|
|
ImGui_End();
|
|
|
|
ImGui_PopStyleVar(1);
|
|
ImGui_PopStyleColor(1);
|
|
}
|
|
#endif
|
|
|