make selection box sub-tile aware
This commit is contained in:
@@ -984,9 +984,9 @@ void WorldRenderer::drawOverlays(QPainter& painter, const WorldCoordinates& coor
|
||||
|
||||
// Deconstruct tint: while dragging a deconstruct box, tint every covered
|
||||
// building/site (REQ-BLD-DECONSTRUCT-BOX); otherwise tint the hovered one.
|
||||
if (frame.buildMode.isDeconstructMode() && frame.isBoxSelecting)
|
||||
if (frame.buildMode.isDeconstructMode() && frame.boxWorldRect.has_value())
|
||||
{
|
||||
for (BuildingId id : buildingsInBox(m_sim.getFactoryState(), frame.boxStartTile, frame.boxCurrentTile))
|
||||
for (BuildingId id : buildingsInBox(m_sim.getFactoryState(), *frame.boxWorldRect))
|
||||
{
|
||||
const Building* b = findBuilding(m_sim.getFactoryState(), id);
|
||||
if (b && b->type == BuildingType::Hq) { continue; }
|
||||
@@ -1019,16 +1019,14 @@ void WorldRenderer::drawOverlays(QPainter& painter, const WorldCoordinates& coor
|
||||
}
|
||||
}
|
||||
|
||||
// Box-select rectangle. Not drawn until the drag has moved far enough to read as
|
||||
// one, so a plain click does not flash a rectangle (REQ-UI-MULTI-SELECT).
|
||||
if (frame.isBoxSelecting && frame.isBoxDragMoved)
|
||||
// Box-select rectangle, drawn from the world rectangle itself and unsnapped, so
|
||||
// the outline sits where the mouse went rather than on the tile grid
|
||||
// (REQ-UI-MULTI-SELECT).
|
||||
if (frame.boxWorldRect.has_value())
|
||||
{
|
||||
const QPoint tl(std::min(frame.boxStartTile.x(), frame.boxCurrentTile.x()),
|
||||
std::min(frame.boxStartTile.y(), frame.boxCurrentTile.y()));
|
||||
const QPoint br(std::max(frame.boxStartTile.x(), frame.boxCurrentTile.x()) + 1,
|
||||
std::max(frame.boxStartTile.y(), frame.boxCurrentTile.y()) + 1);
|
||||
const QRectF selRect(coordinates.tileToWidget(tl),
|
||||
coordinates.tileToWidget(br));
|
||||
const QRectF selRect(
|
||||
coordinates.worldToWidget(QVector2D(frame.boxWorldRect->topLeft())),
|
||||
coordinates.worldToWidget(QVector2D(frame.boxWorldRect->bottomRight())));
|
||||
// In deconstruct mode the box marks buildings for demolition, so it is
|
||||
// drawn in the deconstruct red instead of the selection color; the
|
||||
// tint's alpha governs only the fills it tints, never this outline
|
||||
|
||||
Reference in New Issue
Block a user