diff --git a/src/lib/eventsystem/event/CMakeLists.txt b/src/lib/eventsystem/event/CMakeLists.txt index ab7f2ff..327abab 100644 --- a/src/lib/eventsystem/event/CMakeLists.txt +++ b/src/lib/eventsystem/event/CMakeLists.txt @@ -22,6 +22,7 @@ SET(HDRS ${CMAKE_CURRENT_SOURCE_DIR}/DemolishModeToggleRequestedEvent.h ${CMAKE_CURRENT_SOURCE_DIR}/BlueprintPlacementRequestedEvent.h ${CMAKE_CURRENT_SOURCE_DIR}/ExitBlueprintModeRequestedEvent.h + ${CMAKE_CURRENT_SOURCE_DIR}/TemporaryBlueprintRequestedEvent.h ${CMAKE_CURRENT_SOURCE_DIR}/SpeedChangeRequestedEvent.h ${CMAKE_CURRENT_SOURCE_DIR}/LayoutDialogRequestedEvent.h ${CMAKE_CURRENT_SOURCE_DIR}/RecipeSelectionRequestedEvent.h diff --git a/src/lib/eventsystem/event/TemporaryBlueprintRequestedEvent.h b/src/lib/eventsystem/event/TemporaryBlueprintRequestedEvent.h new file mode 100644 index 0000000..4c89ce5 --- /dev/null +++ b/src/lib/eventsystem/event/TemporaryBlueprintRequestedEvent.h @@ -0,0 +1,9 @@ +#pragma once + +#include "Event.h" + +// Emitted when the player presses the temporary-blueprint hotkey (REQ-UI-BLUEPRINT-TEMP). +// Carries no payload: the blueprint is built from the current selection by the receiver. +class TemporaryBlueprintRequestedEvent : public Event +{ +}; diff --git a/src/ui/BlueprintPanel.cpp b/src/ui/BlueprintPanel.cpp index 8b57cea..b3d984a 100644 --- a/src/ui/BlueprintPanel.cpp +++ b/src/ui/BlueprintPanel.cpp @@ -339,3 +339,17 @@ void BlueprintPanel::handleEvent(std::shared_ptr { clearActiveBlueprintButton(); } + +void BlueprintPanel::handleEvent(std::shared_ptr /*event*/) +{ + // Temporary blueprint (REQ-UI-BLUEPRINT-TEMP): build from the current selection and + // enter placement mode without adding it to the list or persisting it. If nothing + // player-placeable is selected, do nothing. + Blueprint bp = createBlueprintFromSelection(); + if (bp.buildings.empty()) { return; } + + // No saved blueprint is active while a temporary one is being placed. + clearActiveBlueprintButton(); + EventManager::getInstance()->sendEventImmediately( + std::make_shared(std::move(bp))); +} diff --git a/src/ui/BlueprintPanel.h b/src/ui/BlueprintPanel.h index bf16846..bbb03b9 100644 --- a/src/ui/BlueprintPanel.h +++ b/src/ui/BlueprintPanel.h @@ -11,6 +11,7 @@ #include "EventHandler.h" #include "GameConfig.h" #include "SelectionChangedEvent.h" +#include "TemporaryBlueprintRequestedEvent.h" #include "Tick.h" class Simulation; @@ -21,7 +22,8 @@ class QVBoxLayout; class BlueprintPanel : public QWidget, public CombinedEventHandler + BlueprintModeExitedEvent, + TemporaryBlueprintRequestedEvent> { Q_OBJECT @@ -33,6 +35,7 @@ private: void handleEvent(std::shared_ptr event) override; void handleEvent(std::shared_ptr event) override; void handleEvent(std::shared_ptr event) override; + void handleEvent(std::shared_ptr event) override; private slots: void onCreateClicked(); diff --git a/src/ui/GameWorldView.cpp b/src/ui/GameWorldView.cpp index c583796..1a4bc20 100644 --- a/src/ui/GameWorldView.cpp +++ b/src/ui/GameWorldView.cpp @@ -56,6 +56,7 @@ #include "EscapeMenuRequestedEvent.h" #include "TracePrintRequestedEvent.h" #include "BuildHotkeyPressedEvent.h" +#include "TemporaryBlueprintRequestedEvent.h" #include "BossWaveUpdatedEvent.h" #include "BuilderModeExitedEvent.h" #include "BlueprintModeExitedEvent.h" @@ -1582,6 +1583,13 @@ void GameWorldView::keyPressEvent(QKeyEvent* event) else if (m_blueprintMode.has_value()) { exitBlueprintMode(); } else { toggleDemolishMode(); } break; + case Qt::Key_T: + // Request a temporary blueprint from the current selection (REQ-UI-BLUEPRINT-TEMP). + // The BlueprintPanel owns the selection and blueprint-capture logic; it decides + // whether anything placeable is selected and drives placement mode from there. + EventManager::getInstance()->sendEventImmediately( + std::make_shared()); + break; case Qt::Key_Escape: EventManager::getInstance()->sendEventImmediately( std::make_shared());