Rename Demolish to Deconstruct
This commit is contained in:
@@ -35,7 +35,7 @@
|
||||
#include "ReplayPlayer.h"
|
||||
#include "ReplayReader.h"
|
||||
#include "ReplayRecorder.h"
|
||||
#include "DemolishModeChangedEvent.h"
|
||||
#include "DeconstructModeChangedEvent.h"
|
||||
#include "EntityHitTest.h"
|
||||
#include "EntitySelectionChangedEvent.h"
|
||||
#include "EventManager.h"
|
||||
@@ -157,7 +157,7 @@ GameWorldView::GameWorldView(Simulation* sim, const GameConfig* config,
|
||||
, m_ghostRotation(Rotation::East)
|
||||
, m_ghostValid(false)
|
||||
, m_dragging(false)
|
||||
, m_demolishMode(false)
|
||||
, m_deconstructMode(false)
|
||||
, m_debugDraw(false)
|
||||
, m_rng(std::random_device{}())
|
||||
, m_boxSelecting(false)
|
||||
@@ -463,7 +463,7 @@ void GameWorldView::paintGL()
|
||||
drawOverlays(painter);
|
||||
drawScreenSpace(painter);
|
||||
drawPauseBorder(painter);
|
||||
drawDemolishBorder(painter);
|
||||
drawDeconstructBorder(painter);
|
||||
drawReplayOverlay(painter);
|
||||
}
|
||||
|
||||
@@ -1984,13 +1984,13 @@ void GameWorldView::drawOverlays(QPainter& painter)
|
||||
if (!b.queuedForDeconstruction) { continue; }
|
||||
for (const QPoint& cell : b.bodyCells)
|
||||
{
|
||||
painter.fillRect(tileRect(cell), m_visuals->overlays.demolishTint);
|
||||
painter.fillRect(tileRect(cell), m_visuals->overlays.deconstructTint);
|
||||
}
|
||||
}
|
||||
|
||||
// Demolish tint: while dragging a demolish box, tint every covered
|
||||
// building/site (REQ-BLD-DEMOLISH-BOX); otherwise tint the hovered one.
|
||||
if (m_demolishMode && m_boxSelecting)
|
||||
// Deconstruct tint: while dragging a deconstruct box, tint every covered
|
||||
// building/site (REQ-BLD-DECONSTRUCT-BOX); otherwise tint the hovered one.
|
||||
if (m_deconstructMode && m_boxSelecting)
|
||||
{
|
||||
for (BuildingId id : buildingsInBox(m_boxStartTile, m_boxCurrentTile))
|
||||
{
|
||||
@@ -2004,19 +2004,19 @@ void GameWorldView::drawOverlays(QPainter& painter)
|
||||
{
|
||||
for (const QPoint& cell : *cells)
|
||||
{
|
||||
painter.fillRect(tileRect(cell), m_visuals->overlays.demolishTint);
|
||||
painter.fillRect(tileRect(cell), m_visuals->overlays.deconstructTint);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (m_demolishMode && m_demolishHoverBuildingId.has_value())
|
||||
else if (m_deconstructMode && m_deconstructHoverBuildingId.has_value())
|
||||
{
|
||||
const Building* b = m_sim->getBuildings().findBuilding(*m_demolishHoverBuildingId);
|
||||
const Building* b = m_sim->getBuildings().findBuilding(*m_deconstructHoverBuildingId);
|
||||
if (b)
|
||||
{
|
||||
for (const QPoint& cell : b->bodyCells)
|
||||
{
|
||||
painter.fillRect(tileRect(cell), m_visuals->overlays.demolishTint);
|
||||
painter.fillRect(tileRect(cell), m_visuals->overlays.deconstructTint);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2124,11 +2124,11 @@ void GameWorldView::drawPauseBorder(QPainter& painter)
|
||||
drawVignetteBorder(painter, QColor(0, 0, 0, 128)); // 50% black at the edge
|
||||
}
|
||||
|
||||
void GameWorldView::drawDemolishBorder(QPainter& painter)
|
||||
void GameWorldView::drawDeconstructBorder(QPainter& painter)
|
||||
{
|
||||
if (!m_demolishMode) { return; }
|
||||
// Reuse the demolish overlay color (with its configured alpha) as the edge color.
|
||||
drawVignetteBorder(painter, m_visuals->overlays.demolishTint);
|
||||
if (!m_deconstructMode) { return; }
|
||||
// Reuse the deconstruct overlay color (with its configured alpha) as the edge color.
|
||||
drawVignetteBorder(painter, m_visuals->overlays.deconstructTint);
|
||||
}
|
||||
|
||||
void GameWorldView::drawVignetteBorder(QPainter& painter, const QColor& edgeColor)
|
||||
@@ -2325,7 +2325,7 @@ void GameWorldView::keyPressEvent(QKeyEvent* event)
|
||||
case Qt::Key_Q:
|
||||
if (m_builderType.has_value()) { exitBuilderMode(); }
|
||||
else if (m_blueprintMode.has_value()) { exitBlueprintMode(); }
|
||||
else { toggleDemolishMode(); }
|
||||
else { toggleDeconstructMode(); }
|
||||
break;
|
||||
case Qt::Key_T:
|
||||
// Request a temporary blueprint from the current selection (REQ-UI-BLUEPRINT-TEMP).
|
||||
@@ -2387,7 +2387,7 @@ void GameWorldView::mousePressEvent(QMouseEvent* event)
|
||||
}
|
||||
}
|
||||
else if (m_blueprintMode.has_value()) { exitBlueprintMode(); }
|
||||
else if (m_demolishMode) { toggleDemolishMode(); }
|
||||
else if (m_deconstructMode) { toggleDeconstructMode(); }
|
||||
else if (event->modifiers() & Qt::ShiftModifier)
|
||||
{
|
||||
// Shift + right-click copies a building's settings, but only in the
|
||||
@@ -2424,10 +2424,10 @@ void GameWorldView::mousePressEvent(QMouseEvent* event)
|
||||
{
|
||||
placeBlueprintAtTile(tile);
|
||||
}
|
||||
else if (m_demolishMode)
|
||||
else if (m_deconstructMode)
|
||||
{
|
||||
// Start a demolish box drag; a plain click resolves as a 1x1 box on
|
||||
// release (REQ-BLD-DEMOLISH-CLICK, REQ-BLD-DEMOLISH-BOX).
|
||||
// Start a deconstruct box drag; a plain click resolves as a 1x1 box on
|
||||
// release (REQ-BLD-DECONSTRUCT-CLICK, REQ-BLD-DECONSTRUCT-BOX).
|
||||
m_boxSelecting = true;
|
||||
m_boxStartTile = tile;
|
||||
m_boxCurrentTile = tile;
|
||||
@@ -2601,9 +2601,9 @@ void GameWorldView::mouseMoveEvent(QMouseEvent* event)
|
||||
{
|
||||
m_blueprintGhostTile = tile;
|
||||
}
|
||||
else if (m_demolishMode)
|
||||
else if (m_deconstructMode)
|
||||
{
|
||||
m_demolishHoverBuildingId = buildingAtTile(tile);
|
||||
m_deconstructHoverBuildingId = buildingAtTile(tile);
|
||||
if (m_boxSelecting) { m_boxCurrentTile = tile; }
|
||||
}
|
||||
else if (m_boxSelecting)
|
||||
@@ -2632,12 +2632,12 @@ void GameWorldView::mouseReleaseEvent(QMouseEvent* event)
|
||||
const std::vector<BuildingId> boxIds =
|
||||
buildingsInBox(m_boxStartTile, m_boxCurrentTile);
|
||||
|
||||
if (m_demolishMode)
|
||||
if (m_deconstructMode)
|
||||
{
|
||||
const BuildingSystem& buildings = m_sim->getBuildings();
|
||||
|
||||
// Split covered ids into construction sites (removed instantly) and
|
||||
// operational demolishable buildings (the HQ is protected; player
|
||||
// operational deconstructible buildings (the HQ is protected; player
|
||||
// defence stations are not Buildings and never appear in the box).
|
||||
std::vector<BuildingId> sites;
|
||||
std::vector<BuildingId> operational;
|
||||
@@ -2654,11 +2654,11 @@ void GameWorldView::mouseReleaseEvent(QMouseEvent* event)
|
||||
}
|
||||
}
|
||||
|
||||
// Sites: instant demolition with the full refund (REQ-BLD-DEMOLISH).
|
||||
// Sites: instant demolition with the full refund (REQ-BLD-DECONSTRUCT).
|
||||
for (BuildingId id : sites)
|
||||
{
|
||||
std::shared_ptr<DemolishCommand> command =
|
||||
std::make_shared<DemolishCommand>();
|
||||
std::shared_ptr<DeconstructCommand> command =
|
||||
std::make_shared<DeconstructCommand>();
|
||||
command->id = id;
|
||||
enqueueCommand(command);
|
||||
}
|
||||
@@ -2666,7 +2666,7 @@ void GameWorldView::mouseReleaseEvent(QMouseEvent* event)
|
||||
// Operational buildings: if every covered one is already queued,
|
||||
// un-queue them all; otherwise queue each one not yet queued. A plain
|
||||
// click is the one-element case, giving the queue/un-queue toggle
|
||||
// (REQ-BLD-DEMOLISH-BOX, REQ-BLD-DEMOLISH-CLICK).
|
||||
// (REQ-BLD-DECONSTRUCT-BOX, REQ-BLD-DECONSTRUCT-CLICK).
|
||||
bool allQueued = !operational.empty();
|
||||
for (BuildingId id : operational)
|
||||
{
|
||||
@@ -2683,14 +2683,14 @@ void GameWorldView::mouseReleaseEvent(QMouseEvent* event)
|
||||
}
|
||||
else if (!buildings.isQueuedForDeconstruction(id))
|
||||
{
|
||||
std::shared_ptr<DemolishCommand> command =
|
||||
std::make_shared<DemolishCommand>();
|
||||
std::shared_ptr<DeconstructCommand> command =
|
||||
std::make_shared<DeconstructCommand>();
|
||||
command->id = id;
|
||||
enqueueCommand(command);
|
||||
}
|
||||
}
|
||||
|
||||
m_demolishHoverBuildingId = std::nullopt;
|
||||
m_deconstructHoverBuildingId = std::nullopt;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2786,21 +2786,21 @@ void GameWorldView::mouseReleaseEvent(QMouseEvent* event)
|
||||
// Methods (formerly slots)
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
void GameWorldView::toggleDemolishMode()
|
||||
void GameWorldView::toggleDeconstructMode()
|
||||
{
|
||||
if (m_demolishMode)
|
||||
if (m_deconstructMode)
|
||||
{
|
||||
m_demolishMode = false;
|
||||
m_demolishHoverBuildingId = std::nullopt;
|
||||
m_deconstructMode = false;
|
||||
m_deconstructHoverBuildingId = std::nullopt;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_builderType.has_value()) { exitBuilderMode(); }
|
||||
if (m_blueprintMode.has_value()) { exitBlueprintMode(); }
|
||||
m_demolishMode = true;
|
||||
m_deconstructMode = true;
|
||||
}
|
||||
EventManager::getInstance()->sendEventImmediately(
|
||||
std::make_shared<DemolishModeChangedEvent>(m_demolishMode));
|
||||
std::make_shared<DeconstructModeChangedEvent>(m_deconstructMode));
|
||||
}
|
||||
|
||||
void GameWorldView::rotateGhost(bool clockwise)
|
||||
@@ -2931,18 +2931,18 @@ void GameWorldView::enterBuilderMode(BuildingType type)
|
||||
m_ghostValid = false;
|
||||
m_tunnelGhostType = BuildingType::TunnelEntry;
|
||||
m_tunnelPartnerTile.reset();
|
||||
m_demolishMode = false;
|
||||
m_deconstructMode = false;
|
||||
m_blueprintMode.reset();
|
||||
EventManager::getInstance()->sendEventImmediately(
|
||||
std::make_shared<DemolishModeChangedEvent>(false));
|
||||
std::make_shared<DeconstructModeChangedEvent>(false));
|
||||
}
|
||||
|
||||
void GameWorldView::enterBlueprintMode(Blueprint blueprint)
|
||||
{
|
||||
if (m_builderType.has_value()) { exitBuilderMode(); }
|
||||
m_demolishMode = false;
|
||||
m_deconstructMode = false;
|
||||
EventManager::getInstance()->sendEventImmediately(
|
||||
std::make_shared<DemolishModeChangedEvent>(false));
|
||||
std::make_shared<DeconstructModeChangedEvent>(false));
|
||||
m_blueprintGhostTile = m_ghostTile;
|
||||
m_blueprintMode = std::move(blueprint);
|
||||
}
|
||||
@@ -2993,10 +2993,10 @@ void GameWorldView::resetForNewGame()
|
||||
m_schematicChoiceShown = false;
|
||||
m_ghostRotation = Rotation::East;
|
||||
m_ghostValid = false;
|
||||
m_demolishMode = false;
|
||||
m_demolishHoverBuildingId = std::nullopt;
|
||||
m_deconstructMode = false;
|
||||
m_deconstructHoverBuildingId = std::nullopt;
|
||||
EventManager::getInstance()->sendEventImmediately(
|
||||
std::make_shared<DemolishModeChangedEvent>(false));
|
||||
std::make_shared<DeconstructModeChangedEvent>(false));
|
||||
m_selectedBuildingIds.clear();
|
||||
clearEntitySelection();
|
||||
clearScrapSelection();
|
||||
@@ -3072,9 +3072,9 @@ void GameWorldView::handleEvent(std::shared_ptr<const ExitBuilderModeRequestedEv
|
||||
exitBuilderMode();
|
||||
}
|
||||
|
||||
void GameWorldView::handleEvent(std::shared_ptr<const DemolishModeToggleRequestedEvent> /*event*/)
|
||||
void GameWorldView::handleEvent(std::shared_ptr<const DeconstructModeToggleRequestedEvent> /*event*/)
|
||||
{
|
||||
toggleDemolishMode();
|
||||
toggleDeconstructMode();
|
||||
}
|
||||
|
||||
void GameWorldView::handleEvent(std::shared_ptr<const BlueprintPlacementRequestedEvent> event)
|
||||
|
||||
Reference in New Issue
Block a user