Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions HMCL/src/main/java/org/jackhuang/hmcl/ui/Controllers.java
Original file line number Diff line number Diff line change
Expand Up @@ -562,12 +562,12 @@ public static void onHyperlinkAction(String href) {
}
}

public static void openUriInBrowser(@Nullable URI uri) {
public static void openUriOrCopy(@Nullable URI uri) {
if (uri == null) return;
openUriInBrowser(uri.toString());
openUriOrCopy(uri.toString());
}

public static void openUriInBrowser(@Nullable String uri) {
public static void openUriOrCopy(@Nullable String uri) {
if (uri == null) return;
var dialog = new MessageDialogPane.Builder(
i18n("web.open_in_browser", uri),
Expand Down
2 changes: 1 addition & 1 deletion HMCL/src/main/java/org/jackhuang/hmcl/ui/FXUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -1718,7 +1718,7 @@ public static void useJFXContextMenu(TextInputControl control) {
}

public static TextFlow renderAddonChangelog(String changelogHtml, String baseUri) {
var textFlow = new HTMLRenderer(Controllers::openUriInBrowser).appendNode(Jsoup.parse(changelogHtml, baseUri)).mergeLineBreaks().render();
var textFlow = new HTMLRenderer(Controllers::openUriOrCopy).appendNode(Jsoup.parse(changelogHtml, baseUri)).mergeLineBreaks().render();
textFlow.getStyleClass().add("addon-changelog");
return textFlow;
}
Expand Down
2 changes: 1 addition & 1 deletion HMCL/src/main/java/org/jackhuang/hmcl/ui/WebPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public WebPage(String title, String content) {

Task.supplyAsync(() -> {
Document document = Jsoup.parseBodyFragment(content);
HTMLRenderer renderer = new HTMLRenderer(Controllers::openUriInBrowser);
HTMLRenderer renderer = new HTMLRenderer(Controllers::openUriOrCopy);
renderer.appendNode(document);
renderer.mergeLineBreaks();
return renderer.render();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ private void loadVersionPageUrl(AddonUpdateObject object, JFXHyperlink button) {
return repo == null ? null : repo.getVersionPageUrl(object.data.targetVersion());
}).whenComplete(Schedulers.javafx(), (result, exception) -> {
if (exception == null && StringUtils.isNotBlank(result)) {
button.setOnAction(__ -> Controllers.openUriInBrowser(result));
button.setExternalLink(result);
button.setDisable(false);
} else {
LOG.warning("Failed to load addon version page url", exception);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ private void loadVersionPageUrl(RemoteAddon.Version version, RemoteAddonReposito
Task.supplyAsync(() -> repo.getVersionPageUrl(version))
.whenComplete(Schedulers.javafx(), (result, exception) -> {
if (exception == null && StringUtils.isNotBlank(result)) {
button.setOnAction(__ -> Controllers.openUriInBrowser(result));
button.setExternalLink(result);
button.setDisable(false);
} else {
LOG.warning("Failed to load addon version page url", exception);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,6 @@ public static DownloadListPage ofMod(DownloadPage.DownloadCallback callback, boo
return new HMCLLocalizedDownloadListPage(callback, instanceSelection, RemoteAddon.Type.MOD, CurseForgeRemoteAddonRepository.MODS, ModrinthRemoteAddonRepository.MODS);
}

public static DownloadListPage ofCurseForgeMod(DownloadPage.DownloadCallback callback, boolean instanceSelection) {
return new HMCLLocalizedDownloadListPage(callback, instanceSelection, RemoteAddon.Type.MOD, CurseForgeRemoteAddonRepository.MODS, null);
}

public static DownloadListPage ofModrinthMod(DownloadPage.DownloadCallback callback, boolean instanceSelection) {
return new HMCLLocalizedDownloadListPage(callback, instanceSelection, RemoteAddon.Type.MOD, null, ModrinthRemoteAddonRepository.MODS);
}

public static DownloadListPage ofModPack(DownloadPage.DownloadCallback callback, boolean instanceSelection) {
return new HMCLLocalizedDownloadListPage(callback, instanceSelection, RemoteAddon.Type.MODPACK, CurseForgeRemoteAddonRepository.MODPACKS, ModrinthRemoteAddonRepository.MODPACKS);
}
Expand All @@ -51,14 +43,6 @@ public static DownloadListPage ofResourcePack(DownloadPage.DownloadCallback call
return new HMCLLocalizedDownloadListPage(callback, instanceSelection, RemoteAddon.Type.RESOURCE_PACK, CurseForgeRemoteAddonRepository.RESOURCE_PACKS, ModrinthRemoteAddonRepository.RESOURCE_PACKS);
}

public static DownloadListPage ofCurseForgeResourcePack(DownloadPage.DownloadCallback callback, boolean instanceSelection) {
return new HMCLLocalizedDownloadListPage(callback, instanceSelection, RemoteAddon.Type.RESOURCE_PACK, CurseForgeRemoteAddonRepository.RESOURCE_PACKS, null);
}

public static DownloadListPage ofModrinthResourcePack(DownloadPage.DownloadCallback callback, boolean instanceSelection) {
return new HMCLLocalizedDownloadListPage(callback, instanceSelection, RemoteAddon.Type.RESOURCE_PACK, null, ModrinthRemoteAddonRepository.RESOURCE_PACKS);
}

public static DownloadListPage ofShaderPack(DownloadPage.DownloadCallback callback, boolean instanceSelection) {
var page = new HMCLLocalizedDownloadListPage(callback, instanceSelection, RemoteAddon.Type.SHADER_PACK, CurseForgeRemoteAddonRepository.SHADERS, ModrinthRemoteAddonRepository.SHADER_PACKS);
page.supportChinese.set(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
import org.jackhuang.hmcl.addon.mod.ModLoaderType;
import org.jackhuang.hmcl.addon.repository.CurseForgeRemoteAddonRepository;
import org.jackhuang.hmcl.addon.repository.ModrinthRemoteAddonRepository;
import org.jackhuang.hmcl.game.HMCLGameRepository;
import org.jackhuang.hmcl.setting.DownloadProviders;
import org.jackhuang.hmcl.setting.GameInstanceIconType;
import org.jackhuang.hmcl.task.Schedulers;
Expand Down Expand Up @@ -481,15 +480,7 @@ final class ModInfoDialog extends JFXDialogLayout {
}
}

button.setOnAction(e -> {
fireEvent(new DialogCloseEvent());
Controllers.navigate(new DownloadPage(
repository instanceof CurseForgeRemoteAddonRepository ? HMCLLocalizedDownloadListPage.ofCurseForgeMod(null, false) : HMCLLocalizedDownloadListPage.ofModrinthMod(null, false),
remoteAddon,
new HMCLGameRepository.InstanceReference(ModListPageSkin.this.getSkinnable().getRepository(), ModListPageSkin.this.getSkinnable().getInstanceId()),
org.jackhuang.hmcl.ui.download.DownloadPage.FOR_MOD
));
});
button.setExternalLink(remoteAddon.pageUrl());
button.setDisable(false);
});
}
Expand All @@ -501,31 +492,21 @@ final class ModInfoDialog extends JFXDialogLayout {

if (StringUtils.isNotBlank(modInfo.getModInfo().getUrl())) {
JFXHyperlink officialPageButton = new JFXHyperlink(i18n("mods.url"));
officialPageButton.setOnAction(e -> {
fireEvent(new DialogCloseEvent());
FXUtils.openLink(modInfo.getModInfo().getUrl());
});

officialPageButton.setExternalLink(modInfo.getModInfo().getUrl());
getActions().add(officialPageButton);
}

if (modInfo.getModTranslations() == null || StringUtils.isBlank(modInfo.getModTranslations().getMcmod())) {
JFXHyperlink searchButton = new JFXHyperlink(i18n("mods.mcmod.search"));
searchButton.setOnAction(e -> {
fireEvent(new DialogCloseEvent());
FXUtils.openLink(NetworkUtils.withQuery("https://search.mcmod.cn/s", mapOf(
pair("key", modInfo.getModInfo().getName()),
pair("site", "all"),
pair("filter", "0")
)));
});
searchButton.setExternalLink(NetworkUtils.withQuery("https://search.mcmod.cn/s", mapOf(
pair("key", modInfo.getModInfo().getName()),
pair("site", "all"),
pair("filter", "0")
)));
getActions().add(searchButton);
} else {
JFXHyperlink mcmodButton = new JFXHyperlink(i18n("mods.mcmod.page"));
mcmodButton.setOnAction(e -> {
fireEvent(new DialogCloseEvent());
FXUtils.openLink(ModTranslations.MOD.getMcmodUrl(modInfo.getModTranslations()));
});
mcmodButton.setExternalLink(ModTranslations.MOD.getMcmodUrl(modInfo.getModTranslations()));
getActions().add(mcmodButton);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -638,17 +638,7 @@ private static final class ResourcePackInfoDialog extends JFXDialogLayout {
if (versionOptional.isPresent()) {
RemoteAddon remoteAddon = repository.getAddonById(DownloadProviders.getDownloadProvider(), versionOptional.get().projectId());
FXUtils.runInFX(() -> {
button.setOnAction(e -> {
fireEvent(new DialogCloseEvent());
Controllers.navigate(new DownloadPage(
repository instanceof CurseForgeRemoteAddonRepository
? HMCLLocalizedDownloadListPage.ofCurseForgeResourcePack(null, false)
: HMCLLocalizedDownloadListPage.ofModrinthResourcePack(null, false),
remoteAddon,
new HMCLGameRepository.InstanceReference(page.repository, page.instanceId),
org.jackhuang.hmcl.ui.download.DownloadPage.FOR_RESOURCE_PACK
));
});
button.setExternalLink(remoteAddon.pageUrl());
button.setDisable(false);
});
}
Expand Down