Add Events.fire(Trigger.unitCommandChange) in select/remove unit by type (#8406)

* Added `Events.fire(Trigger.unitCommandChange)` and `boolean fireInRebuildCommand`

Added `Events.fire(Trigger.unitCommandChange)` to **left click - select** and **right click - remove**.
Added `boolean fireInRebuildCommand` to prevent infinite event loop with `rebuildCommand`.

* Remove useless `fireInRebuildCommand` flag.
This commit is contained in:
SITUVNgcd
2023-03-26 00:10:21 +07:00
committed by GitHub
parent f23d203095
commit 4ddb78e8d5

View File

@@ -462,9 +462,15 @@ public class PlacementFragment{
var listener = new ClickListener();
//left click -> select
b.clicked(KeyCode.mouseLeft, () -> control.input.selectedUnits.removeAll(unit -> unit.type != type));
b.clicked(KeyCode.mouseLeft, () -> {
control.input.selectedUnits.removeAll(unit -> unit.type != type);
Events.fire(Trigger.unitCommandChange);
});
//right click -> remove
b.clicked(KeyCode.mouseRight, () -> control.input.selectedUnits.removeAll(unit -> unit.type == type));
b.clicked(KeyCode.mouseRight, () -> {
control.input.selectedUnits.removeAll(unit -> unit.type == type);
Events.fire(Trigger.unitCommandChange);
});
b.addListener(listener);
b.addListener(new HandCursorListener());