From 4ddb78e8d59ba1d7a1aee0b0ac757d6f04051f21 Mon Sep 17 00:00:00 2001 From: SITUVNgcd <44901211+SITUVNgcd@users.noreply.github.com> Date: Sun, 26 Mar 2023 00:10:21 +0700 Subject: [PATCH] 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. --- core/src/mindustry/ui/fragments/PlacementFragment.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/core/src/mindustry/ui/fragments/PlacementFragment.java b/core/src/mindustry/ui/fragments/PlacementFragment.java index e1d659199d..87b7d61cf0 100644 --- a/core/src/mindustry/ui/fragments/PlacementFragment.java +++ b/core/src/mindustry/ui/fragments/PlacementFragment.java @@ -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());