Rewrote close handling of VFPScreen to support recursive opening

This commit is contained in:
FlorianMichael 2024-02-21 22:03:18 +01:00
parent f61cb8b8f6
commit 1c206b83e0
No known key found for this signature in database
GPG Key ID: C2FB87E71C425126
3 changed files with 7 additions and 9 deletions

View File

@ -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);
}
}
/**

View File

@ -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

View File

@ -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);