From d1d659d8f9e380e5f0d23198c63585c54b3409c3 Mon Sep 17 00:00:00 2001 From: cinnaboot Date: Fri, 30 Jan 2026 10:10:57 -0500 Subject: [PATCH] Extract UI panel constants from magic numbers --- docs/planning/rendering-cleanup-plan.md | 2 +- src/ui_renderer.cpp | 32 +++++++++++++++---------- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/docs/planning/rendering-cleanup-plan.md b/docs/planning/rendering-cleanup-plan.md index 2399d07..fc4af6a 100644 --- a/docs/planning/rendering-cleanup-plan.md +++ b/docs/planning/rendering-cleanup-plan.md @@ -56,7 +56,7 @@ Remove all spacecraft texture-related code: - Handle BURN_CUSTOM case separately if needed - **PAUSE** for user review -### Step 6: Extract UI Panel Constants +### Step 6: Extract UI Panel Constants [COMPLETED] - Add constants to ui_renderer.cpp: - `INFO_PANEL_WIDTH = 300` - `INFO_PANEL_HEIGHT = 300` diff --git a/src/ui_renderer.cpp b/src/ui_renderer.cpp index ee4b157..593ed48 100644 --- a/src/ui_renderer.cpp +++ b/src/ui_renderer.cpp @@ -10,15 +10,25 @@ #include "raygui.h" #include "amber/style_amber.h" +// UI Panel constants +#define INFO_PANEL_WIDTH 300 +#define INFO_PANEL_HEIGHT 300 +#define BODY_LIST_WIDTH 200 +#define BODY_LIST_HEIGHT 400 +#define BODY_INFO_WIDTH 250 +#define BODY_INFO_HEIGHT 300 +#define MANEUVER_LIST_WIDTH 300 +#define MANEUVER_LIST_HEIGHT 400 +#define MANEUVER_LIST_Y_OFFSET 320 + void gui_init() { GuiLoadStyleAmber(); } // Render simulation information overlay void render_info(SimulationState* sim) { - // Panel dimensions - int panel_width = 300; - int panel_height = 300; + int panel_width = INFO_PANEL_WIDTH; + int panel_height = INFO_PANEL_HEIGHT; int panel_x = 10; int panel_y = GetScreenHeight() - panel_height - 10; @@ -74,9 +84,8 @@ void render_info(SimulationState* sim) { // Render body list UI panel void render_body_list_ui(SimulationState* sim, RenderState* render_state, UIState* ui_state) { - // Panel dimensions - int panel_width = 200; - int panel_height = 400; + int panel_width = BODY_LIST_WIDTH; + int panel_height = BODY_LIST_HEIGHT; int panel_x = 10; int panel_y = 10; @@ -147,9 +156,8 @@ void render_body_list_ui(SimulationState* sim, RenderState* render_state, UIStat // Render body information UI panel void render_body_info_ui(SimulationState* sim, RenderState* render_state, UIState* ui_state) { - // Panel dimensions - int panel_width = 250; - int panel_height = 300; + int panel_width = BODY_INFO_WIDTH; + int panel_height = BODY_INFO_HEIGHT; int panel_x = GetScreenWidth() - panel_width - 10; int panel_y = 10; @@ -324,10 +332,10 @@ void render_maneuver_list_ui(SimulationState* sim, RenderState* render_state, UI return; // No spacecraft selected } - int panel_width = 300; - int panel_height = 400; + int panel_width = MANEUVER_LIST_WIDTH; + int panel_height = MANEUVER_LIST_HEIGHT; int panel_x = GetScreenWidth() - panel_width - 10; - int panel_y = 320; // Below info panel + int panel_y = MANEUVER_LIST_Y_OFFSET; // Below info panel Rectangle panel_bounds = { (float)panel_x, (float)panel_y, (float)panel_width, (float)panel_height };