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:
@@ -176,9 +176,6 @@ private:
|
||||
QPointF center, float halfPx);
|
||||
void drawDebris(QPainter& painter, const WorldCoordinates& coordinates);
|
||||
void drawShips(QPainter& painter, const WorldCoordinates& coordinates);
|
||||
void drawHpBar(QPainter& painter, const WorldCoordinates& coordinates,
|
||||
qreal left, qreal top, qreal width,
|
||||
float fraction, bool isEnemy);
|
||||
void drawDebugSensorRanges(QPainter& painter, const WorldCoordinates& coordinates);
|
||||
void drawDebugTargetLines(QPainter& painter, const WorldCoordinates& coordinates);
|
||||
void drawDebugOverlay(QPainter& painter);
|
||||
|
||||
Reference in New Issue
Block a user