#pragma once

#include <QWidget>

#include "Tick.h"

struct Building;
class BarRow;
class SectionBox;

// The cycle time and production progress of one building (REQ-UI-PRODUCTION-PROGRESS).
//
// Reading the progress off an active cycle is the same for every building type, so it
// happens here; working out how long that cycle is differs per type (a recipe's
// duration, a schematic's production time plus its modules'), so the owning content
// supplies it.
class ProductionSection : public QWidget
{
    Q_OBJECT

public:
    explicit ProductionSection(QWidget* parent = nullptr);

    // runsProduction false hides the section entirely -- the building produces nothing
    // (a Salvage Bay) or has no recipe or schematic selected yet. When it is true but
    // durationSeconds is 0 or less, the building is between cycles with no single recipe
    // to name a cycle time for (an idle auto-recipe building), so the progress line
    // reads "idle" and the cycle time is left out.
    void setProduction(bool runsProduction, const Building& building,
                       double durationSeconds, Tick currentTick);

private:
    SectionBox* m_section;
    BarRow*     m_bar;
};
