show production progress
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
#include "SelectedBuildingPanel.h"
|
#include "SelectedBuildingPanel.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#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);
|
m_buffersLabel->setText(bufText);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user