Skip to content

Commit

Permalink
jak2: prepare for jak 2 support (#341)
Browse files Browse the repository at this point in the history
  • Loading branch information
xTVaser authored Oct 10, 2023
1 parent 3f5c4cc commit 578855d
Show file tree
Hide file tree
Showing 10 changed files with 207 additions and 36 deletions.
100 changes: 77 additions & 23 deletions src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down
6 changes: 6 additions & 0 deletions src-tauri/src/commands/binaries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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(),
Expand Down
22 changes: 22 additions & 0 deletions src-tauri/src/commands/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<LauncherConfig>>,
game_name: String,
) -> Result<bool, CommandError> {
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),
}
}
1 change: 1 addition & 0 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
11 changes: 4 additions & 7 deletions src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down Expand Up @@ -82,12 +85,6 @@
primary={false}
let:params
/>
<Route
path="/jak2"
component={GameInProgress}
primary={false}
let:params
/>
<Route
path="/settings/:tab"
component={Settings}
Expand Down
11 changes: 10 additions & 1 deletion src/assets/translations/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -152,5 +152,14 @@
"update_changelog_header_pullRequest": "Pull Request",
"update_description": "View the changes below and click the button to update to the latest version. The launcher will restart when finished.",
"update_header": "Launcher Update Available",
"update_versionLabel": "Version"
"update_versionLabel": "Version",
"gameControls_toolingTooOld_button_setVersion": "Set Version",
"gameControls_toolingTooOld_header": "Tooling Version Does Not Support Game!",
"gameControls_toolingTooOld_subheader": "Head over to the following settings page to download the latest release",
"gameControls_beta_headerA": "Jak 2 is in Beta!",
"gameControls_beta_headerB": "You will encounter minor bugs and instability.",
"gameControls_beta_issueTracker_linkPreText": "For a list of all known issues, see",
"gameControls_beta_issueTracker_linkText": "here",
"gameControls_beta_bugReport_linkPreText": "To submit a non-duplicate bug report, see",
"gameControls_beta_bugReport_linkText": "here"
}
18 changes: 18 additions & 0 deletions src/components/games/GameNotSupportedByTooling.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<script>
import { Button } from "flowbite-svelte";
import { _ } from "svelte-i18n";
</script>

<div class="flex flex-col h-full justify-center items-center p-5 text-center">
<h1 class="text-2xl font-black mb-5 text-outline">
{$_("gameControls_toolingTooOld_header")}
</h1>
<p class="mb-10">
{$_("gameControls_toolingTooOld_subheader")}
</p>
<Button
class="border-solid border-2 border-slate-500 rounded bg-slate-900 hover:bg-slate-800 text-sm text-white font-semibold px-5 py-2"
href="/settings/versions"
>{$_("gameControls_toolingTooOld_button_setVersion")}</Button
>
</div>
12 changes: 12 additions & 0 deletions src/lib/rpc/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,3 +244,15 @@ export async function setEnabledTexturePacks(
},
);
}

export async function doesActiveToolingVersionSupportGame(
gameName: string,
): Promise<boolean> {
return await invoke_rpc(
"does_active_tooling_version_support_game",
{
gameName: gameName,
},
() => false,
);
}
Loading

0 comments on commit 578855d

Please sign in to comment.