Show each culture's world population share in the Cultures tab

A follow-up to the dominance-schism trigger: each row now shows the
culture's share of the world's living population, computed the same way
cultDominanceShare reads it, so a culture nearing the split threshold is
visible before it actually splits. A culture at/past the threshold draws
in an orange warning tint.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TMfyZv91tonDnPJqbaTVJE
This commit is contained in:
Jonas Reith 2026-08-31 20:34:22 +02:00
parent b1175c6e54
commit ae9059a868
2 changed files with 15 additions and 1 deletions

View File

@ -611,6 +611,13 @@ on the Live World clock). **Steps 17 of the roadmap are done (plus a derived
surprise for an edit that looks perfectly reasonable. `test_cultevo.cpp` gained two new scenarios surprise for an edit that looks perfectly reasonable. `test_cultevo.cpp` gained two new scenarios
(force every settlement onto one culture and watch it split near-deterministically; inject a (force every settlement onto one culture and watch it split near-deterministically; inject a
same-culture war and check the split) alongside the existing distant-cluster one. same-culture war and check the split) alongside the existing distant-cluster one.
- **Cultures tab: show each people's world population share** *(done — see `Viewer::renderLiveInfo()`,
`src/render/ViewerRender.cpp`)* — a follow-up to the dominance-schism trigger above: each row in the
Live-info **Culture** tab now shows its share of the world's living population (`"the Velmar (34%)"`),
computed the same way `cultDominanceShare` is (a culture's `totalPop` over the sum across all
cultures) so a culture nearing the split threshold is visible before it actually splits; a culture
at/past `cultDominanceShare` draws in an orange warning tint instead of its usual `cultureColor`.
`src/render` only, no save-format or `src/sim` change.
## Current state ## Current state

View File

@ -1018,6 +1018,10 @@ void Viewer::renderLiveInfo() {
DrawText(planet.settlementsPlaced() ? "press X for the culture view" : "press U then X", x, y, 13, Color{150, 155, 170, 255}); DrawText(planet.settlementsPlaced() ? "press X for the culture view" : "press U then X", x, y, 13, Color{150, 155, 170, 255});
} else { } else {
const auto& sc = planet.settleCulture(); const auto& sc = planet.settleCulture();
// World population share -- the same basis the dominance-schism trigger (cultDominanceShare)
// reads, so a culture nearing the threshold is visible here before it actually splits.
double totalLivingPop = 0.0;
for (const Culture& cu : C) totalLivingPop += cu.totalPop;
std::vector<int> idx(C.size()); std::vector<int> idx(C.size());
for (size_t i = 0; i < C.size(); ++i) idx[i] = (int)i; for (size_t i = 0; i < C.size(); ++i) idx[i] = (int)i;
std::sort(idx.begin(), idx.end(), [&](int a, int b) { return C[a].totalPop > C[b].totalPop; }); std::sort(idx.begin(), idx.end(), [&](int a, int b) { return C[a].totalPop > C[b].totalPop; });
@ -1032,7 +1036,10 @@ void Viewer::renderLiveInfo() {
{ repPop = planet.settlements[s].population; repCell = planet.settlements[s].cell; } { repPop = planet.settlements[s].population; repCell = planet.settlements[s].cell; }
Rectangle row{ r.x + 10.0f, (float)y - 2.0f, r.width - 20.0f, 19.0f }; Rectangle row{ r.x + 10.0f, (float)y - 2.0f, r.width - 20.0f, 19.0f };
eventRowRects.push_back(row); atlasRowCells.push_back(repCell); eventRowRects.push_back(row); atlasRowCells.push_back(repCell);
DrawText(cu.name.c_str(), (int)row.x + 6, (int)row.y + 2, 14, cultureColor(ci)); double share = totalLivingPop > 0.0 ? cu.totalPop / totalLivingPop * 100.0 : 0.0;
bool dominant = share >= planet.cfg.cultDominanceShare * 100.0; // nearing/past the split threshold
DrawText(TextFormat("%s (%.0f%%)", cu.name.c_str(), share), (int)row.x + 6, (int)row.y + 2, 14,
dominant ? Color{235, 150, 90, 255} : cultureColor(ci));
// Step 8: a schism child shows its founding year (roots have been there since the dawn). // Step 8: a schism child shows its founding year (roots have been there since the dawn).
if (cu.foundedYear >= 0) if (cu.foundedYear >= 0)
DrawText(TextFormat("b. yr %ld", cu.foundedYear), DrawText(TextFormat("b. yr %ld", cu.foundedYear),