feat(baseball): make bases, outs, and count display configurable#81
Conversation
Add user-configurable settings for the live game bases diamond, outs circles, and balls-strikes count display. All settings appear in the web UI under Customization with proper form controls. New settings under customization: - bases: diamond_size, occupied_color, empty_color, x/y_offset - outs: circle_diameter, counted_color, empty_color, spacing, distance_from_bases - count: text_color, y_offset Both switch mode (baseball.py) and scroll mode (game_renderer.py) read from the same config. Defaults match the previous hardcoded values so existing displays are unchanged. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
📝 WalkthroughWalkthroughThe baseball-scoreboard plugin now supports configurable rendering for bases, outs, and count display. Geometric parameters (sizing, spacing, offsets) and colors previously hardcoded in Python files are now read from a Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
plugins/baseball-scoreboard/game_renderer.py (1)
297-318:⚠️ Potential issue | 🟠 MajorOccupied bases incorrectly inherit empty-base outline color in scroll mode.
When
occupied_colorandempty_colordiffer, occupied bases are still drawn withoutline=base_outline, which makes scroll mode visually inconsistent with switch mode.Proposed fix
- draw.polygon(poly2, fill=base_fill if bases_occupied[1] else None, outline=base_outline) + if bases_occupied[1]: + draw.polygon(poly2, fill=base_fill) + else: + draw.polygon(poly2, outline=base_outline) @@ - draw.polygon(poly3, fill=base_fill if bases_occupied[2] else None, outline=base_outline) + if bases_occupied[2]: + draw.polygon(poly3, fill=base_fill) + else: + draw.polygon(poly3, outline=base_outline) @@ - draw.polygon(poly1, fill=base_fill if bases_occupied[0] else None, outline=base_outline) + if bases_occupied[0]: + draw.polygon(poly1, fill=base_fill) + else: + draw.polygon(poly1, outline=base_outline)🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@plugins/baseball-scoreboard/game_renderer.py` around lines 297 - 318, The occupied bases use base_outline regardless of occupancy; update the draw.polygon calls for poly2, poly3, and poly1 so the outline parameter is conditional: use base_outline when the base is empty, otherwise use base_fill (i.e., outline=base_fill if bases_occupied[index] else base_outline) so occupied bases get the occupied color as their outline instead of inheriting the empty-base outline.
🧹 Nitpick comments (1)
plugins/baseball-scoreboard/game_renderer.py (1)
266-344: Consider centralizing base/out/count rendering config normalization.This block duplicates defaulting and geometry setup also implemented in
plugins/baseball-scoreboard/baseball.py, which increases drift risk between switch and scroll modes.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@plugins/baseball-scoreboard/game_renderer.py` around lines 266 - 344, The rendering code duplicates config defaulting and geometry math from baseball.py; extract a shared normalization helper (e.g., normalize_display_config or normalize_base_layout) that accepts self.config, inning_bbox, inning_half and game and returns normalized bases_cfg, outs_cfg, count_cfg, base_diamond_size, out_circle_diameter, out_vertical_spacing, spacing_between_bases_outs, base_cluster_width, base_cluster_height, bases_origin_x, overall_start_y, out_cluster_height and has_count_data; update the GameRenderer method (the method using self.config, bases_cfg, outs_cfg, count_cfg, bases_origin_x, overall_start_y, base_cluster_* and has_count_data) to call that helper and use its returned values instead of repeating default logic, and make baseball.py call the same helper so both switch and scroll modes share a single source of truth while leaving drawing calls (_draw_text_with_outline, draw.polygon/ellipse) unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@plugins/baseball-scoreboard/game_renderer.py`:
- Around line 297-318: The occupied bases use base_outline regardless of
occupancy; update the draw.polygon calls for poly2, poly3, and poly1 so the
outline parameter is conditional: use base_outline when the base is empty,
otherwise use base_fill (i.e., outline=base_fill if bases_occupied[index] else
base_outline) so occupied bases get the occupied color as their outline instead
of inheriting the empty-base outline.
---
Nitpick comments:
In `@plugins/baseball-scoreboard/game_renderer.py`:
- Around line 266-344: The rendering code duplicates config defaulting and
geometry math from baseball.py; extract a shared normalization helper (e.g.,
normalize_display_config or normalize_base_layout) that accepts self.config,
inning_bbox, inning_half and game and returns normalized bases_cfg, outs_cfg,
count_cfg, base_diamond_size, out_circle_diameter, out_vertical_spacing,
spacing_between_bases_outs, base_cluster_width, base_cluster_height,
bases_origin_x, overall_start_y, out_cluster_height and has_count_data; update
the GameRenderer method (the method using self.config, bases_cfg, outs_cfg,
count_cfg, bases_origin_x, overall_start_y, base_cluster_* and has_count_data)
to call that helper and use its returned values instead of repeating default
logic, and make baseball.py call the same helper so both switch and scroll modes
share a single source of truth while leaving drawing calls
(_draw_text_with_outline, draw.polygon/ellipse) unchanged.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 65376cf8-646c-4a83-9630-9736c26f26d3
📒 Files selected for processing (3)
plugins/baseball-scoreboard/baseball.pyplugins/baseball-scoreboard/config_schema.jsonplugins/baseball-scoreboard/game_renderer.py
Summary
baseball.py) and scroll mode (game_renderer.py) respect the same configNew settings (under
customization)Bases Diamond: diamond_size, occupied_color, empty_color, x_offset, y_offset
Outs Circles: circle_diameter, counted_color, empty_color, spacing, distance_from_bases
Count Text: text_color, y_offset
Test plan
🤖 Generated with Claude Code
Summary by CodeRabbit