Full pass of launcher code-base, fixing bugs and cleanup (#100)

Co-authored-by: tripp <86533397+trippjoe@users.noreply.github.com>
This commit is contained in:
Tyler Wilding 2022-07-14 18:04:01 -04:00 committed by GitHub
parent cb8629c8c6
commit d259c477eb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
79 changed files with 8209 additions and 586 deletions

View file

@ -3,10 +3,7 @@
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link <link href="/src/css/fontawesome/all.min.css" rel="stylesheet" />
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.8.1/font/bootstrap-icons.css"
/>
<link rel="stylesheet" href="/src/css/style.css" /> <link rel="stylesheet" href="/src/css/style.css" />
<title>OpenGOAL Launcher</title> <title>OpenGOAL Launcher</title>
</head> </head>

View file

@ -17,7 +17,7 @@
"appimage", "appimage",
"updater" "updater"
], ],
"identifier": "opengoal-launcher", "identifier": "OpenGOAL-Launcher",
"icon": [ "icon": [
"icons/32x32.png", "icons/32x32.png",
"icons/128x128.png", "icons/128x128.png",
@ -95,9 +95,9 @@
"center": true "center": true
}, },
{ {
"title": "OpenGOAL Launcher", "title": "OpenGOAL Launcher - Splash",
"width": 600, "width": 200,
"height": 200, "height": 300,
"center": true, "center": true,
"decorations": false, "decorations": false,
"transparent": true, "transparent": true,
@ -112,4 +112,4 @@
"csp": null "csp": null
} }
} }
} }

View file

@ -4,13 +4,14 @@
// Other Imports // Other Imports
import { onMount } from "svelte"; import { onMount } from "svelte";
import { Router, Route } from "svelte-navigator"; import { Router, Route } from "svelte-navigator";
import Jak1 from "./routes/Jak1.svelte"; import Game from "./routes/Game.svelte";
import Settings from "./routes/Settings.svelte"; import Settings from "./routes/Settings.svelte";
import Sidebar from "./components/sidebar/Sidebar.svelte"; import Sidebar from "./components/sidebar/Sidebar.svelte";
import Background from "./components/background/Background.svelte"; import Background from "./components/background/Background.svelte";
import { isInDebugMode } from "$lib/setup/setup"; import { isInDebugMode } from "$lib/setup/setup";
import { appWindow } from "@tauri-apps/api/window"; import { appWindow } from "@tauri-apps/api/window";
import { isInstalling } from "./stores/InstallStore"; import { isInstalling } from "./lib/stores/AppStore";
import { loadTranslations } from "$lib/translations/translations";
let revokeSpecificActions = false; let revokeSpecificActions = false;
@ -70,9 +71,9 @@
<!-- TODO - pass background component current active game --> <!-- TODO - pass background component current active game -->
<Background {bgVideo} /> <Background {bgVideo} />
<div id="main"> <div id="main">
<Route path="/" component={Jak1} /> <Route path="/" component={Game} primary={false} let:params />
<Route path="/jak1" component={Jak1} /> <Route path="/:game_name" component={Game} primary={false} let:params />
<Route path="/settings" component={Settings} /> <Route path="/settings" component={Settings} primary={false} />
</div> </div>
</div> </div>
</Router> </Router>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1,93 @@
Copyright (c) 2010-2014 by tyPoland Lukasz Dziedzic (team@latofonts.com) with Reserved Font Name "Lato"
This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL
-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.
"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are
not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.

View file

@ -0,0 +1,202 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View file

@ -1,5 +1,4 @@
Copyright (c) 2011, Andreas Kalpakides (hello@inderesting.com), Copyright 2018 The Staatliches Authors (https://github.com/googlefonts/staatliches)
with Reserved Font Name "Advent Pro".
This Font Software is licensed under the SIL Open Font License, Version 1.1. This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at: This license is copied below, and is also available with a FAQ at:

Binary file not shown.

View file

@ -0,0 +1,3 @@
{
"jak1_gameName": "Jak & Daxter: The Precursor Legacy"
}

View file

@ -1,7 +0,0 @@
<script>
import logo from "$assets/images/logo.webp";
</script>
<div class="logo">
<img id="logo" width="65%" src={logo} alt="OpenGOAL" />
</div>

View file

@ -1,65 +0,0 @@
<script>
export let errorMsg;
// 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",
// },
// ];
// }
// }
</script>
<section>
<h2>Error: {errorMsg}</h2>
</section>

View file

@ -1,9 +1,31 @@
<script type="ts"> <script type="ts">
export let bgVideo: string; export let bgVideo: string;
import "./background.css";
</script> </script>
<div class="video-container"> <div class="video-container">
<div class="overlay" /> <div class="overlay" />
<video id="backgroundVideo" src={bgVideo} autoplay muted loop /> <video id="backgroundVideo" src={bgVideo} autoplay muted loop />
</div> </div>
<style>
.video-container {
position: absolute;
z-index: -1;
height: 100vh;
}
.overlay {
position: absolute;
top: 0;
left: 0;
background-color: #181818;
width: 100%;
height: 100vh;
opacity: 0.35;
}
#backgroundVideo {
z-index: -1;
height: 100vh;
}
</style>

View file

@ -1,20 +0,0 @@
.video-container {
position: absolute;
z-index: -1;
height: 100vh;
}
.overlay {
position: absolute;
top: 0;
left: 0;
background-color: #181818;
width: 100%;
height: 100vh;
opacity: 0.35;
}
#backgroundVideo {
z-index: -1;
height: 100vh;
}

View file

@ -1,15 +0,0 @@
<script>
import { Console } from "../../stores/InstallStore";
import "./console.css";
</script>
<div class="row">
<details>
<summary>Installation Logs</summary>
<div class="logContainer">
{#if $Console}
{$Console}
{/if}
</div>
</details>
</div>

View file

@ -1,25 +0,0 @@
.logContainer {
max-height: 10em;
overflow-y: scroll;
padding: 1em;
background: black;
white-space: pre-wrap;
font-family: monospace;
}
details {
min-width: 75vw;
max-width: 75vw;
}
summary {
text-align: center;
}
.logContainer {
text-align: start;
}
details > summary:hover {
cursor: pointer;
}

View file

@ -0,0 +1,57 @@
<script type="ts">
import { getGameInstallVersion, setInstallStatus } from "$lib/config";
import { getInternalName, SupportedGame } from "$lib/constants";
import { launchGame } from "$lib/launch";
import { openDir } from "$lib/rpc/commands";
import { compileGame, decompileGameData } from "$lib/setup/setup";
import { appDir, configDir, join } from "@tauri-apps/api/path";
import { createEventDispatcher, onMount } from "svelte";
export let activeGame: SupportedGame;
const dispatch = createEventDispatcher();
let componentLoaded = false;
let configPath = undefined;
let gameVersion = undefined;
onMount(async () => {
gameVersion = await getGameInstallVersion(activeGame);
configPath = await join(await configDir(), "OpenGOAL", getInternalName(activeGame));
componentLoaded = true;
});
function onClickPlay() {
launchGame();
}
async function onClickUninstall() {
await setInstallStatus(SupportedGame.Jak1, false);
dispatch('change');
}
async function onClickDecompile() {
// TODO - ensure this path is correct!
const isoPath = await join(await appDir(), "data", "extracted_iso");
await decompileGameData(isoPath);
}
async function onClickCompile() {
// TODO - ensure this path is correct!
const isoPath = await join(await appDir(), "data", "extracted_iso");
await compileGame(isoPath);
}
</script>
{#if componentLoaded}
<div id="launcherControls">
<button class="btn lg" on:click={onClickPlay}>Play</button>
<p>Game Version: {gameVersion}</p>
<!-- TODO - when clicking decompile/compile -- show logs -->
<div class="mt-1">
<button class="btn md" on:click={() => openDir(configPath)}>Settings and Saves</button>
<button class="btn md" on:click={onClickDecompile}>Decompile</button>
<button class="btn md" on:click={onClickCompile}>Compile</button>
<button class="btn md" on:click={onClickUninstall}>Uninstall</button>
</div>
</div>
{/if}

View file

@ -1,25 +0,0 @@
<script>
import { setInstallStatus } from "$lib/config";
import { SupportedGame } from "$lib/constants";
import { navigate } from "svelte-navigator";
import { launchGame } from "$lib/launch";
function onClickConfig() {}
function onClickPlay() {
launchGame();
}
async function onClickUninstall() {
await setInstallStatus(SupportedGame.Jak1, false);
navigate(0);
}
</script>
<div id="launcherControls">
<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>

View file

@ -0,0 +1,66 @@
<script type="ts">
import { areRequirementsMet } from "$lib/config";
import { gameNeedsReinstall, isInstalling, ProcessLogs } from "$lib/stores/AppStore";
import { fullInstallation, recompileGame } from "$lib/setup/setup";
// components
import Progress from "./Progress.svelte";
// constants
import type { SupportedGame } from "$lib/constants";
import LogViewer from "./LogViewer.svelte";
import Requirements from "./Requirements.svelte";
import { createEventDispatcher, onMount } from "svelte";
export let activeGame: SupportedGame;
const dispatch = createEventDispatcher();
let componentLoaded = false;
let requirementsMet = false;
onMount(async () => {
requirementsMet = await areRequirementsMet();
componentLoaded = true;
});
async function fullInstall() {
const installationSuccess = await fullInstallation(activeGame);
if (installationSuccess) {
dispatch('change');
}
}
</script>
{#if componentLoaded}
<div class="content">
<div style="text-align:center">
{#if !requirementsMet}
<Requirements />
{:else}
{#if !$isInstalling}
{#if $gameNeedsReinstall}
<button
class="btn"
on:click={async () => await recompileGame(activeGame)}
>
Update Install
</button>
{:else}
<button
class="btn"
on:click={fullInstall}
>
Setup
</button>
{/if}
{:else}
<Progress />
{/if}
{#if $ProcessLogs}
<LogViewer />
{/if}
{/if}
</div>
</div>
{:else}
<!-- TODO - component library - spinner -->
{/if}

View file

@ -0,0 +1,43 @@
<script>
import { ProcessLogs } from "$lib/stores/AppStore";
</script>
<div class="row">
<details>
<summary>Installation Logs</summary>
<div class="logContainer">
{#if $ProcessLogs}
{$ProcessLogs}
{/if}
</div>
</details>
</div>
<style>
.logContainer {
max-height: 10em;
min-height: 100px;
overflow-y: scroll;
padding: 1em;
background: black;
white-space: pre-wrap;
font-family: monospace;
}
details {
min-width: 75vw;
max-width: 75vw;
}
summary {
text-align: center;
}
.logContainer {
text-align: start;
}
details > summary:hover {
cursor: pointer;
}
</style>

View file

@ -0,0 +1,79 @@
<script>
import { InstallStatus } from "../../../lib/stores/AppStore";
import { tweened } from "svelte/motion";
import { cubicOut } from "svelte/easing";
const progress = tweened($InstallStatus.percent, {
duration: 1000,
easing: cubicOut,
});
InstallStatus.subscribe((InstallStatus) => {
progress.update(() => InstallStatus.percent);
});
</script>
<section>
{#if $InstallStatus.status !== undefined}
<div class="status">
<h2>{$InstallStatus.status}</h2>
</div>
{/if}
{#if $InstallStatus.percent >= 0}
<div class="progress">
<div
class="progress-bar progress-bar-animated"
style="width: {$progress}%"
/>
</div>
{/if}
</section>
<style>
.progress {
display: flex;
overflow: hidden;
height: 30px;
background-color: #ecf0f1;
width: 45vw;
max-width: 45vw;
margin: 20px auto;
}
.progress-bar {
overflow: hidden;
text-align: center;
background-color: dodgerblue;
}
.progress-bar-animated {
position: relative;
}
.progress-bar-animated::before {
content: "";
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.5));
transform: translateX(-100%);
animation: progress-bar-shine 2s infinite;
}
@keyframes progress-bar-shine {
to {
transform: translateX(0);
opacity: 0.1;
}
}
.status {
justify-content: center;
align-items: center;
text-align: center;
}
</style>

View file

@ -0,0 +1,56 @@
<script type="ts">
import { isAVXRequirementMet, isOpenGLRequirementMet } from "$lib/config";
import { onMount } from "svelte";
let componentLoaded = false;
let isAVXMet = false;
let isOpenGLMet = false;
onMount(async () => {
isAVXMet = await isAVXRequirementMet();
isOpenGLMet = await isOpenGLRequirementMet();
componentLoaded = true;
});
</script>
{#if componentLoaded}
<div class="row">
<p class="description">
OpenGOAL Requires the following requirements:
</p>
<ul class="requirements-list">
<li>
{#if isAVXMet}
✅ CPU Supports <a class="help-link" target="_blank" href="https://en.wikipedia.org/wiki/Advanced_Vector_Extensions#CPUs_with_AVX">AVX</a>
{:else}
❌ CPU Does NOT Support <a class="help-link" target="_blank" href="https://en.wikipedia.org/wiki/Advanced_Vector_Extensions#CPUs_with_AVX">AVX</a>
{/if}
</li>
<li>
{#if isOpenGLMet}
✅ GPU Supports <a class="help-link" target="_blank" href="https://en.wikipedia.org/wiki/OpenGL#OpenGL_4.3">OpenGL 4.3</a>
{:else}
❌ GPU does NOT Support <a class="help-link" target="_blank" href="https://en.wikipedia.org/wiki/OpenGL#OpenGL_4.3">OpenGL 4.3</a>
{/if}
</li>
</ul>
</div>
{/if}
<style>
.description {
font-size: 1.5em;
font-weight: 700;
}
.requirements-list {
list-style: none;
font-size: 1.25em;
}
.help-link {
color: #ffc301;
}
</style>

View file

@ -1,2 +0,0 @@
<script>
</script>

View file

@ -1,54 +0,0 @@
<script type="ts">
import { navigate } from "svelte-navigator";
import { filePrompt } from "$lib/utils/file";
import { setInstallStatus } from "$lib/config";
import { clearInstallLogs } from "$lib/utils/file";
import {
compileGame,
decompileGameData,
extractAndValidateISO,
} from "$lib/setup/setup";
// components
import Progress from "./Progress.svelte";
// constants
import { SupportedGame } from "$lib/constants";
import { InstallStatus, isInstalling } from "../../stores/InstallStore";
// TODO: MOVE THIS FUNCTION TO THE LIB DIR AND DELETE IMPORTS
async function installProcess() {
let isoPath: string | string[];
isInstalling.update(() => true);
try {
await clearInstallLogs(SupportedGame.Jak1);
isoPath = await filePrompt();
await extractAndValidateISO(isoPath);
await decompileGameData(isoPath);
await compileGame(isoPath);
await setInstallStatus(SupportedGame.Jak1, true);
isInstalling.update(() => false);
// NOTE - CHANGED THIS NAVIGATE, BUT I STILL THINK IT CAN BE BETTER
navigate(0);
return;
} catch (err) {
console.log(`[OG]: Error encountered - ${err}`);
let errStatus = {
status: err,
percent: undefined,
};
InstallStatus.update(() => errStatus);
isInstalling.update(() => false);
return false;
}
}
</script>
<div class="content">
<Progress />
<div style="text-align:center">
{#if !$isInstalling}
<button class="btn" on:click={async () => await installProcess()}>
Setup
</button>
{/if}
</div>
</div>

View file

@ -1,32 +0,0 @@
<script>
import "./progress.css";
import { InstallStatus } from "../../stores/InstallStore";
import { tweened } from "svelte/motion";
import { cubicOut } from "svelte/easing";
const progress = tweened($InstallStatus.percent, {
duration: 1000,
easing: cubicOut,
});
InstallStatus.subscribe((InstallStatus) => {
progress.update(() => InstallStatus.percent);
});
</script>
<section>
{#if $InstallStatus.status !== undefined}
<div class="status">
<h2>{$InstallStatus.status}</h2>
</div>
{/if}
{#if $InstallStatus.percent >= 0}
<div class="progress">
<div
class="progress-bar progress-bar-animated"
style="width: {$progress}%"
/>
</div>
{/if}
</section>

View file

@ -1,43 +0,0 @@
.progress {
display: flex;
overflow: hidden;
height: 30px;
background-color: #ecf0f1;
min-width: 45vw;
margin: 20px auto;
}
.progress-bar {
overflow: hidden;
text-align: center;
background-color: dodgerblue;
}
.progress-bar-animated {
position: relative;
}
.progress-bar-animated::before {
content: "";
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.5));
transform: translateX(-100%);
animation: progress-bar-shine 2s infinite;
}
@keyframes progress-bar-shine {
to {
transform: translateX(0);
opacity: 0.1;
}
}
.status {
justify-content: center;
align-items: center;
text-align: center;
}

View file

@ -3,13 +3,12 @@
import logoJak2 from "$assets/images/jak-2.webp"; import logoJak2 from "$assets/images/jak-2.webp";
import logoJak3 from "$assets/images/jak-3.webp"; import logoJak3 from "$assets/images/jak-3.webp";
import { Link } from "svelte-navigator"; import { Link } from "svelte-navigator";
import "./sidebar.css";
</script> </script>
<nav id="sidebar"> <nav id="sidebar">
<div class="games"> <div class="games">
<div class="jak-1 nav-item active"> <div class="jak-1 nav-item active">
<Link to="jak1" data-tooltip="Jak & Daxter: The Precursor Legacy"> <Link to="/jak1" data-tooltip="Jak & Daxter: The Precursor Legacy">
<img src={logoJak1} alt="Jak - TPL" /> <img src={logoJak1} alt="Jak - TPL" />
</Link> </Link>
</div> </div>
@ -26,15 +25,91 @@
</div> </div>
<div class="spacer" /> <div class="spacer" />
<div class="controls"> <div class="controls">
<div class="console nav-item disabled"> <!-- <div class="console nav-item disabled">
<!-- <Link to="" data-tooltip="Toggle Debug Console"> --> <Link to="" data-tooltip="Toggle Debug Console">
<i class="bi bi-terminal-fill" /> <i class="bi bi-terminal-fill" />
<!-- </Link> --> </Link>
</div> </div> -->
<div class="settings nav-item"> <div class="settings nav-item">
<Link to="settings" data-tooltip="Settings"> <Link to="settings" data-tooltip="Settings">
<i class="bi bi-sliders" /> <i class="fa-solid fa-gear"></i>
</Link> </Link>
</div> </div>
</div> </div>
</nav> </nav>
<style>
#sidebar {
display: flex;
flex-direction: column;
height: 100vh;
background-color: var(--bg-blue);
opacity: 75%;
transition: 500ms ease;
width: 10vw;
max-width: 10vw;
}
#sidebar:hover {
opacity: 100%;
}
.games {
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-around;
height: 50vh;
}
.nav-item {
margin: 0 5px;
filter: grayscale(100%);
transition: 500ms ease;
opacity: 50%;
}
.nav-item.active {
filter: grayscale(0%);
}
.nav-item:hover {
filter: grayscale(0%);
opacity: 100%;
cursor: pointer;
}
.nav-item.disabled:hover,
.nav-item.disabled {
cursor: not-allowed;
filter: grayscale(100%);
}
.nav-item a::before,
.nav-item a::after {
--scale: 0;
position: absolute;
transform: translateX(55px) scale(var(--scale));
transition: 200ms ease;
transform-origin: left center;
}
.nav-item a::before {
padding: 0.5rem;
width: max-content;
background: #333;
color: white;
content: attr(data-tooltip);
border-radius: 0.3rem;
text-align: center;
}
.nav-item a:hover::before {
--scale: 1;
}
.nav-item img {
width: 100%;
}
</style>

View file

@ -1,72 +0,0 @@
#sidebar {
display: flex;
flex-direction: column;
height: 100vh;
background-color: var(--bg-blue);
opacity: 75%;
transition: 500ms ease;
width: 10vw;
max-width: 10vw;
}
#sidebar:hover {
opacity: 100%;
}
.games {
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-around;
height: 50vh;
}
.nav-item {
margin: 0 5px;
filter: grayscale(100%);
transition: 500ms ease;
opacity: 50%;
}
.nav-item.active {
filter: grayscale(0%);
}
.nav-item:hover {
filter: grayscale(0%);
opacity: 100%;
cursor: pointer;
}
.nav-item.disabled:hover,
.nav-item.disabled {
cursor: not-allowed;
filter: grayscale(100%);
}
.nav-item a::before,
.nav-item a::after {
--scale: 0;
position: absolute;
transform: translateX(55px) scale(var(--scale));
transition: 200ms ease;
transform-origin: left center;
}
.nav-item a::before {
padding: 0.5rem;
width: max-content;
background: #333;
color: white;
content: attr(data-tooltip);
border-radius: 0.3rem;
text-align: center;
}
.nav-item a:hover::before {
--scale: 1;
}
.nav-item img {
width: 100%;
}

6879
src/css/fontawesome/all.min.css vendored Normal file

File diff suppressed because it is too large Load diff

View file

@ -1,17 +1,39 @@
@font-face {
font-family: "Staatliches";
src: url("/src/assets/fonts/Staatliches/Staatliches-Regular.ttf");
}
@font-face {
font-family: "Lato";
src: url("/src/assets/fonts/Lato/Lato-Regular.ttf");
}
@font-face {
font-family: "Lato";
src: url("/src/assets/fonts/Lato/Lato-Bold.ttf");
font-weight: 700;
}
@font-face {
font-family: "Roboto Mono";
src: url("/src/assets/fonts/Roboto_Mono/static/RobotoMono-Regular.ttf");
}
@font-face {
font-family: "Roboto Mono";
src: url("/src/assets/fonts/Roboto_Mono/static/RobotoMono-Bold.ttf");
font-weight: 700;
}
* { * {
-webkit-user-drag: none; -webkit-user-drag: none;
font-family: "Oswald", sans-serif; font-family: "Staatliches", sans-serif;
} }
:root { :root {
--bg-blue: #1b202b; --bg-blue: #1b202b;
} }
@font-face {
font-family: "Oswald";
src: url("/src/assets/fonts/Oswald-VariableFont_wght.ttf");
}
body { body {
height: 100vh; height: 100vh;
padding: 0; padding: 0;
@ -80,7 +102,6 @@ body {
padding-right: 1em; padding-right: 1em;
font-size: 1em; font-size: 1em;
border: black 1px solid; border: black 1px solid;
font-weight: 700;
border-radius: 5px; border-radius: 5px;
transition: all 0.1s ease; transition: all 0.1s ease;
color: black; color: black;
@ -91,6 +112,8 @@ body {
padding: 10px 0; padding: 10px 0;
font-weight: bold; font-weight: bold;
font-size: 1rem; font-size: 1rem;
padding-left: 0.5em;
padding-right: 0.5em;
} }
.btn.lg { .btn.lg {

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -1,10 +1,5 @@
import { import { createDir, readTextFile, writeFile } from "@tauri-apps/api/fs";
BaseDirectory, import { appDir, join } from "@tauri-apps/api/path";
createDir,
readTextFile,
writeFile,
} from "@tauri-apps/api/fs";
import { appDir, join, homeDir } from "@tauri-apps/api/path";
import { Store } from "tauri-plugin-store-api"; import { Store } from "tauri-plugin-store-api";
import { SupportedGame } from "./constants"; import { SupportedGame } from "./constants";
import { fileExists } from "./utils/file"; import { fileExists } from "./utils/file";
@ -81,7 +76,7 @@ export async function getInstallStatus(
if (!(await validVersion("1.0"))) { if (!(await validVersion("1.0"))) {
return false; return false;
} }
// TODO: create a proper type for gameConfigs // TODO: create a proper type for gameConfigs - exists with 'LauncherConfig'
const gameConfigs: object = await store.get("games"); const gameConfigs: object = await store.get("games");
if (gameConfigs == null || !(supportedGame in gameConfigs)) { if (gameConfigs == null || !(supportedGame in gameConfigs)) {
return false; return false;
@ -116,7 +111,7 @@ export async function setInstallStatus(
if (!(await validVersion("1.0"))) { if (!(await validVersion("1.0"))) {
return; return;
} }
// TODO: create a proper type for gameConfigs // TODO: create a proper type for gameConfigs - 'LauncherConfig'
let gameConfigs: object = await store.get("games"); let gameConfigs: object = await store.get("games");
// NOTE: Do we need this conditional? Considering we generate the store file this condition should never happen. // NOTE: Do we need this conditional? Considering we generate the store file this condition should never happen.
if (gameConfigs == null || !(supportedGame in gameConfigs)) { if (gameConfigs == null || !(supportedGame in gameConfigs)) {
@ -134,22 +129,33 @@ export async function setRequirementsMet(
await store.load(); await store.load();
await store.set("requirements", { avx, openGL }); await store.set("requirements", { avx, openGL });
await store.save(); await store.save();
return; return;
} }
/** /**
* Checks the user config file to see if avx and openGL requirements are met. * Checks the user config file to see if avx and openGL requirements are met.
*/ */
export async function areRequirementsMet(): Promise<Boolean> { export async function areRequirementsMet(): Promise<boolean> {
if ((await isAVXRequirementMet()) && (await isOpenGLRequirementMet())) {
return true;
}
return false;
}
export async function isAVXRequirementMet(): Promise<boolean> {
await store.load(); await store.load();
let requirements = await store.get("requirements"); let requirements = await store.get("requirements");
let { avx, openGL } = requirements; if (!requirements["avx"]) {
if (!avx) {
console.log("Unsupported AVX"); console.log("Unsupported AVX");
return false; return false;
} }
if (!openGL) { return true;
}
export async function isOpenGLRequirementMet(): Promise<boolean> {
await store.load();
let requirements = await store.get("requirements");
if (!requirements["openGL"]) {
console.log("Unsupported OpenGL"); console.log("Unsupported OpenGL");
return false; return false;
} }
@ -159,6 +165,8 @@ export async function areRequirementsMet(): Promise<Boolean> {
export async function getGameInstallVersion( export async function getGameInstallVersion(
game: SupportedGame game: SupportedGame
): Promise<String> { ): Promise<String> {
// TODO - this can fail on first time startup from splash (where the config is init)
// no idea why yet
await store.load(); await store.load();
let games: GameConfig = await store.get("games"); let games: GameConfig = await store.get("games");
const { version } = games[game]; const { version } = games[game];
@ -175,7 +183,9 @@ export async function setGameInstallVersion(game: SupportedGame) {
} }
export async function getLatestToolsVersion(): Promise<String> { export async function getLatestToolsVersion(): Promise<String> {
const data = await readTextFile("metadata.json", { dir: BaseDirectory.App }); const appDirPath = await appDir();
const userMetaPath = await join(appDirPath, "data", "metadata.json");
const data = await readTextFile(userMetaPath);
const { version } = JSON.parse(data); const { version } = JSON.parse(data);
return version; return version;
} }
@ -184,9 +194,14 @@ export async function shouldUpdateGameInstall(
game: SupportedGame game: SupportedGame
): Promise<Boolean> { ): Promise<Boolean> {
const installVersion = await getGameInstallVersion(game); const installVersion = await getGameInstallVersion(game);
if (installVersion === null || installVersion === undefined) {
return false;
}
const toolsVersion = await getLatestToolsVersion(); const toolsVersion = await getLatestToolsVersion();
if (installVersion === toolsVersion) return false; if (installVersion === toolsVersion) {
return false;
}
console.log("Tools version is different than install verison"); console.log("Tools version is different than install verison");
console.log("Tools: ", toolsVersion); console.log("Tools: ", toolsVersion);

View file

@ -1,3 +1,5 @@
import { TranslatedStrings } from "./translations/translations";
// TODO: update setup status messages to use typescript // TODO: update setup status messages to use typescript
export const SETUP_SUCCESS = { export const SETUP_SUCCESS = {
awaitingISO: { status: "Awaiting ISO File", percent: 0 }, awaitingISO: { status: "Awaiting ISO File", percent: 0 },
@ -21,3 +23,40 @@ export const enum SupportedGame {
Jak3 = "Jak 3", Jak3 = "Jak 3",
JakX = "Jak X", JakX = "Jak X",
} }
// TODO - we should really just have `SupportedGame` be a class instead of an enum
// then these could just be methods
export function getGameTitle(game: SupportedGame) {
switch (game) {
case SupportedGame.Jak1:
return TranslatedStrings.jak1_gameName;
default:
return "";
}
}
export function fromRoute(gameName: string): SupportedGame {
switch (gameName) {
case "jak1":
return SupportedGame.Jak1;
case "jak2":
return SupportedGame.Jak2;
case "jak3":
return SupportedGame.Jak3;
case "jakx":
return SupportedGame.JakX;
}
}
export function getInternalName(activeGame: SupportedGame): string {
switch (activeGame) {
case SupportedGame.Jak1:
return "jak1";
case SupportedGame.Jak2:
return "jak2";
case SupportedGame.Jak3:
return "jak3";
case SupportedGame.JakX:
return "jakx";
}
}

View file

@ -1,11 +1,20 @@
import { Command } from "@tauri-apps/api/shell"; import { Command } from "@tauri-apps/api/shell";
import { appDir } from "@tauri-apps/api/path"; import { appDir, join } from "@tauri-apps/api/path";
import { os } from "@tauri-apps/api"; import { os } from "@tauri-apps/api";
import { getHighestSimd } from "$lib/commands"; import { getHighestSimd } from "$lib/rpc/commands";
import { InstallStatus, isInstalling } from "../../stores/InstallStore"; import { InstallStatus, isInstalling } from "../stores/AppStore";
import { SETUP_SUCCESS, SETUP_ERROR, SupportedGame } from "$lib/constants"; import { SETUP_SUCCESS, SupportedGame } from "$lib/constants";
import { appendToInstallErrorLog, appendToInstallLog } from "$lib/utils/file"; import {
import { setRequirementsMet } from "../config"; appendToInstallErrorLog,
appendToInstallLog,
clearInstallLogs,
filePrompt,
} from "$lib/utils/file";
import {
setGameInstallVersion,
setInstallStatus,
setRequirementsMet,
} from "../config";
import { BaseDirectory, copyFile } from "@tauri-apps/api/fs"; import { BaseDirectory, copyFile } from "@tauri-apps/api/fs";
import { resolveErrorCode } from "./setup_errors"; import { resolveErrorCode } from "./setup_errors";
@ -161,3 +170,54 @@ export async function compileGame(filePath: string): Promise<Boolean> {
} }
handleErrorCode(output.code, "Compiler"); handleErrorCode(output.code, "Compiler");
} }
export async function fullInstallation(game: SupportedGame): Promise<boolean> {
let isoPath: string | string[];
isInstalling.update(() => true);
try {
await clearInstallLogs(game);
isoPath = await filePrompt();
await extractAndValidateISO(isoPath);
await decompileGameData(isoPath);
await compileGame(isoPath);
await setInstallStatus(game, true);
isInstalling.update(() => false);
await setGameInstallVersion(game);
return true;
} catch (err) {
console.log(`[OG]: Error encountered - ${err}`);
let errStatus = {
status: err,
percent: undefined,
};
InstallStatus.update(() => errStatus);
isInstalling.update(() => false);
return false;
}
}
export async function recompileGame(game: SupportedGame) {
// TODO - this assumes their files are in this folder, this is potentially wrong now!
// ensure the extractor outputs to a sensible folder (per game)
// and we are grabbing the right one
const isoPath = await join(await appDir(), "data", "extracted_iso");
// TODO - probably should check the dir exists
isInstalling.update(() => true);
try {
await clearInstallLogs(game);
// decompile & compile game
await decompileGameData(isoPath);
await compileGame(isoPath);
// update settings.json with latest tools version from metadata.json
await setGameInstallVersion(game);
isInstalling.update(() => false);
} catch (err) {
console.log(`[OG]: Error encountered - ${err}`);
let errStatus = {
status: err,
percent: undefined,
};
InstallStatus.update(() => errStatus);
isInstalling.update(() => false);
}
}

View file

@ -5,4 +5,5 @@ export const InstallStatus = writable({
percent: undefined, percent: undefined,
}); });
export const isInstalling = writable(false); export const isInstalling = writable(false);
export const Console = writable(); export const gameNeedsReinstall = writable(false);
export const ProcessLogs = writable();

View file

@ -0,0 +1,181 @@
// Code Generated from - https://app.quicktype.io/
// Don't Hand Modify!
// To parse this data:
//
// import { Convert, TranslationSchema } from "./file";
//
// const translationSchema = Convert.toTranslationSchema(json);
//
// These functions will throw an error if the JSON doesn't
// match the expected interface, even if the JSON is valid.
export interface TranslationSchema {
jak1_gameName: string;
}
// Converts JSON strings to/from your types
// and asserts the results of JSON.parse at runtime
export class Convert {
public static toTranslationSchema(json: string): TranslationSchema {
return cast(JSON.parse(json), r("TranslationSchema"));
}
public static translationSchemaToJson(value: TranslationSchema): string {
return JSON.stringify(uncast(value, r("TranslationSchema")), null, 2);
}
}
function invalidValue(typ: any, val: any, key: any = ""): never {
if (key) {
throw Error(
`Invalid value for key "${key}". Expected type ${JSON.stringify(
typ
)} but got ${JSON.stringify(val)}`
);
}
throw Error(
`Invalid value ${JSON.stringify(val)} for type ${JSON.stringify(typ)}`
);
}
function jsonToJSProps(typ: any): any {
if (typ.jsonToJS === undefined) {
const map: any = {};
typ.props.forEach((p: any) => (map[p.json] = { key: p.js, typ: p.typ }));
typ.jsonToJS = map;
}
return typ.jsonToJS;
}
function jsToJSONProps(typ: any): any {
if (typ.jsToJSON === undefined) {
const map: any = {};
typ.props.forEach((p: any) => (map[p.js] = { key: p.json, typ: p.typ }));
typ.jsToJSON = map;
}
return typ.jsToJSON;
}
function transform(val: any, typ: any, getProps: any, key: any = ""): any {
function transformPrimitive(typ: string, val: any): any {
if (typeof typ === typeof val) return val;
return invalidValue(typ, val, key);
}
function transformUnion(typs: any[], val: any): any {
// val must validate against one typ in typs
const l = typs.length;
for (let i = 0; i < l; i++) {
const typ = typs[i];
try {
return transform(val, typ, getProps);
} catch (_) {}
}
return invalidValue(typs, val);
}
function transformEnum(cases: string[], val: any): any {
if (cases.indexOf(val) !== -1) return val;
return invalidValue(cases, val);
}
function transformArray(typ: any, val: any): any {
// val must be an array with no invalid elements
if (!Array.isArray(val)) return invalidValue("array", val);
return val.map((el) => transform(el, typ, getProps));
}
function transformDate(val: any): any {
if (val === null) {
return null;
}
const d = new Date(val);
if (isNaN(d.valueOf())) {
return invalidValue("Date", val);
}
return d;
}
function transformObject(
props: { [k: string]: any },
additional: any,
val: any
): any {
if (val === null || typeof val !== "object" || Array.isArray(val)) {
return invalidValue("object", val);
}
const result: any = {};
Object.getOwnPropertyNames(props).forEach((key) => {
const prop = props[key];
const v = Object.prototype.hasOwnProperty.call(val, key)
? val[key]
: undefined;
result[prop.key] = transform(v, prop.typ, getProps, prop.key);
});
Object.getOwnPropertyNames(val).forEach((key) => {
if (!Object.prototype.hasOwnProperty.call(props, key)) {
result[key] = transform(val[key], additional, getProps, key);
}
});
return result;
}
if (typ === "any") return val;
if (typ === null) {
if (val === null) return val;
return invalidValue(typ, val);
}
if (typ === false) return invalidValue(typ, val);
while (typeof typ === "object" && typ.ref !== undefined) {
typ = typeMap[typ.ref];
}
if (Array.isArray(typ)) return transformEnum(typ, val);
if (typeof typ === "object") {
return typ.hasOwnProperty("unionMembers")
? transformUnion(typ.unionMembers, val)
: typ.hasOwnProperty("arrayItems")
? transformArray(typ.arrayItems, val)
: typ.hasOwnProperty("props")
? transformObject(getProps(typ), typ.additional, val)
: invalidValue(typ, val);
}
// Numbers can be parsed by Date but shouldn't be.
if (typ === Date && typeof val !== "number") return transformDate(val);
return transformPrimitive(typ, val);
}
function cast<T>(val: any, typ: any): T {
return transform(val, typ, jsonToJSProps);
}
function uncast<T>(val: T, typ: any): any {
return transform(val, typ, jsToJSONProps);
}
function a(typ: any) {
return { arrayItems: typ };
}
function u(...typs: any[]) {
return { unionMembers: typs };
}
function o(props: any[], additional: any) {
return { props, additional };
}
function m(additional: any) {
return { props: [], additional };
}
function r(name: string) {
return { ref: name };
}
const typeMap: any = {
TranslationSchema: o(
[{ json: "jak1_gameName", js: "jak1_gameName", typ: "" }],
false
),
};

View file

@ -0,0 +1,18 @@
import { Convert } from "./translation_schema";
import type { TranslationSchema } from "./translation_schema";
import english from "$assets/translations/english.json";
let supportedTranslations = ["english"];
export let TranslatedStrings: TranslationSchema;
export function loadTranslations(language: string) {
if (!supportedTranslations.includes(language)) {
console.log("Language not supported!");
}
// TODO - would prefer to import this by a raw path but have to import
// for vite reasons -- maybe there is a different way?
if (language === "english") {
TranslatedStrings = Convert.toTranslationSchema(JSON.stringify(english));
}
}

View file

@ -1,4 +1,4 @@
import { copyDirectory } from "$lib/commands"; import { copyDirectory } from "$lib/rpc/commands";
import { SETUP_SUCCESS, SETUP_ERROR, SupportedGame } from "$lib/constants"; import { SETUP_SUCCESS, SETUP_ERROR, SupportedGame } from "$lib/constants";
import { invoke } from "@tauri-apps/api"; import { invoke } from "@tauri-apps/api";
import { open } from "@tauri-apps/api/dialog"; import { open } from "@tauri-apps/api/dialog";
@ -16,7 +16,7 @@ import {
logDir, logDir,
resourceDir, resourceDir,
} from "@tauri-apps/api/path"; } from "@tauri-apps/api/path";
import { InstallStatus, Console } from "../../stores/InstallStore"; import { InstallStatus, ProcessLogs } from "../stores/AppStore";
export async function fileExists(path: string): Promise<boolean> { export async function fileExists(path: string): Promise<boolean> {
try { try {
@ -29,6 +29,7 @@ export async function fileExists(path: string): Promise<boolean> {
export async function dirExists(path: string): Promise<boolean> { export async function dirExists(path: string): Promise<boolean> {
try { try {
// NOTE - this isn't case sensitive!
await readDir(path); await readDir(path);
return true; return true;
} catch (err) { } catch (err) {
@ -37,6 +38,7 @@ export async function dirExists(path: string): Promise<boolean> {
} }
export async function filePrompt(): Promise<string> { export async function filePrompt(): Promise<string> {
// TODO - shouldn't be ISO specific in this function
// TODO - pull strings out into args // TODO - pull strings out into args
InstallStatus.update(() => SETUP_SUCCESS.awaitingISO); InstallStatus.update(() => SETUP_SUCCESS.awaitingISO);
const path = await open({ const path = await open({
@ -53,26 +55,45 @@ export async function filePrompt(): Promise<string> {
return path; return path;
} }
// TODO - we need to copy over something to let us detect when the user updates and we need to copy again // TODO - move this stuff into a separate file, this isn't generic file util stuff anymore
// - this could be as simple as a json file with a version (launcher version)
export async function isDataDirectoryUpToDate(): Promise<boolean> {
const appDirPath = await appDir();
console.log(appDirPath);
return dirExists(`${appDirPath}data`); export async function dataDirectoryExists(): Promise<boolean> {
return await dirExists(await join(await appDir(), "data"));
}
export async function isDataDirectoryUpToDate(): Promise<boolean> {
const resourceDirPath = await resourceDir();
const appDirPath = await appDir();
// There should be a `metadata.json` which will help us know if the directory is out of date
// aka, does the app have updated files compared to what the user has in their appDir.
const userMetaPath = await join(appDirPath, "data", "metadata.json");
const appMetaPath = await join(resourceDirPath, "data", "metadata.json");
if (!(await fileExists(userMetaPath))) {
console.log(
`[Launcher]: Couldn't locate user's metadata file at '${userMetaPath}'`
);
return false;
}
// If it's there, read it in and check the version, compare with the app's
const userMetaVersion = JSON.parse(await readTextFile(userMetaPath)).version;
const appMetaVersion = JSON.parse(await readTextFile(appMetaPath)).version;
if (userMetaVersion != appMetaVersion) {
console.log(
`[Launcher]: User version ${userMetaVersion} does not match app version ${appMetaVersion}`
);
return false;
}
// NOTE - the user can of course mess up their directory more, but we can only hold their hands so much
// TODO - better to add some sort of "verify local data" feature in the app imo
return true;
} }
export async function copyDataDirectory(): Promise<boolean> { export async function copyDataDirectory(): Promise<boolean> {
const resourceDirPath = await resourceDir(); const resourceDirPath = await resourceDir();
console.log(resourceDirPath);
const appDirPath = await appDir(); const appDirPath = await appDir();
console.log(appDirPath);
let src = `${resourceDirPath.replaceAll("\\\\?\\", "")}data`; let src = `${resourceDirPath.replaceAll("\\\\?\\", "")}data`;
let dst = `${appDirPath}data`; let dst = `${appDirPath}data`;
console.log(src);
console.log(dst);
try { try {
await copyDirectory(src, dst); await copyDirectory(src, dst);
@ -82,8 +103,10 @@ export async function copyDataDirectory(): Promise<boolean> {
} }
} }
// TODO - move this to a logging file and replace all `console.logs` in the entire project
export async function clearInstallLogs(supportedGame: SupportedGame) { export async function clearInstallLogs(supportedGame: SupportedGame) {
Console.set(null); ProcessLogs.set(null);
const dir = await logDir(); const dir = await logDir();
let fileName = `${supportedGame}-install.log`; let fileName = `${supportedGame}-install.log`;
let fullPath = await join(dir, fileName); let fullPath = await join(dir, fileName);
@ -108,10 +131,11 @@ export async function appendToInstallLog(
let contents: string; let contents: string;
if (!(await fileExists(fullPath))) { if (!(await fileExists(fullPath))) {
await createDir(await dirname(fullPath), { recursive: true }); await createDir(await dirname(fullPath), { recursive: true });
} else {
contents = await readTextFile(fullPath);
} }
contents = await readTextFile(fullPath);
contents += text; contents += text;
Console.update(() => contents); ProcessLogs.update(() => contents);
await writeFile({ contents: contents, path: fullPath }); await writeFile({ contents: contents, path: fullPath });
} }
@ -126,9 +150,10 @@ export async function appendToInstallErrorLog(
let contents: string; let contents: string;
if (!(await fileExists(fullPath))) { if (!(await fileExists(fullPath))) {
await createDir(await dirname(fullPath), { recursive: true }); await createDir(await dirname(fullPath), { recursive: true });
} else {
contents = await readTextFile(fullPath);
} }
contents = await readTextFile(fullPath);
contents += text; contents += text;
Console.update(() => contents); ProcessLogs.update(() => contents);
await writeFile({ contents: contents, path: fullPath }); await writeFile({ contents: contents, path: fullPath });
} }

View file

@ -1,5 +1,8 @@
import { loadTranslations } from "$lib/translations/translations";
import App from "./App.svelte"; import App from "./App.svelte";
loadTranslations("english");
const app = new App({ const app = new App({
target: document.getElementById("app"), target: document.getElementById("app"),
}); });

101
src/routes/Game.svelte Normal file
View file

@ -0,0 +1,101 @@
<script>
import { fade } from "svelte/transition";
import { getInstallStatus, shouldUpdateGameInstall } from "$lib/config";
import { fromRoute, getGameTitle, SupportedGame } from "$lib/constants";
import { useParams } from "svelte-navigator";
import GameContent from "../components/games/GameControls.svelte";
import GameSetup from "../components/games/setup/GameSetup.svelte";
import { onMount } from "svelte";
import { copyDataDirectory, isDataDirectoryUpToDate } from "$lib/utils/file";
import { gameNeedsReinstall } from "$lib/stores/AppStore";
const params = useParams();
let activeGame = SupportedGame.Jak1;
let componentLoaded = false;
let isGameInstalled = false;
let dataDirUpToDate = false;
let updatingDataDir = false;
let errorText = "";
onMount(async () => {
if (
$params["game_name"] !== undefined &&
$params["game_name"] !== null &&
$params["game_name"] !== ""
) {
activeGame = fromRoute($params["game_name"]);
}
isGameInstalled = await getInstallStatus(activeGame);
// Do some checks before the user can play the game
// First, let's see if their data directory needs updating
// we do it here so we can get the user's consent
dataDirUpToDate = await isDataDirectoryUpToDate();
// If it's up to date we'll do the second check now, does their game need to be re-compiled?
if (dataDirUpToDate) {
if (await shouldUpdateGameInstall(activeGame)) {
// await recompileGame(activeGame);
gameNeedsReinstall.update(() => true);
}
}
componentLoaded = true;
});
async function syncDataDirectory() {
updatingDataDir = true;
errorText = "";
try {
await copyDataDirectory();
// Now that the directory is up to date, let's see if they need to reinstall the game
if (await shouldUpdateGameInstall(activeGame)) {
gameNeedsReinstall.update(() => true);
}
} catch (err) {
errorText = `Error encountered when syncing data files - ${err}`;
}
updatingDataDir = false;
}
async function updateGameState(evt) {
isGameInstalled = await getInstallStatus(activeGame);
}
</script>
{#if componentLoaded}
<div class="flex-center" in:fade>
<h1>
{getGameTitle(activeGame)}
</h1>
{#if isGameInstalled && !$gameNeedsReinstall}
{#if !dataDirUpToDate}
<p>Local data files must be synced up in-order to proceed</p>
<p>
This may overwrite any custom changes to the game's code or textures
</p>
<p>Save files and settings will not be modified</p>
{#if !updatingDataDir}
<button class="btn" on:click={syncDataDirectory}>
Sync Data Files
</button>
{/if}
{#if errorText != ""}
{errorText}
{/if}
{:else}
<GameContent {activeGame} on:change={updateGameState}/>
{/if}
{:else}
{#if $gameNeedsReinstall}
<p>Game installed with a previous version of OpenGOAL</p>
<p>The game must be re-installed before you can proceed</p>
<p>Save files and settings will not be modified</p>
{/if}
<GameSetup {activeGame} on:change={updateGameState} />
{/if}
</div>
{:else}
<!-- TODO - component library - spinner -->
{/if}

View file

@ -1,36 +0,0 @@
<script>
// Assets
import { fade } from "svelte/transition";
import { areRequirementsMet, getInstallStatus } from "$lib/config";
import Setup from "../components/setup/Jak1Setup.svelte";
import Jak1Main from "../components/games/Jak1Main.svelte";
import Console from "../components/console/Console.svelte";
import Logo from "../components/Logo.svelte";
import { SupportedGame } from "$lib/constants";
// State
const gameInstalled = async () => await getInstallStatus(SupportedGame.Jak1);
</script>
<div class="flex-center" in:fade>
<Logo />
{#await gameInstalled() then installed}
{#if installed}
<Jak1Main />
{:else}
<!-- TODO: MOVE THIS ELSE INTO ITS OWN ROUTE -->
{#await areRequirementsMet then requirementsMet}
{#if requirementsMet}
<Setup />
<Console />
{:else}
<!-- TODO: MAKE AN ERROR PAGE TO PROPERLY DISPLAY THE MISSING REQUIREMENT(S) -->
<p>
You do not meet the requirements to play this game: Missing
AVX/OpenGL Support
</p>
{/if}
{/await}
{/if}
{/await}
</div>

View file

@ -1,20 +1,9 @@
<script> <script>
import { fade } from "svelte/transition"; import { fade } from "svelte/transition";
import { openDir } from "$lib/commands"; import { openDir } from "$lib/rpc/commands";
import { appDir, join } from "@tauri-apps/api/path"; import { appDir } from "@tauri-apps/api/path";
import { getGameInstallVersion } from "$lib/config";
import { SupportedGame } from "$lib/constants";
import { getVersion } from "@tauri-apps/api/app"; import { getVersion } from "@tauri-apps/api/app";
import { decompileGameData, compileGame } from "$lib/setup/setup";
import { onMount } from "svelte";
import { isInstalling } from "../stores/InstallStore";
// NOTE: added this to shut up the console warning
export let location;
let isoPath;
onMount(async () => {
isoPath = await join(await appDir(), "/data/extracted_iso/");
});
</script> </script>
<!-- TODO - STYLE THIS PAGE --> <!-- TODO - STYLE THIS PAGE -->
@ -26,19 +15,6 @@
Open App Directory</button Open App Directory</button
> >
{/await} {/await}
<button
disabled={$isInstalling}
class="btn"
on:click={async () => decompileGameData(isoPath)}>Decompile</button
>
<button
disabled={$isInstalling}
class="btn"
on:click={async () => compileGame(isoPath)}>Compile</button
>
{#await getGameInstallVersion(SupportedGame.Jak1) then version}
<p>Game Version: {version}</p>
{/await}
{#await getVersion() then version} {#await getVersion() then version}
<p>App Version: {version}</p> <p>App Version: {version}</p>
{/await} {/await}

View file

@ -1,77 +1,103 @@
<script> <script>
import { closeSplashScreen } from "$lib/commands"; import { closeSplashScreen } from "$lib/rpc/commands";
import { import { areRequirementsMet, initConfig } from "$lib/config";
areRequirementsMet, import { checkRequirements } from "$lib/setup/setup";
initConfig,
setGameInstallVersion,
shouldUpdateGameInstall,
} from "$lib/config";
import {
checkRequirements,
compileGame,
decompileGameData,
} from "$lib/setup/setup";
import { onMount } from "svelte"; import { onMount } from "svelte";
import logo from "$assets/images/logo.webp"; import logo from "$assets/images/icon.webp";
import "./splash.css"; import { copyDataDirectory, dataDirectoryExists } from "$lib/utils/file";
import { copyDataDirectory, isDataDirectoryUpToDate } from "$lib/utils/file";
import { SupportedGame } from "$lib/constants";
import { appDir, join } from "@tauri-apps/api/path";
import { InstallStatus } from "../stores/InstallStore";
let dataFilesCopied = false; let currentProgress = 0;
let unableToCopy = false; let currentStatusText = "Initializing Config";
// Events // Events
onMount(async () => { onMount(async () => {
await initConfig(); await initConfig();
currentStatusText = "Checking Requirements";
currentProgress = 10;
// NOTE - potentially has problems if the user changes hardware
if (!(await areRequirementsMet())) { if (!(await areRequirementsMet())) {
await checkRequirements(); await checkRequirements();
} }
// See if we've copied the files to the AppDir yet currentStatusText = "Checking Data Files";
if (!(await isDataDirectoryUpToDate())) { currentProgress = 25;
try {
await copyDataDirectory();
dataFilesCopied = true;
} catch (err) {
console.log(err);
unableToCopy = true;
}
}
if (await shouldUpdateGameInstall(SupportedGame.Jak1)) { // Check if the data directory exists or not
// copy latest tools to the proper directory // - if it doesn't this is the users first launch, so lets copy it
const isoPath = await join(await appDir(), "/data/extracted_iso/"); if (!(await dataDirectoryExists())) {
try { try {
currentStatusText = "Copying Data Files";
currentProgress = 50;
await copyDataDirectory(); await copyDataDirectory();
dataFilesCopied = true;
} catch (err) { } catch (err) {
console.log(err); console.log(err);
unableToCopy = true; currentStatusText = `Error - ${err}`;
return;
} }
// decompile & compile game
await decompileGameData(isoPath);
await compileGame(isoPath);
// update settings.json with latest tools version from metadata.json
await setGameInstallVersion(SupportedGame.Jak1);
} }
currentStatusText = "Finishing Up";
currentProgress = 100;
await new Promise((res) => setTimeout(res, 2500)); await new Promise((res) => setTimeout(res, 2500));
await closeSplashScreen(); await closeSplashScreen();
}); });
</script> </script>
<div class="splash-logo"> <div class="content">
<img src={logo} alt="" /> <div class="splash-logo">
</div> <img src={logo} alt="" />
<div class="splash-status"> </div>
{#if !dataFilesCopied} <div class="splash-status-text">{currentStatusText}</div>
Copying Data Files... <div>
{#if unableToCopy} <div class="splash-status-bar fg" style="width: {currentProgress}%" />
Error - Unable to Copy Data Files <div class="splash-status-bar bg" />
{/if} </div>
{:else}
Checking Data Files...
<br />
{$InstallStatus.status}
{/if}
</div> </div>
<style>
@font-face {
font-family: "Roboto Mono";
src: url("/src/assets/fonts/Roboto_Mono/static/RobotoMono-Regular.ttf");
}
@font-face {
font-family: "Roboto Mono";
src: url("/src/assets/fonts/Roboto_Mono/static/RobotoMono-Bold.ttf");
font-weight: 700;
}
.content {
color: white;
}
.splash-logo {
height: 65vh;
margin-bottom: 1em;
padding: 10px;
}
.splash-logo img {
object-fit: contain;
height: 100%;
width: 100%;
}
.splash-status-text {
text-align: center;
font-family: "Roboto Mono", monospace;
font-size: 8pt;
margin-bottom: 1.5em;
}
.splash-status-bar {
width: 100%;
height: 15px;
}
.splash-status-bar.bg {
background-color: #775500;
position: absolute;
}
.splash-status-bar.fg {
background-color: #ffb807;
position: absolute;
z-index: 999;
}
</style>

View file

@ -7,6 +7,18 @@
<title>Splash</title> <title>Splash</title>
</head> </head>
<style>
body {
margin: 0;
overflow: hidden;
}
#app {
height: 100vh;
background-color: #202020;
}
</style>
<body> <body>
<div id="app"></div> <div id="app"></div>
</body> </body>

View file

@ -1,23 +0,0 @@
body {
height: 100vh;
overflow: hidden;
margin: 0;
color: white;
text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000,
1px 1px 0 #000;
font-size: 1.5em;
}
.splash-logo {
height: 75vh;
}
.splash-logo img {
object-fit: contain;
height: 100%;
width: 100%;
}
.splash-status {
text-align: center;
}

View file

@ -37,21 +37,11 @@
* to avoid limiting type declarations. * to avoid limiting type declarations.
*/ */
"include": [ "include": [
"src/**/*.d.ts", "./src/**/*.d.ts",
"src/**/*.js", "./src/**/*.js",
"src/**/*.ts", "./src/**/*.ts",
"src/**/*.svelte", "./src/**/*.svelte",
"svelte.config.js", "./svelte.config.js"
"src/main.ts",
"src/lib/launch.ts",
"src/lib/setup/setup.ts",
"src/lib/setup/setup_errors.ts",
"src/lib/launch.ys",
"src/lib/constants.ts",
"src/lib/config.ts",
"src/lib/commands.ts",
"src/lib/utils/file.ts",
"src/splash/splash.ts"
], ],
"references": [ "references": [
{ {