summaryrefslogtreecommitdiffstats
path: root/src/main/java/com
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com')
-rw-r--r--src/main/java/com/aizistral/nochatreports/gui/EncryptionConfigScreen.java21
-rw-r--r--src/main/java/com/aizistral/nochatreports/gui/EncryptionWarningScreen.java60
2 files changed, 68 insertions, 13 deletions
diff --git a/src/main/java/com/aizistral/nochatreports/gui/EncryptionConfigScreen.java b/src/main/java/com/aizistral/nochatreports/gui/EncryptionConfigScreen.java
index 4875340..051be2c 100644
--- a/src/main/java/com/aizistral/nochatreports/gui/EncryptionConfigScreen.java
+++ b/src/main/java/com/aizistral/nochatreports/gui/EncryptionConfigScreen.java
@@ -81,7 +81,7 @@ public class EncryptionConfigScreen extends Screen {
w -= 52;
- this.keyField = new CustomEditBox(this.font, (this.width - w)/2 - 2, FIELDS_Y_START + keyDescSpace - 16,
+ this.keyField = new CustomEditBox(this.font, (this.width - w)/2 - 2, (this.hugeGUI() ? 30 : FIELDS_Y_START) + keyDescSpace - 15,
w, 18, CommonComponents.EMPTY);
this.keyField.setMaxLength(512);
this.keyField.setResponder(this::onKeyUpdate);
@@ -120,7 +120,7 @@ public class EncryptionConfigScreen extends Screen {
w += 25;
this.passField = new CustomEditBox(this.font, (this.width - w)/2 + 11, this.keyField.y +
- this.keyField.getHeight() + passDescSpace + 10, w, 18, CommonComponents.EMPTY);
+ this.keyField.getHeight() + passDescSpace + (this.hugeGUI() ? -3 : 13), w, 18, CommonComponents.EMPTY);
this.passField.setMaxLength(512);
this.passField.setResponder(this::onPassphraseUpdate);
this.addWidget(this.passField);
@@ -174,6 +174,8 @@ public class EncryptionConfigScreen extends Screen {
@Override
public void render(PoseStack poseStack, int i, int j, float f) {
+ this.init();
+
if (!this.passField.isActive()) {
if (this.passField.isFocused()) {
this.passField.setFocused(false);
@@ -182,13 +184,13 @@ public class EncryptionConfigScreen extends Screen {
}
this.renderBackground(poseStack);
- Screen.drawCenteredString(poseStack, this.font, HEADER, this.width / 2, 16, 0xFFFFFF);
+ Screen.drawCenteredString(poseStack, this.font, HEADER, this.width / 2, this.hugeGUI() ? 12 : 16, 0xFFFFFF);
- this.keyDesc.renderLeftAligned(poseStack, this.keyField.x - 20, FIELDS_Y_START, this.getLineHeight(), 0xFFFFFF);
+ this.keyDesc.renderLeftAligned(poseStack, this.keyField.x - 20, (this.hugeGUI() ? 30 : FIELDS_Y_START), this.getLineHeight(), 0xFFFFFF);
this.keyField.render(poseStack, i, j, f);
- this.passDesc.renderLeftAligned(poseStack, this.passField.x - 20, this.keyField.y + this.keyField.getHeight() + 28,
+ this.passDesc.renderLeftAligned(poseStack, this.passField.x - 20, this.keyField.y + this.keyField.getHeight() + (this.hugeGUI() ? 12 : 28),
this.getLineHeight(), 0xFFFFFF);
this.passField.render(poseStack, i, j, f);
@@ -216,7 +218,10 @@ public class EncryptionConfigScreen extends Screen {
}
private int getLineHeight() {
- return this.font.lineHeight * 2;
+ if (this.minecraft.options.guiScale().get() > 3)
+ return (int) (this.minecraft.font.lineHeight * 1.5) + 1;
+ else
+ return this.minecraft.font.lineHeight * 2;
}
@Override
@@ -275,6 +280,10 @@ public class EncryptionConfigScreen extends Screen {
config.setEncryptPublic(this.encryptPublicCheck.selected());
}
+ private boolean hugeGUI() {
+ return this.height <= 1080 / 4;
+ }
+
@Override
public void onClose() {
this.minecraft.setScreen(this.previous);
diff --git a/src/main/java/com/aizistral/nochatreports/gui/EncryptionWarningScreen.java b/src/main/java/com/aizistral/nochatreports/gui/EncryptionWarningScreen.java
index 349c52d..72734c8 100644
--- a/src/main/java/com/aizistral/nochatreports/gui/EncryptionWarningScreen.java
+++ b/src/main/java/com/aizistral/nochatreports/gui/EncryptionWarningScreen.java
@@ -1,8 +1,11 @@
package com.aizistral.nochatreports.gui;
+import org.jetbrains.annotations.Nullable;
+
import com.aizistral.nochatreports.NoChatReportsClient;
import com.aizistral.nochatreports.config.NCRConfig;
import com.aizistral.nochatreports.core.ServerSafetyState;
+import com.mojang.blaze3d.vertex.PoseStack;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
@@ -10,6 +13,8 @@ import net.minecraft.ChatFormatting;
import net.minecraft.Util;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.components.Button;
+import net.minecraft.client.gui.components.Checkbox;
+import net.minecraft.client.gui.components.MultiLineLabel;
import net.minecraft.client.gui.screens.ConfirmLinkScreen;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.gui.screens.TitleScreen;
@@ -18,28 +23,45 @@ import net.minecraft.client.gui.screens.multiplayer.WarningScreen;
import net.minecraft.client.multiplayer.resolver.ServerAddress;
import net.minecraft.network.chat.CommonComponents;
import net.minecraft.network.chat.Component;
+import net.minecraft.network.chat.FormattedText;
@Environment(EnvType.CLIENT)
-public class EncryptionWarningScreen extends WarningScreen {
+public class EncryptionWarningScreen extends Screen {
private static final Component TITLE = Component.translatable("gui.nochatreports.encryption_warning.header").withStyle(ChatFormatting.BOLD);
private static final Component CONTENT = Component.translatable("gui.nochatreports.encryption_warning.contents");
private static final Component CHECK = Component.translatable("gui.nochatreports.encryption_warning.check");
private static final Component NARRATION = TITLE.copy().append("\n").append(CONTENT);
private static final String WIKI_LINK = "https://github.com/Aizistral-Studios/No-Chat-Reports/wiki/To-Encrypt-or-Not-to-Encrypt";
private static boolean sessionSeen = false;
-
private final Screen previous;
+ private MultiLineLabel message = MultiLineLabel.EMPTY;
+ private Checkbox stopShowing = null;
public EncryptionWarningScreen(Screen previous) {
- super(TITLE, CONTENT, CHECK, NARRATION);
+ super(TITLE);
this.previous = previous;
}
@Override
- protected void initButtons(int i) {
+ protected void init() {
+ this.clearWidgets();
+ super.init();
+ this.message = MultiLineLabel.create(this.font, CONTENT, this.width - 100);
+ int i = (this.message.getLineCount() + 1) * this.getLineHeight();
+ if (CHECK != null) {
+ int checkY = this.hugeGUI() ? 32 : 76;
+ int j = this.font.width(CHECK);
+ this.stopShowing = new Checkbox(this.width / 2 - j / 2 - 8, checkY + i, j + 24, 20, CHECK, false);
+ this.addRenderableWidget(this.stopShowing);
+ }
+ this.initButtons(i);
+ }
+
+ private void initButtons(int i) {
int offset = 28;
+ int buttonY = this.hugeGUI() ? 60 : 100;
- this.addRenderableWidget(new Button(this.width / 2 - 260 + offset, 100 + i, 150, 20, CommonComponents.GUI_PROCEED, button -> {
+ this.addRenderableWidget(new Button(this.width / 2 - 260 + offset, buttonY + i, 150, 20, CommonComponents.GUI_PROCEED, button -> {
this.minecraft.setScreen(new EncryptionConfigScreen(this.previous));
if (this.stopShowing.selected()) {
NCRConfig.getEncryption().disableWarning();
@@ -47,7 +69,7 @@ public class EncryptionWarningScreen extends WarningScreen {
sessionSeen = true;
}));
- this.addRenderableWidget(new Button(this.width / 2 - 100 + offset, 100 + i, 150, 20, Component.translatable("gui.nochatreports.encryption_warning.learn_more"), button -> {
+ this.addRenderableWidget(new Button(this.width / 2 - 100 + offset, buttonY + i, 150, 20, Component.translatable("gui.nochatreports.encryption_warning.learn_more"), button -> {
Minecraft.getInstance().setScreen(new ConfirmLinkScreen(agree -> {
if (agree) {
Util.getPlatform().openUri(WIKI_LINK);
@@ -56,11 +78,35 @@ public class EncryptionWarningScreen extends WarningScreen {
Minecraft.getInstance().setScreen(this);
}, WIKI_LINK, true));
}));
- this.addRenderableWidget(new Button(this.width / 2 + 60 + offset, 100 + i, 150, 20, CommonComponents.GUI_BACK, button -> {
+ this.addRenderableWidget(new Button(this.width / 2 + 60 + offset, buttonY + i, 150, 20, CommonComponents.GUI_BACK, button -> {
this.minecraft.setScreen(this.previous);
}));
}
+ @Override
+ public void render(PoseStack poseStack, int i, int j, float f) {
+ this.renderBackground(poseStack);
+ this.renderTitle(poseStack);
+ int k = this.width / 2 - this.message.getWidth() / 2;
+ this.message.renderLeftAligned(poseStack, k, this.hugeGUI() ? 40 : 70, this.getLineHeight(), 0xFFFFFF);
+ super.render(poseStack, i, j, f);
+ }
+
+ private void renderTitle(PoseStack poseStack) {
+ drawString(poseStack, this.font, this.title, 25, this.hugeGUI() ? 15 : 30, 0xFFFFFF);
+ }
+
+ private int getLineHeight() {
+ if (this.hugeGUI())
+ return (int) (this.minecraft.font.lineHeight * 1.5) + 1;
+ else
+ return this.minecraft.font.lineHeight * 2;
+ }
+
+ private boolean hugeGUI() {
+ return this.height <= 1080 / 4;
+ }
+
public static boolean seenOnThisSession() {
return sessionSeen;
}