Browse Source

Extract child indicator constants from magic numbers

main
cinnaboot 5 months ago
parent
commit
14526bf7bb
  1. 2
      docs/planning/rendering-cleanup-plan.md
  2. 10
      src/renderer.cpp

2
docs/planning/rendering-cleanup-plan.md

@ -70,7 +70,7 @@ Remove all spacecraft texture-related code:
- Replace magic numbers in all UI rendering functions
- **PAUSE** for user review
### Step 7: Extract Child Indicator Constants
### Step 7: Extract Child Indicator Constants [COMPLETED]
- Add constants to renderer.cpp:
- `CHILD_INDICATOR_RADIUS = 20.0f`
- `CHILD_INDICATOR_FONT_SIZE = 10`

10
src/renderer.cpp

@ -29,6 +29,10 @@
#define MIN_DISTANCE_SPACECRAFT_PARENT_RADIUS_MULT 0.1f
#define CAMERA_NEAR_CULL_DISTANCE 0.05f
// Child indicator constants
#define CHILD_INDICATOR_RADIUS 20.0f
#define CHILD_INDICATOR_FONT_SIZE 10
// Zoom direction enumeration for improved readability
enum ZoomDirection {
ZOOM_IN = 1,
@ -47,11 +51,9 @@ enum ZoomDirection {
static Vector3 sim_to_render(Vec3 pos, double scale);
static void draw_child_indicator(Vector2 screen_pos, const char* name, Color color) {
const float radius = 20.0f;
DrawCircleLinesV(screen_pos, radius, color);
DrawCircleLinesV(screen_pos, CHILD_INDICATOR_RADIUS, color);
int font_size = 10;
int font_size = CHILD_INDICATOR_FONT_SIZE;
int text_width = MeasureText(name, font_size);
Vector2 text_pos = {screen_pos.x - text_width/2, screen_pos.y - font_size/2};
DrawText(name, (int)text_pos.x, (int)text_pos.y, font_size, color);

Loading…
Cancel
Save