Skip to content

Commit

Permalink
#5613: Implement EntityInspector::updatePrimitiveNumber()
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Oct 22, 2021
1 parent aaca0b1 commit d95a6ce
Showing 1 changed file with 44 additions and 2 deletions.
46 changes: 44 additions & 2 deletions radiant/ui/einspector/EntityInspector.cpp
Expand Up @@ -777,11 +777,53 @@ void EntityInspector::updateGUIElements()

void EntityInspector::updatePrimitiveNumber()
{
if (GlobalMapModule().getEditMode() == IMap::EditMode::Merge && _entitySelection->size() > 1)
auto numSelectedEntities = _entitySelection->size();

if (GlobalMapModule().getEditMode() == IMap::EditMode::Merge)
{
if (numSelectedEntities > 1)
{
_primitiveNumLabel->SetLabelText(_("No multi-selection in merge mode"));
return;
}
else if (numSelectedEntities == 1)
{
_primitiveNumLabel->SetLabelText(_("Merge Preview"));
return;
}
}

// Do we have exactly one primitive selected?
if (numSelectedEntities > 1)
{
_primitiveNumLabel->SetLabelText(_("No multi-selection in merge mode"));
_primitiveNumLabel->SetLabelText(fmt::format("[{0} Entities]", numSelectedEntities));
return;
}

// Check if the node is a primitive
if (GlobalSelectionSystem().countSelected() == 1)
{
try
{
auto selectedNode = GlobalSelectionSystem().ultimateSelected();
auto indices = scene::getNodeIndices(selectedNode);

if (Node_isEntity(selectedNode))
{
_primitiveNumLabel->SetLabelText(fmt::format(_("Entity {0}"), indices.first));
}
else
{
_primitiveNumLabel->SetLabelText(fmt::format(_("Entity {0}, Primitive {1}"), indices.first, indices.second));
}

return;
}
catch (const std::out_of_range& ex)
{
rWarning() << ex.what() << std::endl;
}
}

_primitiveNumLabel->SetLabelText("");
}
Expand Down

0 comments on commit d95a6ce

Please sign in to comment.