From 5cdee0e765de357eb87e39805d5e77224791f36f Mon Sep 17 00:00:00 2001 From: Anuken Date: Sat, 8 Feb 2025 21:41:36 -0500 Subject: [PATCH] Allow commanding while planning on mobile --- core/src/mindustry/input/MobileInput.java | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/core/src/mindustry/input/MobileInput.java b/core/src/mindustry/input/MobileInput.java index d67ed72d33..d6d8485454 100644 --- a/core/src/mindustry/input/MobileInput.java +++ b/core/src/mindustry/input/MobileInput.java @@ -279,7 +279,7 @@ public class MobileInput extends InputHandler implements GestureListener{ group.fill(t -> { t.visible(this::showCancel); t.bottom().left(); - t.button("@cancel", Icon.cancel, () -> { + t.button("@cancel", Icon.cancel, Styles.clearTogglet, () -> { if(!player.dead()){ player.unit().clearBuilding(); } @@ -290,7 +290,7 @@ public class MobileInput extends InputHandler implements GestureListener{ }); group.fill(t -> { - t.visible(() -> !showCancel() && block == null && !hasSchematic() && !state.rules.editor); + t.visible(() -> !hasSchematic() && !state.rules.editor); t.bottom().left(); t.button("@command.queue", Icon.rightOpen, Styles.clearTogglet, () -> { @@ -299,7 +299,14 @@ public class MobileInput extends InputHandler implements GestureListener{ t.button("@command", Icon.units, Styles.clearTogglet, () -> { commandMode = !commandMode; - }).width(155f).height(48f).margin(12f).checked(b -> commandMode); + if(commandMode){ + block = null; + rebuildMode = false; + mode = none; + } + }).width(155f).height(48f).margin(12f).checked(b -> commandMode).row(); + + t.spacerY(() -> showCancel() ? 50f : 0f).row(); //for better looking insets t.rect((x, y, w, h) -> { @@ -516,7 +523,7 @@ public class MobileInput extends InputHandler implements GestureListener{ if(cursor == null || Core.scene.hasMouse(screenX, screenY)) return false; //only begin selecting if the tapped block is a plan - selecting = hasPlan(cursor); + selecting = hasPlan(cursor) && !commandMode; //call tap events if(pointer == 0 && !selecting){ @@ -678,7 +685,7 @@ public class MobileInput extends InputHandler implements GestureListener{ } //remove if plan present - if(hasPlan(cursor)){ + if(hasPlan(cursor) && !commandMode){ removePlan(getPlan(cursor)); }else if(mode == placing && isPlacing() && validPlace(cursor.x, cursor.y, block, rotation) && !checkOverlapPlacement(cursor.x, cursor.y, block)){ //add to selection queue if it's a valid place position @@ -757,7 +764,7 @@ public class MobileInput extends InputHandler implements GestureListener{ payloadTarget = null; } - if(locked || block != null || scene.hasField() || hasSchematic() || selectPlans.size > 0){ + if(locked || block != null || scene.hasField() || hasSchematic()){ commandMode = false; }