diff --git a/src/main/java/de/florianmichael/viafabricplus/screen/VFPScreen.java b/src/main/java/de/florianmichael/viafabricplus/screen/VFPScreen.java index c7162208..a6f36d33 100644 --- a/src/main/java/de/florianmichael/viafabricplus/screen/VFPScreen.java +++ b/src/main/java/de/florianmichael/viafabricplus/screen/VFPScreen.java @@ -57,11 +57,10 @@ public class VFPScreen extends Screen { this.backButton = backButton; } - /*** + /** * Sets the subtitle and the subtitle press action to the default values * The default value of the subtitle is the url to the GitHub repository of VFP * The default value of the subtitle press action is to open the url in a confirmation screen - * */ public void setupDefaultSubtitle() { this.setupUrlSubtitle(MOD_URL); @@ -77,7 +76,7 @@ public class VFPScreen extends Screen { } - /*** + /** * Sets the subtitle and the subtitle press action * * @param subtitle The subtitle which should be rendered @@ -86,7 +85,7 @@ public class VFPScreen extends Screen { this.setupSubtitle(subtitle, null); } - /*** + /** * Sets the subtitle and the subtitle press action * * @param subtitle The subtitle which should be rendered @@ -96,10 +95,14 @@ public class VFPScreen extends Screen { this.subtitle = subtitle; this.subtitlePressAction = subtitlePressAction; - if (subtitleWidget != null && subtitlePressAction == null) { // Allows to remove the subtitle when calling this method twice. + if (subtitleWidget != null) { // Allows to remove the subtitle when calling this method twice. remove(subtitleWidget); subtitleWidget = null; } + if (subtitlePressAction != null) { + final int subtitleWidth = textRenderer.getWidth(subtitle); + this.addDrawableChild(subtitleWidget = new PressableTextWidget(width / 2 - (subtitleWidth / 2), (textRenderer.fontHeight + 2) * 2 + 3, subtitleWidth, textRenderer.fontHeight + 2, subtitle, subtitlePressAction, textRenderer)); + } } /** @@ -118,11 +121,6 @@ public class VFPScreen extends Screen { if (backButton) { this.addDrawableChild(ButtonWidget.builder(Text.literal("<-"), button -> this.close()).position(5, 5).size(20, 20).build()); } - - if (this.subtitle != null && this.subtitlePressAction != null) { - final int subtitleWidth = textRenderer.getWidth(subtitle); - this.addDrawableChild(subtitleWidget = new PressableTextWidget(width / 2 - (subtitleWidth / 2), (textRenderer.fontHeight + 2) * 2 + 3, subtitleWidth, textRenderer.fontHeight + 2, subtitle, subtitlePressAction, textRenderer)); - } } @Override diff --git a/src/main/java/de/florianmichael/viafabricplus/screen/classic4j/BetaCraftScreen.java b/src/main/java/de/florianmichael/viafabricplus/screen/classic4j/BetaCraftScreen.java index e3481cc9..7fdc19ea 100644 --- a/src/main/java/de/florianmichael/viafabricplus/screen/classic4j/BetaCraftScreen.java +++ b/src/main/java/de/florianmichael/viafabricplus/screen/classic4j/BetaCraftScreen.java @@ -48,11 +48,11 @@ public class BetaCraftScreen extends VFPScreen { protected BetaCraftScreen() { super("BetaCraft", true); - this.setupSubtitle(Text.of(BETA_CRAFT_SERVER_LIST_URL), ConfirmLinkScreen.opening(this, BETA_CRAFT_SERVER_LIST_URL)); } @Override protected void init() { + 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)); this.addDrawableChild(ButtonWidget.builder(Text.translatable("base.viafabricplus.reset"), button -> { 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 3f4a79a7..efb79a91 100644 --- a/src/main/java/de/florianmichael/viafabricplus/screen/classic4j/ClassiCubeLoginScreen.java +++ b/src/main/java/de/florianmichael/viafabricplus/screen/classic4j/ClassiCubeLoginScreen.java @@ -42,18 +42,13 @@ public class ClassiCubeLoginScreen extends VFPScreen { super("ClassiCube Login", true); } - @Override - public void open(Screen prevScreen) { - this.setupSubtitle(Text.translatable("classicube.viafabricplus.account"), ConfirmLinkScreen.opening(this, ClassiCubeHandler.CLASSICUBE_ROOT_URI.toString())); - super.open(prevScreen); - } - private TextFieldWidget nameField; private TextFieldWidget passwordField; @Override protected void init() { super.init(); + this.setupSubtitle(Text.translatable("classicube.viafabricplus.account"), ConfirmLinkScreen.opening(this, ClassiCubeHandler.CLASSICUBE_ROOT_URI.toString())); this.addDrawableChild(nameField = new TextFieldWidget(textRenderer, width / 2 - 150, 70 + 10, 300, 20, Text.empty())); this.addDrawableChild(passwordField = new TextFieldWidget(textRenderer, width / 2 - 150, nameField.getY() + 20 + 5, 300, 20, Text.empty())); diff --git a/src/main/java/de/florianmichael/viafabricplus/screen/classic4j/ClassiCubeMFAScreen.java b/src/main/java/de/florianmichael/viafabricplus/screen/classic4j/ClassiCubeMFAScreen.java index f873bf86..bcef7188 100644 --- a/src/main/java/de/florianmichael/viafabricplus/screen/classic4j/ClassiCubeMFAScreen.java +++ b/src/main/java/de/florianmichael/viafabricplus/screen/classic4j/ClassiCubeMFAScreen.java @@ -40,17 +40,12 @@ public class ClassiCubeMFAScreen extends VFPScreen { super("ClassiCube MFA", false); } - @Override - public void open(Screen prevScreen) { - this.setupSubtitle(Text.translatable("classic4j_library.viafabricplus.error.logincode")); - super.open(prevScreen); - } - private TextFieldWidget mfaField; @Override protected void init() { super.init(); + this.setupSubtitle(Text.translatable("classic4j_library.viafabricplus.error.logincode")); this.addDrawableChild(mfaField = new TextFieldWidget(textRenderer, width / 2 - 150, 70 + 10, 300, 20, Text.empty())); 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 a72fc7b5..61a670ed 100644 --- a/src/main/java/de/florianmichael/viafabricplus/screen/classic4j/ClassiCubeServerListScreen.java +++ b/src/main/java/de/florianmichael/viafabricplus/screen/classic4j/ClassiCubeServerListScreen.java @@ -64,15 +64,15 @@ public class ClassiCubeServerListScreen extends VFPScreen { public ClassiCubeServerListScreen() { super("ClassiCube", true); - - final var account = ViaFabricPlus.global().getSaveManager().getAccountsSave().getClassicubeAccount(); - if (account != null) { - this.setupUrlSubtitle(CLASSICUBE_SERVER_LIST_URL); - } } @Override protected void init() { + final var account = ViaFabricPlus.global().getSaveManager().getAccountsSave().getClassicubeAccount(); + if (account != null) { + this.setupUrlSubtitle(CLASSICUBE_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 + 4) * 3)); this.addDrawableChild(ButtonWidget.builder(Text.translatable("base.viafabricplus.logout"), button -> { diff --git a/src/main/java/de/florianmichael/viafabricplus/screen/settings/SettingsScreen.java b/src/main/java/de/florianmichael/viafabricplus/screen/settings/SettingsScreen.java index f5a1a53a..377067d6 100644 --- a/src/main/java/de/florianmichael/viafabricplus/screen/settings/SettingsScreen.java +++ b/src/main/java/de/florianmichael/viafabricplus/screen/settings/SettingsScreen.java @@ -34,11 +34,11 @@ public class SettingsScreen extends VFPScreen { public SettingsScreen() { super("Setting", true); - this.setupDefaultSubtitle(); } @Override protected void init() { + this.setupDefaultSubtitle(); this.addDrawableChild(new SlotList(this.client, width, height, 3 + 3 /* start offset */ + (textRenderer.fontHeight + 2) * 3 /* title is 2 */, -5, (textRenderer.fontHeight + 2) * 2)); super.init();