Opened 14 years ago

Closed 13 years ago

Last modified 8 years ago

#515 closed enhancement (fixed)

Doubleclicking a unit should select all similar units on screen

Reported by: Christoph Seipel Owned by: Evans
Priority: Should Have Milestone: Alpha 3
Component: Core engine Keywords:
Cc: Philip Taylor Patch:

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 (4)

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

Download all attachments as: .zip

Change History (21)

by Christoph Seipel, 14 years ago

Attachment: doubleclick.patch added

Patch implementing multiple selection per double-click

comment:1 by Christoph Seipel, 14 years ago

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.

by Christoph Seipel, 14 years ago

Attachment: trippleclick.patch added

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

comment:2 by Philip Taylor, 14 years ago

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 by Christoph Seipel, 14 years ago

Owner: set to Christoph Seipel
Status: newassigned

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 by (none), 13 years ago

Milestone: Unclassified

Milestone Unclassified deleted

comment:5 by Andrew, 13 years ago

Milestone: OS Alpha 2

comment:6 by Erik Johansson, 13 years ago

Summary: Doubleckicking a unit should select all similar units on screenDoubleclicking a unit should select all similar units on screen

comment:7 by Kieran P, 13 years ago

Milestone: OS Alpha 2OS Alpha 3

comment:8 by Kieran P, 13 years ago

Priority: minormajor

comment:9 by Michael D. Hafer, 13 years ago

This is an essential functionality feature.

comment:10 by Christoph Seipel, 13 years ago

Owner: Christoph Seipel removed
Status: assignednew

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.

by Evans, 13 years ago

Attachment: TripleClick.patch added

comment:11 by Evans, 13 years ago

Cc: Philip Taylor added
Owner: set to Evans
Status: newassigned

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

comment:12 by Erik Johansson, 13 years ago

Keywords: review added

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

comment:13 by Philip Taylor, 13 years ago

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

by Evans, 13 years ago

Attachment: TripleClick.2.patch added

comment:14 by Evans, 13 years ago

Updated according to comments.

comment:15 by Philip Taylor, 13 years ago

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 by philip, 13 years ago

Resolution: fixed
Status: assignedclosed

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

comment:17 by sanderd17, 8 years ago

Keywords: review removed
Note: See TracTickets for help on using tickets.