diff --git a/src/ui/GameWorldView.cpp b/src/ui/GameWorldView.cpp index f5b57bc..d793148 100644 --- a/src/ui/GameWorldView.cpp +++ b/src/ui/GameWorldView.cpp @@ -1382,21 +1382,6 @@ void GameWorldView::drawBuildings(QPainter& painter) painter.setPen(QPen(m_visuals->statusLight.outline, 1)); painter.drawEllipse(center, r, r); } - - // HP bar below the HQ footprint; the HQ's HP lives on its proxy entity. - if (b.type == BuildingType::Hq) - { - m_sim->getAdmin().forEach( - [&](entt::entity /*e*/, const HqProxyComponent& /*hq*/, - const FactionComponent& f, const HealthComponent& h) - { - if (h.maxHp > 0.0f) - { - drawHpBar(painter, bboxRect.left(), bboxRect.bottom() + 1.0, - bboxRect.width(), h.hp / h.maxHp, f.isEnemy); - } - }); - } } painter.setOpacity(0.5); @@ -1473,6 +1458,29 @@ void GameWorldView::drawBuildings(QPainter& painter) } painter.setOpacity(1.0); + // HP bar below the HQ footprint; the HQ's HP lives on its proxy entity. Drawn + // after every building and construction site fill so a belt (or other tile) + // placed directly below the HQ cannot overpaint the bar (REQ-UI-STATUS-LIGHT + // neighbours case, same rationale as the selection highlights below). + for (const Building& b : m_sim->getBuildings().getAllBuildings()) + { + if (b.type != BuildingType::Hq) { continue; } + const QPointF tl = tileToWidget(b.anchor); + const QRectF bboxRect(tl.x(), tl.y(), + b.footprint.width() * static_cast(getTilePx()), + b.footprint.height() * static_cast(getTilePx())); + m_sim->getAdmin().forEach( + [&](entt::entity /*e*/, const HqProxyComponent& /*hq*/, + const FactionComponent& f, const HealthComponent& h) + { + if (h.maxHp > 0.0f) + { + drawHpBar(painter, bboxRect.left(), bboxRect.bottom() + 1.0, + bboxRect.width(), h.hp / h.maxHp, f.isEnemy); + } + }); + } + // Selection highlights are drawn last, after every building and construction // site fill, so a selected building surrounded by neighbours keeps its outline: // the highlight sits 1px outside the footprint (into adjacent tiles), and drawing