implement ship modules
This commit is contained in:
38
src/ui/ShipLayoutPreview.h
Normal file
38
src/ui/ShipLayoutPreview.h
Normal file
@@ -0,0 +1,38 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
#include "ModulesConfig.h"
|
||||
#include "ShipLayout.h"
|
||||
|
||||
class ShipLayoutPreview : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ShipLayoutPreview(QWidget* parent = nullptr);
|
||||
|
||||
void setShipAndLayout(const std::vector<std::string>& shipLayout,
|
||||
const ShipLayoutConfig& layout,
|
||||
const std::vector<ModuleDef>* modules);
|
||||
void clear();
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent* event) override;
|
||||
|
||||
private:
|
||||
struct CellInfo
|
||||
{
|
||||
bool buildable;
|
||||
int moduleIndex; // -1 if empty
|
||||
};
|
||||
|
||||
std::vector<std::vector<CellInfo>> m_grid;
|
||||
std::vector<PlacedModule> m_placedModules;
|
||||
const std::vector<ModuleDef>* m_modules;
|
||||
int m_rows;
|
||||
int m_cols;
|
||||
};
|
||||
Reference in New Issue
Block a user