conversion to c by gemini 4 argon
This commit is contained in:
1 parent
b70e2d21d2
commit
f9356f9ba7
369 files changed
+18074
-107634
No files matched your search
@@ -0,0 +1,63 @@
|
||||
#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
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
#include <Debug/DebugTopBar.h>
|
||||
|
||||
#include <game.h>
|
||||
#include <imgui.h>
|
||||
|
||||
namespace
|
||||
{
|
||||
String GetGameModeName(GameMode gameMode)
|
||||
{
|
||||
switch (gameMode)
|
||||
{
|
||||
case GameMode::Editor: return WrapString("Editor");
|
||||
case GameMode::Play: return WrapString("Play");
|
||||
case GameMode::Debug: return WrapString("Debug");
|
||||
default: return WrapString("Unknown ERROR");
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void DrawTopBar()
|
||||
{
|
||||
auto* gameState = GetGameState();
|
||||
|
||||
ImGuiViewport* viewport = ImGui::GetMainViewport();
|
||||
ImGui::SetNextWindowPos(viewport->Pos);
|
||||
ImGui::SetNextWindowSize(ImVec2(viewport->Size.x, 10.0f));
|
||||
|
||||
ImGuiWindowFlags flags = ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoSavedSettings |
|
||||
ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav;
|
||||
|
||||
ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(0.0f, 0.0f, 0.0f, 0.6f));
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(10.0f, 5.0f));
|
||||
|
||||
if (ImGui::Begin("TopBarOverlay", nullptr, flags))
|
||||
{
|
||||
ImGui::Text("Game Mode: %s", CStr(GetGameModeName(gameState->Mode)));
|
||||
|
||||
char fps_text[32];
|
||||
snprintf(fps_text, sizeof(fps_text), "FPS: %.1f (%.2f ms)", ImGui::GetIO().Framerate, 1000.0f / ImGui::GetIO().Framerate);
|
||||
float text_width = ImGui::CalcTextSize(fps_text).x;
|
||||
ImGui::SameLine(viewport->Size.x - text_width - 15.0f); // 15px right padding
|
||||
// Render FPS text
|
||||
ImGui::Text("%s", fps_text);
|
||||
}
|
||||
ImGui::End();
|
||||
|
||||
ImGui::PopStyleVar();
|
||||
ImGui::PopStyleColor();
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <Juliet.h>
|
||||
|
||||
#if JULIET_DEBUG
|
||||
void DrawTopBar();
|
||||
void DrawTopBar(void);
|
||||
#endif
|
||||
Reference in new issue
Block a user