From db1b7b617f20cfc0db7b4f4bccb1be8b95292a7f Mon Sep 17 00:00:00 2001 From: Malte Langkabel Date: Mon, 20 Jul 2026 20:32:35 +0200 Subject: [PATCH] Rename EntitySelectedEvent to EntitySelectionChangedEvent The event also fires on deselection and now carries a set of entities rather than a single one, so the "SelectionChanged" name (matching SelectionChangedEvent and ScrapSelectionChangedEvent) is more accurate. Pure rename: header + include guard, CMake entry, and all usages. Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_01Y7N59FsLA5e2kuVdqe4Uhc --- src/balancing/ArenaView.cpp | 4 ++-- src/balancing/ArenaView.h | 2 +- src/balancing/InspectWindow.cpp | 2 +- src/balancing/InspectWindow.h | 6 +++--- src/lib/eventsystem/event/CMakeLists.txt | 2 +- ...tySelectedEvent.h => EntitySelectionChangedEvent.h} | 10 +++++----- src/ui/GameWorldView.cpp | 10 +++++----- src/ui/GameWorldView.h | 4 ++-- src/ui/SelectedBuildingPanel.cpp | 4 ++-- src/ui/SelectedBuildingPanel.h | 6 +++--- 10 files changed, 25 insertions(+), 25 deletions(-) rename src/lib/eventsystem/event/{EntitySelectedEvent.h => EntitySelectionChangedEvent.h} (64%) diff --git a/src/balancing/ArenaView.cpp b/src/balancing/ArenaView.cpp index 36443ca..f781e19 100644 --- a/src/balancing/ArenaView.cpp +++ b/src/balancing/ArenaView.cpp @@ -15,7 +15,7 @@ #include "Building.h" #include "BuildingSystem.h" #include "EntityHitTest.h" -#include "EntitySelectedEvent.h" +#include "EntitySelectionChangedEvent.h" #include "EventManager.h" #include "FacingComponent.h" #include "FactionComponent.h" @@ -266,7 +266,7 @@ void ArenaView::mousePressEvent(QMouseEvent* event) selection.push_back(*m_selectedEntity); } EventManager::getInstance()->sendEventImmediately( - std::make_shared(selection)); + std::make_shared(selection)); } QOpenGLWidget::mousePressEvent(event); diff --git a/src/balancing/ArenaView.h b/src/balancing/ArenaView.h index 5849b32..4bfc9f7 100644 --- a/src/balancing/ArenaView.h +++ b/src/balancing/ArenaView.h @@ -13,7 +13,7 @@ #include "BeamFiredEvent.h" #include "entt/entity/entity.hpp" -#include "EntitySelectedEvent.h" +#include "EntitySelectionChangedEvent.h" #include "Tick.h" #include "TickDriver.h" #include "VisualsConfig.h" diff --git a/src/balancing/InspectWindow.cpp b/src/balancing/InspectWindow.cpp index 24121d6..419ee60 100644 --- a/src/balancing/InspectWindow.cpp +++ b/src/balancing/InspectWindow.cpp @@ -250,7 +250,7 @@ void InspectWindow::updateInfoPanel(const ArenaStatus& status) } } -void InspectWindow::handleEvent(std::shared_ptr event) +void InspectWindow::handleEvent(std::shared_ptr event) { if (!event->entities.empty()) { diff --git a/src/balancing/InspectWindow.h b/src/balancing/InspectWindow.h index ea3826b..008d2ea 100644 --- a/src/balancing/InspectWindow.h +++ b/src/balancing/InspectWindow.h @@ -12,7 +12,7 @@ #include "entt/entity/entity.hpp" #include "ArenaSimulation.h" -#include "EntitySelectedEvent.h" +#include "EntitySelectionChangedEvent.h" #include "EventHandler.h" #include "GameConfig.h" #include "GameSpeedChangedEvent.h" @@ -22,7 +22,7 @@ class ArenaView; class ShipStatsPanel; class InspectWindow : public QWidget, - public CombinedEventHandler { Q_OBJECT @@ -38,7 +38,7 @@ protected: void keyPressEvent(QKeyEvent* event) override; private: - void handleEvent(std::shared_ptr event) override; + void handleEvent(std::shared_ptr event) override; void handleEvent(std::shared_ptr event) override; private slots: diff --git a/src/lib/eventsystem/event/CMakeLists.txt b/src/lib/eventsystem/event/CMakeLists.txt index 327abab..784387d 100644 --- a/src/lib/eventsystem/event/CMakeLists.txt +++ b/src/lib/eventsystem/event/CMakeLists.txt @@ -4,7 +4,7 @@ SET(HDRS ${CMAKE_CURRENT_SOURCE_DIR}/TickAdvancedEvent.h ${CMAKE_CURRENT_SOURCE_DIR}/BuildingBlocksChangedEvent.h ${CMAKE_CURRENT_SOURCE_DIR}/ExpansionCostChangedEvent.h - ${CMAKE_CURRENT_SOURCE_DIR}/EntitySelectedEvent.h + ${CMAKE_CURRENT_SOURCE_DIR}/EntitySelectionChangedEvent.h ${CMAKE_CURRENT_SOURCE_DIR}/GameSpeedChangedEvent.h ${CMAKE_CURRENT_SOURCE_DIR}/BossWaveUpdatedEvent.h ${CMAKE_CURRENT_SOURCE_DIR}/SchematicChoicesAvailableEvent.h diff --git a/src/lib/eventsystem/event/EntitySelectedEvent.h b/src/lib/eventsystem/event/EntitySelectionChangedEvent.h similarity index 64% rename from src/lib/eventsystem/event/EntitySelectedEvent.h rename to src/lib/eventsystem/event/EntitySelectionChangedEvent.h index 9c5c5a1..2419358 100644 --- a/src/lib/eventsystem/event/EntitySelectedEvent.h +++ b/src/lib/eventsystem/event/EntitySelectionChangedEvent.h @@ -1,5 +1,5 @@ -#ifndef ENTITY_SELECTED_EVENT_H -#define ENTITY_SELECTED_EVENT_H +#ifndef ENTITY_SELECTION_CHANGED_EVENT_H +#define ENTITY_SELECTION_CHANGED_EVENT_H #include @@ -11,10 +11,10 @@ // no actor is selected. Actors share the "field" selection category with scrap piles // (REQ-UI-SELECTION-CATEGORIES): they can be selected together, but never together with // buildings. -class EntitySelectedEvent : public Event +class EntitySelectionChangedEvent : public Event { public: - explicit EntitySelectedEvent(std::vector entities) + explicit EntitySelectionChangedEvent(std::vector entities) : entities(std::move(entities)) { } @@ -22,4 +22,4 @@ public: const std::vector entities; }; -#endif // ENTITY_SELECTED_EVENT_H +#endif // ENTITY_SELECTION_CHANGED_EVENT_H diff --git a/src/ui/GameWorldView.cpp b/src/ui/GameWorldView.cpp index a39a9cf..543abc3 100644 --- a/src/ui/GameWorldView.cpp +++ b/src/ui/GameWorldView.cpp @@ -37,7 +37,7 @@ #include "ReplayRecorder.h" #include "DemolishModeChangedEvent.h" #include "EntityHitTest.h" -#include "EntitySelectedEvent.h" +#include "EntitySelectionChangedEvent.h" #include "EventManager.h" #include "FacingComponent.h" #include "FactionComponent.h" @@ -731,7 +731,7 @@ void GameWorldView::clearEntitySelection() if (m_selectedEntities.empty()) { return; } m_selectedEntities.clear(); EventManager::getInstance()->sendEventImmediately( - std::make_shared(m_selectedEntities)); + std::make_shared(m_selectedEntities)); } void GameWorldView::pruneDespawnedActors() @@ -753,7 +753,7 @@ void GameWorldView::pruneDespawnedActors() { m_selectedEntities = std::move(live); EventManager::getInstance()->sendEventImmediately( - std::make_shared(m_selectedEntities)); + std::make_shared(m_selectedEntities)); } } @@ -2118,7 +2118,7 @@ void GameWorldView::mousePressEvent(QMouseEvent* event) clearScrapSelection(); } EventManager::getInstance()->sendEventImmediately( - std::make_shared(m_selectedEntities)); + std::make_shared(m_selectedEntities)); return; } @@ -2308,7 +2308,7 @@ void GameWorldView::mouseReleaseEvent(QMouseEvent* event) } } EventManager::getInstance()->sendEventImmediately( - std::make_shared(m_selectedEntities)); + std::make_shared(m_selectedEntities)); EventManager::getInstance()->sendEventImmediately( std::make_shared(m_selectedScrap)); return; diff --git a/src/ui/GameWorldView.h b/src/ui/GameWorldView.h index 2a44caf..7a44199 100644 --- a/src/ui/GameWorldView.h +++ b/src/ui/GameWorldView.h @@ -36,7 +36,7 @@ #include "entt/entity/entity.hpp" #include "CommandManager.h" -#include "EntitySelectedEvent.h" +#include "EntitySelectionChangedEvent.h" #include "GameConfig.h" #include "Rotation.h" #include "Tick.h" @@ -191,7 +191,7 @@ private: // Drops despawned or fully-collected piles from the scrap selection and re-emits // when it changed (REQ-UI-SCRAP-CLICK-SELECT). Called each frame from onFrame(). void pruneDespawnedScrap(); - // Clears the actor selection, emitting an empty EntitySelectedEvent when it was + // Clears the actor selection, emitting an empty EntitySelectionChangedEvent when it was // non-empty (REQ-UI-ENTITY-CLICK-SELECT). Used when buildings take over. void clearEntitySelection(); // Drops despawned or dead actors from the selection and re-emits when it changed diff --git a/src/ui/SelectedBuildingPanel.cpp b/src/ui/SelectedBuildingPanel.cpp index 7c9d448..f416da4 100644 --- a/src/ui/SelectedBuildingPanel.cpp +++ b/src/ui/SelectedBuildingPanel.cpp @@ -17,7 +17,7 @@ #include "DisplayName.h" #include "DynamicBodyComponent.h" #include "EntityAdmin.h" -#include "EntitySelectedEvent.h" +#include "EntitySelectionChangedEvent.h" #include "EventManager.h" #include "FactionComponent.h" #include "HealthComponent.h" @@ -914,7 +914,7 @@ void SelectedBuildingPanel::onClearBelt() } } -void SelectedBuildingPanel::handleEvent(std::shared_ptr event) +void SelectedBuildingPanel::handleEvent(std::shared_ptr event) { m_selectedEntities = event->entities; if (!m_selectedEntities.empty()) diff --git a/src/ui/SelectedBuildingPanel.h b/src/ui/SelectedBuildingPanel.h index 164f251..a0893c7 100644 --- a/src/ui/SelectedBuildingPanel.h +++ b/src/ui/SelectedBuildingPanel.h @@ -13,7 +13,7 @@ #include "Building.h" #include "BuildingId.h" #include "DebugDrawToggledEvent.h" -#include "EntitySelectedEvent.h" +#include "EntitySelectionChangedEvent.h" #include "EventHandler.h" #include "GameConfig.h" #include "PlayerCommandsAppliedEvent.h" @@ -36,7 +36,7 @@ class QVBoxLayout; class SelectedBuildingPanel : public QWidget, public CombinedEventHandler @@ -51,7 +51,7 @@ public: 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; void handleEvent(std::shared_ptr event) override; void handleEvent(std::shared_ptr event) override; void handleEvent(std::shared_ptr event) override;