Always show shipyard layout preview and Configure button, disabled until schematic selected

The ship layout preview and Configure Layout button are now always shown
for a selected shipyard and disabled while no schematic is selected,
rather than being hidden. The preview shows an empty placeholder box in
that state. Update REQ-MOD-UI-PREVIEW to match.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DZR44tA8sn4dPqDzAVXyps
This commit is contained in:
2026-07-13 07:40:21 +02:00
parent 851eeff6f4
commit 6dd8da4ff8
4 changed files with 56 additions and 9 deletions

View File

@@ -8,6 +8,10 @@ namespace
const int kCellSize = 8;
// Size of the empty placeholder box shown when no schematic is selected.
const int kPlaceholderWidth = 64;
const int kPlaceholderHeight = 40;
const ModuleDef* findModuleDef(const std::vector<ModuleDef>& modules,
const std::string& id)
{
@@ -90,14 +94,28 @@ void ShipLayoutPreview::clear()
m_modules = nullptr;
m_rows = 0;
m_cols = 0;
m_placeholder = false;
setFixedSize(0, 0);
update();
}
void ShipLayoutPreview::showPlaceholder()
{
m_grid.clear();
m_placedModules.clear();
m_modules = nullptr;
m_rows = 0;
m_cols = 0;
m_placeholder = true;
setFixedSize(kPlaceholderWidth, kPlaceholderHeight);
update();
}
void ShipLayoutPreview::setShipAndLayout(const std::vector<std::string>& shipLayout,
const ShipLayoutConfig& layout,
const std::vector<ModuleDef>* modules)
{
m_placeholder = false;
m_modules = modules;
m_placedModules = layout.placedModules;
m_rows = static_cast<int>(shipLayout.size());
@@ -156,6 +174,18 @@ void ShipLayoutPreview::setShipAndLayout(const std::vector<std::string>& shipLay
void ShipLayoutPreview::paintEvent(QPaintEvent* /*event*/)
{
if (m_placeholder)
{
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing, false);
const QRect box = rect().adjusted(0, 0, -1, -1);
painter.fillRect(box, QColor(40, 40, 40));
painter.setPen(QColor(128, 128, 128));
painter.drawRect(box);
painter.drawText(box, Qt::AlignCenter, tr("No schematic"));
return;
}
if (m_rows == 0 || m_cols == 0)
{
return;