split the selection panel into one card per kind of selection

This commit is contained in:
2026-08-07 18:38:55 +02:00
parent cc0ef856e3
commit 2289277e12
60 changed files with 3014 additions and 1559 deletions

View File

@@ -0,0 +1,34 @@
#include "BuildingTarget.h"
#include "FactoryQueries.h"
#include "SelectionContext.h"
#include "Simulation.h"
BuildingTarget resolveBuildingTarget(const SelectionContext& context, BuildingId id)
{
BuildingTarget target;
target.building = findBuilding(context.sim->getFactoryState(), id);
target.site = target.building
? nullptr
: findSite(context.sim->getFactoryState(), id);
if (!target.isValid())
{
return target;
}
target.type = target.building ? target.building->type : target.site->type;
target.recipeId = target.building ? target.building->recipeId : target.site->recipeId;
target.shipLayout = target.building ? target.building->shipLayout : target.site->shipLayout;
target.anchor = target.building ? target.building->anchor : target.site->anchor;
return target;
}
std::optional<BuildingId> asConstructionSite(const SelectionContext& context,
BuildingId id)
{
if (findSite(context.sim->getFactoryState(), id) != nullptr)
{
return id;
}
return std::nullopt;
}