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
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public SearchResult search(DownloadProvider downloadProvider, String gameVersion
}

RemoteMod remoteMod = iterator.next();
ModTranslations.Mod chineseTranslation = ModTranslations.getTranslationsByRepositoryType(getType()).getModByCurseForgeId(remoteMod.getSlug());
ModTranslations.Mod chineseTranslation = ModTranslations.getTranslationsByRepositoryType(getType()).getModByCurseForgeId(remoteMod.slug());
if (chineseTranslation != null && !StringUtils.isBlank(chineseTranslation.getName()) && StringUtils.containsChinese(chineseTranslation.getName())) {
searchResultArray[chineseIndex++] = remoteMod;
} else {
Expand All @@ -86,7 +86,7 @@ public SearchResult search(DownloadProvider downloadProvider, String gameVersion

StringUtils.LevCalculator levCalculator = new StringUtils.LevCalculator();
return new SearchResult(Stream.concat(Arrays.stream(searchResultArray, 0, chineseIndex).map(remoteMod -> {
ModTranslations.Mod chineseRemoteMod = ModTranslations.getTranslationsByRepositoryType(getType()).getModByCurseForgeId(remoteMod.getSlug());
ModTranslations.Mod chineseRemoteMod = ModTranslations.getTranslationsByRepositoryType(getType()).getModByCurseForgeId(remoteMod.slug());
if (chineseRemoteMod == null || StringUtils.isBlank(chineseRemoteMod.getName()) || !StringUtils.containsChinese(chineseRemoteMod.getName())) {
return Pair.pair(remoteMod, Integer.MAX_VALUE);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ public static void download(DownloadProvider downloadProvider, Profile profile,
Path dest = runDirectory.resolve(subdirectoryName).resolve(result);

Controllers.taskDialog(Task.composeAsync(() -> {
var task = new FileDownloadTask(downloadProvider.injectURLWithCandidates(file.getFile().getUrl()), dest);
task.setName(file.getName());
var task = new FileDownloadTask(downloadProvider.injectURLWithCandidates(file.file().url()), dest);
task.setName(file.name());
return task;
}).whenComplete(Schedulers.javafx(), exception -> {
if (exception != null) {
Expand All @@ -171,7 +171,7 @@ public static void download(DownloadProvider downloadProvider, Profile profile,
}
}), i18n("message.downloading"), TaskCancellationAction.NORMAL);
handler.resolve();
}, file.getFile().getFilename(), new Validator(i18n("install.new_game.malformed"), FileUtils::isNameValidForJar), new Validator(i18n("profile.already_exists"), (it) -> !finalExistingFiles.contains(it)));
}, file.file().filename(), new Validator(i18n("install.new_game.malformed"), FileUtils::isNameValidForJar), new Validator(i18n("profile.already_exists"), (it) -> !finalExistingFiles.contains(it)));

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -575,19 +575,19 @@ protected void updateItem(RemoteMod item, boolean empty) {
if (empty || item == null) {
setGraphic(null);
} else {
ModTranslations.Mod mod = ModTranslations.getTranslationsByRepositoryType(getSkinnable().repository.getType()).getModByCurseForgeId(item.getSlug());
content.setTitle(mod != null && I18n.isUseChinese() ? mod.getDisplayName() : item.getTitle());
String description = item.getDescription();
ModTranslations.Mod mod = ModTranslations.getTranslationsByRepositoryType(getSkinnable().repository.getType()).getModByCurseForgeId(item.slug());
content.setTitle(mod != null && I18n.isUseChinese() ? mod.getDisplayName() : item.title());
String description = item.description();
if (description != null) {
description = description.replaceAll("\\R", " ");
}
content.setSubtitle(description);
content.getTags().clear();
for (String category : item.getCategories()) {
for (String category : item.categories()) {
if (getSkinnable().shouldDisplayCategory(category))
content.addTag(getSkinnable().getLocalizedCategory(category));
}
iconLoader.load(imageContainer.imageProperty(), item.getIconUrl());
iconLoader.load(imageContainer.imageProperty(), item.iconUrl());
setGraphic(wrapper);
}
}
Expand Down
60 changes: 30 additions & 30 deletions HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/DownloadPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,20 +81,20 @@ public DownloadPage(DownloadListPage page, RemoteMod addon, Profile.ProfileVersi
this.repository = page.repository;
this.addon = addon;
this.translations = ModTranslations.getTranslationsByRepositoryType(repository.getType());
this.mod = translations.getModByCurseForgeId(addon.getSlug());
this.mod = translations.getModByCurseForgeId(addon.slug());
this.version = version;
this.callback = callback;
loadModVersions();

this.state.set(State.fromTitle(addon.getTitle()));
this.state.set(State.fromTitle(addon.title()));
}

private void loadModVersions() {
setLoading(true);
setFailed(false);

Task.supplyAsync(() -> {
Stream<RemoteMod.Version> versions = addon.getData().loadVersions(repository, page.getDownloadProvider());
Stream<RemoteMod.Version> versions = addon.data().loadVersions(repository, page.getDownloadProvider());
return sortVersions(versions);
}).whenComplete(Schedulers.javafx(), (result, exception) -> {
if (exception == null) {
Expand All @@ -113,14 +113,14 @@ private SimpleMultimap<String, RemoteMod.Version, List<RemoteMod.Version>> sortV
SimpleMultimap<String, RemoteMod.Version, List<RemoteMod.Version>> classifiedVersions
= new SimpleMultimap<>(HashMap::new, ArrayList::new);
versions.forEach(version -> {
for (String gameVersion : version.getGameVersions()) {
for (String gameVersion : version.gameVersions()) {
classifiedVersions.put(gameVersion, version);
}
});

for (String gameVersion : classifiedVersions.keys()) {
List<RemoteMod.Version> versionList = classifiedVersions.get(gameVersion);
versionList.sort(Comparator.comparing(RemoteMod.Version::getDatePublished).reversed());
versionList.sort(Comparator.comparing(RemoteMod.Version::datePublished).reversed());
}
return classifiedVersions;
}
Expand Down Expand Up @@ -166,21 +166,21 @@ public void download(RemoteMod mod, RemoteMod.Version file) {
}

public void saveAs(RemoteMod mod, RemoteMod.Version file) {
String extension = StringUtils.substringAfterLast(file.getFile().getFilename(), '.');
String extension = StringUtils.substringAfterLast(file.file().filename(), '.');

FileChooser fileChooser = new FileChooser();
fileChooser.setTitle(i18n("button.save_as"));
fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter(i18n("file"), "*." + extension));
fileChooser.setInitialFileName(file.getFile().getFilename());
fileChooser.setInitialFileName(file.file().filename());
Path dest = FileUtils.toPath(fileChooser.showSaveDialog(Controllers.getStage()));
if (dest == null) {
return;
}

Controllers.taskDialog(
Task.composeAsync(() -> {
var task = new FileDownloadTask(file.getFile().getUrl(), dest, file.getFile().getIntegrityCheck());
task.setName(file.getName());
var task = new FileDownloadTask(file.file().url(), dest, file.file().getIntegrityCheck());
task.setName(file.name());
return task;
}),
i18n("message.downloading"),
Expand Down Expand Up @@ -213,18 +213,18 @@ protected ModDownloadPageSkin(DownloadPage control) {
descriptionPane.getStyleClass().add("card-non-transparent");
{
var imageContainer = new ImageContainer(40);
if (StringUtils.isNotBlank(getSkinnable().addon.getIconUrl())) {
imageContainer.imageProperty().bind(FXUtils.newRemoteImage(getSkinnable().addon.getIconUrl(), 80, 80, true, true));
if (StringUtils.isNotBlank(getSkinnable().addon.iconUrl())) {
imageContainer.imageProperty().bind(FXUtils.newRemoteImage(getSkinnable().addon.iconUrl(), 80, 80, true, true));
}
descriptionPane.getChildren().add(imageContainer);

TwoLineListItem content = new TwoLineListItem();
HBox.setHgrow(content, Priority.ALWAYS);
ModTranslations.Mod mod = getSkinnable().translations.getModByCurseForgeId(getSkinnable().addon.getSlug());
content.setTitle(mod != null && I18n.isUseChinese() ? mod.getDisplayName() : getSkinnable().addon.getTitle());
content.setSubtitle(getSkinnable().addon.getDescription());
ModTranslations.Mod mod = getSkinnable().translations.getModByCurseForgeId(getSkinnable().addon.slug());
content.setTitle(mod != null && I18n.isUseChinese() ? mod.getDisplayName() : getSkinnable().addon.title());
content.setSubtitle(getSkinnable().addon.description());
content.getSubtitleLabel().setWrapText(true);
getSkinnable().addon.getCategories().stream()
getSkinnable().addon.categories().stream()
.filter(category -> getSkinnable().page.shouldDisplayCategory(category))
.map(category -> getSkinnable().page.getLocalizedCategory(category))
.forEach(content::addTag);
Expand All @@ -239,7 +239,7 @@ protected ModDownloadPageSkin(DownloadPage control) {
}

JFXHyperlink openUrlButton = new JFXHyperlink(control.page.getLocalizedOfficialPage());
openUrlButton.setExternalLink(getSkinnable().addon.getPageUrl());
openUrlButton.setExternalLink(getSkinnable().addon.pageUrl());
descriptionPane.getChildren().add(openUrlButton);
openUrlButton.setMinWidth(Region.USE_PREF_SIZE);
}
Expand Down Expand Up @@ -282,7 +282,7 @@ protected ModDownloadPageSkin(DownloadPage control) {

resolve:
for (RemoteMod.Version modVersion : modVersions) {
for (ModLoaderType loader : modVersion.getLoaders()) {
for (ModLoaderType loader : modVersion.loaders()) {
if (targetLoaders.contains(loader)) {
list.getContent().addAll(
ComponentList.createComponentListTitle(i18n("mods.download.recommend", gameVersion)),
Expand Down Expand Up @@ -381,15 +381,15 @@ private static final class DependencyModItem extends LineButton {
setNode(IDX_LEADING, pane);

if (addon != RemoteMod.BROKEN) {
ModTranslations.Mod mod = ModTranslations.getTranslationsByRepositoryType(page.repository.getType()).getModByCurseForgeId(addon.getSlug());
content.setTitle(mod != null && I18n.isUseChinese() ? mod.getDisplayName() : addon.getTitle());
content.setSubtitle(addon.getDescription());
for (String category : addon.getCategories()) {
ModTranslations.Mod mod = ModTranslations.getTranslationsByRepositoryType(page.repository.getType()).getModByCurseForgeId(addon.slug());
content.setTitle(mod != null && I18n.isUseChinese() ? mod.getDisplayName() : addon.title());
content.setSubtitle(addon.description());
for (String category : addon.categories()) {
if (page.shouldDisplayCategory(category))
content.addTag(page.getLocalizedCategory(category));
}
if (StringUtils.isNotBlank(addon.getIconUrl())) {
imageView.imageProperty().bind(FXUtils.newRemoteImage(addon.getIconUrl(), 80, 80, true, true));
if (StringUtils.isNotBlank(addon.iconUrl())) {
imageView.imageProperty().bind(FXUtils.newRemoteImage(addon.iconUrl(), 80, 80, true, true));
}
} else {
content.setTitle(i18n("mods.broken_dependency.title"));
Expand All @@ -415,10 +415,10 @@ private static final class ModItem extends StackPane {
StackPane graphicPane = new StackPane();
TwoLineListItem content = new TwoLineListItem();
HBox.setHgrow(content, Priority.ALWAYS);
content.setTitle(dataItem.getName());
content.setSubtitle(I18n.formatDateTime(dataItem.getDatePublished()));
content.setTitle(dataItem.name());
content.setSubtitle(I18n.formatDateTime(dataItem.datePublished()));

switch (dataItem.getVersionType()) {
switch (dataItem.versionType()) {
case Alpha:
content.addTag(i18n("mods.channel.alpha"));
graphicPane.getChildren().setAll(SVG.ALPHA_CIRCLE.createIcon(24));
Expand All @@ -433,7 +433,7 @@ private static final class ModItem extends StackPane {
break;
}

for (ModLoaderType modLoaderType : dataItem.getLoaders()) {
for (ModLoaderType modLoaderType : dataItem.loaders()) {
switch (modLoaderType) {
case FORGE:
content.addTag(i18n("install.installer.forge"));
Expand Down Expand Up @@ -482,7 +482,7 @@ public ModVersion(RemoteMod mod, RemoteMod.Version version, DownloadPage selfPag
case SHADER_PACK -> "shaderpack.download.title";
default -> "mods.download.title";
};
this.setHeading(new HBox(new Label(i18n(title, version.getName()))));
this.setHeading(new HBox(new Label(i18n(title, version.name()))));

VBox box = new VBox(8);
box.setPadding(new Insets(8));
Expand Down Expand Up @@ -549,8 +549,8 @@ private void loadDependencies(RemoteMod.Version version, DownloadPage selfPage,
Task.composeAsync(() -> {
// TODO: Massive tasks may cause OOM.
EnumMap<RemoteMod.DependencyType, List<Node>> dependencies = new EnumMap<>(RemoteMod.DependencyType.class);
List<Task<?>> queue = new ArrayList<>(version.getDependencies().size());
for (RemoteMod.Dependency dependency : version.getDependencies()) {
List<Task<?>> queue = new ArrayList<>(version.dependencies().size());
for (RemoteMod.Dependency dependency : version.dependencies()) {
if (dependency.getType() == RemoteMod.DependencyType.INCOMPATIBLE || dependency.getType() == RemoteMod.DependencyType.BROKEN) {
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public ModCheckUpdatesTask(DownloadProvider downloadProvider, String gameVersion
continue;
}

if (candidate == null || candidate.getCandidate().getDatePublished().isBefore(update.getCandidate().getDatePublished())) {
if (candidate == null || candidate.getCandidate().datePublished().isBefore(update.getCandidate().datePublished())) {
candidate = update;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -480,9 +480,9 @@ final class ModInfoDialog extends JFXDialogLayout {
Task.runAsync(() -> {
Optional<RemoteMod.Version> versionOptional = repository.getRemoteVersionByLocalFile(modInfo.getModInfo(), modInfo.getModInfo().getFile());
if (versionOptional.isPresent()) {
RemoteMod remoteMod = repository.getModById(DownloadProviders.getDownloadProvider(), versionOptional.get().getModid());
RemoteMod remoteMod = repository.getModById(DownloadProviders.getDownloadProvider(), versionOptional.get().modid());
FXUtils.runInFX(() -> {
for (ModLoaderType modLoaderType : versionOptional.get().getLoaders()) {
for (ModLoaderType modLoaderType : versionOptional.get().loaders()) {
String loaderName = switch (modLoaderType) {
case FORGE -> i18n("install.installer.forge");
case CLEANROOM -> i18n("install.installer.cleanroom");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,9 @@ public ModUpdateObject(LocalModFile.ModUpdate data) {

enabled.set(!data.getLocalMod().getModManager().isDisabled(data.getLocalMod().getFile()));
fileName.set(data.getLocalMod().getFileName());
currentVersion.set(data.getCurrentVersion().getVersion());
targetVersion.set(data.getCandidate().getVersion());
switch (data.getCurrentVersion().getSelf().getType()) {
currentVersion.set(data.getCurrentVersion().version());
targetVersion.set(data.getCandidate().version());
switch (data.getCurrentVersion().self().getType()) {
case CURSEFORGE:
source.set(i18n("mods.curseforge"));
break;
Expand Down Expand Up @@ -291,15 +291,15 @@ public static class ModUpdateTask extends Task<Void> {
dependents.add(Task
.runAsync(Schedulers.javafx(), () -> local.setOld(true))
.thenComposeAsync(() -> {
String fileName = remote.getFile().getFilename();
String fileName = remote.file().filename();
if (isDisabled)
fileName += ModManager.DISABLED_EXTENSION;

var task = new FileDownloadTask(
remote.getFile().getUrl(),
remote.file().url(),
modManager.getModsDirectory().resolve(fileName));

task.setName(remote.getName());
task.setName(remote.name());
return task;
})
.whenComplete(Schedulers.javafx(), exception -> {
Expand Down
Loading