Skip to content

Adds a new Squad Selection widget for creating and managing squads of units#8045

Open
MadeByGabe wants to merge 5 commits into
beyond-all-reason:masterfrom
MadeByGabe:pr/squad-selection
Open

Adds a new Squad Selection widget for creating and managing squads of units#8045
MadeByGabe wants to merge 5 commits into
beyond-all-reason:masterfrom
MadeByGabe:pr/squad-selection

Conversation

@MadeByGabe

@MadeByGabe MadeByGabe commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

Work done

Adds a new Squad Selection widget for creating and managing squads of units, plus the keybinds and options it needs.

This widget is fairly big with lots of features. There is a website that demos most features with short videoclips but I think it's better to just try it out with as much information as the average player would have after reading a short changelog. An example changelog below.

But first some notes:

  1. With default settings the widget doesn't do anything if its hotkeys aren't used and all its features are set to hotkeys that by default do nothing (e.g. ctrl+left-click). So players won't even notice the widget is on unless they intentionally use it (which could happen by accident but is unlikely).
  2. Using all its features isn't required at all. It has some features and settings which will only make sense after the player actively uses it for a while. This fact technically makes some of its features confusing. We could have a simpler similar widget like uBdead's version, but players would probably eventually request exactly the features it has now, in fact most of the 'weirder' features were requested by players.
  3. The widget is designed to be unintrusive and while a guide of sorts on the official website would be nice to have for it, I think its options in the settings panel describe most features well enough.

Included keybind change: The FactoryQ Manager load hotkeys (Meta+[0-9]) conflict with the Squad Selection select group hotkeys. #8047 fixes this by adding a new action to the FactoryQ Manager that accepts the load hotkeys only when the preset panel is open.

Test steps

Sorry but exhaustive step-by-step testing isn't practical for a widget this interaction heavy. The example changelog below is a good starting point for testing.

An example changelog for the widget could be:

Added a new widget that allows players to create and manage squads of units.

  • ctrl+right-click drag creates a squad from the selection
  • ctrl+left-click selects the closest squad. (with alt it filters to the closest unit type, with shift it appends to the selection)
  • When nothing is selected, right-click-drag move-orders the squad nearest the press point to the release point. Hold Alt to do this even when you have a selection.
  • space+[0-9] selects that group and the closest squad's intersection.
    Note: most units the factories make already belong to a reserve squad assigned to that factory.

I'm not sure what's the process of getting this merged, I assume it's going to be difficult because it's a huge change but I tried to do my best to make it as good as possible.
This widget is already used by a few dozen players and most of its features have been tested for months (except the right-click-drag move-orders, those are unit control features...).

AI / LLM usage statement:

Everything related to this widget was assisted by Claude Code. It also wrote some of the code, either by transforming my pseudocode/drafts or by implementing decision matrices I made. Everything was reviewed and tested by me for weeks/months.

Links:

Feature demonstration website (Please try the widget out first as if you were an average player because the demos are confusing, it's difficult to demo selection features in videos):
https://bar-stuff.madebygabe.dev/squad-selection

(Relevant Discord thread: https://discord.com/channels/549281623154229250/1483283773939257344)

The features that weren't mentioned in the changelog above:

The features that weren't mentioned in the changelog above can be tried out with these example binds. Technically these could be added to the default binds but I think it's better to let players experience the basic features first.

// squad selection
bind            sc_mouse5      squad_limit_flip
bind        Alt+sc_mouse4      squad_cycle_idle
bind       Meta+sc_mouse4      squad_cycle_recent
bind      Shift+sc_mouse4      squad_select_portion 0.5 append_domain distance_850
bind            sc_mouse4      squad_select_portion 0.5

// sc_0x064 = ISO key (between Shift and Z/Y, varies by layout)
bind       Shift+sc_0x064      squad_select_portion 0 append distance_850
bind             sc_0x064      squad_select_portion 0 //0% of the squad but at least 1 unit
bind  Ctrl+Shift+sc_0x064      squad_select_portion_filtered 0 append distance_850
bind        Ctrl+sc_0x064      squad_select_portion_filtered 0

// alternatives in case no thumb mouse buttons, or ansi layout keyboard:
bind            Meta+sc_a      squad_limit_flip
bind            Meta+sc_s      squad_cycle_recent
bind            Meta+sc_d      squad_cycle_idle
bind      Shift+Meta+sc_w      squad_select_portion 0.5 append_domain distance_850
bind            Meta+sc_w      squad_select_portion 0.5

@github-actions

github-actions Bot commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

Integration Test Results

14 tests   - 1   6 ✅ ±0   3s ⏱️ ±0s
 1 suites ±0   8 💤 ±0 
 1 files   ±0   0 ❌  - 1 

Results for commit b1ba4af. ± Comparison against base commit 5db84d3.

This pull request removes 1 test.
gui_pip/test_gui_pip_autostart_maximize.lua

♻️ This comment has been updated with latest results.

@MadeByGabe MadeByGabe force-pushed the pr/squad-selection branch from db283a9 to e189cd0 Compare June 21, 2026 12:16
@MadeByGabe MadeByGabe changed the title Adds a new Squad Selection widget for creating and managing squads of units, Adds a new Squad Selection widget for creating and managing squads of units Jun 21, 2026
Comment thread luaui/Widgets/unit_squad_selection.lua
Comment thread luaui/Widgets/unit_squad_selection.lua
@przystuj

Copy link
Copy Markdown
Contributor

I would:

  1. put factoryq manager changes in separate PR
  2. put stuff related to drawing in separate file
  3. put the whole squad-related "backend" in separate file (more or less all functions up to "-- GL4 hull rendering" section). So everything squad related, what is called by widget:xx functions would be in the separate file. Main file would have widget callbacks, option related functions and delegate the actual logic to 'backend' and 'drawing' files

@MadeByGabe

Copy link
Copy Markdown
Contributor Author

put factoryq manager changes in separate PR

And I should close this PR until that's merged, or just remove the hotkey binds and make a PR for the binds after both are merged?

@przystuj

Copy link
Copy Markdown
Contributor

put factoryq manager changes in separate PR

And I should close this PR until that's merged, or just remove the hotkey binds and make a PR for the binds after both are merged?

I guess removing hot key binds should work, so this one can get the review in the meantime

@WatchTheFort WatchTheFort added the Awaiting GDT Approval Awaiting approval from the Game Design Team (game mechanics, balance only) label Jun 21, 2026
@MadeByGabe MadeByGabe force-pushed the pr/squad-selection branch from e189cd0 to 33fe9a3 Compare June 21, 2026 14:08
@MadeByGabe

Copy link
Copy Markdown
Contributor Author

I guess removing hot key binds should work, so this one can get the review in the meantime

I made a separate PR for the FactoryQ Manager but I kept the meta+[0-9] hotkeys because even though there is conflict, the FactoryQ Manager is off by default so it shouldn't cause issues.
I will add one more hotkey change when that PR #8047 is merged.

Adds unit_squad_selection.lua: automagical squad creation and
proximity-based selection. Effectively inert by default.

Included: options panel integration, i18n strings, and some default keybinds

num_keys.txt: default Meta+[0-9] / Shift+Meta+[0-9] squad_select_group binds,
@MadeByGabe MadeByGabe force-pushed the pr/squad-selection branch from c09746c to b87a018 Compare June 22, 2026 03:46
…options

An onchange that did widgetHandler:Enable/DisableWidget and then called init() inline would read the pre-toggle state since Enable/DisableWidget are deferred.
The result was for example that changing keybinds to grid would show/hide the grid sub-options one action late. (Change to legacy -> you see grid options. Change back to grid -> you don't see the grid options)

If the newly added scheduleInit flag is set, the options rebuild is deferred to the next frame which allows reading the correct state of the widgets.
@MadeByGabe

Copy link
Copy Markdown
Contributor Author

I split up the widget into 3 parts:

Hull visualization is a companion widget now. That was a good idea and it was already possible anyway, we even have two more companion widgets for visualization though none of them are feature complete yet.

I split off the utility functions into a separate file. I technically could split off even the core squad logic but I decided against that because in my opinion that would hurt the maintainability of the widget.

I also improved type annotations though there were some issues so it's not perfect but I don't think perfect is possible currently.

Finally I fixed a bug in the options panel. I maybe should make a separate PR for that and I will do that if requested. I didn't do it now because that bug only affects the keyboard layout and the grid menu options and those are not very important.
It affects the squad widget hull options too, that's the main reason for the fix so I decided to include it in this PR.

@MadeByGabe MadeByGabe requested a review from przystuj June 23, 2026 08:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Awaiting GDT Approval Awaiting approval from the Game Design Team (game mechanics, balance only)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants