Files
dota_factory/src/ui/ShipLayoutPreview.h
Malte Langkabel 69848eb9f8 remove the last duplicate findModuleDef from ShipLayoutPreview
ShipLayoutPreview was the one widget the findFooDef sweep missed: it held a
bare const std::vector<ModuleDef>* rather than a config, so the shared
ModulesConfig::findModuleDef was not a drop-in and the file-local copy
survived. Hold the ModulesConfig instead and call the shared finder.

The sole caller already had the ModulesConfig one dereference away.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YHcUerKAZKWNvSKJxYKbnG
2026-08-03 21:28:53 +02:00

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;
};