switch to using own event system
This commit is contained in:
@@ -12,8 +12,11 @@
|
||||
#include <QScrollArea>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include "BlueprintPlacementRequestedEvent.h"
|
||||
#include "BlueprintSerializer.h"
|
||||
#include "BuildingBlocksChangedEvent.h"
|
||||
#include "EventManager.h"
|
||||
#include "ExitBlueprintModeRequestedEvent.h"
|
||||
|
||||
#include "Building.h"
|
||||
#include "BuildingSystem.h"
|
||||
@@ -62,12 +65,12 @@ BlueprintPanel::BlueprintPanel(Simulation* sim, const GameConfig* config, QWidge
|
||||
connect(m_saveBtn, &QPushButton::clicked, this, &BlueprintPanel::onSaveClicked);
|
||||
connect(m_loadBtn, &QPushButton::clicked, this, &BlueprintPanel::onLoadClicked);
|
||||
|
||||
registerForEvent();
|
||||
registerForEvents();
|
||||
}
|
||||
|
||||
BlueprintPanel::~BlueprintPanel()
|
||||
{
|
||||
unregisterForEvent();
|
||||
unregisterForEvents();
|
||||
}
|
||||
|
||||
void BlueprintPanel::onSelectionChanged(const std::vector<BuildingId>& ids)
|
||||
@@ -114,7 +117,8 @@ void BlueprintPanel::onDeleteBlueprintClicked(int index)
|
||||
if (m_activeIndex == index)
|
||||
{
|
||||
m_activeIndex = -1;
|
||||
emit exitBlueprintModeRequested();
|
||||
EventManager::getInstance()->sendEventImmediately(
|
||||
std::make_shared<ExitBlueprintModeRequestedEvent>());
|
||||
}
|
||||
else if (m_activeIndex > index)
|
||||
{
|
||||
@@ -131,7 +135,8 @@ void BlueprintPanel::onBlueprintButtonClicked(int index)
|
||||
if (m_activeIndex == index)
|
||||
{
|
||||
clearActiveBlueprintButton();
|
||||
emit exitBlueprintModeRequested();
|
||||
EventManager::getInstance()->sendEventImmediately(
|
||||
std::make_shared<ExitBlueprintModeRequestedEvent>());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -142,7 +147,8 @@ void BlueprintPanel::onBlueprintButtonClicked(int index)
|
||||
|
||||
m_activeIndex = index;
|
||||
m_blueprintButtons[static_cast<std::size_t>(index)]->setChecked(true);
|
||||
emit blueprintPlacementRequested(m_blueprints[static_cast<std::size_t>(index)]);
|
||||
EventManager::getInstance()->sendEventImmediately(
|
||||
std::make_shared<BlueprintPlacementRequestedEvent>(m_blueprints[static_cast<std::size_t>(index)]));
|
||||
}
|
||||
|
||||
Blueprint BlueprintPanel::createBlueprintFromSelection() const
|
||||
@@ -312,7 +318,8 @@ void BlueprintPanel::onLoadClicked()
|
||||
|
||||
if (m_activeIndex >= 0)
|
||||
{
|
||||
emit exitBlueprintModeRequested();
|
||||
EventManager::getInstance()->sendEventImmediately(
|
||||
std::make_shared<ExitBlueprintModeRequestedEvent>());
|
||||
m_activeIndex = -1;
|
||||
}
|
||||
|
||||
@@ -350,3 +357,13 @@ void BlueprintPanel::refreshButtonStates()
|
||||
canAfford || m_activeIndex == i);
|
||||
}
|
||||
}
|
||||
|
||||
void BlueprintPanel::handleEvent(std::shared_ptr<const SelectionChangedEvent> event)
|
||||
{
|
||||
onSelectionChanged(event->ids);
|
||||
}
|
||||
|
||||
void BlueprintPanel::handleEvent(std::shared_ptr<const BlueprintModeExitedEvent> /*event*/)
|
||||
{
|
||||
clearActiveBlueprintButton();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user