remove the Shift copy-building-settings gesture
This commit is contained in:
@@ -269,20 +269,6 @@ void GameWorldView::onFrame()
|
||||
pruneDespawnedDebris();
|
||||
pruneDespawnedActors();
|
||||
|
||||
// Expire copy/paste flashes. Lifetime is wall-clock (the frame delta), so the
|
||||
// flash plays for a fixed real duration regardless of game speed, including
|
||||
// while the game is paused (REQ-BLD-COPY-CONFIG-FEEDBACK).
|
||||
if (!m_copyConfigFlashes.empty())
|
||||
{
|
||||
std::vector<CopyConfigFlash> live;
|
||||
for (CopyConfigFlash flash : m_copyConfigFlashes)
|
||||
{
|
||||
flash.remainingMs -= elapsed;
|
||||
if (flash.remainingMs > 0) { live.push_back(flash); }
|
||||
}
|
||||
m_copyConfigFlashes = std::move(live);
|
||||
}
|
||||
|
||||
// Apply held scroll
|
||||
{
|
||||
const bool viewMoved =
|
||||
@@ -414,9 +400,8 @@ void GameWorldView::paintGL()
|
||||
|
||||
WorldRenderFrame GameWorldView::makeRenderFrame() const
|
||||
{
|
||||
return WorldRenderFrame{m_selection, m_buildMode, m_activeBeams, m_copiedConfig,
|
||||
m_copyConfigFlashes, m_boxSelecting, m_boxStartTile,
|
||||
m_boxCurrentTile, m_debugDraw};
|
||||
return WorldRenderFrame{m_selection, m_buildMode, m_activeBeams, m_boxSelecting,
|
||||
m_boxStartTile, m_boxCurrentTile, m_debugDraw};
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -1026,10 +1011,6 @@ void GameWorldView::keyReleaseEvent(QKeyEvent* event)
|
||||
return;
|
||||
}
|
||||
if (m_inputMapper.handleKeyRelease(event)) { return; }
|
||||
// Releasing Shift discards the copied building settings (REQ-BLD-COPY-CONFIG).
|
||||
// Stays here rather than moving to the input mapper: Shift is the modifier of a
|
||||
// mouse gesture, not a keyboard action of its own.
|
||||
if (event->key() == Qt::Key_Shift) { m_copiedConfig.reset(); }
|
||||
QOpenGLWidget::keyReleaseEvent(event);
|
||||
}
|
||||
|
||||
@@ -1061,15 +1042,6 @@ void GameWorldView::mousePressEvent(QMouseEvent* event)
|
||||
{
|
||||
m_buildMode.exitCurrentMode();
|
||||
}
|
||||
else if (event->modifiers() & Qt::ShiftModifier)
|
||||
{
|
||||
// Shift + right-click copies a building's settings, but only in the
|
||||
// default selection mode (REQ-BLD-COPY-CONFIG).
|
||||
const QPoint tile = coordinates.widgetToTile(event->pos());
|
||||
std::optional<BuildingId> id = buildingAtTile(tile);
|
||||
if (!id.has_value()) { id = siteAtTile(tile); }
|
||||
if (id.has_value()) { copyConfigFrom(*id); }
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -1105,20 +1077,6 @@ void GameWorldView::mousePressEvent(QMouseEvent* event)
|
||||
}
|
||||
else
|
||||
{
|
||||
// Shift + left-click applies the copied settings to a same-type building
|
||||
// (REQ-BLD-COPY-CONFIG). Consumes the click so it does not change the
|
||||
// selection. Only active in the default selection mode.
|
||||
if ((event->modifiers() & Qt::ShiftModifier) && m_copiedConfig.has_value())
|
||||
{
|
||||
std::optional<BuildingId> id = buildingAtTile(tile);
|
||||
if (!id.has_value()) { id = siteAtTile(tile); }
|
||||
if (id.has_value())
|
||||
{
|
||||
pasteConfigTo(*id);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const bool ctrl = (event->modifiers() & Qt::ControlModifier) != 0;
|
||||
|
||||
// Only a click that hit nothing starts a box drag. Starting one on a hit
|
||||
@@ -1375,85 +1333,6 @@ void GameWorldView::rotateGhost(bool clockwise)
|
||||
}
|
||||
}
|
||||
|
||||
void GameWorldView::copyConfigFrom(BuildingId id)
|
||||
{
|
||||
const std::optional<BuildingConfig> config = readBuildingConfig(*m_sim, id);
|
||||
if (!config.has_value()) { return; }
|
||||
|
||||
// Only cache when there is something to copy: a selected recipe / schematic
|
||||
// (Miner, Assembler, Shipyard) or any Splitter (empty filters = accept-all).
|
||||
// Building types with no settings (Smelter, Reprocessing Plant, Salvage Bay,
|
||||
// belts / tunnels, HQ) leave any existing cache untouched (REQ-BLD-COPY-CONFIG).
|
||||
if (!config->recipeId.has_value() && !config->isSplitter) { return; }
|
||||
|
||||
m_copiedConfig = config;
|
||||
m_copyConfigFlashes.push_back({ id, kCopyFlashDurationMs });
|
||||
}
|
||||
|
||||
void GameWorldView::pasteConfigTo(BuildingId id)
|
||||
{
|
||||
if (!m_copiedConfig.has_value()) { return; }
|
||||
|
||||
const std::optional<BuildingConfig> target = readBuildingConfig(*m_sim, id);
|
||||
if (!target.has_value() || target->type != m_copiedConfig->type) { return; }
|
||||
|
||||
// The paste applies below; flash the target to confirm (REQ-BLD-COPY-CONFIG-FEEDBACK).
|
||||
m_copyConfigFlashes.push_back({ id, kCopyFlashDurationMs });
|
||||
|
||||
const BuildingConfig& source = *m_copiedConfig;
|
||||
|
||||
// The cached settings were valid on a same-type source building, so they are
|
||||
// valid and available on the target: unlock state is global, so a selected
|
||||
// recipe / schematic (REQ-LOCK-UI-RECIPE, REQ-LOCK-UI-SCHEMATIC) and splitter
|
||||
// filter item types (REQ-LOCK-UI-SPLITTER) remain unlocked. Applying reuses the
|
||||
// same configuration commands as the selected building panel, inheriting their
|
||||
// buffer-clearing and mid-cycle-cancel semantics (REQ-MAT-INPUT-BUFFER,
|
||||
// REQ-MAT-OUTPUT-BUFFER, REQ-BLD-SHIPYARD).
|
||||
if (source.isSplitter)
|
||||
{
|
||||
// Operational splitters are configured by tile; sites by BuildingId
|
||||
// (mirrors SelectedBuildingPanel::onSplitterFilterChanged).
|
||||
if (const Building* building = findBuilding(m_sim->getFactoryState(), id))
|
||||
{
|
||||
std::shared_ptr<SetSplitterFiltersCommand> command =
|
||||
std::make_shared<SetSplitterFiltersCommand>();
|
||||
command->tile = building->anchor;
|
||||
command->filterA = source.splitterFilterA;
|
||||
command->filterB = source.splitterFilterB;
|
||||
enqueueCommand(command);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::shared_ptr<SetSiteSplitterFiltersCommand> command =
|
||||
std::make_shared<SetSiteSplitterFiltersCommand>();
|
||||
command->id = id;
|
||||
command->filterA = source.splitterFilterA;
|
||||
command->filterB = source.splitterFilterB;
|
||||
enqueueCommand(command);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (source.recipeId.has_value())
|
||||
{
|
||||
std::shared_ptr<SetRecipeCommand> command = std::make_shared<SetRecipeCommand>();
|
||||
command->id = id;
|
||||
command->recipeId = *source.recipeId;
|
||||
enqueueCommand(command);
|
||||
}
|
||||
|
||||
// For a shipyard the schematic (above) must be applied before its module
|
||||
// layout, so both commands drain in order at the next tick boundary.
|
||||
if (source.type == BuildingType::Shipyard && source.shipLayout.has_value())
|
||||
{
|
||||
std::shared_ptr<SetShipLayoutCommand> command =
|
||||
std::make_shared<SetShipLayoutCommand>();
|
||||
command->id = id;
|
||||
command->layout = *source.shipLayout;
|
||||
enqueueCommand(command);
|
||||
}
|
||||
}
|
||||
|
||||
double GameWorldView::getGameSpeed() const
|
||||
{
|
||||
return m_gameSpeedMultiplier;
|
||||
@@ -1484,8 +1363,6 @@ void GameWorldView::resetForNewGame()
|
||||
m_activeBeams.clear();
|
||||
m_schematicChoiceShown = false;
|
||||
m_selection.clearAll();
|
||||
m_copiedConfig = std::nullopt;
|
||||
m_copyConfigFlashes.clear();
|
||||
m_boxSelecting = false;
|
||||
m_camera.reset();
|
||||
// Drops any key still held across the restart, which also republishes the pan
|
||||
|
||||
Reference in New Issue
Block a user