Opened 10 years ago

Closed 9 years ago

Last modified 8 years ago

#2407 closed enhancement (fixed)

[PATCH] Selecting only idling units

Reported by: Oimat Owned by: Itms
Priority: Nice to Have Milestone: Alpha 18
Component: UI & Simulation Keywords:
Cc: Patch:

Description (last modified by leper)

#1598 and #1989 would allow having a wide range of way to select units. I propose to add the following:

  • Pressing '.' while selecting units with the mouse, select only the idle workers.
  • Pressing '/' while selecting units with the mouse, select only the idle military units.

(See HotKeys)

That would be very usefull for selecting workers that finished a metal mine and are waiting too close to the women (farming), near the first cc for example.

If the other patchs mentionned above are included too, that would allow to select 3 idling females that are waiting near the cc to create a new farm, and infinite other possibilities

Attachments (4)

refactor _selection_v1.diff (7.5 KB ) - added by Rolf Sievers 10 years ago.
refactor_selection_v4.diff (7.4 KB ) - added by Rolf Sievers 9 years ago.
Created the diff of the patch from revision 15892.
refactor_selection_v5.diff (7.3 KB ) - added by Rolf Sievers 9 years ago.
refactor_selection_tweaked.patch (6.8 KB ) - added by Itms 9 years ago.
actually working version (with re-updated structure)

Download all attachments as: .zip

Change History (17)

comment:1 by leper, 10 years ago

Description: modified (diff)

comment:2 by Hybrandt, 10 years ago

Owner: set to Hybrandt
Status: newassigned

comment:3 by Michael, 10 years ago

See #2357 for a definition of worker units.

idle_worker_blink_v12.patch:

g_idleWorkerClasses = Engine.GuiInterfaceCall("GetIdleWorkerClasses");

Units are defined in binaries/data/mods/public/simulation/templates/special/player.xml.

comment:4 by historic_bruno, 10 years ago

Owner: Hybrandt removed
Status: assignednew

comment:5 by Rolf Sievers, 10 years ago

There is a crypic comment inside the selection code: (gui/session/input.js) // TODO: Should we handle "control all units" here as well?

Apparently it refers to a requested feature. Does anyone know more about that?

(Answered on IRC)

Last edited 10 years ago by Itms (previous) (diff)

by Rolf Sievers, 10 years ago

Attachment: refactor _selection_v1.diff added

comment:6 by Rolf Sievers, 10 years ago

The attached patch version 1 refactors the unit selection code to be more general. It does not actually address the FR #2407 yet. For that I would like to use infrastructure provided by #2357 which may or may not come in the near future. It does however implement the "I" shortcut which selects idle units of any kind.

It changes the way unit highlighting works. Prior, all units where highlighted when arranging the selection, even those that won't be in the final selection. I did consider that a bug and fixed it. Now the highlight uses the exact same filter as the selection itself.

Please provide criticism. Should I remove the caching in input.js:482? (For Code readability)

Last edited 10 years ago by Rolf Sievers (previous) (diff)

comment:7 by Rolf Sievers, 10 years ago

Keywords: review patch added
Milestone: BacklogAlpha 18
Summary: Selecting only idling units[PATCH] Selecting only idling units

by Rolf Sievers, 9 years ago

Attachment: refactor_selection_v4.diff added

Created the diff of the patch from revision 15892.

comment:8 by Rolf Sievers, 9 years ago

Just to be clear, what the current patch „v4“ does, and what it doesn't.

  • It refactors the unit filter mechanic, to make it more versatile.
  • It fixes a bug, where the preview under the bandbox does not actually match the units which will be selected in the end.
  • It adds a hotkey I, to select only IDLE units. (This is most likely not a good choice, but the most obvious one)

But what is doesn't do:

  • Fix the bug where the selection preview is not updated when hotkeys change.
  • Fix the bug where units running into (or out of) the box don't update their selection status.

I do intend to overhaul that loop, as I suggested in #2826. That should make the whole mechanism easier to maintain and understand.

by Rolf Sievers, 9 years ago

Attachment: refactor_selection_v5.diff added

comment:9 by Itms, 9 years ago

Hello rolf, I modified a bit your patch to make it work with the current SVN and I moved some bits of code to make it clearer. Please tell me if you agree with my changes, and after that I'll test for bugs and look into committing it.

Thanks for working on it :)

comment:10 by Rolf Sievers, 9 years ago

Seems fine to me :D Thanks for looking at it.

by Itms, 9 years ago

actually working version (with re-updated structure)

comment:11 by Itms, 9 years ago

Owner: set to Itms
Resolution: fixed
Status: newclosed

In 16007:

Change the way we filter out selected entities when we draw a selection box. Add a hotkey to allow selecting only idle units.

Patch by Rolf Sievers, fixes #2407.

comment:12 by Itms, 9 years ago

Keywords: simple review patch removed

Thanks for the patch! :)

comment:13 by elexis, 8 years ago

In 17957:

Add a missing check to r16007 as the previous one throws errors in case a dead sheep lies in the selection rectangle.
Thanks bb for reporting, refs #2407.

Note: See TracTickets for help on using tickets.