setup logic planning

This commit is contained in:
trippjoe 2022-06-02 00:03:18 -04:00
commit c69e5ee5a0
6 changed files with 51 additions and 37 deletions

View file

@ -3,4 +3,4 @@
/target/ /target/
WixTools WixTools
data/ data/
bin/* bin

View file

@ -1,15 +1,25 @@
<script> <script>
import { setInstallStatus } from "$lib/config";
import { SUPPORTED_GAME } from "$lib/constants";
import { navigate } from "svelte-routing";
import { launchGame } from "$lib/launch"; import { launchGame } from "$lib/launch";
function onClickConfig() { function onClickConfig() {}
alert("TODO");
}
function onClickPlay() { function onClickPlay() {
launchGame(); launchGame();
} }
async function onClickUninstall() {
await setInstallStatus(SUPPORTED_GAME.Jak1, false);
navigate("/jak1", { replace: true });
}
</script> </script>
<div id="launcherControls"> <div id="launcherControls">
<button class="btn lg" on:click={onClickConfig} disabled>Config</button>
<button class="btn lg" on:click={onClickPlay}>Play</button> <button class="btn lg" on:click={onClickPlay}>Play</button>
<div class="mt-1">
<button class="btn md" on:click={onClickConfig} disabled>Config</button>
<button class="btn md" on:click={onClickUninstall}>Uninstall</button>
</div>
</div> </div>

View file

@ -1,5 +1,6 @@
<script> <script>
import { Link, navigate } from "svelte-routing"; import { onMount } from "svelte";
import { navigate } from "svelte-routing";
import { filePrompt } from "$lib/utils/file"; import { filePrompt } from "$lib/utils/file";
import { setInstallStatus } from "$lib/config"; import { setInstallStatus } from "$lib/config";
import { clearInstallLogs } from "$lib/utils/file"; import { clearInstallLogs } from "$lib/utils/file";
@ -24,23 +25,19 @@
let currentStatus = {}; let currentStatus = {};
const setStatus = (status) => (currentStatus = status); const setStatus = (status) => (currentStatus = status);
async function areRequirementsMet() { let installInProgress = false;
const res = await Promise.resolve()
.then(async () => {
setStatus(SETUP_SUCCESS.checkCompatible);
await isAVXSupported();
setStatus(SETUP_SUCCESS.avxSupported);
})
.then(async () => {
await isOpenGLVersionSupported("4.3");
setStatus(SETUP_SUCCESS.openGLSupported);
})
.catch((err) => {
setStatus({ status: err.message, percent: -1 });
console.error(err);
});
return res; async function areRequirementsMet() {
try {
setStatus(SETUP_SUCCESS.checkCompatible);
await isAVXSupported();
setStatus(SETUP_SUCCESS.avxSupported);
await isOpenGLVersionSupported("4.3");
setStatus(SETUP_SUCCESS.openGLSupported);
} catch (err) {
// TODO - if they aren't met, it would be nice to display which ones aren't
setStatus({ status: err.message, percent: -1 });
}
} }
async function installProcess() { async function installProcess() {
@ -74,6 +71,14 @@
return res; return res;
} }
onMount(async () => {
// TODO - use (requirements met) conditional rendering below
// if requirements met: show setup button
// else: display which requirement isn't met (AVX/OpenGL/Both)
// await areRequirementsMet();
// await installProcess();
});
</script> </script>
<div class="content"> <div class="content">
@ -85,8 +90,5 @@
Setup Setup
</button> </button>
{/if} {/if}
<!-- <Link to="/jak1">
<button class="btn">Cancel</button>
</Link> -->
</div> </div>
</div> </div>

View file

@ -67,6 +67,10 @@ body {
margin: 15px 0; margin: 15px 0;
} }
.mt-1 {
margin-top: 1em;
}
.btn { .btn {
text-align: center; text-align: center;
background: linear-gradient(to top, #f3b33f, #fbec4f); background: linear-gradient(to top, #f3b33f, #fbec4f);
@ -82,6 +86,13 @@ body {
color: black; color: black;
} }
.btn.md {
min-width: 100px;
padding: 10px 0;
font-weight: bold;
font-size: 1rem;
}
.btn.lg { .btn.lg {
min-width: 200px; min-width: 200px;
padding: 10px 0; padding: 10px 0;
@ -89,10 +100,6 @@ body {
font-size: x-large; font-size: x-large;
} }
.btn:not(:last-child) {
margin-right: 1em;
}
.btn:enabled:active { .btn:enabled:active {
transform: scale(0.9); transform: scale(0.9);
box-shadow: 0px 0px 20px rgba(0, 0, 0, 1); box-shadow: 0px 0px 20px rgba(0, 0, 0, 1);

View file

@ -1,17 +1,15 @@
import { Command } from "@tauri-apps/api/shell"; import { Command } from "@tauri-apps/api/shell";
import { resourceDir } from "@tauri-apps/api/path"; import { resourceDir } from "@tauri-apps/api/path";
// TODO - is this set to `production` properly in release mode?
function isInDebugMode() { function isInDebugMode() {
return process.env.NODE_ENV === "development"; return process.env.NODE_ENV === "development";
} }
// TODO - this is kind of a total hack - likely windows only currently // NOTE - this is kind of a total hack - likely windows only currently
let debugPath; let debugPath;
if (isInDebugMode()) { if (isInDebugMode()) {
let path = await resourceDir(); let path = await resourceDir();
debugPath = path.split("launcher")[0].split("?\\")[1]; debugPath = path.split("launcher")[0].split("?\\")[1];
// debugPath += "launcher\\bundle-test\\data";
debugPath += "launcher\\src-tauri\\data"; debugPath += "launcher\\src-tauri\\data";
} }
@ -29,7 +27,5 @@ export async function launchGame() {
cwd: "bin", cwd: "bin",
}); });
} }
let output = await command.execute(); command.spawn();
console.log(output.stdout);
console.log(output.stderr);
} }

View file

@ -11,10 +11,9 @@ export function isInDebugMode() {
} }
if (isInDebugMode()) { if (isInDebugMode()) {
// TODO - this is kind of a total hack // NOTE - this is kind of a total hack
let path = await resourceDir(); let path = await resourceDir();
debugPath = path.split("launcher")[0].split("?\\")[1]; debugPath = path.split("launcher")[0].split("?\\")[1];
// debugPath += "launcher\\bundle-test\\data";
debugPath += "launcher\\src-tauri\\data\\"; debugPath += "launcher\\src-tauri\\data\\";
sidecarOptions = { cwd: "bin" }; sidecarOptions = { cwd: "bin" };
} }