Change button dimensions in server list

This commit is contained in:
FlorianMichael 2024-10-11 15:32:55 +02:00
parent 6a144d9290
commit 24ba0402e1
No known key found for this signature in database
GPG Key ID: C2FB87E71C425126
3 changed files with 17 additions and 14 deletions

View File

@ -47,35 +47,35 @@ public class ServerListScreen extends VFPScreen {
// ClassiCube
final boolean loggedIn = ViaFabricPlus.global().getSaveManager().getAccountsSave().getClassicubeAccount() != null;
ButtonWidget.Builder classiCubeBuilder = ButtonWidget.builder(ClassiCubeServerListScreen.INSTANCE.getTitle(), button -> {
final ButtonWidget.Builder classiCubeBuilder = ButtonWidget.builder(ClassiCubeServerListScreen.INSTANCE.getTitle(), button -> {
if (!loggedIn) {
ClassiCubeLoginScreen.INSTANCE.open(this);
return;
}
ClassiCubeServerListScreen.INSTANCE.open(this);
}).position(this.width / 2 - 50, this.height / 2 - 25).size(98, 20);
}).position(this.width / 2 - 100, this.height / 2 - 25).size(200, 20);
if (!loggedIn) {
classiCubeBuilder = classiCubeBuilder.tooltip(Tooltip.of(Text.translatable("classicube.viafabricplus.warning")));
classiCubeBuilder.tooltip(Tooltip.of(Text.translatable("classicube.viafabricplus.warning")));
}
this.addDrawableChild(classiCubeBuilder.build());
ButtonWidget.Builder betaCraftBuilder = ButtonWidget.builder(BetaCraftScreen.INSTANCE.getTitle(), button -> {
final ButtonWidget.Builder betaCraftBuilder = ButtonWidget.builder(BetaCraftScreen.INSTANCE.getTitle(), button -> {
BetaCraftScreen.INSTANCE.open(this);
}).position(this.width / 2 - 50, this.height / 2 - 25 + 20 + 3).size(98, 20);
}).position(this.width / 2 - 100, this.height / 2 - 25 + 20 + 3).size(200, 20);
if (BetaCraftScreen.SERVER_LIST == null) {
betaCraftBuilder = betaCraftBuilder.tooltip(Tooltip.of(Text.translatable("betacraft.viafabricplus.warning")));
betaCraftBuilder.tooltip(Tooltip.of(Text.translatable("betacraft.viafabricplus.warning")));
}
this.addDrawableChild(betaCraftBuilder.build());
ButtonWidget.Builder bedrockRealmsBuilder = ButtonWidget.builder(BedrockRealmsScreen.INSTANCE.getTitle(), button -> {
final ButtonWidget.Builder bedrockRealmsBuilder = ButtonWidget.builder(BedrockRealmsScreen.INSTANCE.getTitle(), button -> {
BedrockRealmsScreen.INSTANCE.open(this);
}).position(this.width / 2 - 50, this.height / 2 - 25 + 40 + 6).size(98, 20);
}).position(this.width / 2 - 100, this.height / 2 - 25 + 40 + 6).size(200, 20);
final boolean missingAccount = ViaFabricPlus.global().getSaveManager().getAccountsSave().getBedrockAccount() == null; // Only check for presence, later validate
if (missingAccount) {
bedrockRealmsBuilder.tooltip(Tooltip.of(Text.translatable("bedrock_realms.viafabricplus.warning")));
}
ButtonWidget bedrockRealmsButton = bedrockRealmsBuilder.build();
final ButtonWidget bedrockRealmsButton = bedrockRealmsBuilder.build();
this.addDrawableChild(bedrockRealmsButton);
if (missingAccount) {
bedrockRealmsButton.active = false;

View File

@ -74,11 +74,6 @@ public class BetaCraftScreen extends VFPScreen {
}).position(width - 98 - 5, 5).size(98, 20).build());
}
@Override
protected boolean subtitleCentered() {
return SERVER_LIST == null;
}
@Override
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
super.render(context, mouseX, mouseY, delta);
@ -86,6 +81,11 @@ public class BetaCraftScreen extends VFPScreen {
this.renderTitle(context);
}
@Override
protected boolean subtitleCentered() {
return SERVER_LIST == null;
}
public static class SlotList extends VFPList<VFPListEntry> {
private static double scrollAmount;

View File

@ -23,6 +23,7 @@ import de.florianmichael.classic4j.ClassiCubeHandler;
import de.florianmichael.classic4j.api.LoginProcessHandler;
import de.florianmichael.classic4j.model.classicube.server.CCServerInfo;
import de.florianmichael.viafabricplus.ViaFabricPlus;
import de.florianmichael.viafabricplus.protocoltranslator.impl.provider.vialegacy.ViaFabricPlusClassicMPPassProvider;
import de.florianmichael.viafabricplus.screen.VFPList;
import de.florianmichael.viafabricplus.screen.VFPListEntry;
import de.florianmichael.viafabricplus.screen.VFPScreen;
@ -128,6 +129,8 @@ public class ClassiCubeServerListScreen extends VFPScreen {
@Override
public void mappedMouseClicked(double mouseX, double mouseY, int button) {
final boolean selectCPE = AuthenticationSettings.global().automaticallySelectCPEInClassiCubeServerList.getValue();
ViaFabricPlusClassicMPPassProvider.classicubeMPPass = classiCubeServerInfo.mpPass();
ConnectionUtil.connect(classiCubeServerInfo.name(), classiCubeServerInfo.ip() + ":" + classiCubeServerInfo.port(), selectCPE ? LegacyProtocolVersion.c0_30cpe : null);
}