place the selection panel beside what it describes
This commit is contained in:
@@ -35,6 +35,7 @@
|
||||
#include "ProductionRules.h"
|
||||
#include "RepairBehavior.h"
|
||||
#include "SalvageScrapBehavior.h"
|
||||
#include "SelectionBounds.h"
|
||||
#include "SensorRangeComponent.h"
|
||||
#include "ShipIdentityComponent.h"
|
||||
#include "Simulation.h"
|
||||
@@ -451,30 +452,6 @@ void WorldRenderer::drawBuildings(QPainter& painter, const WorldCoordinates& coo
|
||||
drawSelectionHighlights(painter, coordinates, frame);
|
||||
}
|
||||
|
||||
std::optional<QRectF> WorldRenderer::footprintWidgetRect(
|
||||
const WorldCoordinates& coordinates, BuildingId id) const
|
||||
{
|
||||
std::optional<QPoint> anchor;
|
||||
std::optional<QSize> footprint;
|
||||
|
||||
if (const Building* b = findBuilding(m_sim.getFactoryState(), id))
|
||||
{
|
||||
anchor = b->anchor;
|
||||
footprint = b->footprint;
|
||||
}
|
||||
else if (const ConstructionSite* s = findSite(m_sim.getFactoryState(), id))
|
||||
{
|
||||
anchor = s->anchor;
|
||||
footprint = s->footprint;
|
||||
}
|
||||
if (!anchor.has_value() || !footprint.has_value()) { return std::nullopt; }
|
||||
|
||||
const QPointF tl = coordinates.tileToWidget(*anchor);
|
||||
return QRectF(tl.x(), tl.y(),
|
||||
footprint->width() * static_cast<qreal>(coordinates.getTilePx()),
|
||||
footprint->height() * static_cast<qreal>(coordinates.getTilePx()));
|
||||
}
|
||||
|
||||
void WorldRenderer::drawSelectionHighlights(QPainter& painter, const WorldCoordinates& coordinates,
|
||||
const WorldRenderFrame& frame)
|
||||
{
|
||||
@@ -483,7 +460,8 @@ void WorldRenderer::drawSelectionHighlights(QPainter& painter, const WorldCoordi
|
||||
|
||||
for (BuildingId selId : frame.selection.getSelectedBuildings())
|
||||
{
|
||||
const std::optional<QRectF> rect = footprintWidgetRect(coordinates, selId);
|
||||
const std::optional<QRectF> rect =
|
||||
getBuildingWidgetRect(m_sim.getFactoryState(), coordinates, selId);
|
||||
if (!rect.has_value()) { continue; }
|
||||
// Outline sits 1px outside the footprint (into adjacent tiles).
|
||||
painter.drawRect(rect->adjusted(-1, -1, 1, 1));
|
||||
|
||||
Reference in New Issue
Block a user