Fixes bug in triple-click unit selection for units without a SelectionGroupName defined. In this case, triple-click will behave the same as double-click.
This was SVN commit r9444.
This commit is contained in:
parent
26de01cdd1
commit
508f56d2dd
@ -726,31 +726,37 @@ function handleInputAfterGui(ev)
|
||||
return true;
|
||||
}
|
||||
|
||||
var showOffscreen = Engine.HotkeyIsPressed("selection.offscreen");
|
||||
var matchRank;
|
||||
var templateToMatch;
|
||||
var selectedEntity = ents[0];
|
||||
var now = new Date();
|
||||
|
||||
if ((now.getTime() - doubleClickTimer < doubleClickTime) && (selectedEntity == prevClickedEntity))
|
||||
{
|
||||
// Double click or triple click has occurred
|
||||
var showOffscreen = Engine.HotkeyIsPressed("selection.offscreen");
|
||||
var matchRank = true;
|
||||
var templateToMatch;
|
||||
|
||||
// Check for double click or triple click
|
||||
if (!doubleClicked)
|
||||
{
|
||||
// If double click hasn't already occurred, this is a double click.
|
||||
// Select units matching exact rank
|
||||
// Select units matching exact template name (same rank)
|
||||
templateToMatch = Engine.GuiInterfaceCall("GetEntityState", selectedEntity).template;
|
||||
matchRank = true;
|
||||
doubleClicked = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Double click has already occurred, so this is a triple click.
|
||||
// Select all similar units regardless of rank
|
||||
// Select similar units regardless of rank
|
||||
templateToMatch = Engine.GuiInterfaceCall("GetEntityState", selectedEntity).identity.selectionGroupName;
|
||||
matchRank = false;
|
||||
if (templateToMatch)
|
||||
{
|
||||
matchRank = false;
|
||||
}
|
||||
else
|
||||
{ // No selection group name defined, so fall back to exact match
|
||||
templateToMatch = Engine.GuiInterfaceCall("GetEntityState", selectedEntity).template;
|
||||
}
|
||||
}
|
||||
|
||||
ents = Engine.PickSimilarFriendlyEntities(templateToMatch, showOffscreen, matchRank);
|
||||
|
@ -145,24 +145,17 @@ std::vector<entity_id_t> EntitySelection::PickSimilarEntities(CSimulation2& simu
|
||||
{
|
||||
entity_id_t ent = it->first;
|
||||
|
||||
CmpPtr<ICmpIdentity> cmpIdentity(simulation.GetSimContext(), ent);
|
||||
|
||||
std::string groupName;
|
||||
if (!cmpIdentity.null())
|
||||
if (matchRank)
|
||||
{
|
||||
groupName = cmpIdentity->GetSelectionGroupName();
|
||||
}
|
||||
|
||||
if (!matchRank && !groupName.empty())
|
||||
{
|
||||
// There's a selection group so match that
|
||||
if (groupName.compare(templateName) != 0)
|
||||
// Exact template name matching
|
||||
if (cmpTemplateManager->GetCurrentTemplateName(ent).compare(templateName) != 0)
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Fall back to exact template name matching
|
||||
if (cmpTemplateManager->GetCurrentTemplateName(ent).compare(templateName) != 0)
|
||||
// Match by selection group name
|
||||
CmpPtr<ICmpIdentity> cmpIdentity(simulation.GetSimContext(), ent);
|
||||
if (cmpIdentity.null() || cmpIdentity->GetSelectionGroupName().compare(templateName) != 0)
|
||||
continue;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user