split the selection panel into one card per kind of selection
This commit is contained in:
38
src/ui/selection/BeltContent.cpp
Normal file
38
src/ui/selection/BeltContent.cpp
Normal file
@@ -0,0 +1,38 @@
|
||||
#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()));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user