44 lines
1.2 KiB
C++
44 lines
1.2 KiB
C++
#pragma once
|
|
|
|
#include <map>
|
|
#include <vector>
|
|
|
|
#include <QWidget>
|
|
|
|
#include "BuilderModeExitedEvent.h"
|
|
#include "BuildingType.h"
|
|
#include "DemolishModeChangedEvent.h"
|
|
#include "EventHandler.h"
|
|
#include "GameConfig.h"
|
|
|
|
class QPushButton;
|
|
|
|
class BuildButtonGrid : public QWidget,
|
|
public CombinedEventHandler<BuilderModeExitedEvent,
|
|
DemolishModeChangedEvent>
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
BuildButtonGrid(const GameConfig* config, QWidget* parent = nullptr);
|
|
~BuildButtonGrid() override;
|
|
|
|
void updateAffordability(int buildingBlocks);
|
|
void clearActiveButton();
|
|
|
|
private:
|
|
void handleEvent(std::shared_ptr<const BuilderModeExitedEvent> event) override;
|
|
void handleEvent(std::shared_ptr<const DemolishModeChangedEvent> event) override;
|
|
|
|
private slots:
|
|
void onBuildButton(int index);
|
|
|
|
private:
|
|
const GameConfig* m_config;
|
|
std::vector<BuildingType> m_types;
|
|
std::vector<QPushButton*> m_buttons;
|
|
std::map<BuildingType, int> m_costs;
|
|
int m_activeIndex;
|
|
QPushButton* m_demolishButton;
|
|
};
|