Browse Source

Extract UI panel constants from magic numbers

main
cinnaboot 5 months ago
parent
commit
d1d659d8f9
  1. 2
      docs/planning/rendering-cleanup-plan.md
  2. 32
      src/ui_renderer.cpp

2
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`

32
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 };

Loading…
Cancel
Save