switch to using own event system
This commit is contained in:
@@ -13,10 +13,20 @@
|
||||
#include <QVector2D>
|
||||
|
||||
#include "Blueprint.h"
|
||||
#include "SchematicChoiceOption.h"
|
||||
#include "BlueprintModeExitedEvent.h"
|
||||
#include "BlueprintPlacementRequestedEvent.h"
|
||||
#include "BuilderModeExitedEvent.h"
|
||||
#include "BuildingType.h"
|
||||
#include "BuildingTypeSelectedEvent.h"
|
||||
#include "BuildingId.h"
|
||||
#include "FireEvent.h"
|
||||
#include "DemolishModeChangedEvent.h"
|
||||
#include "DemolishModeToggleRequestedEvent.h"
|
||||
#include "EventHandler.h"
|
||||
#include "ExitBlueprintModeRequestedEvent.h"
|
||||
#include "ExitBuilderModeRequestedEvent.h"
|
||||
#include "WeaponFiredEvent.h"
|
||||
#include "SchematicChoiceOption.h"
|
||||
#include "SpeedChangeRequestedEvent.h"
|
||||
|
||||
#include "entt/entity/entity.hpp"
|
||||
#include "EntitySelectedEvent.h"
|
||||
@@ -38,32 +48,24 @@ struct QPointCompare
|
||||
}
|
||||
};
|
||||
|
||||
class GameWorldView : public QOpenGLWidget
|
||||
class GameWorldView : public QOpenGLWidget,
|
||||
public CombinedEventHandler<WeaponFiredEvent,
|
||||
BuildingTypeSelectedEvent,
|
||||
ExitBuilderModeRequestedEvent,
|
||||
DemolishModeToggleRequestedEvent,
|
||||
BlueprintPlacementRequestedEvent,
|
||||
ExitBlueprintModeRequestedEvent,
|
||||
SpeedChangeRequestedEvent>
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
GameWorldView(Simulation* sim, const GameConfig* config,
|
||||
const VisualsConfig* visuals, QWidget* parent = nullptr);
|
||||
~GameWorldView() override;
|
||||
|
||||
signals:
|
||||
void selectionChanged(const std::vector<BuildingId>& ids);
|
||||
void gameOver();
|
||||
void builderModeExited();
|
||||
void blueprintModeExited();
|
||||
void escapeMenuRequested();
|
||||
void demolishModeChanged(bool active);
|
||||
|
||||
public:
|
||||
double gameSpeed() const;
|
||||
void resetFrameTimer();
|
||||
|
||||
public slots:
|
||||
void enterBuilderMode(BuildingType type);
|
||||
void exitBuilderMode();
|
||||
void enterBlueprintMode(Blueprint blueprint);
|
||||
void exitBlueprintMode();
|
||||
void toggleDemolishMode();
|
||||
void setGameSpeed(double multiplier);
|
||||
void resetForNewGame();
|
||||
|
||||
@@ -80,6 +82,14 @@ private slots:
|
||||
void onFrame();
|
||||
|
||||
private:
|
||||
void handleEvent(std::shared_ptr<const WeaponFiredEvent> event) override;
|
||||
void handleEvent(std::shared_ptr<const BuildingTypeSelectedEvent> event) override;
|
||||
void handleEvent(std::shared_ptr<const ExitBuilderModeRequestedEvent> event) override;
|
||||
void handleEvent(std::shared_ptr<const DemolishModeToggleRequestedEvent> event) override;
|
||||
void handleEvent(std::shared_ptr<const BlueprintPlacementRequestedEvent> event) override;
|
||||
void handleEvent(std::shared_ptr<const ExitBlueprintModeRequestedEvent> event) override;
|
||||
void handleEvent(std::shared_ptr<const SpeedChangeRequestedEvent> event) override;
|
||||
|
||||
void drawTiles(QPainter& painter);
|
||||
void drawBuildings(QPainter& painter);
|
||||
void drawStations(QPainter& painter);
|
||||
@@ -119,9 +129,15 @@ private:
|
||||
void stepSpeed(int delta);
|
||||
void placeAtTile(QPoint tile);
|
||||
|
||||
void enterBuilderMode(BuildingType type);
|
||||
void exitBuilderMode();
|
||||
void enterBlueprintMode(Blueprint blueprint);
|
||||
void exitBlueprintMode();
|
||||
void toggleDemolishMode();
|
||||
|
||||
struct ActiveBeam
|
||||
{
|
||||
FireEvent event;
|
||||
WeaponFiredEvent event;
|
||||
qint64 emittedWallMs;
|
||||
QVector2D targetOffset;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user