Change "redownload asset index" to "Update game asset files"

This commit is contained in:
huanghongxun
2018-12-20 19:30:35 +08:00
parent bfe7398e17
commit 7d42c0f581
9 changed files with 23 additions and 51 deletions

View File

@@ -258,6 +258,10 @@ public final class Controllers {
return pane; return pane;
} }
public static Region taskDialog(TaskExecutor executor, String title) {
return taskDialog(executor, title, "");
}
public static Region taskDialog(TaskExecutor executor, String title, String subtitle) { public static Region taskDialog(TaskExecutor executor, String title, String subtitle) {
return taskDialog(executor, title, subtitle, null); return taskDialog(executor, title, subtitle, null);
} }

View File

@@ -36,7 +36,6 @@ import org.jackhuang.hmcl.ui.account.AccountAdvancedListItem;
import org.jackhuang.hmcl.ui.account.AddAccountPane; import org.jackhuang.hmcl.ui.account.AddAccountPane;
import org.jackhuang.hmcl.ui.construct.AdvancedListBox; import org.jackhuang.hmcl.ui.construct.AdvancedListBox;
import org.jackhuang.hmcl.ui.construct.AdvancedListItem; import org.jackhuang.hmcl.ui.construct.AdvancedListItem;
import org.jackhuang.hmcl.ui.construct.DialogCloseEvent;
import org.jackhuang.hmcl.ui.profile.ProfileAdvancedListItem; import org.jackhuang.hmcl.ui.profile.ProfileAdvancedListItem;
import org.jackhuang.hmcl.ui.versions.GameAdvancedListItem; import org.jackhuang.hmcl.ui.versions.GameAdvancedListItem;
import org.jackhuang.hmcl.ui.versions.Versions; import org.jackhuang.hmcl.ui.versions.Versions;
@@ -127,7 +126,7 @@ public final class LeftPaneController extends AdvancedListBox {
Modpack modpack = var.get("modpack"); Modpack modpack = var.get("modpack");
TaskExecutor executor = ModpackHelper.getInstallTask(repository.getProfile(), modpackFile, modpack.getName(), modpack) TaskExecutor executor = ModpackHelper.getInstallTask(repository.getProfile(), modpackFile, modpack.getName(), modpack)
.with(Task.of(Schedulers.javafx(), this::checkAccount)).executor(); .with(Task.of(Schedulers.javafx(), this::checkAccount)).executor();
region.set(Controllers.taskDialog(executor, i18n("modpack.installing"), "")); region.set(Controllers.taskDialog(executor, i18n("modpack.installing")));
executor.start(); executor.start();
})).start(); })).start();
} }

View File

@@ -42,14 +42,12 @@ import org.jackhuang.hmcl.Metadata;
import org.jackhuang.hmcl.auth.authlibinjector.AuthlibInjectorDnD; import org.jackhuang.hmcl.auth.authlibinjector.AuthlibInjectorDnD;
import org.jackhuang.hmcl.setting.Config; import org.jackhuang.hmcl.setting.Config;
import org.jackhuang.hmcl.setting.EnumBackgroundImage; import org.jackhuang.hmcl.setting.EnumBackgroundImage;
import org.jackhuang.hmcl.task.TaskExecutor;
import org.jackhuang.hmcl.ui.Controllers; import org.jackhuang.hmcl.ui.Controllers;
import org.jackhuang.hmcl.ui.FXUtils; import org.jackhuang.hmcl.ui.FXUtils;
import org.jackhuang.hmcl.ui.account.AddAuthlibInjectorServerPane; import org.jackhuang.hmcl.ui.account.AddAuthlibInjectorServerPane;
import org.jackhuang.hmcl.ui.construct.*; import org.jackhuang.hmcl.ui.construct.*;
import org.jackhuang.hmcl.ui.wizard.Refreshable; import org.jackhuang.hmcl.ui.wizard.Refreshable;
import org.jackhuang.hmcl.ui.wizard.WizardProvider; import org.jackhuang.hmcl.ui.wizard.WizardProvider;
import org.jackhuang.hmcl.util.FutureCallback;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Files; import java.nio.file.Files;
@@ -59,7 +57,6 @@ import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Optional; import java.util.Optional;
import java.util.Random; import java.util.Random;
import java.util.function.Consumer;
import java.util.logging.Level; import java.util.logging.Level;
import static java.util.stream.Collectors.toList; import static java.util.stream.Collectors.toList;
@@ -359,45 +356,6 @@ public class DecoratorController {
} }
} }
public void showDialog(String text) {
showDialog(text, null);
}
public void showDialog(String text, String title) {
showDialog(text, title, MessageBox.INFORMATION_MESSAGE);
}
public void showDialog(String text, String title, int type) {
showDialog(text, title, type, null);
}
public void showDialog(String text, String title, int type, Runnable onAccept) {
showDialog(new MessageDialogPane(text, title, type, onAccept));
}
public void showConfirmDialog(String text, String title, Runnable onAccept, Runnable onCancel) {
showDialog(new MessageDialogPane(text, title, onAccept, onCancel));
}
public InputDialogPane showInputDialog(String text, FutureCallback<String> onResult) {
InputDialogPane pane = new InputDialogPane(text, onResult);
showDialog(pane);
return pane;
}
public Region showTaskDialog(TaskExecutor executor, String title, String subtitle) {
return showTaskDialog(executor, title, subtitle, null);
}
public Region showTaskDialog(TaskExecutor executor, String title, String subtitle, Consumer<Region> onCancel) {
TaskExecutorDialogPane pane = new TaskExecutorDialogPane(onCancel);
pane.setTitle(title);
pane.setSubtitle(subtitle);
pane.setExecutor(executor);
showDialog(pane);
return pane;
}
// ==== Wizard ==== // ==== Wizard ====
public void startWizard(WizardProvider wizardProvider) { public void startWizard(WizardProvider wizardProvider) {

View File

@@ -26,7 +26,6 @@ import javafx.beans.property.ReadOnlyStringWrapper;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.scene.control.Tab; import javafx.scene.control.Tab;
import javafx.scene.layout.StackPane; import javafx.scene.layout.StackPane;
import org.jackhuang.hmcl.download.game.GameAssetIndexDownloadTask;
import org.jackhuang.hmcl.setting.Profile; import org.jackhuang.hmcl.setting.Profile;
import org.jackhuang.hmcl.setting.Theme; import org.jackhuang.hmcl.setting.Theme;
import org.jackhuang.hmcl.ui.FXUtils; import org.jackhuang.hmcl.ui.FXUtils;
@@ -97,7 +96,7 @@ public final class VersionPage extends StackPane implements DecoratorPage {
managementList.getContent().setAll( managementList.getContent().setAll(
new IconedMenuItem(null, i18n("version.manage.rename"), FXUtils.withJFXPopupClosing(() -> Versions.renameVersion(profile, version), managementPopup)), new IconedMenuItem(null, i18n("version.manage.rename"), FXUtils.withJFXPopupClosing(() -> Versions.renameVersion(profile, version), managementPopup)),
new IconedMenuItem(null, i18n("version.manage.remove"), FXUtils.withJFXPopupClosing(() -> Versions.deleteVersion(profile, version), managementPopup)), new IconedMenuItem(null, i18n("version.manage.remove"), FXUtils.withJFXPopupClosing(() -> Versions.deleteVersion(profile, version), managementPopup)),
new IconedMenuItem(null, i18n("version.manage.redownload_assets_index"), FXUtils.withJFXPopupClosing(() -> new GameAssetIndexDownloadTask(profile.getDependency(), profile.getRepository().getResolvedVersion(version)).start(), managementPopup)), new IconedMenuItem(null, i18n("version.manage.redownload_assets_index"), FXUtils.withJFXPopupClosing(() -> Versions.updateGameAssets(profile, version), managementPopup)),
new IconedMenuItem(null, i18n("version.manage.remove_libraries"), FXUtils.withJFXPopupClosing(() -> FileUtils.deleteDirectoryQuietly(new File(profile.getRepository().getBaseDirectory(), "libraries")), managementPopup)), new IconedMenuItem(null, i18n("version.manage.remove_libraries"), FXUtils.withJFXPopupClosing(() -> FileUtils.deleteDirectoryQuietly(new File(profile.getRepository().getBaseDirectory(), "libraries")), managementPopup)),
new IconedMenuItem(null, i18n("version.manage.clean"), FXUtils.withJFXPopupClosing(() -> Versions.cleanVersion(profile, version), managementPopup)) new IconedMenuItem(null, i18n("version.manage.clean"), FXUtils.withJFXPopupClosing(() -> Versions.cleanVersion(profile, version), managementPopup))
); );

View File

@@ -18,11 +18,15 @@
package org.jackhuang.hmcl.ui.versions; package org.jackhuang.hmcl.ui.versions;
import javafx.stage.FileChooser; import javafx.stage.FileChooser;
import org.jackhuang.hmcl.download.game.GameAssetDownloadTask;
import org.jackhuang.hmcl.download.game.GameAssetIndexDownloadTask;
import org.jackhuang.hmcl.game.GameRepository; import org.jackhuang.hmcl.game.GameRepository;
import org.jackhuang.hmcl.game.LauncherHelper; import org.jackhuang.hmcl.game.LauncherHelper;
import org.jackhuang.hmcl.game.Version;
import org.jackhuang.hmcl.setting.Accounts; import org.jackhuang.hmcl.setting.Accounts;
import org.jackhuang.hmcl.setting.EnumGameDirectory; import org.jackhuang.hmcl.setting.EnumGameDirectory;
import org.jackhuang.hmcl.setting.Profile; import org.jackhuang.hmcl.setting.Profile;
import org.jackhuang.hmcl.task.TaskExecutor;
import org.jackhuang.hmcl.ui.Controllers; import org.jackhuang.hmcl.ui.Controllers;
import org.jackhuang.hmcl.ui.FXUtils; import org.jackhuang.hmcl.ui.FXUtils;
import org.jackhuang.hmcl.ui.download.ModpackInstallWizardProvider; import org.jackhuang.hmcl.ui.download.ModpackInstallWizardProvider;
@@ -75,6 +79,15 @@ public class Versions {
Controllers.getDecorator().startWizard(new ModpackInstallWizardProvider(profile, version)); Controllers.getDecorator().startWizard(new ModpackInstallWizardProvider(profile, version));
} }
public static void updateGameAssets(Profile profile, String version) {
Version resolvedVersion = profile.getRepository().getResolvedVersion(version);
TaskExecutor executor = new GameAssetIndexDownloadTask(profile.getDependency(), resolvedVersion)
.then(new GameAssetDownloadTask(profile.getDependency(), resolvedVersion))
.executor();
Controllers.taskDialog(executor, i18n("version.manage.redownload_assets_index"));
executor.start();
}
public static void cleanVersion(Profile profile, String id) { public static void cleanVersion(Profile profile, String id) {
try { try {
profile.getRepository().clean(id); profile.getRepository().clean(id);

View File

@@ -26,7 +26,6 @@ import org.jackhuang.hmcl.Metadata;
import org.jackhuang.hmcl.task.Task; import org.jackhuang.hmcl.task.Task;
import org.jackhuang.hmcl.task.TaskExecutor; import org.jackhuang.hmcl.task.TaskExecutor;
import org.jackhuang.hmcl.ui.Controllers; import org.jackhuang.hmcl.ui.Controllers;
import org.jackhuang.hmcl.ui.construct.DialogCloseEvent;
import org.jackhuang.hmcl.ui.construct.MessageBox; import org.jackhuang.hmcl.ui.construct.MessageBox;
import org.jackhuang.hmcl.util.StringUtils; import org.jackhuang.hmcl.util.StringUtils;
import org.jackhuang.hmcl.util.io.FileUtils; import org.jackhuang.hmcl.util.io.FileUtils;
@@ -103,7 +102,7 @@ public final class UpdateHandler {
Task task = new HMCLDownloadTask(version, downloaded); Task task = new HMCLDownloadTask(version, downloaded);
TaskExecutor executor = task.executor(); TaskExecutor executor = task.executor();
Region dialog = Controllers.taskDialog(executor, i18n("message.downloading"), "", null); Region dialog = Controllers.taskDialog(executor, i18n("message.downloading"));
thread(() -> { thread(() -> {
boolean success = executor.test(); boolean success = executor.test();

View File

@@ -392,7 +392,7 @@ version.launch_script.success=Finished script creation, %s.
version.manage=Game List version.manage=Game List
version.manage.clean=Clean game directory version.manage.clean=Clean game directory
version.manage.manage=Manage Game version.manage.manage=Manage Game
version.manage.redownload_assets_index=Redownload Assets Index version.manage.redownload_assets_index=Update Game Asset Files
version.manage.remove=Delete this game version.manage.remove=Delete this game
version.manage.remove.confirm=Sure to remove game %s? You cannot restore this game again! version.manage.remove.confirm=Sure to remove game %s? You cannot restore this game again!
version.manage.remove.confirm.trash=Sure to remove game %s? You can restore the game with the name of %s in your system trash. version.manage.remove.confirm.trash=Sure to remove game %s? You can restore the game with the name of %s in your system trash.

View File

@@ -391,7 +391,7 @@ version.launch_script.success=啟動腳本已生成完畢:%s
version.manage=遊戲列表 version.manage=遊戲列表
version.manage.clean=清理遊戲目錄 version.manage.clean=清理遊戲目錄
version.manage.manage=游戏管理 version.manage.manage=游戏管理
version.manage.redownload_assets_index=更新資源列表 version.manage.redownload_assets_index=更新遊戲資源檔案
version.manage.remove=刪除該版本 version.manage.remove=刪除該版本
version.manage.remove.confirm=真的要刪除版本 %s 嗎?你將無法找回被刪除的檔案! version.manage.remove.confirm=真的要刪除版本 %s 嗎?你將無法找回被刪除的檔案!
version.manage.remove.confirm.trash=真的要刪除版本 %s 嗎?你可以在系統的資源回收桶 (或垃圾桶) 中還原資料夾 %s 來找回該版本。 version.manage.remove.confirm.trash=真的要刪除版本 %s 嗎?你可以在系統的資源回收桶 (或垃圾桶) 中還原資料夾 %s 來找回該版本。

View File

@@ -391,7 +391,7 @@ version.launch_script.success=启动脚本已生成完毕:%s
version.manage=游戏列表 version.manage=游戏列表
version.manage.clean=清理游戏目录 version.manage.clean=清理游戏目录
version.manage.manage=游戏管理 version.manage.manage=游戏管理
version.manage.redownload_assets_index=更新资源列表 version.manage.redownload_assets_index=更新游戏资源文件
version.manage.remove=删除该版本 version.manage.remove=删除该版本
version.manage.remove.confirm=真的要删除版本 %s 吗?你将无法找回被删除的文件! version.manage.remove.confirm=真的要删除版本 %s 吗?你将无法找回被删除的文件!
version.manage.remove.confirm.trash=真的要删除版本 %s 吗?你可以在系统的回收站中恢复文件夹 %s 来找回该版本。 version.manage.remove.confirm.trash=真的要删除版本 %s 吗?你可以在系统的回收站中恢复文件夹 %s 来找回该版本。