45 lines
1.0 KiB
C++
45 lines
1.0 KiB
C++
#pragma once
|
|
|
|
#include <optional>
|
|
#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 ModulesConfig* modules);
|
|
void clear();
|
|
|
|
// Shows an empty placeholder box (no ship layout) so the preview stays
|
|
// visible while no schematic is selected (REQ-MOD-UI-PREVIEW).
|
|
void showPlaceholder();
|
|
|
|
protected:
|
|
void paintEvent(QPaintEvent* event) override;
|
|
|
|
private:
|
|
struct CellInfo
|
|
{
|
|
bool buildable;
|
|
std::optional<int> moduleIndex; // nullopt if empty
|
|
};
|
|
|
|
std::vector<std::vector<CellInfo>> m_grid;
|
|
std::vector<PlacedModule> m_placedModules;
|
|
const ModulesConfig* m_modules;
|
|
int m_rows;
|
|
int m_cols;
|
|
bool m_placeholder = false;
|
|
};
|