share the world shapes both views (game and balancing) draw identically
This commit is contained in:
@@ -66,6 +66,7 @@
|
||||
#include "StationBodyComponent.h"
|
||||
#include "DebrisComponent.h"
|
||||
#include "SurfaceMask.h"
|
||||
#include "WorldPrimitives.h"
|
||||
#include "Tick.h"
|
||||
#include "TunnelCompletion.h"
|
||||
#include "EscapeMenuRequestedEvent.h"
|
||||
@@ -1331,7 +1332,7 @@ void GameWorldView::drawBuildings(QPainter& painter, const WorldCoordinates& coo
|
||||
{
|
||||
if (h.maxHp > 0.0f)
|
||||
{
|
||||
drawHpBar(painter, coordinates,
|
||||
drawHealthBar(painter, coordinates,
|
||||
bboxRect.left(), bboxRect.bottom() + 1.0,
|
||||
bboxRect.width(), h.hp / h.maxHp, f.isEnemy);
|
||||
}
|
||||
@@ -1384,11 +1385,11 @@ void GameWorldView::drawSelectionHighlights(QPainter& painter,
|
||||
}
|
||||
|
||||
// A ring around each selected piece of debris, sitting just outside the debris's
|
||||
// rendered circle (radius getTilePx()*0.2, matching drawDebris) (REQ-UI-DEBRIS-CLICK-SELECT).
|
||||
// own rendered circle (REQ-UI-DEBRIS-CLICK-SELECT).
|
||||
if (!m_selection.getSelectedDebris().empty())
|
||||
{
|
||||
const qreal outlineRadius =
|
||||
static_cast<qreal>(coordinates.getTilePx() * 0.2f) + 3.0;
|
||||
static_cast<qreal>(getDebrisRadiusPx(coordinates)) + 3.0;
|
||||
for (const DebrisInfo& debris : getAllDebrisInfo(m_sim->getAdmin()))
|
||||
{
|
||||
if (!m_selection.isDebrisSelected(debris.entity)) { continue; }
|
||||
@@ -1534,14 +1535,10 @@ void GameWorldView::drawBeltItems(QPainter& painter, const WorldCoordinates& coo
|
||||
|
||||
void GameWorldView::drawDebris(QPainter& painter, const WorldCoordinates& coordinates)
|
||||
{
|
||||
const float r = coordinates.getTilePx() * 0.2f;
|
||||
for (const DebrisInfo& debris : getAllDebrisInfo(m_sim->getAdmin()))
|
||||
{
|
||||
const QPointF center = coordinates.worldToWidget(debris.position);
|
||||
painter.setBrush(QColor(128, 110, 90));
|
||||
painter.setPen(QPen(QColor(50, 40, 30), 1));
|
||||
painter.drawEllipse(center,
|
||||
static_cast<qreal>(r), static_cast<qreal>(r));
|
||||
drawDebrisMarker(painter, coordinates,
|
||||
coordinates.worldToWidget(debris.position));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1589,7 +1586,7 @@ void GameWorldView::drawStations(QPainter& painter, const WorldCoordinates& coor
|
||||
// HP bar below footprint.
|
||||
if (h.maxHp > 0.0f)
|
||||
{
|
||||
drawHpBar(painter, coordinates,
|
||||
drawHealthBar(painter, coordinates,
|
||||
bboxRect.left(), bboxRect.bottom() + 1.0,
|
||||
bboxRect.width(), h.hp / h.maxHp, f.isEnemy);
|
||||
}
|
||||
@@ -1598,6 +1595,8 @@ void GameWorldView::drawStations(QPainter& painter, const WorldCoordinates& coor
|
||||
|
||||
void GameWorldView::drawShips(QPainter& painter, const WorldCoordinates& coordinates)
|
||||
{
|
||||
const float forward = getShipForwardExtentPx(coordinates);
|
||||
|
||||
m_sim->getAdmin().forEach<ShipIdentityComponent, PositionComponent, FacingComponent,
|
||||
FactionComponent, HealthComponent>(
|
||||
[&](entt::entity e, const ShipIdentityComponent& si,
|
||||
@@ -1609,58 +1608,31 @@ void GameWorldView::drawShips(QPainter& painter, const WorldCoordinates& coordin
|
||||
if (it == m_visuals->ships.end()) { return; }
|
||||
|
||||
const QPointF center = coordinates.worldToWidget(pos.value);
|
||||
const QVector2D dir(std::cos(facing.radians), std::sin(facing.radians));
|
||||
const QVector2D perp(-dir.y(), dir.x());
|
||||
|
||||
const float fwd = coordinates.getTilePx() * 0.45f;
|
||||
const float side = coordinates.getTilePx() * 0.25f;
|
||||
|
||||
QPolygonF tri;
|
||||
tri << QPointF(center.x() + static_cast<qreal>(dir.x() * fwd),
|
||||
center.y() + static_cast<qreal>(dir.y() * fwd))
|
||||
<< QPointF(center.x() + static_cast<qreal>(perp.x() * side - dir.x() * side),
|
||||
center.y() + static_cast<qreal>(perp.y() * side - dir.y() * side))
|
||||
<< QPointF(center.x() + static_cast<qreal>(-perp.x() * side - dir.x() * side),
|
||||
center.y() + static_cast<qreal>(-perp.y() * side - dir.y() * side));
|
||||
|
||||
painter.setPen(QPen(it->second.outline, 1));
|
||||
painter.setBrush(it->second.fill);
|
||||
painter.drawPolygon(tri);
|
||||
drawShipBody(painter, coordinates, center, facing.radians,
|
||||
it->second.fill, it->second.outline);
|
||||
|
||||
if (m_selection.isActorSelected(e))
|
||||
{
|
||||
painter.setPen(QPen(m_visuals->overlays.selectedOutline, 2));
|
||||
painter.setBrush(Qt::NoBrush);
|
||||
const qreal r = static_cast<qreal>(fwd) + 2.0;
|
||||
const qreal r = static_cast<qreal>(forward) + 2.0;
|
||||
painter.drawEllipse(center, r, r);
|
||||
}
|
||||
|
||||
if (h.maxHp > 0.0f)
|
||||
{
|
||||
const qreal barW = static_cast<qreal>(fwd) * 2.0;
|
||||
const qreal barX = center.x() - static_cast<qreal>(fwd);
|
||||
const qreal barY = center.y() + static_cast<qreal>(fwd) + 1.0;
|
||||
drawHpBar(painter, coordinates, barX, barY, barW,
|
||||
h.hp / h.maxHp, fac.isEnemy);
|
||||
const qreal barW = static_cast<qreal>(forward) * 2.0;
|
||||
const qreal barX = center.x() - static_cast<qreal>(forward);
|
||||
const qreal barY = center.y() + static_cast<qreal>(forward) + 1.0;
|
||||
drawHealthBar(painter, coordinates, barX, barY, barW,
|
||||
h.hp / h.maxHp, fac.isEnemy);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void GameWorldView::drawHpBar(QPainter& painter, const WorldCoordinates& coordinates,
|
||||
qreal left, qreal top, qreal width,
|
||||
float fraction, bool isEnemy)
|
||||
{
|
||||
const qreal barH = static_cast<qreal>(coordinates.getTilePx()) * 0.12;
|
||||
const float clamped = std::max(0.0f, fraction);
|
||||
painter.fillRect(QRectF(left, top, width, barH), QColor(60, 60, 60));
|
||||
painter.fillRect(QRectF(left, top, width * static_cast<qreal>(clamped), barH),
|
||||
isEnemy ? QColor(200, 60, 60) : QColor(60, 200, 60));
|
||||
}
|
||||
|
||||
void GameWorldView::drawDebugSensorRanges(QPainter& painter,
|
||||
const WorldCoordinates& coordinates)
|
||||
{
|
||||
painter.setBrush(Qt::NoBrush);
|
||||
m_sim->getAdmin().forEach<ShipIdentityComponent, PositionComponent, FacingComponent,
|
||||
FactionComponent, SensorRangeComponent>(
|
||||
[&](entt::entity /*e*/, const ShipIdentityComponent& si,
|
||||
@@ -1671,13 +1643,9 @@ void GameWorldView::drawDebugSensorRanges(QPainter& painter,
|
||||
m_visuals->ships.find(si.schematicId);
|
||||
if (it == m_visuals->ships.end()) { return; }
|
||||
|
||||
const QPointF center = coordinates.worldToWidget(pos.value);
|
||||
const qreal radiusPx = static_cast<qreal>(sensor.value_tiles)
|
||||
* static_cast<qreal>(coordinates.getTilePx());
|
||||
QColor circleColor = it->second.outline;
|
||||
circleColor.setAlpha(77);
|
||||
painter.setPen(QPen(circleColor, 1));
|
||||
painter.drawEllipse(center, radiusPx, radiusPx);
|
||||
drawSensorRange(painter, coordinates,
|
||||
coordinates.worldToWidget(pos.value),
|
||||
sensor.value_tiles, it->second.outline);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user