Rename Demolish to Deconstruct

This commit is contained in:
2026-07-22 21:40:42 +02:00
parent b2ce20e6ad
commit e20a0bba67
30 changed files with 166 additions and 166 deletions

View File

@@ -8,7 +8,7 @@
#include "BuildingType.h"
#include "BuildingTypeSelectedEvent.h"
#include "DemolishModeToggleRequestedEvent.h"
#include "DeconstructModeToggleRequestedEvent.h"
#include "DisplayName.h"
#include "EventManager.h"
#include "ExitBuilderModeRequestedEvent.h"
@@ -73,13 +73,13 @@ BuildButtonGrid::BuildButtonGrid(Simulation* sim, const GameConfig* config, QWid
}
connect(mapper, qOverload<int>(&QSignalMapper::mapped), this, &BuildButtonGrid::onBuildButton);
m_demolishButton = new QPushButton(tr("Demolish"), this);
m_demolishButton->setCheckable(true);
m_demolishButton->setFixedHeight(48);
layout->addWidget(m_demolishButton, row, col);
connect(m_demolishButton, &QPushButton::clicked, this, [this]() {
m_deconstructButton = new QPushButton(tr("Deconstruct"), this);
m_deconstructButton->setCheckable(true);
m_deconstructButton->setFixedHeight(48);
layout->addWidget(m_deconstructButton, row, col);
connect(m_deconstructButton, &QPushButton::clicked, this, [this]() {
EventManager::getInstance()->sendEventImmediately(
std::make_shared<DemolishModeToggleRequestedEvent>());
std::make_shared<DeconstructModeToggleRequestedEvent>());
});
updateVisibility();
@@ -183,9 +183,9 @@ void BuildButtonGrid::handleEvent(std::shared_ptr<const UnlockedBuildingsChanged
updateAffordability();
}
void BuildButtonGrid::handleEvent(std::shared_ptr<const DemolishModeChangedEvent> event)
void BuildButtonGrid::handleEvent(std::shared_ptr<const DeconstructModeChangedEvent> event)
{
m_demolishButton->setChecked(event->active);
m_deconstructButton->setChecked(event->active);
}
void BuildButtonGrid::handleEvent(std::shared_ptr<const BuildHotkeyPressedEvent> event)

View File

@@ -10,7 +10,7 @@
#include "BuildHotkeyPressedEvent.h"
#include "BuildingBlocksChangedEvent.h"
#include "BuildingType.h"
#include "DemolishModeChangedEvent.h"
#include "DeconstructModeChangedEvent.h"
#include "EventHandler.h"
#include "GameConfig.h"
#include "UnlockedBuildingsChangedEvent.h"
@@ -20,7 +20,7 @@ class Simulation;
class BuildButtonGrid : public QWidget,
public CombinedEventHandler<BuilderModeExitedEvent,
DemolishModeChangedEvent,
DeconstructModeChangedEvent,
BuildHotkeyPressedEvent,
BuildingBlocksChangedEvent,
UnlockedBuildingsChangedEvent>
@@ -44,7 +44,7 @@ private:
void updateVisibility();
void handleEvent(std::shared_ptr<const BuilderModeExitedEvent> event) override;
void handleEvent(std::shared_ptr<const DemolishModeChangedEvent> event) override;
void handleEvent(std::shared_ptr<const DeconstructModeChangedEvent> event) override;
void handleEvent(std::shared_ptr<const BuildHotkeyPressedEvent> event) override;
void handleEvent(std::shared_ptr<const BuildingBlocksChangedEvent> event) override;
void handleEvent(std::shared_ptr<const UnlockedBuildingsChangedEvent> event) override;
@@ -59,5 +59,5 @@ private:
std::vector<QPushButton*> m_buttons;
std::map<BuildingType, int> m_costs;
std::optional<std::size_t> m_activeIndex;
QPushButton* m_demolishButton;
QPushButton* m_deconstructButton;
};

View File

@@ -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)

View File

@@ -23,8 +23,8 @@
#include "BuildingType.h"
#include "BuildingTypeSelectedEvent.h"
#include "BuildingId.h"
#include "DemolishModeChangedEvent.h"
#include "DemolishModeToggleRequestedEvent.h"
#include "DeconstructModeChangedEvent.h"
#include "DeconstructModeToggleRequestedEvent.h"
#include "EventHandler.h"
#include "ExitBlueprintModeRequestedEvent.h"
#include "ExitBuilderModeRequestedEvent.h"
@@ -66,7 +66,7 @@ class GameWorldView : public QOpenGLWidget,
public CombinedEventHandler<BeamFiredEvent,
BuildingTypeSelectedEvent,
ExitBuilderModeRequestedEvent,
DemolishModeToggleRequestedEvent,
DeconstructModeToggleRequestedEvent,
BlueprintPlacementRequestedEvent,
ExitBlueprintModeRequestedEvent,
SpeedChangeRequestedEvent,
@@ -102,7 +102,7 @@ private:
void handleEvent(std::shared_ptr<const BeamFiredEvent> event) override;
void handleEvent(std::shared_ptr<const BuildingTypeSelectedEvent> event) override;
void handleEvent(std::shared_ptr<const ExitBuilderModeRequestedEvent> event) override;
void handleEvent(std::shared_ptr<const DemolishModeToggleRequestedEvent> event) override;
void handleEvent(std::shared_ptr<const DeconstructModeToggleRequestedEvent> event) override;
void handleEvent(std::shared_ptr<const BlueprintPlacementRequestedEvent> event) override;
void handleEvent(std::shared_ptr<const ExitBlueprintModeRequestedEvent> event) override;
void handleEvent(std::shared_ptr<const SpeedChangeRequestedEvent> event) override;
@@ -139,11 +139,11 @@ private:
// to make the paused state hard to miss: a black frame whose alpha fades from 50% at
// the viewport edges to 0% toward the center.
void drawPauseBorder(QPainter& painter);
// Vignette-style border shown while demolish mode is active (REQ-UI-DEMOLISH-BORDER),
// tinted with the demolish overlay color (including its configured alpha) from
// Vignette-style border shown while deconstruct mode is active (REQ-UI-DECONSTRUCT-BORDER),
// tinted with the deconstruct overlay color (including its configured alpha) from
// visuals.toml instead of black.
void drawDemolishBorder(QPainter& painter);
// Shared drawing for the pause/demolish vignettes: a mitred picture-frame border
void drawDeconstructBorder(QPainter& painter);
// Shared drawing for the pause/deconstruct vignettes: a mitred picture-frame border
// whose alpha fades from `edgeColor` (with its own alpha) at the viewport edge to
// fully transparent toward the center.
void drawVignetteBorder(QPainter& painter, const QColor& edgeColor);
@@ -252,7 +252,7 @@ private:
void exitBuilderMode();
void enterBlueprintMode(Blueprint blueprint);
void exitBlueprintMode();
void toggleDemolishMode();
void toggleDeconstructMode();
void rotateGhost(bool clockwise);
struct ActiveBeam
@@ -328,8 +328,8 @@ private:
std::vector<CopyConfigFlash> m_copyConfigFlashes;
static constexpr qint64 kCopyFlashDurationMs = 300;
bool m_demolishMode;
std::optional<BuildingId> m_demolishHoverBuildingId;
bool m_deconstructMode;
std::optional<BuildingId> m_deconstructHoverBuildingId;
bool m_debugDraw;
std::vector<BuildingId> m_selectedBuildingIds;

View File

@@ -44,7 +44,7 @@ struct OverlayVisuals
{
QColor ghostValid;
QColor ghostInvalid;
QColor demolishTint;
QColor deconstructTint;
QColor selectionRect;
QColor tileHighlight;
QColor selectedOutline;

View File

@@ -220,7 +220,7 @@ VisualsConfig VisualsLoader::load(const std::string& path)
toml::table& ov = requireSubtable(tbl, "overlays", "root");
cfg.overlays.ghostValid = parseColor(requireString(ov, "ghost_valid", "overlays"), "overlays.ghost_valid");
cfg.overlays.ghostInvalid = parseColor(requireString(ov, "ghost_invalid", "overlays"), "overlays.ghost_invalid");
cfg.overlays.demolishTint = parseColor(requireString(ov, "demolish_tint", "overlays"), "overlays.demolish_tint");
cfg.overlays.deconstructTint = parseColor(requireString(ov, "deconstruct_tint", "overlays"), "overlays.deconstruct_tint");
cfg.overlays.selectionRect = parseColor(requireString(ov, "selection_rect", "overlays"), "overlays.selection_rect");
cfg.overlays.tileHighlight = parseColor(requireString(ov, "tile_highlight", "overlays"), "overlays.tile_highlight");
cfg.overlays.selectedOutline = parseColor(requireString(ov, "selected_outline", "overlays"), "overlays.selected_outline");