From 90cc38357eb9a640aa100fbbd60dfd7fe59359e9 Mon Sep 17 00:00:00 2001 From: BianXiao <137746769+mcbianxiao@users.noreply.github.com> Date: Tue, 17 Sep 2024 23:08:16 +0800 Subject: [PATCH] Create pojavlauncherWarnScreen.java --- .../client/gui/pojavlauncherWarnScreen.java | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 src/main/java/me/jellysquid/mods/sodium/client/gui/pojavlauncherWarnScreen.java diff --git a/src/main/java/me/jellysquid/mods/sodium/client/gui/pojavlauncherWarnScreen.java b/src/main/java/me/jellysquid/mods/sodium/client/gui/pojavlauncherWarnScreen.java new file mode 100644 index 0000000000..b85eb31eb5 --- /dev/null +++ b/src/main/java/me/jellysquid/mods/sodium/client/gui/pojavlauncherWarnScreen.java @@ -0,0 +1,54 @@ +package me.jellysquid.mods.sodium.client.gui; + +import me.jellysquid.mods.sodium.client.SodiumClientMod; +import net.minecraft.client.font.MultilineText; +import net.minecraft.client.gui.screen.Screen; +import net.minecraft.client.gui.screen.ScreenTexts; +import net.minecraft.client.gui.widget.ButtonWidget; +import net.minecraft.client.gui.widget.CheckboxWidget; +import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.text.LiteralText; +import net.minecraft.text.Text; +import net.minecraft.text.TranslatableText; +import net.minecraft.util.Formatting; +import net.minecraft.util.Util; + +public class pojavlauncherWarnScreen extends Screen { + + private static final Text HEADER = new TranslatableText("sodium.console.pojav_launcher").formatted(Formatting.BOLD); + private static final Text MESSAGE = new TranslatableText("sodium.console.pojav_launcher"); + private static final Text CHECK_MESSAGE = new TranslatableText("multiplayerWarning.check"); + private final Screen prevScreen; + private CheckboxWidget checkbox; + private MultilineText lines = MultilineText.EMPTY; + + public pojavlauncherWarnScreen(Screen prevScreen) { + super(new LiteralText("BianXiao Edit Sodium Warning")); + this.prevScreen = prevScreen; + } + + @Override + protected void init() { + super.init(); + this.lines = MultilineText.create(this.textRenderer, MESSAGE, this.width - 50); + int i = (this.lines.count() + 1) * this.textRenderer.fontHeight * 2; + this.addDrawableChild(new ButtonWidget(this.width / 2 - 155, 100 + i, 150, 20, ScreenTexts.PROCEED, buttonWidget -> { + if (this.checkbox.isChecked()) { + SodiumExtraClientMod.options().notificationSettings.hideRSORecommendation = true; + SodiumExtraClientMod.options().writeChanges(); + } + this.client.setScreen(this.prevScreen); + })); + this.addDrawableChild(new ButtonWidget(this.width / 2 - 155 + 160, 100 + i, 150, 20, new TranslatableText("menu.quit"), buttonWidget -> this.client.scheduleStop())); + this.checkbox = new CheckboxWidget(this.width / 2 - 155 + 80, 76 + i, 150, 20, CHECK_MESSAGE, false); + this.addDrawableChild(this.checkbox); + } + + @Override + public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) { + this.renderBackgroundTexture(0); + drawTextWithShadow(matrices, this.textRenderer, HEADER, 25, 30, 0xFFFFFF); + this.lines.drawWithShadow(matrices, 25, 70, this.textRenderer.fontHeight * 2, 0xFFFFFF); + super.render(matrices, mouseX, mouseY, delta); + } +}