Ticket #515 (closed enhancement: fixed)

Opened 3 years ago

Last modified 3 years ago

Doubleclicking a unit should select all similar units on screen

Reported by: Christoph Owned by: evans
Priority: Should Have Milestone: Alpha 3
Component: Core engine Keywords: review
Cc: Philip

Description

When doubleclicking a unit, you should select all units of the same type which are visible at once. This behavior was described in input.js comments, but not yet implemented.

With this ticket I supply a patch, implementing this feature.

Attachments

doubleclick.patch (6.5 KB) - added by Christoph 3 years ago.
Patch implementing multiple selection per double-click
trippleclick.patch (6.5 KB) - added by Christoph 3 years ago.
implements double and triple-click selection. Updated, after a used function has changed.
TripleClick.patch (10.4 KB) - added by evans 3 years ago.
TripleClick.2.patch (12.9 KB) - added by evans 3 years ago.

Change History

Changed 3 years ago by Christoph

Patch implementing multiple selection per double-click

comment:1 Changed 3 years ago by Christoph

I submitted a new patch. trippleclick.patch, that implements both, double and tripple-click selection. A tripple click selects all units of the same type on the map belonging to the player.

doubleclick.patch is obsolete, as the changes are included in trippleclick.patch.

Changed 3 years ago by Christoph

implements double and triple-click selection. Updated, after a used function has changed.

comment:2 Changed 3 years ago by Philip

  • Keywords review removed

Thanks for this! It looks like it works well, but there's a few changes I'd like to see.

Instead of picking entities based on the actor name, it would be better to use the entity template name (i.e. the XML file used to load the entity). (Some units might not have an actor, some different units might have the same actor, no actors will be loaded if the game is run in a non-graphical mode, etc.)

To do that, it seems most efficient to add a method to ICmpTemplateManager like GetEntitiesUsingTemplate(templateName), and implement it in CCmpTemplateManager to loop over m_LatestTemplates and return a list of matching entities.

Then PickSimilarEntities can call that method to get a list of similar entities, then filter out the ones that are off-screen etc like it does now, and return that list.

In the future we might want new ways of picking entities, e.g. double-click on a unit icon in the panel at the bottom of the screen to select all units of the same type, or something like that. So I'd prefer PickSimilarEntities to be a bit more flexible: instead of passing in screenX and screenY as arguments, just pass the entity template name to match. Then the GUI scripts can call PickEntitiesAtPoint and Engine.GuiInterfaceCall("GetEntityState", ent).template to work out what template name to select, or (in the future) could use some other method to choose a name, before picking all entities with that name.

I think the patch will be fine after those changes. (But please let me know if anything I'm saying is unclear and/or crazy.)

comment:3 Changed 3 years ago by Christoph

  • Owner set to Christoph
  • Status changed from new to assigned

That suggestions make sense. As i am very new to 0ad development i have chosen this task to get into the codebase. I appreciate your explanations and will improve the patch next week.

comment:4 Changed 3 years ago by anonymous

  • Milestone Unclassified deleted

Milestone Unclassified deleted

comment:5 Changed 3 years ago by wacko

  • Milestone set to OS Alpha 2

comment:6 Changed 3 years ago by feneur

  • Summary changed from Doubleckicking a unit should select all similar units on screen to Doubleclicking a unit should select all similar units on screen

comment:7 Changed 3 years ago by k776

  • Milestone changed from OS Alpha 2 to OS Alpha 3

comment:8 Changed 3 years ago by k776

  • Priority changed from minor to major

comment:9 Changed 3 years ago by Mythos_Ruler

This is an essential functionality feature.

comment:10 Changed 3 years ago by Christoph

  • Owner Christoph deleted
  • Status changed from assigned to new

I have so much to do with other things (work) at present. I don't think i will find time to to this until Alpha 3.

Changed 3 years ago by evans

comment:11 Changed 3 years ago by evans

  • Cc Philip added
  • Owner set to evans
  • Status changed from new to assigned

I have added a patch based on Christoph's patch - implementing Philip's comments.

comment:12 Changed 3 years ago by feneur

  • Keywords review added

Added the review keyword as I assume this should be reviewed :)

comment:13 Changed 3 years ago by Philip

Just some minor things:

EntitySelection::PickSimilarEntities:

I think this might accidentally select garrisoned units, since it doesn't check IsInWorld. It should probably just include the GetLosVisibility check (as with the other Pick functions) which will exclude out-of-world units.

The GetCurrentTemplateName check seems unnecessary, since GetEntitiesUsingTemplate shouldn't return any entities that fail the test.

The whole cmpVisual thing should probably be inside an if (onScreenOnly), so that we don't waste time getting the position unless we're actually going to check its visibility.

CCmpTemplateManager::GetEntitiesUsingTemplate should just use == instead of .compare

Changed 3 years ago by evans

comment:14 Changed 3 years ago by evans

Updated according to comments.

comment:15 Changed 3 years ago by Philip

Thanks! Applying with minor changes. Moved the GetLosVisibility check back out of the if (onScreenOnly), because otherwise triple-clicks will still select garrisoned units which seems confusing. Cleaned up the comments a bit - "" should always be followed by a space, "occured" should be "occurred", PickSimilarEntities comment wasn't updated. The latest patch also includes some garrison changes, which I assume aren't meant to be part of this, so I'll skip them.

comment:16 Changed 3 years ago by philip

  • Status changed from assigned to closed
  • Resolution set to fixed

(In [8544]) # Add double-click and triple-click selection modes, based on patch by Christoph and evans. Fixes #515.

Note: See TracTickets for help on using tickets.