Skip to content

Commit

Permalink
jak2: prepare for jak 2 support
Browse files Browse the repository at this point in the history
  • Loading branch information
xTVaser committed Oct 10, 2023
1 parent 83abded commit 1fa54a4
Show file tree
Hide file tree
Showing 8 changed files with 126 additions and 11 deletions.
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,
);
}
56 changes: 53 additions & 3 deletions src/routes/Game.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;
Expand All @@ -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 &&
Expand All @@ -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();
Expand Down Expand Up @@ -73,9 +94,9 @@
}
componentLoaded = true;
});
}
async function updateGameState(evt) {
async function updateGameState(event) {
gameInstalled = await isGameInstalled(getInternalName(activeGame));
}
Expand All @@ -94,6 +115,8 @@
<div class="flex flex-col h-full justify-center items-center">
<Spinner color="yellow" size={"12"} />
</div>
{:else if !gameSupportedByTooling}
<GameNotSupportedByTooling />
{:else if $VersionStore.activeVersionName === null || $VersionStore.activeVersionType === null}
<GameToolsNotSet />
{:else if !gameInstalled}
Expand All @@ -112,6 +135,33 @@
on:job={runGameJob}
/>
{:else}
<Alert color="red" rounded={false} class="border-t-4">
<span class="font-bold">{$_("gameControls_beta_headerA")}</span>
<em>{$_("gameControls_beta_headerB")}</em>
<br />
<ul>
<li>
{$_("gameControls_beta_issueTracker_linkPreText")}
<a
class="text-blue-400"
href="https://github.com/orgs/open-goal/projects/3/views/8?query=is%3Aopen+sort%3Aupdated-desc"
target="_blank"
rel="noopener noreferrer"
>{$_("gameControls_beta_issueTracker_linkText")}</a
>
</li>
<li>
{$_("gameControls_beta_bugReport_linkPreText")}
<a
class="text-blue-400"
href="https://github.com/open-goal/jak-project/issues/new?assignees=&labels=bug%2Cjak2&projects=&template=jak2-bug-report.yml"
target="_blank"
rel="noopener noreferrer"
>{$_("gameControls_beta_bugReport_linkText")}</a
>
</li>
</ul>
</Alert>
<GameControls
{activeGame}
on:change={updateGameState}
Expand Down

0 comments on commit 1fa54a4

Please sign in to comment.