diff --git a/src/main/java/org/cubewhy/celestial/gui/pages/GuiSettings.java b/src/main/java/org/cubewhy/celestial/gui/pages/GuiSettings.java index 94e3d9cc..ef5676e1 100644 --- a/src/main/java/org/cubewhy/celestial/gui/pages/GuiSettings.java +++ b/src/main/java/org/cubewhy/celestial/gui/pages/GuiSettings.java @@ -226,34 +226,21 @@ private void initGui() { // installation (loader) JPanel p11 = new JPanel(); // lunarcn - JButton btnSelectLunarCNInstallation = new JButton(LunarCNMod.getInstallation().getPath()); - btnSelectLunarCNInstallation.addActionListener((e) -> { - File file = GuiUtils.saveFile(new FileNameExtensionFilter("LunarCN Loader", "jar")); - if (file == null) { - return; - } - JButton source = (JButton) e.getSource(); - source.setText(file.getPath()); - setModLoaderInstallation("lunarcn", file); - }); + JButton btnSelectLunarCNInstallation = getSelectInstallationButton(LunarCNMod.getInstallation(), "LunarCN Loader", "lunarcn"); p11.add(new JLabel(f.getString("gui.settings.addon.loader.cn.installation"))); p11.add(btnSelectLunarCNInstallation); panelAddon.add(p11); JPanel p12 = new JPanel(); - JButton btnSelectWeaveInstallation = new JButton(WeaveMod.getInstallation().getPath()); - btnSelectWeaveInstallation.addActionListener((e) -> { - File file = GuiUtils.saveFile(new FileNameExtensionFilter("Weave Loader", "jar")); - if (file == null) { - return; - } - JButton source = (JButton) e.getSource(); - source.setText(file.getPath()); - setModLoaderInstallation("weave", file); - }); + JButton btnSelectWeaveInstallation = getSelectInstallationButton(WeaveMod.getInstallation(), "Weave Loader", "weave"); p12.add(new JLabel(f.getString("gui.settings.addon.loader.weave.installation"))); p12.add(btnSelectWeaveInstallation); panelAddon.add(p12); + JPanel p13 = new JPanel(); + p13.add(getAutoSaveCheckBox(config.getConfig().getAsJsonObject("addon").getAsJsonObject("weave"), "check-update", f.getString("gui.settings.addon.loader.weave.check-update"))); + p13.add(getAutoSaveCheckBox(config.getConfig().getAsJsonObject("addon").getAsJsonObject("lunarcn"), "check-update", f.getString("gui.settings.addon.loader.cn.check-update"))); + panelAddon.add(p13); + claim("addon", panelAddon); // game settings @@ -262,24 +249,24 @@ private void initGui() { panelGame.setLayout(new VerticalFlowLayout(VerticalFlowLayout.LEFT)); // program args - JPanel p13 = new JPanel(); + JPanel p14 = new JPanel(); JButton btnProgramArgs = new JButton(f.getString("gui.settings.game.args")); btnProgramArgs.addActionListener((e) -> new ArgsConfigDialog("program-args", config.getConfig()).setVisible(true)); - p13.add(btnProgramArgs); - panelGame.add(p13); + p14.add(btnProgramArgs); + panelGame.add(p14); // resize - JPanel p14 = new JPanel(); - p14.setBorder(new TitledBorder(null, f.getString("gui.settings.game.resize"), TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, Color.orange)); - p14.setLayout(new VerticalFlowLayout(VerticalFlowLayout.LEFT)); JPanel p15 = new JPanel(); - p15.add(new JLabel(f.getString("gui.settings.game.resize.width"))); - p15.add(getAutoSaveTextField(config.getValue("resize").getAsJsonObject(), "width")); - p14.add(p15); + p15.setBorder(new TitledBorder(null, f.getString("gui.settings.game.resize"), TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, Color.orange)); + p15.setLayout(new VerticalFlowLayout(VerticalFlowLayout.LEFT)); JPanel p16 = new JPanel(); - p16.add(new JLabel(f.getString("gui.settings.game.resize.height"))); - p16.add(getAutoSaveTextField(config.getValue("resize").getAsJsonObject(), "height")); - p14.add(p16); - panelGame.add(p14); + p16.add(new JLabel(f.getString("gui.settings.game.resize.width"))); + p16.add(getAutoSaveTextField(config.getValue("resize").getAsJsonObject(), "width")); + p15.add(p16); + JPanel p17 = new JPanel(); + p17.add(new JLabel(f.getString("gui.settings.game.resize.height"))); + p17.add(getAutoSaveTextField(config.getValue("resize").getAsJsonObject(), "height")); + p15.add(p17); + panelGame.add(p15); claim("program-args", panelGame); claim("resize"); @@ -293,6 +280,21 @@ private void initGui() { } } + @NotNull + private JButton getSelectInstallationButton(File Installation, String name, String type) { + JButton btnSelectLunarCNInstallation = new JButton(Installation.getPath()); + btnSelectLunarCNInstallation.addActionListener((e) -> { + File file = GuiUtils.saveFile(new FileNameExtensionFilter(name, "jar")); + if (file == null) { + return; + } + JButton source = (JButton) e.getSource(); + source.setText(file.getPath()); + setModLoaderInstallation(type, file); + }); + return btnSelectLunarCNInstallation; + } + private void setModLoaderInstallation(String key, @NotNull File file) { config.getValue("addon").getAsJsonObject().getAsJsonObject(key).addProperty("installation", file.getPath()); config.save(); diff --git a/src/main/resources/languages/launcher.properties b/src/main/resources/languages/launcher.properties index 3d4eac5b..429566c5 100644 --- a/src/main/resources/languages/launcher.properties +++ b/src/main/resources/languages/launcher.properties @@ -169,4 +169,6 @@ gui.settings.game=Game gui.settings.game.args=Game args gui.settings.game.resize=Resize gui.settings.game.resize.width=Width: -gui.settings.game.resize.height=Height: \ No newline at end of file +gui.settings.game.resize.height=Height: +gui.settings.addon.loader.weave.check-update=Check for updates for Weave +gui.settings.addon.loader.cn.check-update=Check for updates for LunarCN \ No newline at end of file diff --git a/src/main/resources/languages/launcher_en.properties b/src/main/resources/languages/launcher_en.properties index d0033a82..6fa8ce07 100644 --- a/src/main/resources/languages/launcher_en.properties +++ b/src/main/resources/languages/launcher_en.properties @@ -169,4 +169,6 @@ gui.settings.game=Game gui.settings.game.args=Game args gui.settings.game.resize=Resize gui.settings.game.resize.width=Width: -gui.settings.game.resize.height=Height: \ No newline at end of file +gui.settings.game.resize.height=Height: +gui.settings.addon.loader.weave.check-update=Check for updates for Weave +gui.settings.addon.loader.cn.check-update=Check for updates for LunarCN \ No newline at end of file diff --git a/src/main/resources/languages/launcher_zh.properties b/src/main/resources/languages/launcher_zh.properties index ab8bc278..94d34cc4 100644 --- a/src/main/resources/languages/launcher_zh.properties +++ b/src/main/resources/languages/launcher_zh.properties @@ -168,4 +168,6 @@ gui.settings.game=游戏 gui.settings.game.args=游戏参数 gui.settings.game.resize=缩放 gui.settings.game.resize.width=宽: -gui.settings.game.resize.height=高: \ No newline at end of file +gui.settings.game.resize.height=高: +gui.settings.addon.loader.weave.check-update=检查Weave的更新 +gui.settings.addon.loader.cn.check-update=检查LunarCN的更新 \ No newline at end of file