diff --git a/splashscreen.html b/splashscreen.html new file mode 100644 index 0000000..6727167 --- /dev/null +++ b/splashscreen.html @@ -0,0 +1,21 @@ + + + + + + + Splash + + + + diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index ba0a1e5..2301116 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -55,7 +55,7 @@ checksum = "08f9b8508dccb7687a1d6c4ce66b2b0ecef467c94667de27d8d7fe1f8d2a9cdc" [[package]] name = "app" -version = "0.2.2" +version = "0.2.3" dependencies = [ "serde", "serde_json", @@ -1419,6 +1419,12 @@ dependencies = [ "autocfg", ] +[[package]] +name = "minisign-verify" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "933dca44d65cdd53b355d0b73d380a2ff5da71f87f036053188bf1eab6a19881" + [[package]] name = "miniz_oxide" version = "0.5.3" @@ -2668,6 +2674,7 @@ checksum = "81af088a87f908dab3a268f92e3c331e911bed6b1756bbfaeadedfe9dd40fe4f" dependencies = [ "anyhow", "attohttpc", + "base64", "bincode", "cocoa", "dirs-next", @@ -2681,6 +2688,7 @@ dependencies = [ "heck 0.4.0", "http", "ignore", + "minisign-verify", "notify-rust", "objc", "once_cell", @@ -2706,12 +2714,14 @@ dependencies = [ "tauri-utils", "tempfile", "thiserror", + "time", "tokio", "url", "uuid 1.1.1", "webkit2gtk", "webview2-com", "windows 0.37.0", + "zip", ] [[package]] @@ -2908,6 +2918,7 @@ version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2702e08a7a860f005826c6815dcac101b19b5eb330c27fe4a5928fec1d20ddd" dependencies = [ + "itoa 1.0.2", "libc", "num_threads", ] @@ -3634,3 +3645,14 @@ name = "xml-rs" version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2d7d3948613f75c98fd9328cfdcc45acc4d360655289d0a7d4ec931392200a3" + +[[package]] +name = "zip" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf225bcf73bb52cbb496e70475c7bd7a3f769df699c0020f6c7bd9a96dcf0b8d" +dependencies = [ + "byteorder", + "crc32fast", + "crossbeam-utils", +] diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index c8c92aa..eb29f03 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -17,7 +17,7 @@ tauri-build = { version = "1.0.0-rc.12", features = [] } [dependencies] serde_json = "1.0" serde = { version = "1.0", features = ["derive"] } -tauri = { version = "1.0.0-rc.14", features = ["api-all", "devtools"] } +tauri = { version = "1.0.0-rc.14", features = ["api-all", "devtools", "updater"] } [dependencies.tauri-plugin-store] git = "https://github.com/tauri-apps/tauri-plugin-store" diff --git a/src-tauri/src/commands.rs b/src-tauri/src/commands.rs index de8a94b..8325875 100644 --- a/src-tauri/src/commands.rs +++ b/src-tauri/src/commands.rs @@ -1,5 +1,6 @@ use std::process::Command; use tauri::command; +use tauri::Manager; #[derive(Debug, serde::Serialize)] pub enum CommandError { @@ -60,3 +61,13 @@ fn open_appdir(dir: String) { .spawn() .unwrap(); } + +#[tauri::command] +pub async fn close_splashscreen(window: tauri::Window) { + // Close splashscreen + if let Some(splashscreen) = window.get_window("splashscreen") { + splashscreen.close().unwrap(); + } + // Show main window + window.get_window("main").unwrap().show().unwrap(); +} diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 55a59ad..cc64443 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -6,13 +6,18 @@ use tauri_plugin_store::PluginBuilder; mod commands; +use commands::close_splashscreen; use commands::get_highest_simd; use commands::open_dir; fn main() { tauri::Builder::default() .plugin(PluginBuilder::default().build()) - .invoke_handler(tauri::generate_handler![get_highest_simd, open_dir]) + .invoke_handler(tauri::generate_handler![ + get_highest_simd, + open_dir, + close_splashscreen + ]) .run(tauri::generate_context!()) .expect("error while running tauri application"); } diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 49a6bcd..60b229b 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -88,8 +88,20 @@ "height": 600, "resizable": false, "fullscreen": false, - "x": 1750, - "y": 0 + "visible": false, + "center": true + }, + { + "width": 600, + "height": 120, + "center": true, + "decorations": false, + "transparent": true, + "resizable": false, + "fullscreen": false, + "url": "./src/splash/index.html", + "label": "splashscreen", + "visible": true } ], "security": { diff --git a/src/App.svelte b/src/App.svelte index 51323cc..6335bc7 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -9,14 +9,20 @@ import Sidebar from "./components/sidebar/Sidebar.svelte"; import Background from "./components/background/Background.svelte"; import { initConfig } from "$lib/config"; - import { isInDebugMode } from "$lib/setup"; + import { checkRequirements, isInDebugMode } from "$lib/setup"; + import { areRequirementsMet } from "$lib/config"; + import { closeSplashScreen } from "$lib/commands"; let revokeSpecificActions = false; // Events - onMount(async () => { - await initConfig(); - }); + // onMount(async () => { + // await initConfig(); + // if (!(await areRequirementsMet())) { + // await checkRequirements(); + // } + // await closeSplashScreen(); + // }); if (!isInDebugMode()) { revokeSpecificActions = true; @@ -54,12 +60,10 @@ -
-
- - - -
+
+ + +
diff --git a/src/components/console/Console.svelte b/src/components/console/Console.svelte index f6212c0..c3db080 100644 --- a/src/components/console/Console.svelte +++ b/src/components/console/Console.svelte @@ -1,12 +1,12 @@
Installation Logs -
+
{#if $Console} {$Console} {/if} diff --git a/src/components/console/console.css b/src/components/console/console.css index c661b10..d1fb747 100644 --- a/src/components/console/console.css +++ b/src/components/console/console.css @@ -7,6 +7,19 @@ font-family: monospace; } +details { + min-width: 75vw; + max-width: 75vw; +} + +summary { + text-align: center; +} + +.logContainer { + text-align: start; +} + details > summary:hover { cursor: pointer; } diff --git a/src/components/setup/Jak1Setup.svelte b/src/components/setup/Jak1Setup.svelte index 536beba..77fa5ef 100644 --- a/src/components/setup/Jak1Setup.svelte +++ b/src/components/setup/Jak1Setup.svelte @@ -1,14 +1,12 @@
-
- {#if !$isInstalling} - {#await areRequirementsMet() then requirementsMet} - {#if requirementsMet} - - {/if} - {/await} + {/if}
diff --git a/src/components/setup/progress.css b/src/components/setup/progress.css index 6dabf6b..d12b2e5 100644 --- a/src/components/setup/progress.css +++ b/src/components/setup/progress.css @@ -3,7 +3,7 @@ overflow: hidden; height: 30px; background-color: #ecf0f1; - width: 75%; + min-width: 45vw; margin: 20px auto; } diff --git a/src/lib/commands.ts b/src/lib/commands.ts index b1dd800..0915cd7 100644 --- a/src/lib/commands.ts +++ b/src/lib/commands.ts @@ -19,3 +19,11 @@ export async function openDir(dir: string): Promise { console.log(e); } } + +export async function closeSplashScreen() { + try { + invoke("close_splashscreen"); + } catch (e) { + console.log(e); + } +} diff --git a/src/lib/config.ts b/src/lib/config.ts index 6eb6ea8..8d7548d 100644 --- a/src/lib/config.ts +++ b/src/lib/config.ts @@ -2,6 +2,7 @@ import { createDir, writeFile } from "@tauri-apps/api/fs"; import { appDir, join } from "@tauri-apps/api/path"; import { Store } from "tauri-plugin-store-api"; import { SupportedGame } from "./constants"; +import { isAVXSupported } from "./setup"; import { fileExists } from "./utils/file"; class GameConfig { @@ -120,3 +121,32 @@ export async function setInstallStatus( await store.set("games", gameConfigs); await store.save(); } + +export async function setRequirementsMet( + avx: boolean = null, + openGL: boolean = null +) { + await store.load(); + await store.set("requirements", { avx, openGL }); + await store.save(); + + return; +} + +/** + * Checks the user config file to see if avx and openGL requirements are met. + */ +export async function areRequirementsMet(): Promise { + await store.load(); + let requirements = await store.get("requirements"); + if (!requirements.avx) { + console.log("Unsupported AVX"); + return false; + } + if (!requirements.openGL) { + console.log("Unsupported OpenGL"); + return false; + } + + return true; +} diff --git a/src/lib/constants.ts b/src/lib/constants.ts index 03a811e..4593209 100644 --- a/src/lib/constants.ts +++ b/src/lib/constants.ts @@ -1,23 +1,18 @@ // TODO: update setup status messages to use typescript export const SETUP_SUCCESS = { - avxSupported: { status: "AVX SUPPORTED", percent: 10 }, - openGLSupported: { status: "OPENGL SUPPORTED", percent: 20 }, - checkCompatible: { status: "Checking Compatibility", percent: 0 }, - awaitingISO: { status: "Awaiting ISO File", percent: 20 }, + awaitingISO: { status: "Awaiting ISO File", percent: 0 }, extractingISO: { status: "Extracting and Validating ISO contents", - percent: 40, + percent: 25, }, - decompiling: { status: "Decompiling the game", percent: 60 }, - compiling: { status: "Compiling the game", percent: 80 }, + decompiling: { status: "Decompiling the game", percent: 50 }, + compiling: { status: "Compiling the game", percent: 75 }, ready: { status: "Ready to Play!", percent: 100 }, }; export const SETUP_ERROR = { - unsupportedAVX: { status: "UNSUPPORTED AVX", percent: -1 }, noISO: { status: "No ISO File Selected!", percent: -1 }, unsupportedOS: { status: "Unsupported OS!", percent: -1 }, - unsupportedOpenGL: { status: "UNSUPPORTED OPENGL VERSION", percent: -1 }, }; export const enum SupportedGame { diff --git a/src/lib/setup.ts b/src/lib/setup.ts index acfe527..98e0aa4 100644 --- a/src/lib/setup.ts +++ b/src/lib/setup.ts @@ -5,6 +5,7 @@ import { getHighestSimd } from "$lib/commands"; import { InstallStatus } from "../stores/InstallStore"; import { SETUP_SUCCESS, SETUP_ERROR, SupportedGame } from "$lib/constants"; import { appendToInstallErrorLog, appendToInstallLog } from "$lib/utils/file"; +import { setRequirementsMet } from "./config"; let debugPath: string; let sidecarOptions = {}; @@ -24,14 +25,11 @@ if (isInDebugMode()) { export async function isAVXSupported() { const highestSIMD = await getHighestSimd(); if (highestSIMD === undefined) { - InstallStatus.update(() => SETUP_SUCCESS.avxSupported); return true; } if (highestSIMD.toLowerCase().startsWith("avx")) { - InstallStatus.set(SETUP_SUCCESS.avxSupported); return true; } - InstallStatus.update(() => SETUP_ERROR.unsupportedAVX); throw new Error("UNSUPPORTED AVX"); } @@ -43,9 +41,7 @@ export async function isOpenGLVersionSupported( version: string ): Promise { if ((await os.platform()) === "darwin") { - InstallStatus.update(() => SETUP_ERROR.unsupportedOS); throw new Error("Unsupported OS!"); - // return RequirementStatus.Unknown; } // Otherwise, query for the version let command = Command.sidecar( @@ -55,13 +51,22 @@ export async function isOpenGLVersionSupported( ); const output = await command.execute(); if (output.code === 0) { - InstallStatus.update(() => SETUP_SUCCESS.openGLSupported); return true; } - InstallStatus.update(() => SETUP_ERROR.unsupportedOpenGL); throw new Error("UNSUPPORTED OPENGL VERSION"); } +export async function checkRequirements(): Promise { + try { + await isAVXSupported(); + await isOpenGLVersionSupported("4.3"); + await setRequirementsMet(true, true); + return true; + } catch (err) { + return false; + } +} + /** * @param {String} filePath * @returns {Promise} diff --git a/src/routes/Jak1.svelte b/src/routes/Jak1.svelte index fa17618..e6f8547 100644 --- a/src/routes/Jak1.svelte +++ b/src/routes/Jak1.svelte @@ -1,7 +1,7 @@ diff --git a/src/splash/index.html b/src/splash/index.html new file mode 100644 index 0000000..11f66a4 --- /dev/null +++ b/src/splash/index.html @@ -0,0 +1,13 @@ + + + + + + + Splash + + + +
+ + diff --git a/src/splash/splash.css b/src/splash/splash.css new file mode 100644 index 0000000..1fd278c --- /dev/null +++ b/src/splash/splash.css @@ -0,0 +1,9 @@ +body { + padding: 0; + margin: 0; + overflow: hidden; + background-image: url("$assets/images/logo.png"); + background-repeat: no-repeat; + background-size: 100vw; + background-position: top; +} diff --git a/src/splash/splash.js b/src/splash/splash.js new file mode 100644 index 0000000..93163c8 --- /dev/null +++ b/src/splash/splash.js @@ -0,0 +1,7 @@ +import App from "./Splash.svelte"; + +const app = new App({ + target: document.getElementById("app"), +}); + +export default app; diff --git a/tsconfig.json b/tsconfig.json index 969d758..97883ee 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -48,7 +48,8 @@ "src/lib/constants.ts", "src/lib/config.ts", "src/lib/commands.ts", - "src/lib/utils/file.ts" + "src/lib/utils/file.ts", + "src/splash/splash.ts" ], "references": [ { diff --git a/vite.config.ts b/vite.config.ts index 8b508f2..4124a80 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,6 +1,7 @@ import { defineConfig } from "vite"; import { svelte } from "@sveltejs/vite-plugin-svelte"; import { fileURLToPath, URL } from "url"; +import { resolve } from "path"; // https://vitejs.dev/config/ export default defineConfig({ @@ -12,4 +13,14 @@ export default defineConfig({ }, }, optimizeDeps: { exclude: ["svelte-navigator"] }, + build: { + rollupOptions: { + input: { + main: fileURLToPath(new URL("./index.html", import.meta.url)), + splash: fileURLToPath( + new URL("./src/splash/index.html", import.meta.url) + ), + }, + }, + }, });