39 lines
804 B
C++
39 lines
804 B
C++
#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;
|
|
};
|