Skip to content

Add type selection by double/triple-click#2297

Draft
leosnake2208 wants to merge 1 commit into
Phobos-developers:developfrom
leosnake2208:feature/multiclick-typeselect
Draft

Add type selection by double/triple-click#2297
leosnake2208 wants to merge 1 commit into
Phobos-developers:developfrom
leosnake2208:feature/multiclick-typeselect

Conversation

@leosnake2208

Copy link
Copy Markdown

Feature

Adds the modern-RTS multi-click selection gesture, complementing the existing type-select hotkey (hold T + click):

  • Double-click a unit → select every unit of the same selection group currently on screen.
  • Triple-click a unit → select every unit of that group across the whole map.

The "selection group" reuses the existing Phobos concept (TechnoTypeExt::GetSelectionGroupID / HasSelectionGroupID, i.e. the [TechnoType] -> GroupAs tag with the type ID as fallback), so it stays consistent with the hotkey-driven type select in Selection.cpp. Only the player's own selectable mobile units are affected.

Config

Gated behind a new user setting, default off:

[Phobos]
TypeSelectByMultiClick=false  ; boolean

Implementation

  • New src/Misc/MultiClickTypeSelect.cpp. A single hook in the tactical LBUTTONUP handler — after the click's own selection has been applied, on the single-click dispatch path only (completed rubber-band selections exit earlier) — tracks the click streak via GetTickCount / GetCursorPos / GetDoubleClickTime (±4 px tolerance) and expands the freshly-clicked unit's selection to its group: on screen for a double-click, map-wide for a triple-click.
  • The map-wide case is the only genuinely new capability; the vanilla/hotkey type select is screen-only.

Docs & credits

  • docs/User-Interface.md (new "Type selection by multi-click" section), docs/Whats-New.md (new setting + changelog entry), CREDITS.md.

Built clean (Debug/Release, 0 warnings) and tested in-game (skirmish) on the CnCNet Yuri's Revenge build.

Double-click a unit to select every unit of its selection group on screen;
triple-click to select them across the whole map. Complements the vanilla
type-select hotkey (hold T + click) with the double/triple-click gesture
common to modern RTS games, reusing Phobos' selection-group concept
(GetSelectionGroupID / HasSelectionGroupID, i.e. the GroupAs tag).

Gated behind [Phobos] TypeSelectByMultiClick (default off).
@github-actions

Copy link
Copy Markdown

Nightly build for this pull request:

This comment is automatic and is meant to allow guests to get latest nightly builds for this pull request without registering. It is updated on every successful build.

leosnake2208 added a commit to leosnake2208/Phobos that referenced this pull request Jul 19, 2026
… TypeSelectByMultiClick

Mirror the upstream PR structure in the integrated local build. The single
ModernControls toggle/file is replaced by two, matching PR Phobos-developers#2298 (right-click
to command) and PR Phobos-developers#2297 (multi-click type-select):

- src/Misc/RightClickCommand.cpp  - RMB command + LMB select/deselect,
  gated by [Phobos] -> RightClickCommand
- src/Misc/MultiClickTypeSelect.cpp - double/triple-click type-select,
  gated by [Phobos] -> TypeSelectByMultiClick

Both default true (this is the personal build). The fork-only 250px
double-click radius and selection-group matching are preserved. The two
features share RightClickCommand::RmbCommandInProgress: the RMB redirect
flows through the 0x693290 multi-click hook, which clears the flag and
skips the event, so an RMB order is never miscounted as a left-click.

WASD panning stays separate and always-on (CameraPanWASD.cpp).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

@TaranDahl TaranDahl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect the entire design is flawed. In other games such as SC2, you can double-click the left mouse button to select all units, as the left click only serves to select units in that game. However, in RA2, the left mouse button has multiple functions, and double-clicking a unit will immediately command it to perform corresponding actions.

return;

// The single click that preceded this streak left the clicked unit as the selection.
const auto pClicked = abstract_cast<FootClass*, true>(ObjectClass::CurrentObjects.GetItem(0));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you tested this? I doubt if this is working as you said in your docs when you are selecting multiple units.

Double-clicking a unit selects every unit of the same selection group currently on screen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants