feat: open mcbbs/mcmod page in mod info/mod donwload page.

This commit is contained in:
huanghongxun 2021-09-12 01:09:16 +08:00
parent d7f5109a65
commit 5057691fb3
2 changed files with 39 additions and 22 deletions

View File

@ -22,6 +22,13 @@ import org.jackhuang.hmcl.setting.Theme;
import org.jackhuang.hmcl.ui.SVG;
public class JFXHyperlink extends Hyperlink {
public JFXHyperlink() {
super();
setGraphic(SVG.launchOutline(Theme.blackFillBinding(), 16, 16));
}
public JFXHyperlink(String text) {
super(text);

View File

@ -35,6 +35,7 @@ import javafx.scene.layout.HBox;
import javafx.scene.layout.Priority;
import javafx.scene.layout.StackPane;
import org.jackhuang.hmcl.mod.ModInfo;
import org.jackhuang.hmcl.mod.ModManager;
import org.jackhuang.hmcl.setting.Theme;
import org.jackhuang.hmcl.task.Schedulers;
import org.jackhuang.hmcl.task.Task;
@ -202,15 +203,29 @@ class ModListPageSkin extends SkinBase<ModListPage> {
Label description = new Label(modInfo.getModInfo().getDescription().toString());
setBody(description);
JFXButton okButton = new JFXButton();
okButton.getStyleClass().add("dialog-accept");
okButton.setText(i18n("button.ok"));
okButton.setOnAction(e -> fireEvent(new DialogCloseEvent()));
if (StringUtils.isNotBlank(modInfo.getModInfo().getUrl())) {
JFXHyperlink officialPageButton = new JFXHyperlink();
officialPageButton.setText(i18n("mods.url"));
officialPageButton.setOnAction(e -> {
fireEvent(new DialogCloseEvent());
FXUtils.openLink(modInfo.getModInfo().getUrl());
});
JFXButton searchButton = new JFXButton();
searchButton.getStyleClass().add("dialog-cancel");
getActions().add(officialPageButton);
}
if (modInfo.getMod() != null && StringUtils.isNotBlank(modInfo.getMod().getMcbbs())) {
JFXHyperlink mcbbsButton = new JFXHyperlink();
mcbbsButton.setText(i18n("mods.mcbbs"));
mcbbsButton.setOnAction(e -> {
fireEvent(new DialogCloseEvent());
FXUtils.openLink(ModManager.getMcbbsUrl(modInfo.getMod().getMcbbs()));
});
getActions().add(mcbbsButton);
}
if (modInfo.getMod() == null || StringUtils.isBlank(modInfo.getMod().getMcmod())) {
JFXHyperlink searchButton = new JFXHyperlink();
searchButton.setText(i18n("mods.mcmod.search"));
searchButton.setOnAction(e -> {
fireEvent(new DialogCloseEvent());
@ -220,27 +235,22 @@ class ModListPageSkin extends SkinBase<ModListPage> {
pair("filter", "0")
)));
});
getActions().add(searchButton);
} else {
searchButton.setText(i18n("mods.mcmod.page"));
searchButton.setOnAction(e -> {
JFXHyperlink mcmodButton = new JFXHyperlink();
mcmodButton.setText(i18n("mods.mcmod.page"));
mcmodButton.setOnAction(e -> {
fireEvent(new DialogCloseEvent());
FXUtils.openLink("https://www.mcmod.cn/class/" + modInfo.getMod().getMcmod() + ".html");
FXUtils.openLink(ModManager.getMcmodUrl(modInfo.getMod().getMcmod()));
});
getActions().add(mcmodButton);
}
if (StringUtils.isNotBlank(modInfo.getModInfo().getUrl())) {
JFXButton officialPageButton = new JFXButton();
officialPageButton.getStyleClass().add("dialog-cancel");
officialPageButton.setText(i18n("mods.url"));
officialPageButton.setOnAction(e -> {
fireEvent(new DialogCloseEvent());
FXUtils.openLink(modInfo.getModInfo().getUrl());
});
setActions(okButton, officialPageButton, searchButton);
} else {
setActions(okButton, searchButton);
}
JFXButton okButton = new JFXButton();
okButton.getStyleClass().add("dialog-accept");
okButton.setText(i18n("button.ok"));
okButton.setOnAction(e -> fireEvent(new DialogCloseEvent()));
getActions().add(okButton);
onEscPressed(this, okButton::fire);
}