allow multi-select for ships/stations, mixable with scrap
This commit is contained in:
@@ -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"
|
||||
@@ -259,8 +259,14 @@ void ArenaView::mousePressEvent(QMouseEvent* event)
|
||||
m_selectedEntity = std::nullopt;
|
||||
}
|
||||
|
||||
// The arena is strictly single-select; emit a vector of size 0 or 1.
|
||||
std::vector<entt::entity> selection;
|
||||
if (m_selectedEntity.has_value())
|
||||
{
|
||||
selection.push_back(*m_selectedEntity);
|
||||
}
|
||||
EventManager::getInstance()->sendEventImmediately(
|
||||
std::make_shared<EntitySelectedEvent>(m_selectedEntity));
|
||||
std::make_shared<EntitySelectionChangedEvent>(selection));
|
||||
}
|
||||
|
||||
QOpenGLWidget::mousePressEvent(event);
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -250,11 +250,12 @@ void InspectWindow::updateInfoPanel(const ArenaStatus& status)
|
||||
}
|
||||
}
|
||||
|
||||
void InspectWindow::handleEvent(std::shared_ptr<const EntitySelectedEvent> event)
|
||||
void InspectWindow::handleEvent(std::shared_ptr<const EntitySelectionChangedEvent> event)
|
||||
{
|
||||
if (event->entity.has_value())
|
||||
if (!event->entities.empty())
|
||||
{
|
||||
m_selectedEntity = event->entity;
|
||||
// The arena is single-select, so only the first entity is inspected.
|
||||
m_selectedEntity = event->entities.front();
|
||||
|
||||
EntityAdmin& admin = m_sim->getAdmin();
|
||||
entt::entity entity = *m_selectedEntity;
|
||||
|
||||
@@ -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<EntitySelectedEvent,
|
||||
public CombinedEventHandler<EntitySelectionChangedEvent,
|
||||
GameSpeedChangedEvent>
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -38,7 +38,7 @@ protected:
|
||||
void keyPressEvent(QKeyEvent* event) override;
|
||||
|
||||
private:
|
||||
void handleEvent(std::shared_ptr<const EntitySelectedEvent> event) override;
|
||||
void handleEvent(std::shared_ptr<const EntitySelectionChangedEvent> event) override;
|
||||
void handleEvent(std::shared_ptr<const GameSpeedChangedEvent> event) override;
|
||||
|
||||
private slots:
|
||||
|
||||
Reference in New Issue
Block a user