share the world shapes both views draw identically
Groundwork for the WorldRenderer extraction: lift the shapes GameWorldView and ArenaView already draw the same way, before writing a renderer around them. Four of them turned out to be identical down to the constants - the ship triangle, the health bar, the debris marker and the sensor-range circle. The health bar was written three times: once in GameWorldView::drawHpBar and inlined twice in ArenaView, for stations and for ships. The argument for sharing is not de-duplication - it is about fifty lines. It is that the arena exists to eyeball combat, so it only does its job while a ship there looks like a ship in the game. Retuning the ship shape and having the balancing tool silently keep the old one is a quiet way to make the tool lie. Deliberately narrow. The two views differ on selection highlights, beams, target lines, and all of the factory rendering, and those stay where they are; the arena has already diverged on some of that and nobody minded, which is a reason to keep the shared set to shapes that are genuinely the same rather than to aspire to more. Free functions over explicit values, no state and no simulation, so each view keeps its own iteration and layer order. The balancing target does not link the ui library, so it compiles WorldPrimitives into itself - the mechanism already used for VisualsLoader and ShipStatsPanel. Two shared getters come with it: the ship's forward extent, which the selection ring and health bar are positioned from, and the debris radius, which the debris selection ring previously tracked via a comment saying "matching drawDebris". Behaviour is unchanged. WorldRenderer is next and will be built on these. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JcReq7hVk4KUPhTDKWAG7K
This commit is contained in:
@@ -371,6 +371,8 @@ The renderer iterates only entities and tiles whose world X lies within the visi
|
||||
|
||||
Shapes are hardcoded in the renderer — a building is a rectangle per footprint tile, a ship is an oriented arrow/triangle, a belt item is a 10×10 square, scrap is a small circle, a beam is a line. These structural choices live in the `draw<X>(painter, entity)` functions of the UI and are not expected to change frequently.
|
||||
|
||||
The few shapes the game view and the balancing tool's arena view draw *identically* — the ship body, the health bar, the debris marker, the sensor-range circle — live in `ui/WorldPrimitives` as free functions over explicit values. The arena exists to eyeball combat, so it only works while a ship there looks like a ship in the game; keeping these in one place means a retuned ship shape cannot silently stop applying to the tool that measures it. The balancing target does not link the `ui` library, so it compiles that file into itself, the same way it already does for `VisualsLoader` and `ShipStatsPanel` (see `balancing/CMakeLists.txt`). Everything the two views draw differently — selection highlights, beams, target lines, and all of the factory — stays with each view; the shared set is deliberately not grown beyond shapes that are genuinely the same.
|
||||
|
||||
Colors, outline widths, glyph text, and tile tints live in a separate config file, `visuals.toml`, loaded once by the UI at startup using the same pattern and lifetime as the sim config files (see Config Loading). The file is UI-scoped: the sim does not read it and does not depend on it.
|
||||
|
||||
Sketch of `visuals.toml`:
|
||||
|
||||
Reference in New Issue
Block a user