Files
dota_factory/src/ui/selection/BeltContent.cpp

39 lines
1.3 KiB
C++

#include "BeltContent.h"
#include <QVBoxLayout>
#include "BuildingTarget.h"
#include "ClearBeltControl.h"
#include "SelectionNames.h"
BeltContent::BeltContent(const SelectionContext& context,
const SelectionRequest& request, QWidget* parent)
// Only an operational tile aggregates, so a card showing several is never a site;
// a single selected tile still can be one.
: SelectionContent(context,
request.buildings.size() == 1
? asConstructionSite(context, request.buildings.front())
: std::nullopt,
parent)
, m_ids(request.buildings)
{
getRuntimeLayout()->addWidget(new ClearBeltControl(context, m_ids, this));
}
void BeltContent::refreshConfiguration()
{
const BuildingTarget target = resolveBuildingTarget(getContext(), m_ids.front());
if (!target.isValid())
{
return;
}
// An aggregated selection may mix belts with tunnel ends, so it is named after the
// first tile; the count says how many are held (REQ-UI-SELECTION-AGGREGATE).
setBuildingIdentity(target.type, getBuildingTypeName(target.type));
if (m_ids.size() > 1)
{
setCountSlot(static_cast<int>(m_ids.size()));
}
}