From 480dca55edaf09cfe3c940cb57cc932a0822f24a Mon Sep 17 00:00:00 2001 From: Tyler Wilding Date: Mon, 18 Apr 2022 17:55:23 -0400 Subject: [PATCH] setup: display errors during installation --- src/css/style.css | 13 ++++ src/lib/setup.js | 25 +------- src/routes/setup/Jak1.svelte | 121 ++++++++++++++++++++++++++--------- 3 files changed, 104 insertions(+), 55 deletions(-) diff --git a/src/css/style.css b/src/css/style.css index 5f411e8..993a4c2 100644 --- a/src/css/style.css +++ b/src/css/style.css @@ -247,6 +247,7 @@ body { .content { padding: 2em; + overflow: auto; } .logContainer { @@ -290,3 +291,15 @@ ul.no-decoration { list-style-type: none; padding-left: 2em; } + +.error-row { + background-color: #782323; + padding: 1em; + border-radius: 0.25em; + margin-top: 0.5em; +} + +.error-row * { + margin: 0; + padding: 0; +} diff --git a/src/lib/setup.js b/src/lib/setup.js index 68f41c1..99fdee0 100644 --- a/src/lib/setup.js +++ b/src/lib/setup.js @@ -65,7 +65,7 @@ export async function isOpenGLVersionSupported(version) { * @param {String} filePath * @returns {Promise} */ -export async function extractISO(filePath) { +export async function extractAndValidateISO(filePath) { let command; if (isInDebugMode()) { command = Command.sidecar( @@ -74,28 +74,7 @@ export async function extractISO(filePath) { { cwd: "bin" } ); } else { - command = Command.sidecar("bin/extractor", [filePath, "--extract"], { - cwd: "bin", - }); - } - - return await command.execute(); -} - -/** - * @param {String} filePath - * @returns {Promise} - */ -export async function validateGameData(filePath) { - let command; - if (isInDebugMode()) { - command = Command.sidecar( - "bin/extractor", - [filePath, "--validate", "--proj-path", debugPath], - { cwd: "bin" } - ); - } else { - command = Command.sidecar("bin/extractor", [filePath, "--validate"], { + command = Command.sidecar("bin/extractor", [filePath, "--extract", "--validate"], { cwd: "bin", }); } diff --git a/src/routes/setup/Jak1.svelte b/src/routes/setup/Jak1.svelte index 1426cf9..4a0e242 100644 --- a/src/routes/setup/Jak1.svelte +++ b/src/routes/setup/Jak1.svelte @@ -5,8 +5,7 @@ import { compileGame, decompileGameData, - extractISO, - validateGameData, + extractAndValidateISO, isAVXSupported, isOpenGLVersionSupported, } from "/src/lib/setup"; @@ -24,7 +23,7 @@ let requirementChecks = [ { status: RequirementStatus.Checking, - text: `CPU Supports AVX or AVX2`, + text: `CPU Supports AVX or AVX2`, check: async () => await isAVXSupported(), }, { @@ -38,13 +37,7 @@ let installSteps = [ { status: InstallationStatus.Pending, - text: "Extracting ISO", - logs: "", - errorLogs: "", - }, - { - status: InstallationStatus.Pending, - text: "Validating Game Data", + text: "Extracting and Validate ISO", logs: "", errorLogs: "", }, @@ -62,6 +55,8 @@ }, ]; + let installErrors = []; + // TODO - move this to the enum function statusIndicator(status) { if ( @@ -98,12 +93,71 @@ return true; } + function handleError(output) { + if (output.code === 0) { + return; + } + switch (output.code) { + case 4000: + installErrors = [ + ...installErrors, + { + title: `can't locate ELF in ISO's contents`, + description: "unable to determine the version of the game", + }, + ]; + break; + case 4001: + installErrors = [ + ...installErrors, + { + title: `Unsupported serial`, + description: + "ISO containing an unsupported game serial or version was provided", + }, + ]; + break; + case 4002: + case 4010: + case 4011: + installErrors = [ + ...installErrors, + { + title: `Unsupported game version`, + description: + "ISO contains files that are for an unsupported version, were modified from the original, or is an incomplete dump", + }, + ]; + break; + case 4020: + installErrors = [ + ...installErrors, + { + title: `Unexpected Extraction Result`, + description: + "The extracted ISO's contents were not as expected, installation cannot proceed", + }, + ]; + break; + default: + installErrors = [ + ...installErrors, + { + title: `Unexpected Error Code ${output.code}`, + description: + "An unexpected error occurred during installation, check logs", + }, + ]; + } + } + function finishStep(output) { appendLogs(output); installSteps[currStep].status = output.code === 0 ? InstallationStatus.Success : InstallationStatus.Failed; + handleError(output); currStep++; if (currStep < installSteps.length) { installSteps[currStep].status = InstallationStatus.InProgress; @@ -128,28 +182,23 @@ await clearInstallLogs(SupportedGame.Jak1); setupInProgress = true; installSteps[currStep].status = InstallationStatus.InProgress; - let output = await extractISO(isoPath); + let output = await extractAndValidateISO(isoPath); finishStep(output); - if (output.code === 0) { - console.log("[OpenGOAL]: Extraction Completed"); - output = await validateGameData(isoPath); - finishStep(output); - } - if (output.code === 0) { - console.log("[OpenGOAL]: Validation Completed"); - output = await decompileGameData(isoPath); - finishStep(output); - } - if (output.code === 0) { - console.log("[OpenGOAL]: Decompilation Completed"); - output = await compileGame(isoPath); - finishStep(output); - } - if (output.code === 0) { - console.log("[OpenGOAL]: Compilation Completed"); - await setInstallStatus(SupportedGame.Jak1, true); - navigate("/jak1", { replace: true }); - } + // if (output.code === 0) { + // console.log("[OpenGOAL]: Extraction and Validation Completed"); + // output = await decompileGameData(isoPath); + // finishStep(output); + // } + // if (output.code === 0) { + // console.log("[OpenGOAL]: Decompilation Completed"); + // output = await compileGame(isoPath); + // finishStep(output); + // } + // if (output.code === 0) { + // console.log("[OpenGOAL]: Compilation Completed"); + // await setInstallStatus(SupportedGame.Jak1, true); + // navigate("/jak1", { replace: true }); + // } } // Events @@ -186,7 +235,9 @@ {#if areRequirementsMet(requirementChecks)}

Browse for your ISO - Obtained by dumping your own legitimate copy

- + {#if isoPath} {isoPath} {/if} @@ -212,6 +263,12 @@ {/each}
+ {#each installErrors as err} +
+

❌ {err.title}

+

{err.description}

+
+ {/each}
Installation Logs