implement blueprints
This commit is contained in:
56
src/ui/BlueprintPanel.h
Normal file
56
src/ui/BlueprintPanel.h
Normal file
@@ -0,0 +1,56 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
#include "Blueprint.h"
|
||||
#include "EntityId.h"
|
||||
#include "GameConfig.h"
|
||||
#include "Tick.h"
|
||||
|
||||
class Simulation;
|
||||
class QPushButton;
|
||||
class QScrollArea;
|
||||
class QVBoxLayout;
|
||||
|
||||
class BlueprintPanel : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
BlueprintPanel(Simulation* sim, const GameConfig* config, QWidget* parent = nullptr);
|
||||
|
||||
public slots:
|
||||
void onSelectionChanged(const std::vector<EntityId>& ids);
|
||||
void onStateUpdated(Tick tick, int blocks, double speed);
|
||||
void clearActiveBlueprintButton();
|
||||
|
||||
signals:
|
||||
void blueprintPlacementRequested(Blueprint blueprint);
|
||||
void exitBlueprintModeRequested();
|
||||
|
||||
private slots:
|
||||
void onCreateClicked();
|
||||
void onDeleteClicked();
|
||||
void onBlueprintButtonClicked(int index);
|
||||
|
||||
private:
|
||||
Blueprint createBlueprintFromSelection() const;
|
||||
int computeBlueprintCost(const Blueprint& bp) const;
|
||||
void rebuildButtons();
|
||||
void refreshButtonStates();
|
||||
|
||||
Simulation* m_sim;
|
||||
const GameConfig* m_config;
|
||||
std::vector<EntityId> m_selectedIds;
|
||||
int m_currentBlocks;
|
||||
bool m_deleteMode;
|
||||
int m_activeIndex;
|
||||
std::vector<Blueprint> m_blueprints;
|
||||
std::vector<QPushButton*> m_blueprintButtons;
|
||||
QPushButton* m_createBtn;
|
||||
QPushButton* m_deleteBtn;
|
||||
QWidget* m_buttonsContainer;
|
||||
QVBoxLayout* m_buttonsLayout;
|
||||
};
|
||||
Reference in New Issue
Block a user