From 1fa54a4ab19f4bc68b25b146735d0094d1ea0d65 Mon Sep 17 00:00:00 2001 From: Tyler Wilding Date: Mon, 9 Oct 2023 20:31:37 -0400 Subject: [PATCH 1/2] jak2: prepare for jak 2 support --- src-tauri/src/commands/binaries.rs | 6 ++ src-tauri/src/commands/config.rs | 22 ++++++++ src-tauri/src/main.rs | 1 + src/App.svelte | 11 ++-- src/assets/translations/en-US.json | 11 +++- .../games/GameNotSupportedByTooling.svelte | 18 ++++++ src/lib/rpc/config.ts | 12 ++++ src/routes/Game.svelte | 56 ++++++++++++++++++- 8 files changed, 126 insertions(+), 11 deletions(-) create mode 100644 src/components/games/GameNotSupportedByTooling.svelte diff --git a/src-tauri/src/commands/binaries.rs b/src-tauri/src/commands/binaries.rs index c23e878f..9e06b90d 100644 --- a/src-tauri/src/commands/binaries.rs +++ b/src-tauri/src/commands/binaries.rs @@ -289,6 +289,8 @@ pub async fn extract_and_validate_iso( let mut args = vec![ path_to_iso.clone(), + "--game".to_string(), + game_name.clone(), "--extract".to_string(), "--validate".to_string(), "--proj-path".to_string(), @@ -387,6 +389,8 @@ pub async fn run_decompiler( command .args([ source_path, + "--game".to_string(), + game_name.clone(), "--decompile".to_string(), "--proj-path".to_string(), data_folder.to_string_lossy().into_owned(), @@ -473,6 +477,8 @@ pub async fn run_compiler( command .args([ source_path, + "--game".to_string(), + game_name.clone(), "--compile".to_string(), "--proj-path".to_string(), data_folder.to_string_lossy().into_owned(), diff --git a/src-tauri/src/commands/config.rs b/src-tauri/src/commands/config.rs index e9d9b84a..b4c2167f 100644 --- a/src-tauri/src/commands/config.rs +++ b/src-tauri/src/commands/config.rs @@ -392,3 +392,25 @@ pub async fn set_enabled_texture_packs( })?; Ok(()) } + +#[tauri::command] +pub async fn does_active_tooling_version_support_game( + config: tauri::State<'_, tokio::sync::Mutex>, + game_name: String, +) -> Result { + let config_lock = config.lock().await; + // If we can't determine the version, assume its our first release + let active_version = config_lock + .active_version + .as_ref() + .ok_or(CommandError::Configuration( + "No active version set, can't perform operation".to_owned(), + ))?; + let tooling_version = Version::parse(active_version.strip_prefix('v').unwrap_or(&active_version)) + .unwrap_or(Version::new(0, 0, 1)); + match game_name.as_str() { + "jak1" => Ok(true), + "jak2" => Ok(tooling_version.minor >= 1 && tooling_version.patch >= 44), + _ => Ok(false), + } +} diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index ca402be4..a0976205 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -140,6 +140,7 @@ fn main() { commands::binaries::update_data_directory, commands::config::cleanup_enabled_texture_packs, commands::config::delete_old_data_directory, + commands::config::does_active_tooling_version_support_game, commands::config::finalize_installation, commands::config::get_active_tooling_version_folder, commands::config::get_active_tooling_version, diff --git a/src/App.svelte b/src/App.svelte index 8348e443..e901d6cf 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -29,7 +29,10 @@ window.sessionStorage.setItem("refreshHack", "true"); } // Set locale from settings - setLocale(await getLocale()); + const locale = await getLocale(); + if (locale !== null) { + setLocale(locale); + } }); if (!isInDebugMode()) { @@ -82,12 +85,6 @@ primary={false} let:params /> - + import { Button } from "flowbite-svelte"; + import { _ } from "svelte-i18n"; + + +
+

+ {$_("gameControls_toolingTooOld_header")} +

+

+ {$_("gameControls_toolingTooOld_subheader")} +

+ +
diff --git a/src/lib/rpc/config.ts b/src/lib/rpc/config.ts index 704fc946..abeec6ce 100644 --- a/src/lib/rpc/config.ts +++ b/src/lib/rpc/config.ts @@ -244,3 +244,15 @@ export async function setEnabledTexturePacks( }, ); } + +export async function doesActiveToolingVersionSupportGame( + gameName: string, +): Promise { + return await invoke_rpc( + "does_active_tooling_version_support_game", + { + gameName: gameName, + }, + () => false, + ); +} diff --git a/src/routes/Game.svelte b/src/routes/Game.svelte index 71b6b706..a7e9e909 100644 --- a/src/routes/Game.svelte +++ b/src/routes/Game.svelte @@ -4,8 +4,10 @@ import GameControls from "../components/games/GameControls.svelte"; import GameSetup from "../components/games/setup/GameSetup.svelte"; import { onMount } from "svelte"; - import { Spinner } from "flowbite-svelte"; + import { Alert, Spinner } from "flowbite-svelte"; + import { _ } from "svelte-i18n"; import { + doesActiveToolingVersionSupportGame, getInstalledVersion, getInstalledVersionFolder, isGameInstalled, @@ -18,9 +20,12 @@ getActiveVersionFolder, } from "$lib/rpc/versions"; import GameToolsNotSet from "../components/games/GameToolsNotSet.svelte"; + import GameNotSupportedByTooling from "../components/games/GameNotSupportedByTooling.svelte"; import { VersionStore } from "$lib/stores/VersionStore"; const params = useParams(); + $: $params, loadGameInfo(); + let activeGame = SupportedGame.Jak1; let componentLoaded = false; @@ -32,7 +37,15 @@ let versionMismatchDetected = false; + let gameInBeta = false; + let gameSupportedByTooling = false; + onMount(async () => { + loadGameInfo(); + }); + + async function loadGameInfo() { + componentLoaded = false; // Figure out what game we are displaying if ( $params["game_name"] !== undefined && @@ -44,6 +57,14 @@ activeGame = SupportedGame.Jak1; } + if (activeGame === SupportedGame.Jak2) { + gameInBeta = true; + } + + gameSupportedByTooling = await doesActiveToolingVersionSupportGame( + getInternalName(activeGame), + ); + // First off, check that they've downloaded and have a jak-project release set const activeVersionExists = await ensureActiveVersionStillExists(); $VersionStore.activeVersionType = await getActiveVersionFolder(); @@ -73,9 +94,9 @@ } componentLoaded = true; - }); + } - async function updateGameState(evt) { + async function updateGameState(event) { gameInstalled = await isGameInstalled(getInternalName(activeGame)); } @@ -94,6 +115,8 @@
+ {:else if !gameSupportedByTooling} + {:else if $VersionStore.activeVersionName === null || $VersionStore.activeVersionType === null} {:else if !gameInstalled} @@ -112,6 +135,33 @@ on:job={runGameJob} /> {:else} + + {$_("gameControls_beta_headerA")} + {$_("gameControls_beta_headerB")} +
+ +
Date: Mon, 9 Oct 2023 20:38:18 -0400 Subject: [PATCH 2/2] deps: update some deps and conditionally render beta alert --- src-tauri/Cargo.lock | 100 +++++++++++++++++++++++++++++++---------- src-tauri/Cargo.toml | 4 +- src/routes/Game.svelte | 56 ++++++++++++----------- 3 files changed, 108 insertions(+), 52 deletions(-) diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index a29b38c0..115a849c 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -1732,7 +1732,21 @@ checksum = "e5c13fb08e5d4dfc151ee5e88bae63f7773d61852f3bdc73c9f4b9e1bde03148" dependencies = [ "log", "mac", - "markup5ever", + "markup5ever 0.10.1", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "html5ever" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bea68cab48b8459f17cf1c944c67ddc572d272d9f2b274140f223ecb1da4a3b7" +dependencies = [ + "log", + "mac", + "markup5ever 0.11.0", "proc-macro2", "quote", "syn 1.0.109", @@ -2074,7 +2088,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1ea8e9c6e031377cff82ee3001dc8026cdf431ed4e2e6b51f98ab8c73484a358" dependencies = [ "cssparser", - "html5ever", + "html5ever 0.25.2", + "matches", + "selectors", +] + +[[package]] +name = "kuchikiki" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f29e4755b7b995046f510a7520c42b2fed58b77bd94d5a87a8eb43d2fd126da8" +dependencies = [ + "cssparser", + "html5ever 0.26.0", + "indexmap 1.9.3", "matches", "selectors", ] @@ -2199,7 +2226,21 @@ checksum = "a24f40fb03852d1cdd84330cddcaf98e9ec08a7b7768e952fad3b4cf048ec8fd" dependencies = [ "log", "phf 0.8.0", - "phf_codegen", + "phf_codegen 0.8.0", + "string_cache", + "string_cache_codegen", + "tendril", +] + +[[package]] +name = "markup5ever" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a2629bb1404f3d34c2e921f21fd34ba00b206124c81f65c50b43b6aaefeb016" +dependencies = [ + "log", + "phf 0.10.1", + "phf_codegen 0.10.0", "string_cache", "string_cache_codegen", "tendril", @@ -2778,6 +2819,16 @@ dependencies = [ "phf_shared 0.8.0", ] +[[package]] +name = "phf_codegen" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fb1c3a8bc4dd4e5cfce29b44ffc14bedd2ee294559a294e2a4d4c9e9a6a13cd" +dependencies = [ + "phf_generator 0.10.0", + "phf_shared 0.10.0", +] + [[package]] name = "phf_generator" version = "0.8.0" @@ -3398,7 +3449,7 @@ dependencies = [ "log", "matches", "phf 0.8.0", - "phf_codegen", + "phf_codegen 0.8.0", "precomputed-hash", "servo_arc", "smallvec", @@ -3925,9 +3976,9 @@ checksum = "9d0e916b1148c8e263850e1ebcbd046f333e0683c724876bb0da63ea4373dc8a" [[package]] name = "tauri" -version = "1.4.1" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fbe522898e35407a8e60dc3870f7579fea2fc262a6a6072eccdd37ae1e1d91e" +checksum = "0238c5063bf9613054149a1b6bce4935922e532b7d8211f36989a490a79806be" dependencies = [ "anyhow", "bytes", @@ -3980,12 +4031,13 @@ dependencies = [ [[package]] name = "tauri-build" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d2edd6a259b5591c8efdeb9d5702cb53515b82a6affebd55c7fd6d3a27b7d1b" +checksum = "defbfc551bd38ab997e5f8e458f87396d2559d05ce32095076ad6c30f7fc5f9c" dependencies = [ "anyhow", "cargo_toml", + "dirs-next", "heck 0.4.1", "json-patch", "semver", @@ -3993,13 +4045,14 @@ dependencies = [ "serde_json", "tauri-utils", "tauri-winres", + "walkdir", ] [[package]] name = "tauri-codegen" -version = "1.4.0" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54ad2d49fdeab4a08717f5b49a163bdc72efc3b1950b6758245fcde79b645e1a" +checksum = "7b3475e55acec0b4a50fb96435f19631fb58cbcd31923e1a213de5c382536bbb" dependencies = [ "base64 0.21.3", "brotli", @@ -4023,9 +4076,9 @@ dependencies = [ [[package]] name = "tauri-macros" -version = "1.4.0" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8eb12a2454e747896929338d93b0642144bb51e0dddbb36e579035731f0d76b7" +checksum = "613740228de92d9196b795ac455091d3a5fbdac2654abb8bb07d010b62ab43af" dependencies = [ "heck 0.4.1", "proc-macro2", @@ -4037,9 +4090,9 @@ dependencies = [ [[package]] name = "tauri-runtime" -version = "0.14.0" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "108683199cb18f96d2d4134187bb789964143c845d2d154848dda209191fd769" +checksum = "07f8e9e53e00e9f41212c115749e87d5cd2a9eebccafca77a19722eeecd56d43" dependencies = [ "gtk", "http", @@ -4058,9 +4111,9 @@ dependencies = [ [[package]] name = "tauri-runtime-wry" -version = "0.14.0" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b7aa256a1407a3a091b5d843eccc1a5042289baf0a43d1179d9f0fcfea37c1b" +checksum = "8141d72b6b65f2008911e9ef5b98a68d1e3413b7a1464e8f85eb3673bb19a895" dependencies = [ "cocoa", "gtk", @@ -4078,19 +4131,20 @@ dependencies = [ [[package]] name = "tauri-utils" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03fc02bb6072bb397e1d473c6f76c953cda48b4a2d0cce605df284aa74a12e84" +checksum = "34d55e185904a84a419308d523c2c6891d5e2dbcee740c4997eb42e75a7b0f46" dependencies = [ "brotli", "ctor", "dunce", "glob", "heck 0.4.1", - "html5ever", + "html5ever 0.26.0", "infer", "json-patch", - "kuchiki", + "kuchikiki", + "log", "memchr", "phf 0.10.1", "proc-macro2", @@ -5211,9 +5265,9 @@ dependencies = [ [[package]] name = "wry" -version = "0.24.3" +version = "0.24.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33748f35413c8a98d45f7a08832d848c0c5915501803d1faade5a4ebcd258cea" +checksum = "88ef04bdad49eba2e01f06e53688c8413bd6a87b0bc14b72284465cf96e3578e" dependencies = [ "base64 0.13.1", "block", @@ -5225,7 +5279,7 @@ dependencies = [ "gio", "glib", "gtk", - "html5ever", + "html5ever 0.25.2", "http", "kuchiki", "libc", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 7179575f..8993c75c 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -12,7 +12,7 @@ rust-version = "1.61" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [build-dependencies] -tauri-build = { version = "1.4.0", features = [] } +tauri-build = { version = "1.5.0", features = [] } [dependencies] backtrace = "0.3.69" @@ -32,7 +32,7 @@ serde = { version = "1.0", features = ["derive"] } serde_json = "1.0.107" sysinfo = "0.29.10" tar = "0.4.40" -tauri = { version = "1.4.1", features = ["api-all", "devtools", "reqwest-client"] } +tauri = { version = "1.5.1", features = ["api-all", "devtools", "reqwest-client"] } thiserror = "1.0.49" tokio = { version = "1", features = ["full"] } walkdir = "2.4.0" diff --git a/src/routes/Game.svelte b/src/routes/Game.svelte index a7e9e909..7609e0ab 100644 --- a/src/routes/Game.svelte +++ b/src/routes/Game.svelte @@ -135,33 +135,35 @@ on:job={runGameJob} /> {:else} - - {$_("gameControls_beta_headerA")} - {$_("gameControls_beta_headerB")} -
- -
+ {#if gameInBeta} + + {$_("gameControls_beta_headerA")} + {$_("gameControls_beta_headerB")} +
+ +
+ {/if}