From a9a0393066a46807370cde0ae12e3a3eaab04a9e Mon Sep 17 00:00:00 2001 From: Rodrigo Verdiani Date: Sat, 27 Dec 2025 19:58:29 -0300 Subject: [PATCH] feat(gui): add status bar --- app.c | 3 ++- gui.c | 35 +++++++++++++++++++++++++++++++++++ gui.h | 3 +++ 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/app.c b/app.c index 28b9609..3dddee1 100644 --- a/app.c +++ b/app.c @@ -13,7 +13,8 @@ void App_Init(App_t *app) { System_QueryMetrics(&app->metrics); - if (!Window_Init(app->metrics.screenWidth, app->metrics.screenHeight)) { + // TODO: start this window maximized + if (!Window_Init(800, 600)) { return; } diff --git a/gui.c b/gui.c index 9f2afeb..59fb810 100644 --- a/gui.c +++ b/gui.c @@ -27,6 +27,7 @@ void Gui_Init(Gui_t *gui) { cImGui_ImplSDLRenderer3_Init(renderer); gui->isPreferencesDialogOpen = false; + gui->statusBarText = "Welcome to Tibia!"; } void Gui_ProcessEvent(const SDL_Event *event) { @@ -41,6 +42,7 @@ void Gui_StartRender() { void Gui_Render(Gui_t *gui, ConfigParams_t *configParams) { Gui_RenderMainMenu(gui); + Gui_RenderStatusBar(gui); Gui_RenderPreferences_Dialog(gui, configParams); } @@ -122,6 +124,39 @@ void Gui_RenderMainMenu(Gui_t *gui) { ImGui_EndMainMenuBar(); } +void Gui_RenderStatusBar(const Gui_t* gui) { + const ImGuiViewport *viewport = ImGui_GetMainViewport(); + + const float height = ImGui_GetFrameHeight(); + const ImVec2 position = {viewport->Pos.x, viewport->Pos.y + viewport->Size.y - height}; + const ImVec2 size = {viewport->Size.x, height}; + + ImGui_SetNextWindowPosEx(position, ImGuiCond_Always, (ImVec2){0.0f, 0.0f}); + ImGui_SetNextWindowSize(size, ImGuiCond_Always); + + // Remove rounding, borders and reduce padding + ImGui_PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f); + ImGui_PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f); + ImGui_PushStyleVarImVec2(ImGuiStyleVar_WindowPadding, (ImVec2){8.0f, 2.0f}); + + // Set background and text colors + ImGui_PushStyleColorImVec4(ImGuiCol_WindowBg, (ImVec4){0.85f, 0.85f, 0.85f, 1.0f}); + ImGui_PushStyleColorImVec4(ImGuiCol_Text, (ImVec4){0.0f, 0.0f, 0.0f, 1.0f}); + + const ImGuiWindowFlags windowFlags = ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoMove | + ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoSavedSettings | + ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoNav; + + if (ImGui_Begin("StatusBar", NULL, windowFlags)) { + ImGui_Text(gui->statusBarText); + } + + ImGui_End(); + + ImGui_PopStyleColorEx(2); + ImGui_PopStyleVarEx(3); +} + void Gui_RenderPreferences_Dialog(Gui_t *gui, ConfigParams_t *configParams) { if (!gui->isPreferencesDialogOpen) { return; diff --git a/gui.h b/gui.h index 9d79a07..8e4d9ad 100644 --- a/gui.h +++ b/gui.h @@ -11,6 +11,7 @@ typedef struct Gui { bool isPreferencesDialogOpen; + char* statusBarText; } Gui_t; void Gui_Init(Gui_t* gui); @@ -21,6 +22,8 @@ void Gui_FinishRender(); void Gui_Shutdown(); void Gui_RenderMainMenu(Gui_t* gui); +void Gui_RenderStatusBar(const Gui_t* gui); + void Gui_RenderPreferences_Dialog(Gui_t* gui, ConfigParams_t* configParams); #endif //TIBIA_GUI_H \ No newline at end of file