65 lines
2.0 KiB
C++
65 lines
2.0 KiB
C++
#pragma once
|
|
|
|
#include <vector>
|
|
|
|
#include <QWidget>
|
|
|
|
#include "Blueprint.h"
|
|
#include "BlueprintModeExitedEvent.h"
|
|
#include "BuildingBlocksChangedEvent.h"
|
|
#include "BuildingId.h"
|
|
#include "EventHandler.h"
|
|
#include "GameConfig.h"
|
|
#include "SelectionChangedEvent.h"
|
|
#include "Tick.h"
|
|
|
|
class Simulation;
|
|
class QPushButton;
|
|
class QScrollArea;
|
|
class QVBoxLayout;
|
|
|
|
class BlueprintPanel : public QWidget,
|
|
public CombinedEventHandler<BuildingBlocksChangedEvent,
|
|
SelectionChangedEvent,
|
|
BlueprintModeExitedEvent>
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
BlueprintPanel(Simulation* sim, const GameConfig* config, QWidget* parent = nullptr);
|
|
~BlueprintPanel() override;
|
|
|
|
private:
|
|
void handleEvent(std::shared_ptr<const BuildingBlocksChangedEvent> event) override;
|
|
void handleEvent(std::shared_ptr<const SelectionChangedEvent> event) override;
|
|
void handleEvent(std::shared_ptr<const BlueprintModeExitedEvent> event) override;
|
|
|
|
private slots:
|
|
void onCreateClicked();
|
|
void onDeleteBlueprintClicked(int index);
|
|
void onBlueprintButtonClicked(int index);
|
|
void onSaveClicked();
|
|
void onLoadClicked();
|
|
|
|
private:
|
|
void onSelectionChanged(const std::vector<BuildingId>& ids);
|
|
void clearActiveBlueprintButton();
|
|
Blueprint createBlueprintFromSelection() const;
|
|
int computeBlueprintCost(const Blueprint& bp) const;
|
|
void rebuildButtons();
|
|
void refreshButtonStates();
|
|
|
|
Simulation* m_sim;
|
|
const GameConfig* m_config;
|
|
std::vector<BuildingId> m_selectedBuildingIds;
|
|
int m_currentBlocks;
|
|
int m_activeIndex;
|
|
std::vector<Blueprint> m_blueprints;
|
|
std::vector<QPushButton*> m_blueprintButtons;
|
|
QPushButton* m_createBtn;
|
|
QPushButton* m_saveBtn;
|
|
QPushButton* m_loadBtn;
|
|
QWidget* m_buttonsContainer;
|
|
QVBoxLayout* m_buttonsLayout;
|
|
};
|