Implement the REQ-UI-MULTI-SELECTION addition: the selected building panel now shows the total placement cost of a multi-selection, counting only player-placeable buildings (HQ and defence stations excluded). Construction sites are charged their type's full cost. Add a shared BuildingsConfig::findBuildingDef accessor and reuse it in BlueprintPanel to remove the duplicated by-type lookup loops. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DZR44tA8sn4dPqDzAVXyps
49 lines
1.5 KiB
C++
49 lines
1.5 KiB
C++
#pragma once
|
|
|
|
#include <optional>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "BuildingType.h"
|
|
|
|
// A single entry from buildings.toml [[building]].
|
|
struct BuildingDef
|
|
{
|
|
std::string id; // Raw id string from TOML, e.g. "miner".
|
|
BuildingType type; // Parsed from id at load time.
|
|
int cost; // REQ-BLD-COST
|
|
bool playerPlaceable; // Shown in the build menu if true.
|
|
double constructionTimeSeconds; // REQ-BLD-QUEUE
|
|
|
|
// Rows of the surface_mask (REQ-BLD requirements, "Surface Mask Format").
|
|
// Stored as raw strings here; parsing into per-cell tiles + output ports
|
|
// happens when buildings are placed, not at load time.
|
|
std::vector<std::string> surfaceMask;
|
|
|
|
// Output-buffer holding size for buildings without a recipe-driven buffer.
|
|
// Only the Salvage Bay sets this (REQ-BLD-SALVAGE-BAY).
|
|
std::optional<int> outputBufferCapacity;
|
|
|
|
// Optional hover-tooltip text for the build button (REQ-UI-BUILD-TOOLTIP).
|
|
std::optional<std::string> tooltip;
|
|
};
|
|
|
|
struct BuildingsConfig
|
|
{
|
|
std::vector<BuildingDef> buildings;
|
|
|
|
// Returns the definition for the given building type, or nullptr if the
|
|
// type has no entry in buildings.toml.
|
|
const BuildingDef* findBuildingDef(BuildingType type) const
|
|
{
|
|
for (const BuildingDef& def : buildings)
|
|
{
|
|
if (def.type == type)
|
|
{
|
|
return &def;
|
|
}
|
|
}
|
|
return nullptr;
|
|
}
|
|
};
|