implement ignore non-buildable buildings for blueprints
This commit is contained in:
@@ -152,7 +152,15 @@ Blueprint BlueprintPanel::createBlueprintFromSelection() const
|
||||
for (const EntityId id : m_selectedIds)
|
||||
{
|
||||
const Building* b = m_sim->buildings().findBuilding(id);
|
||||
if (b) { entries.push_back({ b }); }
|
||||
if (!b) { continue; }
|
||||
const bool placeable = [&]() {
|
||||
for (const BuildingDef& def : m_config->buildings.buildings)
|
||||
{
|
||||
if (def.type == b->type) { return def.playerPlaceable; }
|
||||
}
|
||||
return false;
|
||||
}();
|
||||
if (placeable) { entries.push_back({ b }); }
|
||||
}
|
||||
|
||||
if (entries.empty()) { return Blueprint{}; }
|
||||
@@ -235,7 +243,19 @@ void BlueprintPanel::rebuildButtons()
|
||||
|
||||
void BlueprintPanel::refreshButtonStates()
|
||||
{
|
||||
m_createBtn->setEnabled(!m_selectedIds.empty());
|
||||
const bool anyPlaceable = [&]() {
|
||||
for (const EntityId id : m_selectedIds)
|
||||
{
|
||||
const Building* b = m_sim->buildings().findBuilding(id);
|
||||
if (!b) { continue; }
|
||||
for (const BuildingDef& def : m_config->buildings.buildings)
|
||||
{
|
||||
if (def.type == b->type) { return def.playerPlaceable; }
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}();
|
||||
m_createBtn->setEnabled(anyPlaceable);
|
||||
|
||||
for (int i = 0; i < static_cast<int>(m_blueprintButtons.size()); ++i)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user