split the selection panel into one card per kind of selection
This commit is contained in:
39
src/ui/selection/BufferedBuildingContent.cpp
Normal file
39
src/ui/selection/BufferedBuildingContent.cpp
Normal file
@@ -0,0 +1,39 @@
|
||||
#include "BufferedBuildingContent.h"
|
||||
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include "Building.h"
|
||||
#include "BufferSection.h"
|
||||
#include "BuildingTarget.h"
|
||||
#include "FactoryQueries.h"
|
||||
#include "ProductionSection.h"
|
||||
#include "Simulation.h"
|
||||
|
||||
BufferedBuildingContent::BufferedBuildingContent(const SelectionContext& context,
|
||||
BuildingId id, QWidget* parent)
|
||||
: SelectionContent(context, asConstructionSite(context, id), parent)
|
||||
, m_id(id)
|
||||
{
|
||||
m_buffers = new BufferSection(this);
|
||||
m_production = new ProductionSection(this);
|
||||
getRuntimeLayout()->addWidget(m_buffers);
|
||||
getRuntimeLayout()->addWidget(m_production);
|
||||
}
|
||||
|
||||
void BufferedBuildingContent::refreshRuntime()
|
||||
{
|
||||
const Building* building = findBuilding(getContext().sim->getFactoryState(), m_id);
|
||||
if (!building)
|
||||
{
|
||||
// Gone under the card. SelectionPanel rebuilds on the same refresh; this only
|
||||
// has to avoid reading it.
|
||||
return;
|
||||
}
|
||||
|
||||
setProductionStatusSlot(*building);
|
||||
|
||||
const CycleInfo cycle = getCycleInfo(*building);
|
||||
m_buffers->setBuffers(*building, cycle.perCycleInputs, cycle.perCycleOutputs);
|
||||
m_production->setProduction(cycle.runsProduction, *building, cycle.durationSeconds,
|
||||
getContext().sim->getCurrentTick());
|
||||
}
|
||||
Reference in New Issue
Block a user