mirror of
https://github.com/ViaVersion/ViaFabricPlus.git
synced 2024-12-31 18:18:04 +01:00
Move BetaCraft loading sequence into screen
This commit is contained in:
parent
9ed44d681f
commit
6a144d9290
@ -35,8 +35,6 @@ public class ServerListScreen extends VFPScreen {
|
||||
|
||||
public static final ServerListScreen INSTANCE = new ServerListScreen();
|
||||
|
||||
private ButtonWidget betaCraftButton;
|
||||
|
||||
public ServerListScreen() {
|
||||
super(Text.translatable("screen.viafabricplus.server_list"), true);
|
||||
}
|
||||
@ -62,18 +60,7 @@ public class ServerListScreen extends VFPScreen {
|
||||
this.addDrawableChild(classiCubeBuilder.build());
|
||||
|
||||
ButtonWidget.Builder betaCraftBuilder = ButtonWidget.builder(BetaCraftScreen.INSTANCE.getTitle(), button -> {
|
||||
if (BetaCraftScreen.SERVER_LIST == null) {
|
||||
betaCraftButton = button;
|
||||
|
||||
BetaCraftHandler.requestV2ServerList(serverList -> {
|
||||
BetaCraftScreen.SERVER_LIST = serverList;
|
||||
|
||||
BetaCraftScreen.INSTANCE.open(this);
|
||||
}, throwable -> showErrorScreen(BetaCraftScreen.INSTANCE.getTitle(), throwable, this));
|
||||
|
||||
} else {
|
||||
BetaCraftScreen.INSTANCE.open(this);
|
||||
}
|
||||
BetaCraftScreen.INSTANCE.open(this);
|
||||
}).position(this.width / 2 - 50, this.height / 2 - 25 + 20 + 3).size(98, 20);
|
||||
if (BetaCraftScreen.SERVER_LIST == null) {
|
||||
betaCraftBuilder = betaCraftBuilder.tooltip(Tooltip.of(Text.translatable("betacraft.viafabricplus.warning")));
|
||||
@ -95,13 +82,6 @@ public class ServerListScreen extends VFPScreen {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
if (betaCraftButton != null) {
|
||||
betaCraftButton.setMessage(Text.translatable("betacraft.viafabricplus.loading"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
|
||||
super.render(context, mouseX, mouseY, delta);
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.screen.classic4j;
|
||||
|
||||
import de.florianmichael.classic4j.BetaCraftHandler;
|
||||
import de.florianmichael.classic4j.model.betacraft.BCServerInfoSpec;
|
||||
import de.florianmichael.classic4j.model.betacraft.BCServerList;
|
||||
import de.florianmichael.classic4j.model.betacraft.BCVersionCategory;
|
||||
@ -51,6 +52,19 @@ public class BetaCraftScreen extends VFPScreen {
|
||||
|
||||
@Override
|
||||
protected void init() {
|
||||
super.init();
|
||||
if (SERVER_LIST != null) {
|
||||
createView();
|
||||
return;
|
||||
}
|
||||
setupSubtitle(Text.translatable("betacraft.viafabricplus.loading"));
|
||||
BetaCraftHandler.requestV2ServerList(serverList -> {
|
||||
BetaCraftScreen.SERVER_LIST = serverList;
|
||||
createView();
|
||||
}, throwable -> showErrorScreen(BetaCraftScreen.INSTANCE.getTitle(), throwable, this));
|
||||
}
|
||||
|
||||
private void createView() {
|
||||
this.setupSubtitle(Text.of(BETA_CRAFT_SERVER_LIST_URL), ConfirmLinkScreen.opening(this, BETA_CRAFT_SERVER_LIST_URL));
|
||||
this.addDrawableChild(new SlotList(this.client, width, height, 3 + 3 /* start offset */ + (textRenderer.fontHeight + 2) * 3 /* title is 2 */, -5, (textRenderer.fontHeight + 2) * 3));
|
||||
|
||||
@ -58,8 +72,11 @@ public class BetaCraftScreen extends VFPScreen {
|
||||
SERVER_LIST = null;
|
||||
client.setScreen(prevScreen);
|
||||
}).position(width - 98 - 5, 5).size(98, 20).build());
|
||||
}
|
||||
|
||||
super.init();
|
||||
@Override
|
||||
protected boolean subtitleCentered() {
|
||||
return SERVER_LIST == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user