Skip to content

Commit

Permalink
config of check-update
Browse files Browse the repository at this point in the history
  • Loading branch information
cubewhy committed Jan 14, 2024
1 parent 69febf5 commit ddccccf
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 36 deletions.
68 changes: 35 additions & 33 deletions src/main/java/org/cubewhy/celestial/gui/pages/GuiSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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");
Expand All @@ -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();
Expand Down
4 changes: 3 additions & 1 deletion src/main/resources/languages/launcher.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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:
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
4 changes: 3 additions & 1 deletion src/main/resources/languages/launcher_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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:
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
4 changes: 3 additions & 1 deletion src/main/resources/languages/launcher_zh.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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=高:
gui.settings.game.resize.height=高:
gui.settings.addon.loader.weave.check-update=检查Weave的更新
gui.settings.addon.loader.cn.check-update=检查LunarCN的更新

0 comments on commit ddccccf

Please sign in to comment.