fix issue where HP bar is drawn below belts
This commit is contained in:
@@ -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<HqProxyComponent, FactionComponent, HealthComponent>(
|
||||
[&](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<qreal>(getTilePx()),
|
||||
b.footprint.height() * static_cast<qreal>(getTilePx()));
|
||||
m_sim->getAdmin().forEach<HqProxyComponent, FactionComponent, HealthComponent>(
|
||||
[&](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
|
||||
|
||||
Reference in New Issue
Block a user