allow to set the recipe already for construction sites
This commit is contained in:
@@ -193,18 +193,26 @@ void MainWindow::handleEvent(std::shared_ptr<const LayoutDialogRequestedEvent> e
|
||||
const double prevSpeed = m_gameWorldView->gameSpeed();
|
||||
m_gameWorldView->setGameSpeed(0.0);
|
||||
|
||||
// A construction site has no Building yet; fall back to its site record so
|
||||
// the shipyard layout can be configured before it is built (REQ-BLD-SITE-CONFIG).
|
||||
const Building* b = m_sim->buildings().findBuilding(event->shipyardId);
|
||||
if (!b)
|
||||
const ConstructionSite* s =
|
||||
b ? nullptr : m_sim->buildings().findSite(event->shipyardId);
|
||||
if (!b && !s)
|
||||
{
|
||||
m_gameWorldView->setGameSpeed(prevSpeed);
|
||||
m_gameWorldView->resetFrameTimer();
|
||||
return;
|
||||
}
|
||||
|
||||
const std::string& schematicId = b ? b->recipeId : s->recipeId;
|
||||
const std::optional<ShipLayoutConfig>& layoutOpt =
|
||||
b ? b->shipLayout : s->shipLayout;
|
||||
|
||||
ShipLayoutConfig currentLayout;
|
||||
if (b->shipLayout.has_value())
|
||||
if (layoutOpt.has_value())
|
||||
{
|
||||
currentLayout = *b->shipLayout;
|
||||
currentLayout = *layoutOpt;
|
||||
}
|
||||
|
||||
std::set<std::string> unlockedModuleIds;
|
||||
@@ -218,7 +226,7 @@ void MainWindow::handleEvent(std::shared_ptr<const LayoutDialogRequestedEvent> e
|
||||
moduleLevels[def.id] = m_sim->moduleSchematicLevel(def.id);
|
||||
}
|
||||
|
||||
ShipLayoutDialog dialog(&m_sim->config(), b->recipeId, currentLayout,
|
||||
ShipLayoutDialog dialog(&m_sim->config(), schematicId, currentLayout,
|
||||
m_layoutBlueprints,
|
||||
std::move(unlockedModuleIds),
|
||||
std::move(moduleLevels),
|
||||
@@ -238,17 +246,22 @@ void MainWindow::handleEvent(std::shared_ptr<const RecipeSelectionRequestedEvent
|
||||
const double prevSpeed = m_gameWorldView->gameSpeed();
|
||||
m_gameWorldView->setGameSpeed(0.0);
|
||||
|
||||
// A construction site has no Building yet; fall back to its site record so
|
||||
// the recipe/schematic can be chosen before it is built (REQ-BLD-SITE-CONFIG).
|
||||
const Building* b = m_sim->buildings().findBuilding(event->buildingId);
|
||||
if (!b)
|
||||
const ConstructionSite* s =
|
||||
b ? nullptr : m_sim->buildings().findSite(event->buildingId);
|
||||
if (!b && !s)
|
||||
{
|
||||
m_gameWorldView->setGameSpeed(prevSpeed);
|
||||
m_gameWorldView->resetFrameTimer();
|
||||
return;
|
||||
}
|
||||
|
||||
const BuildingType type = b ? b->type : s->type;
|
||||
const std::vector<RecipeSelectionOption> options =
|
||||
buildRecipeSelectionOptions(*b, *m_sim, m_sim->config());
|
||||
const QString title = (b->type == BuildingType::Shipyard)
|
||||
buildRecipeSelectionOptions(type, *m_sim, m_sim->config());
|
||||
const QString title = (type == BuildingType::Shipyard)
|
||||
? tr("Select Schematic")
|
||||
: tr("Select Recipe");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user