diff --git a/binaries/data/config/default.cfg b/binaries/data/config/default.cfg index 8270adebf2..152347997d 100644 --- a/binaries/data/config/default.cfg +++ b/binaries/data/config/default.cfg @@ -433,6 +433,7 @@ disjointcontrolgroups = "true" ; Whether control groups are disjoint sets or defaultformation = "special/formations/box" ; For walking orders, automatically put units into this formation if they don't have one already. formationwalkonly = "true" ; Formations are disabled when giving gather/attack/... orders. howtoshownames = 0 ; Whether the specific names are show as default, as opposed to the generic names. And whether the secondary names are shown. (0 - show both; specific names primary, 1 - show both; generic names primary, 2 - show only specific names, 3 - show only generic names) +selectformationasone = "true" ; Whether to select formations as a whole by default. [gui.session.minimap] blinkduration = 1.7 ; The blink duration while pinging diff --git a/binaries/data/mods/public/gui/options/options.json b/binaries/data/mods/public/gui/options/options.json index 05aa607ad4..d01bf90d9d 100644 --- a/binaries/data/mods/public/gui/options/options.json +++ b/binaries/data/mods/public/gui/options/options.json @@ -737,6 +737,12 @@ "tooltip": "Units in formations stay in formations." } ] + }, + { + "type": "boolean", + "label": "Battalion-style formations", + "tooltip": "Whether formations are selected as a whole.", + "config": "gui.session.selectformationasone" } ] } diff --git a/binaries/data/mods/public/gui/session/input.js b/binaries/data/mods/public/gui/session/input.js index f15547b370..aeb10218ce 100644 --- a/binaries/data/mods/public/gui/session/input.js +++ b/binaries/data/mods/public/gui/session/input.js @@ -1170,7 +1170,7 @@ function popOneFromSelection(action) )); if (unit) { - g_Selection.removeList([unit], true); + g_Selection.removeList([unit], false); return [unit]; } return null; diff --git a/binaries/data/mods/public/gui/session/selection.js b/binaries/data/mods/public/gui/session/selection.js index ebc40a458c..6c3e1185c1 100644 --- a/binaries/data/mods/public/gui/session/selection.js +++ b/binaries/data/mods/public/gui/session/selection.js @@ -175,6 +175,17 @@ function EntitySelection() // Public properties: this.dirty = false; // set whenever the selection has changed this.groups = new EntityGroups(); + + this.UpdateFormationSelectionBehaviour(); + registerConfigChangeHandler(changes => { + if (changes.has("gui.session.selectformationasone")) + this.UpdateFormationSelectionBehaviour(); + }); +} + +EntitySelection.prototype.UpdateFormationSelectionBehaviour = function() +{ + this.SelectFormationAsOne = Engine.ConfigDB_GetValue("user", "gui.session.selectformationasone") == "true"; } /** @@ -331,13 +342,13 @@ EntitySelection.prototype.addList = function(ents, quiet, force = false, addForm /** * @param {number[]} ents - The entities to remove. - * @param {boolean} dontAddFormationMembers - If true we need to exclude adding formation members. + * @param {boolean} addFormationMembers - If true we need to add formation members. */ -EntitySelection.prototype.removeList = function(ents, dontAddFormationMembers = false) +EntitySelection.prototype.removeList = function(ents, addFormationMembers = true) { const removed = []; - for (const ent of dontAddFormationMembers ? ents : this.addFormationMembers(ents)) + for (const ent of addFormationMembers ? this.addFormationMembers(ents) : ents) if (this.selected.has(ent)) { this.groups.removeEnt(ent); @@ -478,7 +489,7 @@ EntitySelection.prototype.selectAndMoveTo = function(entityID) */ EntitySelection.prototype.addFormationMembers = function(entities) { - if (!entities.length || Engine.HotkeyIsPressed("selection.singleselection")) + if (!entities.length || !this.SelectFormationAsOne || Engine.HotkeyIsPressed("selection.singleselection")) return entities; const result = new Set(entities); diff --git a/binaries/data/mods/public/gui/text/tips/formations.txt b/binaries/data/mods/public/gui/text/tips/formations.txt index 182fbda47b..232097c08c 100644 --- a/binaries/data/mods/public/gui/text/tips/formations.txt +++ b/binaries/data/mods/public/gui/text/tips/formations.txt @@ -1,3 +1,3 @@ FORMATIONS Arrange your soldiers in formations to keep them organized during battles. -Formations are selected as a whole by default. +Formations are selected as a whole by default, but that can be changed in the game settings.