From 1c206b83e02408e3d23a109b3c344dd3a8a4943d Mon Sep 17 00:00:00 2001 From: FlorianMichael <60033407+FlorianMichael@users.noreply.github.com> Date: Wed, 21 Feb 2024 22:03:18 +0100 Subject: [PATCH] Rewrote close handling of VFPScreen to support recursive opening --- .../de/florianmichael/viafabricplus/screen/VFPScreen.java | 6 +++++- .../screen/classic4j/ClassiCubeLoginScreen.java | 3 +-- .../screen/classic4j/ClassiCubeServerListScreen.java | 7 +------ 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/main/java/de/florianmichael/viafabricplus/screen/VFPScreen.java b/src/main/java/de/florianmichael/viafabricplus/screen/VFPScreen.java index 95a2d1ec..c7162208 100644 --- a/src/main/java/de/florianmichael/viafabricplus/screen/VFPScreen.java +++ b/src/main/java/de/florianmichael/viafabricplus/screen/VFPScreen.java @@ -127,7 +127,11 @@ public class VFPScreen extends Screen { @Override public void close() { - MinecraftClient.getInstance().setScreen(prevScreen); + if (prevScreen instanceof VFPScreen vfpScreen) { + vfpScreen.open(vfpScreen.prevScreen); // Support recursive opening + } else { + MinecraftClient.getInstance().setScreen(prevScreen); + } } /** diff --git a/src/main/java/de/florianmichael/viafabricplus/screen/classic4j/ClassiCubeLoginScreen.java b/src/main/java/de/florianmichael/viafabricplus/screen/classic4j/ClassiCubeLoginScreen.java index f1504f01..3f4a79a7 100644 --- a/src/main/java/de/florianmichael/viafabricplus/screen/classic4j/ClassiCubeLoginScreen.java +++ b/src/main/java/de/florianmichael/viafabricplus/screen/classic4j/ClassiCubeLoginScreen.java @@ -27,7 +27,6 @@ import de.florianmichael.viafabricplus.ViaFabricPlus; import de.florianmichael.viafabricplus.injection.access.ITextFieldWidget; import de.florianmichael.viafabricplus.save.impl.AccountsSave; import de.florianmichael.viafabricplus.screen.VFPScreen; -import de.florianmichael.viafabricplus.screen.base.ProtocolSelectionScreen; import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.screen.ConfirmLinkScreen; import net.minecraft.client.gui.screen.Screen; @@ -104,7 +103,7 @@ public class ClassiCubeLoginScreen extends VFPScreen { public void close() { // The user wasn't logged in when opening this screen, so he cancelled the login process, so we can safely unset the account ViaFabricPlus.global().getSaveManager().getAccountsSave().setClassicubeAccount(null); - ProtocolSelectionScreen.INSTANCE.open(prevScreen); + super.close(); } @Override diff --git a/src/main/java/de/florianmichael/viafabricplus/screen/classic4j/ClassiCubeServerListScreen.java b/src/main/java/de/florianmichael/viafabricplus/screen/classic4j/ClassiCubeServerListScreen.java index 9a562b2b..a72fc7b5 100644 --- a/src/main/java/de/florianmichael/viafabricplus/screen/classic4j/ClassiCubeServerListScreen.java +++ b/src/main/java/de/florianmichael/viafabricplus/screen/classic4j/ClassiCubeServerListScreen.java @@ -63,7 +63,7 @@ public class ClassiCubeServerListScreen extends VFPScreen { } public ClassiCubeServerListScreen() { - super("ClassiCube ServerList", true); + super("ClassiCube", true); final var account = ViaFabricPlus.global().getSaveManager().getAccountsSave().getClassicubeAccount(); if (account != null) { @@ -84,11 +84,6 @@ public class ClassiCubeServerListScreen extends VFPScreen { super.init(); } - @Override - public void close() { - ProtocolSelectionScreen.INSTANCE.open(prevScreen); - } - @Override public void render(DrawContext context, int mouseX, int mouseY, float delta) { this.renderBackground(context, mouseX, mouseY, delta);