keep an auto-recipe building's summary between its cycles
This commit is contained in:
@@ -41,13 +41,22 @@ BufferedBuildingContent::CycleInfo AutoProductionContent::getCycleInfo(
|
||||
}
|
||||
}
|
||||
|
||||
if (!target.building || !target.building->production.has_value())
|
||||
// Which recipe describes the cycle: the one running, or -- between cycles -- the one
|
||||
// that ran last. Dropping it while idle would take the summary row and the chips'
|
||||
// per-cycle amounts away and bring them back with every cycle, resizing the card in
|
||||
// step with the building's status (REQ-UI-RECIPE-SUMMARY). Only a building that has
|
||||
// never run has nothing to describe.
|
||||
if (target.building && target.building->production.has_value())
|
||||
{
|
||||
m_lastRecipeId = target.building->production->recipeId;
|
||||
}
|
||||
if (!target.building || m_lastRecipeId.empty())
|
||||
{
|
||||
return info;
|
||||
}
|
||||
|
||||
const RecipeDef* recipe = getContext().config->recipes.findRecipeDef(
|
||||
target.building->production->recipeId, target.type);
|
||||
const RecipeDef* recipe =
|
||||
getContext().config->recipes.findRecipeDef(m_lastRecipeId, target.type);
|
||||
if (!recipe)
|
||||
{
|
||||
return info;
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "BufferedBuildingContent.h"
|
||||
#include "SelectionContentFactory.h"
|
||||
|
||||
// The card for a Smelter or a Reprocessing Plant (REQ-UI-SELECTION-CONTENT). Both
|
||||
// auto-process whatever they receive and have no player-facing recipe selection
|
||||
// (REQ-BLD-SMELTER, REQ-BLD-REPROCESSING), so the card has no configuration group at
|
||||
// all; its cycle is whichever recipe is currently in production.
|
||||
// all; its cycle is whichever recipe is in production, or the last one that was.
|
||||
class AutoProductionContent : public BufferedBuildingContent
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -17,4 +19,11 @@ public:
|
||||
|
||||
protected:
|
||||
CycleInfo getCycleInfo(const BuildingTarget& target) const override;
|
||||
|
||||
private:
|
||||
// The recipe last seen in production, which keeps describing the cycle while the
|
||||
// building sits between cycles (REQ-UI-RECIPE-SUMMARY). Mutable because it is a
|
||||
// record of what getCycleInfo() has observed rather than state of its own: the card
|
||||
// shows the same thing whether or not it has been asked before.
|
||||
mutable std::string m_lastRecipeId;
|
||||
};
|
||||
|
||||
@@ -44,8 +44,9 @@ protected:
|
||||
// REQ-BLD-SALVAGE-BAY) or has no recipe or schematic selected yet: the
|
||||
// production section is then not shown (REQ-UI-PRODUCTION-PROGRESS).
|
||||
bool runsProduction = false;
|
||||
// 0 while an auto-recipe building sits between cycles, when no single recipe
|
||||
// names a cycle time; the progress line then reads "idle".
|
||||
// 0 only when no recipe describes the cycle at all -- an auto-recipe building
|
||||
// that has yet to run one (REQ-UI-RECIPE-SUMMARY). The progress line reads
|
||||
// "idle" whenever no cycle is actually running, whatever this says.
|
||||
double durationSeconds = 0.0;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user