show production progress

This commit is contained in:
2026-04-22 20:40:08 +02:00
parent 3e1d97e5db
commit 36d6842f71

View File

@@ -1,5 +1,6 @@
#include "SelectedBuildingPanel.h"
#include <algorithm>
#include <cctype>
#include <map>
#include <string>
@@ -264,6 +265,30 @@ void SelectedBuildingPanel::refreshBuffers(const Building* b)
}
}
if (isProductionBuilding(b->type) && (recipe || shipDef))
{
const double durationSeconds = recipe
? recipe->durationSeconds
: shipDef->blueprint.productionTimeSeconds;
bufText += QString("Cycle: %1 s\n").arg(durationSeconds, 0, 'f', 1);
if (b->production.has_value())
{
const Tick cycleTicks = secondsToTicks(durationSeconds);
const Tick completesAt = b->production->completesAt;
const Tick currentTick = m_sim->currentTick();
const Tick elapsed = currentTick - (completesAt - cycleTicks);
const int pct = static_cast<int>(
std::max(Tick(0), std::min(cycleTicks, elapsed)) * 100 / cycleTicks);
bufText += QString("Progress: %1%\n").arg(pct);
}
else
{
bufText += "Progress: idle\n";
}
}
m_buffersLabel->setText(bufText);
}