Merge branch 'javafx' into patch-1

This commit is contained in:
Yuhui Huang
2020-02-05 12:40:33 +08:00
committed by GitHub
18 changed files with 691 additions and 298 deletions

View File

@@ -22,7 +22,7 @@ import javafx.application.Platform;
import javafx.stage.Stage;
import org.jackhuang.hmcl.setting.ConfigHolder;
import org.jackhuang.hmcl.task.Schedulers;
import org.jackhuang.hmcl.task.TaskExecutor;
import org.jackhuang.hmcl.task.AsyncTaskExecutor;
import org.jackhuang.hmcl.ui.Controllers;
import org.jackhuang.hmcl.upgrade.UpdateChecker;
import org.jackhuang.hmcl.util.CrashReporter;
@@ -78,7 +78,7 @@ public final class Launcher extends Application {
public static void main(String[] args) {
Thread.setDefaultUncaughtExceptionHandler(CRASH_REPORTER);
TaskExecutor.setUncaughtExceptionHandler(new CrashReporter(false));
AsyncTaskExecutor.setUncaughtExceptionHandler(new CrashReporter(false));
try {
LOG.info("*** " + Metadata.TITLE + " ***");

View File

@@ -154,12 +154,11 @@ public class HMCLGameRepository extends DefaultGameRepository {
if (id == null || !isLoaded())
return newImage("/assets/img/grass.png");
Version version = getVersion(id);
Version version = getVersion(id).resolve(this);
File iconFile = getVersionIconFile(id);
if (iconFile.exists())
return new Image("file:" + iconFile.getAbsolutePath());
else if (!version.getPatches().isEmpty() ||
version.getMainClass() != null &&
else if (version.getMainClass() != null &&
("net.minecraft.launchwrapper.Launch".equals(version.getMainClass())
|| version.getMainClass().startsWith("net.fabricmc")
|| "cpw.mods.modlauncher.Launcher".equals(version.getMainClass())))

View File

@@ -23,7 +23,9 @@ import org.jackhuang.hmcl.Launcher;
import org.jackhuang.hmcl.auth.Account;
import org.jackhuang.hmcl.auth.AuthInfo;
import org.jackhuang.hmcl.auth.AuthenticationException;
import org.jackhuang.hmcl.auth.CharacterDeletedException;
import org.jackhuang.hmcl.auth.CredentialExpiredException;
import org.jackhuang.hmcl.auth.authlibinjector.AuthlibInjectorDownloadException;
import org.jackhuang.hmcl.download.DefaultDependencyManager;
import org.jackhuang.hmcl.download.MaintainTask;
import org.jackhuang.hmcl.download.game.GameAssetIndexDownloadTask;
@@ -55,6 +57,7 @@ import org.jackhuang.hmcl.util.Pair;
import org.jackhuang.hmcl.util.StringUtils;
import org.jackhuang.hmcl.util.function.ExceptionalSupplier;
import org.jackhuang.hmcl.util.gson.UUIDTypeAdapter;
import org.jackhuang.hmcl.util.io.ResponseCodeException;
import org.jackhuang.hmcl.util.platform.CommandBuilder;
import org.jackhuang.hmcl.util.platform.JavaVersion;
import org.jackhuang.hmcl.util.platform.ManagedProcess;
@@ -64,7 +67,14 @@ import org.jackhuang.hmcl.util.versioning.VersionNumber;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.*;
import java.net.URL;
import java.util.Collections;
import java.util.Comparator;
import java.util.LinkedList;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicInteger;
@@ -203,7 +213,7 @@ public final class LauncherHelper {
});
}
})
.executor();
.cancellableExecutor();
launchingStepsPane.setExecutor(executor, false);
executor.addTaskListener(new TaskListener() {
@@ -239,9 +249,32 @@ public final class LauncherHelper {
} else if (ex instanceof NotDecompressingNativesException) {
message = i18n("launch.failed.decompressing_natives") + ex.getLocalizedMessage();
} else if (ex instanceof LibraryDownloadException) {
message = i18n("launch.failed.download_library", ((LibraryDownloadException) ex).getLibrary().getName()) + "\n" + StringUtils.getStackTrace(ex.getCause());
message = i18n("launch.failed.download_library", ((LibraryDownloadException) ex).getLibrary().getName()) + "\n";
if (ex.getCause() instanceof ResponseCodeException) {
ResponseCodeException rce = (ResponseCodeException) ex.getCause();
int responseCode = rce.getResponseCode();
URL url = rce.getUrl();
if (responseCode == 404)
message += i18n("download.code.404", url);
else
message += i18n("download.failed", url, responseCode);
} else {
message += StringUtils.getStackTrace(ex.getCause());
}
} else if (ex instanceof GameAssetIndexDownloadTask.GameAssetIndexMalformedException) {
message = i18n("assets.index.malformed");
} else if (ex instanceof AuthlibInjectorDownloadException) {
message = i18n("account.failed.injector_download_failure");
} else if (ex instanceof CharacterDeletedException) {
message = i18n("account.failed.character_deleted");
} else if (ex instanceof ResponseCodeException) {
ResponseCodeException rce = (ResponseCodeException) ex;
int responseCode = rce.getResponseCode();
URL url = rce.getUrl();
if (responseCode == 404)
message = i18n("download.code.404", url);
else
message = i18n("download.failed", url, responseCode);
} else {
message = StringUtils.getStackTrace(ex);
}

View File

@@ -39,6 +39,7 @@ import org.jackhuang.hmcl.util.i18n.I18n;
import org.jackhuang.hmcl.util.io.ResponseCodeException;
import java.net.SocketTimeoutException;
import java.net.URL;
import java.util.Map;
import static org.jackhuang.hmcl.util.i18n.I18n.i18n;
@@ -103,7 +104,19 @@ public final class InstallerWizardProvider implements WizardProvider {
public static void alertFailureMessage(Exception exception, Runnable next) {
if (exception instanceof LibraryDownloadException) {
Controllers.dialog(i18n("launch.failed.download_library", ((LibraryDownloadException) exception).getLibrary().getName()) + "\n" + StringUtils.getStackTrace(exception.getCause()), i18n("install.failed.downloading"), MessageType.ERROR, next);
String message = i18n("launch.failed.download_library", ((LibraryDownloadException) exception).getLibrary().getName()) + "\n";
if (exception.getCause() instanceof ResponseCodeException) {
ResponseCodeException rce = (ResponseCodeException) exception.getCause();
int responseCode = rce.getResponseCode();
URL url = rce.getUrl();
if (responseCode == 404)
message += i18n("download.code.404", url);
else
message += i18n("download.failed", url, responseCode);
} else {
message += StringUtils.getStackTrace(exception.getCause());
}
Controllers.dialog(message, i18n("install.failed.downloading"), MessageType.ERROR, next);
} else if (exception instanceof DownloadException) {
if (exception.getCause() instanceof SocketTimeoutException) {
Controllers.dialog(i18n("install.failed.downloading.timeout", ((DownloadException) exception).getUrl()), i18n("install.failed.downloading"), MessageType.ERROR, next);

View File

@@ -60,7 +60,7 @@ public interface TaskExecutorDialogWizardDisplayer extends AbstractWizardDisplay
}
runInFX(() -> {
TaskExecutor executor = task.executor(new TaskListener() {
TaskExecutor executor = task.cancellableExecutor(new TaskListener() {
@Override
public void onStop(boolean success, TaskExecutor executor) {
runInFX(() -> {

View File

@@ -92,8 +92,8 @@ crash.NoClassDefFound=Please verify that the "Hello Minecraft! Launcher" softwar
crash.user_fault=Your OS or Java environment may not be properly installed which may result in a crash, please check your Java Runtime Environment or your computer!
download=Download
download.code.404=File not found on the remote server
download.failed=Failed to download
download.code.404=File not found on the remote server: %s
download.failed=Failed to download %1$s, response code: %2$d
download.failed.empty=No candidates. Click here to return.
download.failed.refresh=Unable to download version list. Click here to retry.
download.provider.mcbbs=MCBBS (https://www.mcbbs.net/)

View File

@@ -91,8 +91,8 @@ crash.NoClassDefFound=Favor verificar que el software "Hello Minecraft! Launcher
crash.user_fault=Su SO o ambiente de Java podría estar mal instalado resultando en fallos de este software, ¡por favor verifique su ambiente de Java o computadora!
download=Descargar
download.code.404=Archivo no encontrado en servidor remoto
download.failed=Falló en descargar
download.code.404=Archivo no encontrado en servidor remoto: %s
download.failed=Falló en descargar: %1$s
download.failed.empty=No hay candidatos. Clic aquí para regresar.
download.failed.refresh=No se pudo cargar lista de versiones. Clic aquí para reintentar.
download.provider.mcbbs=MCBBS (https://www.mcbbs.net/)

View File

@@ -91,8 +91,8 @@ crash.NoClassDefFound=Пожалуйста, проверьте, что прог
crash.user_fault=Ваша ОС или среда Java могут быть неправильно установлены, что приведет к сбою этого программного обеспечения, пожалуйста, проверьте свою среду Java или свой компьютер\!
download=Загрузка
download.code.404=Файл не найден на удаленном сервере
download.failed=Не удалось загрузить
download.code.404=Файл не найден на удаленном сервере: %s
download.failed=Не удалось загрузить: %1$s
download.failed.empty=Нет вариантов. Нажмите здесь, чтобы вернуться.
download.failed.refresh=Невозможно загрузить список версий. Нажмите здесь, чтобы повторить попытку.
download.provider.mcbbs=MCBBS (https://www.mcbbs.net/)

View File

@@ -91,8 +91,8 @@ crash.NoClassDefFound=請確認 Hello Minecraft! Launcher 本體是否完整,
crash.user_fault=您的系統或 Java 環境可能安裝不當導致本軟體當機,請檢查您的 Java 環境或您的電腦! 可以嘗試重新安裝 Java。
download=下載
download.code.404=遠端伺服器沒有需要下載的檔案
download.failed=下載失敗
download.code.404=遠端伺服器沒有需要下載的檔案: %s
download.failed=下載失敗: %1$s錯誤碼%2$d
download.failed.empty=沒有能安裝的版本,按一下此處返回。
download.failed.refresh=載入版本列表失敗,按一下此處重試。
download.provider.mcbbs=我的世界中文論壇 (MCBBS, https://www.mcbbs.net/)

View File

@@ -91,8 +91,8 @@ crash.NoClassDefFound=请确认 Hello Minecraft! Launcher 本体是否完整,
crash.user_fault=您的系统或 Java 环境可能安装不当导致本软件崩溃,请检查您的 Java 环境或您的电脑!可以尝试重新安装 Java。
download=下载
download.code.404=远程服务器不包含需要下载的文件
download.failed=下载失败
download.code.404=远程服务器不包含需要下载的文件: %s
download.failed=下载失败: %1$s错误码%2$d
download.failed.empty=没有可供安装的版本,点击此处返回。
download.failed.refresh=加载版本列表失败,点击此处重试。
download.provider.mcbbs=我的世界中文论坛 (MCBBS, https://www.mcbbs.net/)