From d3436101f86e165a6137d61b2f7ada4a8342df2f Mon Sep 17 00:00:00 2001 From: 17146 <1714673995@qq.com> Date: Thu, 27 Feb 2025 14:11:11 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=B4=E6=97=B6=E6=B7=BB=E5=8A=A0=E6=96=87?= =?UTF-8?q?=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../client/screens/ModSellWarningScreen.java | 50 +++++++++++-------- .../assets/superbwarfare/lang/en_us.json | 6 ++- .../assets/superbwarfare/lang/zh_cn.json | 6 ++- 3 files changed, 38 insertions(+), 24 deletions(-) diff --git a/src/main/java/com/atsuishio/superbwarfare/client/screens/ModSellWarningScreen.java b/src/main/java/com/atsuishio/superbwarfare/client/screens/ModSellWarningScreen.java index e4a7dc0b1..6345f13d7 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/screens/ModSellWarningScreen.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/screens/ModSellWarningScreen.java @@ -3,6 +3,7 @@ package com.atsuishio.superbwarfare.client.screens; import com.atsuishio.superbwarfare.config.client.ModSellWarningConfig; import net.minecraft.ChatFormatting; import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.components.AbstractButton; import net.minecraft.client.gui.components.Button; import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.gui.screens.multiplayer.JoinMultiplayerScreen; @@ -61,11 +62,9 @@ public class ModSellWarningScreen extends WarningScreen { } } - // TODO 正确实现提示文本 - // private static final Component TITLE = Component.translatable("multiplayerWarning.header").withStyle(ChatFormatting.BOLD); - private static final Component TITLE = Component.literal("test").withStyle(ChatFormatting.BOLD); - private static final Component CONTENT = Component.literal("这里应该写个多人游戏警告"); - private static final Component CHECK = Component.literal("这里应该是确认勾选框"); + private static final Component TITLE = Component.translatable("multiplayer.superbwarfare.warning.title").withStyle(ChatFormatting.BOLD); + private static final Component CONTENT = Component.translatable("multiplayer.superbwarfare.warning.content"); + private static final Component CHECK = Component.translatable("multiplayer.superbwarfare.warning.check"); private static final Component NARRATION = TITLE.copy().append("\n").append(CONTENT); private final Screen lastScreen; @@ -74,6 +73,30 @@ public class ModSellWarningScreen extends WarningScreen { this.lastScreen = lastScreen; } + @Override + protected void initButtons(int pYOffset) { + this.addRenderableWidget(this.createProceedButton(pYOffset)); + + this.addRenderableWidget( + Button.builder(CommonComponents.GUI_BACK, button -> Minecraft.getInstance().setScreen(this.lastScreen)) + .bounds(this.width / 2 - 155 + 160, 100 + pYOffset, 150, 20) + .build() + ); + } + + // TODO 实现按钮状态刷新 + private AbstractButton createProceedButton(int pYOffset) { + boolean flag = this.stopShowing != null && this.stopShowing.selected(); + var proceedButton = Button.builder(CommonComponents.GUI_PROCEED, button -> { + if (flag) { + ModSellWarningConfig.ENVIRONMENT_CHECKSUM.set(ENVIRONMENT_CHECKSUM); + ModSellWarningConfig.ENVIRONMENT_CHECKSUM.save(); + } + Minecraft.getInstance().setScreen(new JoinMultiplayerScreen(this.lastScreen)); + }).bounds(this.width / 2 - 155, 100 + pYOffset, 150, 20).build(); + proceedButton.active = flag; + return proceedButton; + } @SubscribeEvent(priority = EventPriority.HIGH) public static void onGuiOpen(ScreenEvent.Opening event) { @@ -86,21 +109,4 @@ public class ModSellWarningScreen extends WarningScreen { event.setCanceled(true); Minecraft.getInstance().setScreen(new ModSellWarningScreen(event.getCurrentScreen())); } - - @Override - protected void initButtons(int pYOffset) { - this.addRenderableWidget(Button.builder(CommonComponents.GUI_PROCEED, button -> { - if (this.stopShowing.selected()) { - ModSellWarningConfig.ENVIRONMENT_CHECKSUM.set(ENVIRONMENT_CHECKSUM); - ModSellWarningConfig.ENVIRONMENT_CHECKSUM.save(); - } - Minecraft.getInstance().setScreen(new JoinMultiplayerScreen(this.lastScreen)); - }).bounds(this.width / 2 - 155, 100 + pYOffset, 150, 20).build()); - - this.addRenderableWidget( - Button.builder(CommonComponents.GUI_BACK, button -> Minecraft.getInstance().setScreen(this.lastScreen)) - .bounds(this.width / 2 - 155 + 160, 100 + pYOffset, 150, 20) - .build() - ); - } } diff --git a/src/main/resources/assets/superbwarfare/lang/en_us.json b/src/main/resources/assets/superbwarfare/lang/en_us.json index 077a70ed1..e7e8ea4d4 100644 --- a/src/main/resources/assets/superbwarfare/lang/en_us.json +++ b/src/main/resources/assets/superbwarfare/lang/en_us.json @@ -525,5 +525,9 @@ "config.jade.plugin_superbwarfare.vehicle_energy": "Vehicle Energy", "config.jade.plugin_superbwarfare.vehicle_health": "Vehicle Health", - "config.jade.plugin_superbwarfare.container_entity": "Container Entity" + "config.jade.plugin_superbwarfare.container_entity": "Container Entity", + + "multiplayer.superbwarfare.warning.title": "【卓越前线 警示声明】", + "multiplayer.superbwarfare.warning.content": "== 本模组完全免费开源,禁止用于任何商业行为 ==\n本模组代码采用GPL-3协议开源,美术资源私有禁止商用\n禁止付费下载、充值获取道具等违反协议和Mojang EULA的行为\n如遇以上行为,请到本模组仓库处提交Issue进行举报", + "multiplayer.superbwarfare.warning.check": "我已阅读并同意,不再显示此警告" } \ No newline at end of file diff --git a/src/main/resources/assets/superbwarfare/lang/zh_cn.json b/src/main/resources/assets/superbwarfare/lang/zh_cn.json index 5278b6f82..7ec0ba1c4 100644 --- a/src/main/resources/assets/superbwarfare/lang/zh_cn.json +++ b/src/main/resources/assets/superbwarfare/lang/zh_cn.json @@ -525,5 +525,9 @@ "config.jade.plugin_superbwarfare.vehicle_energy": "载具能量", "config.jade.plugin_superbwarfare.vehicle_health": "载具血量", - "config.jade.plugin_superbwarfare.container_entity": "集装箱实体" + "config.jade.plugin_superbwarfare.container_entity": "集装箱实体", + + "multiplayer.superbwarfare.warning.title": "【卓越前线 警示声明】", + "multiplayer.superbwarfare.warning.content": "== 本模组完全免费开源,禁止用于任何商业行为 ==\n本模组代码采用GPL-3协议开源,美术资源私有禁止商用\n禁止付费下载、充值获取道具等违反协议和Mojang EULA的行为\n如遇以上行为,请到本模组仓库处提交Issue进行举报", + "multiplayer.superbwarfare.warning.check": "我已阅读并同意,不再显示此警告" } \ No newline at end of file