From 992a3b6ea7b144f887d72000757cef236f8045c6 Mon Sep 17 00:00:00 2001 From: Aizistral Date: Fri, 7 Oct 2022 11:15:27 +0200 Subject: Make GUIs more adaptive to uncommon resolutions Fixes #220 --- .../com/aizistral/nochatreports/gui/EncryptionConfigScreen.java | 8 ++++---- .../com/aizistral/nochatreports/gui/ExtendedWarningScreen.java | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/main/java/com/aizistral/nochatreports/gui/EncryptionConfigScreen.java b/src/main/java/com/aizistral/nochatreports/gui/EncryptionConfigScreen.java index 919a145..383748e 100644 --- a/src/main/java/com/aizistral/nochatreports/gui/EncryptionConfigScreen.java +++ b/src/main/java/com/aizistral/nochatreports/gui/EncryptionConfigScreen.java @@ -71,7 +71,7 @@ public class EncryptionConfigScreen extends Screen { this.clearWidgets(); super.init(); - int w = (int) (this.width * 0.7); + int w = (int) (this.width * (this.hugeGUI() ? 0.9 : 0.7)); this.keyDesc = MultiLineLabel.create(this.font, KEY_DESC, w - 5); int keyDescSpace = (this.keyDesc.getLineCount() + 1) * this.getLineHeight(); @@ -81,7 +81,7 @@ public class EncryptionConfigScreen extends Screen { w -= 52; - this.keyField = new CustomEditBox(this.font, (this.width - w)/2 - 2, (this.hugeGUI() ? 30 : FIELDS_Y_START) + keyDescSpace - 15, + this.keyField = new CustomEditBox(this.font, (this.width - w)/2 - 2, (this.hugeGUI() ? 25 : FIELDS_Y_START) + keyDescSpace - 15, w, 18, CommonComponents.EMPTY); this.keyField.setMaxLength(512); this.keyField.setResponder(this::onKeyUpdate); @@ -183,9 +183,9 @@ public class EncryptionConfigScreen extends Screen { } this.renderBackground(poseStack); - Screen.drawCenteredString(poseStack, this.font, HEADER, this.width / 2, this.hugeGUI() ? 12 : 16, 0xFFFFFF); + Screen.drawCenteredString(poseStack, this.font, HEADER, this.width / 2, this.hugeGUI() ? 8 : 16, 0xFFFFFF); - this.keyDesc.renderLeftAligned(poseStack, this.keyField.x - 20, (this.hugeGUI() ? 30 : FIELDS_Y_START), this.getLineHeight(), 0xFFFFFF); + this.keyDesc.renderLeftAligned(poseStack, this.keyField.x - 20, (this.hugeGUI() ? 25 : FIELDS_Y_START), this.getLineHeight(), 0xFFFFFF); this.keyField.render(poseStack, i, j, f); diff --git a/src/main/java/com/aizistral/nochatreports/gui/ExtendedWarningScreen.java b/src/main/java/com/aizistral/nochatreports/gui/ExtendedWarningScreen.java index d3327e3..39a7b86 100644 --- a/src/main/java/com/aizistral/nochatreports/gui/ExtendedWarningScreen.java +++ b/src/main/java/com/aizistral/nochatreports/gui/ExtendedWarningScreen.java @@ -38,10 +38,10 @@ public abstract class ExtendedWarningScreen extends Screen { protected void init() { this.clearWidgets(); super.init(); - this.message = MultiLineLabel.create(this.font, this.CONTENT, this.width - 100); + this.message = MultiLineLabel.create(this.font, this.CONTENT, this.width - (this.hugeGUI() ? 65 : 100)); int i = (this.message.getLineCount() + 1) * this.getLineHeight(); if (this.CHECK != null) { - int checkY = this.hugeGUI() ? 32 : 76; + int checkY = this.hugeGUI() ? 27 : 76; int j = this.font.width(this.CHECK); this.stopShowing = new Checkbox(this.width / 2 - j / 2 - 8, checkY + i, j + 24, 20, this.CHECK, false); this.addRenderableWidget(this.stopShowing); @@ -51,7 +51,7 @@ public abstract class ExtendedWarningScreen extends Screen { private void initButtons(int i) { int offset = 28; - int buttonY = this.hugeGUI() ? 60 : 100; + int buttonY = this.hugeGUI() ? 55 : 100; this.addRenderableWidget(new Button(this.width / 2 - 260 + offset, buttonY + i, 150, 20, CommonComponents.GUI_PROCEED, this::onProceed)); this.addRenderableWidget(new Button(this.width / 2 - 100 + offset, buttonY + i, 150, 20, Component.translatable("gui.nochatreports.encryption_warning.learn_more"), button -> { @@ -75,7 +75,7 @@ public abstract class ExtendedWarningScreen extends Screen { 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); + this.message.renderLeftAligned(poseStack, k, this.hugeGUI() ? 35 : 70, this.getLineHeight(), 0xFFFFFF); super.render(poseStack, i, j, f); } -- cgit v1.2.3