From 1fa54a4ab19f4bc68b25b146735d0094d1ea0d65 Mon Sep 17 00:00:00 2001 From: Tyler Wilding Date: Mon, 9 Oct 2023 20:31:37 -0400 Subject: [PATCH] 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")} +
+ +