From efef398c79663ac6e7aa17ecdba2b71f09100ef1 Mon Sep 17 00:00:00 2001 From: Xujiayao Date: Wed, 23 Oct 2024 00:57:38 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=9A=E8=AF=AD=E8=A8=80=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E9=80=9A=E8=BF=87=EF=BC=8C=E6=B7=BB=E5=8A=A0=E4=B8=A4=E4=B8=AA?= =?UTF-8?q?=E8=B6=85=E9=93=BE=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/xujiayao/discord_mc_chat/gui/GUI.form | 58 ++++++++++++++-- .../com/xujiayao/discord_mc_chat/gui/GUI.java | 66 +++++++++++++++++-- .../xujiayao/discord_mc_chat/gui/Main.java | 3 + .../src/main/resources/lang/lang.properties | 5 +- .../main/resources/lang/lang_en_US.properties | 9 +++ .../main/resources/lang/lang_zh.properties | 6 -- .../main/resources/lang/lang_zh_CN.properties | 9 +++ 7 files changed, 141 insertions(+), 15 deletions(-) create mode 100644 wrapper/src/main/resources/lang/lang_en_US.properties delete mode 100644 wrapper/src/main/resources/lang/lang_zh.properties create mode 100644 wrapper/src/main/resources/lang/lang_zh_CN.properties diff --git a/wrapper/src/main/java/com/xujiayao/discord_mc_chat/gui/GUI.form b/wrapper/src/main/java/com/xujiayao/discord_mc_chat/gui/GUI.form index 748bc61..5df2430 100644 --- a/wrapper/src/main/java/com/xujiayao/discord_mc_chat/gui/GUI.form +++ b/wrapper/src/main/java/com/xujiayao/discord_mc_chat/gui/GUI.form @@ -1,6 +1,6 @@
- + @@ -33,12 +33,12 @@ - + - + @@ -46,7 +46,7 @@ - + @@ -82,6 +82,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/wrapper/src/main/java/com/xujiayao/discord_mc_chat/gui/GUI.java b/wrapper/src/main/java/com/xujiayao/discord_mc_chat/gui/GUI.java index 58041e9..4187511 100644 --- a/wrapper/src/main/java/com/xujiayao/discord_mc_chat/gui/GUI.java +++ b/wrapper/src/main/java/com/xujiayao/discord_mc_chat/gui/GUI.java @@ -4,12 +4,16 @@ import com.formdev.flatlaf.extras.FlatSVGUtils; import com.intellij.uiDesigner.core.GridConstraints; import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import javax.swing.*; import javax.swing.plaf.FontUIResource; import javax.swing.text.StyleContext; import java.awt.*; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; import java.lang.reflect.Method; +import java.net.URI; import java.text.MessageFormat; import java.util.Locale; import java.util.PropertyResourceBundle; @@ -26,6 +30,8 @@ public class GUI extends JFrame { private JLabel versionLabel; private JButton button; private JLabel iconLabel; + private JLabel docsLabel; + private JLabel discordLabel; public GUI() { ResourceBundle bundle = PropertyResourceBundle.getBundle("lang/lang"); @@ -41,6 +47,31 @@ public GUI() { String pattern = bundle.getString("version"); versionLabel.setText(MessageFormat.format(pattern, VERSION)); + docsLabel.setCursor(new Cursor(Cursor.HAND_CURSOR)); + discordLabel.setCursor(new Cursor(Cursor.HAND_CURSOR)); + + docsLabel.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + try { + Desktop.getDesktop().browse(new URI("https://blog.xujiayao.com/posts/4ba0a17a/")); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + }); + + discordLabel.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + try { + Desktop.getDesktop().browse(new URI("https://discord.gg/kbXkV6k2XU")); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + }); + setPreferredSize(new Dimension(500, 400)); pack(); @@ -66,7 +97,7 @@ public GUI() { */ private void $$$setupUI$$$() { contentPane = new JPanel(); - contentPane.setLayout(new GridLayoutManager(6, 3, new Insets(10, 10, 10, 10), -1, -1)); + contentPane.setLayout(new GridLayoutManager(13, 3, new Insets(10, 10, 10, 10), -1, -1)); versionLabel = new JLabel(); Font versionLabelFont = this.$$$getFont$$$(null, -1, 12, versionLabel.getFont()); if (versionLabelFont != null) versionLabel.setFont(versionLabelFont); @@ -78,17 +109,17 @@ public GUI() { final JLabel label1 = new JLabel(); Font label1Font = this.$$$getFont$$$(null, -1, 12, label1.getFont()); if (label1Font != null) label1.setFont(label1Font); - this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("lang/lang", "description")); + this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("lang/lang", "description1")); contentPane.add(label1, new GridConstraints(3, 0, 1, 3, GridConstraints.ANCHOR_NORTHWEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); final JSeparator separator2 = new JSeparator(); separator2.setOrientation(0); - contentPane.add(separator2, new GridConstraints(4, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + contentPane.add(separator2, new GridConstraints(11, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); button = new JButton(); Font buttonFont = this.$$$getFont$$$(null, -1, 12, button.getFont()); if (buttonFont != null) button.setFont(buttonFont); button.setHorizontalAlignment(0); this.$$$loadButtonText$$$(button, this.$$$getMessageFromBundle$$$("lang/lang", "buttonText")); - contentPane.add(button, new GridConstraints(5, 2, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + contentPane.add(button, new GridConstraints(12, 2, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); final JLabel label2 = new JLabel(); Font label2Font = this.$$$getFont$$$(null, Font.BOLD, 20, label2.getFont()); if (label2Font != null) label2.setFont(label2Font); @@ -101,6 +132,32 @@ public GUI() { contentPane.add(label3, new GridConstraints(1, 2, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); iconLabel = new JLabel(); contentPane.add(iconLabel, new GridConstraints(0, 0, 2, 1, GridConstraints.ANCHOR_SOUTHWEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, new Dimension(50, 50), new Dimension(50, 50), new Dimension(50, 50), 0, false)); + final JLabel label4 = new JLabel(); + Font label4Font = this.$$$getFont$$$(null, -1, 12, label4.getFont()); + if (label4Font != null) label4.setFont(label4Font); + label4.setOpaque(false); + this.$$$loadLabelText$$$(label4, this.$$$getMessageFromBundle$$$("lang/lang", "description2")); + contentPane.add(label4, new GridConstraints(5, 0, 1, 3, GridConstraints.ANCHOR_NORTHWEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + docsLabel = new JLabel(); + Font docsLabelFont = this.$$$getFont$$$(null, -1, 12, docsLabel.getFont()); + if (docsLabelFont != null) docsLabel.setFont(docsLabelFont); + this.$$$loadLabelText$$$(docsLabel, this.$$$getMessageFromBundle$$$("lang/lang", "description3")); + docsLabel.setToolTipText("https://blog.xujiayao.com/posts/4ba0a17a/"); + contentPane.add(docsLabel, new GridConstraints(7, 0, 1, 3, GridConstraints.ANCHOR_NORTHWEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + contentPane.add(spacer1, new GridConstraints(8, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final Spacer spacer2 = new Spacer(); + contentPane.add(spacer2, new GridConstraints(6, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final Spacer spacer3 = new Spacer(); + contentPane.add(spacer3, new GridConstraints(4, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final Spacer spacer4 = new Spacer(); + contentPane.add(spacer4, new GridConstraints(10, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + discordLabel = new JLabel(); + Font discordLabelFont = this.$$$getFont$$$(null, -1, 12, discordLabel.getFont()); + if (discordLabelFont != null) discordLabel.setFont(discordLabelFont); + this.$$$loadLabelText$$$(discordLabel, this.$$$getMessageFromBundle$$$("lang/lang", "description4")); + discordLabel.setToolTipText("https://discord.gg/kbXkV6k2XU"); + contentPane.add(discordLabel, new GridConstraints(9, 0, 1, 3, GridConstraints.ANCHOR_NORTHWEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); } /** @@ -202,4 +259,5 @@ public GUI() { public JComponent $$$getRootComponent$$$() { return contentPane; } + } diff --git a/wrapper/src/main/java/com/xujiayao/discord_mc_chat/gui/Main.java b/wrapper/src/main/java/com/xujiayao/discord_mc_chat/gui/Main.java index 1cd6ab7..c3c849e 100644 --- a/wrapper/src/main/java/com/xujiayao/discord_mc_chat/gui/Main.java +++ b/wrapper/src/main/java/com/xujiayao/discord_mc_chat/gui/Main.java @@ -7,6 +7,7 @@ import javax.swing.*; import java.io.InputStreamReader; import java.io.Reader; +import java.util.Locale; import java.util.Objects; /** @@ -31,6 +32,8 @@ public static void main(String[] args) { SwingUtilities.invokeLater(() -> { FlatIntelliJLaf.setup(); + //Locale.setDefault(Locale.US); + GUI gui = new GUI(); gui.setVisible(true); }); diff --git a/wrapper/src/main/resources/lang/lang.properties b/wrapper/src/main/resources/lang/lang.properties index 75a7989..cb1b301 100644 --- a/wrapper/src/main/resources/lang/lang.properties +++ b/wrapper/src/main/resources/lang/lang.properties @@ -2,5 +2,8 @@ title=Welcome - Discord-MC-Chat (DMCC) welcome=Welcome to Discord-MC-Chat (DMCC)! version=Version: {0} author=By Xujiayao -description=You are trying to open the Discord-MC-Chat JAR file.

Note:
This file is a Minecraft mod. Please place it in the mods folder of your Minecraft server and run it through the Fabric mod loader, instead of opening the JAR file directly. +description1=Oops! You are attempting to run Discord-MC-Chat directly! +description2=Note:

Discord-MC-Chat is a Fabric Minecraft mod. Please place the JAR file in the "mods" folder of your Minecraft server and run it through the Fabric mod loader, instead of opening it directly. +description3=Please follow Discord-MC-Chat Docs to configure Discord-MC-Chat. +description4=If you need more help, you can ask me questions in the DMCC Discord Server. buttonText=&Close \ No newline at end of file diff --git a/wrapper/src/main/resources/lang/lang_en_US.properties b/wrapper/src/main/resources/lang/lang_en_US.properties new file mode 100644 index 0000000..cb1b301 --- /dev/null +++ b/wrapper/src/main/resources/lang/lang_en_US.properties @@ -0,0 +1,9 @@ +title=Welcome - Discord-MC-Chat (DMCC) +welcome=Welcome to Discord-MC-Chat (DMCC)! +version=Version: {0} +author=By Xujiayao +description1=Oops! You are attempting to run Discord-MC-Chat directly! +description2=Note:

Discord-MC-Chat is a Fabric Minecraft mod. Please place the JAR file in the "mods" folder of your Minecraft server and run it through the Fabric mod loader, instead of opening it directly. +description3=Please follow Discord-MC-Chat Docs to configure Discord-MC-Chat. +description4=If you need more help, you can ask me questions in the DMCC Discord Server. +buttonText=&Close \ No newline at end of file diff --git a/wrapper/src/main/resources/lang/lang_zh.properties b/wrapper/src/main/resources/lang/lang_zh.properties deleted file mode 100644 index 97f9b34..0000000 --- a/wrapper/src/main/resources/lang/lang_zh.properties +++ /dev/null @@ -1,6 +0,0 @@ -title=欢迎 - Discord-MC-Chat (DMCC) -welcome=欢迎使用 Discord-MC-Chat (DMCC)! -version=版本:{0} -author=作者:Xujiayao -description=你正在尝试打开 Discord-MC-Chat JAR 文件。

注意:
此文件乃 Minecraft 模组。请将其放入 Minecraft 服务器的 mods 文件夹中,并通过 Fabric 模组加载器运行,而非直接打开 JAR 文件。 -buttonText=&关闭 \ No newline at end of file diff --git a/wrapper/src/main/resources/lang/lang_zh_CN.properties b/wrapper/src/main/resources/lang/lang_zh_CN.properties new file mode 100644 index 0000000..e9eadeb --- /dev/null +++ b/wrapper/src/main/resources/lang/lang_zh_CN.properties @@ -0,0 +1,9 @@ +title=欢迎 - Discord-MC-Chat (DMCC) +welcome=欢迎使用 Discord-MC-Chat (DMCC)! +version=版本:{0} +author=作者:Xujiayao +description1=哎呀!你正试图直接运行 Discord-MC-Chat! +description2=注意:

Discord-MC-Chat 是一个 Fabric Minecraft 模组。请将 JAR 文件放入 Minecraft 服务器的 "mods" 文件夹中,并通过 Fabric 模组加载器运行,而并非直接打开。 +description3=请按照 Discord-MC-Chat 文档 配置 Discord-MC-Chat。 +description4=如果你需要更多帮助,你可以在 DMCC Discord Server 向我提问。 +buttonText=&关闭 \ No newline at end of file