mirror of
https://github.com/open-goal/launcher.git
synced 2024-10-20 04:57:38 -04:00
frontend: update background when a game is uninstalled/installed
This commit is contained in:
parent
9952261eb5
commit
4435296c42
|
@ -1,4 +1,5 @@
|
|||
use crate::config::LauncherConfig;
|
||||
use tauri::Manager;
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn get_install_directory(
|
||||
|
@ -48,10 +49,12 @@ pub async fn is_opengl_requirement_met(
|
|||
#[tauri::command]
|
||||
pub async fn finalize_installation(
|
||||
config: tauri::State<'_, tokio::sync::Mutex<LauncherConfig>>,
|
||||
app_handle: tauri::AppHandle,
|
||||
game_name: String,
|
||||
) -> Result<(), ()> {
|
||||
let mut config_lock = config.lock().await;
|
||||
config_lock.update_installed_game_version(game_name, true);
|
||||
app_handle.emit_all("gameInstalled", {}).unwrap();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
use std::{path::Path, process::Command};
|
||||
|
||||
use tauri::Manager;
|
||||
|
||||
use crate::config::LauncherConfig;
|
||||
|
||||
#[tauri::command]
|
||||
|
@ -41,6 +43,7 @@ pub async fn launch_game(
|
|||
#[tauri::command]
|
||||
pub async fn uninstall_game(
|
||||
config: tauri::State<'_, tokio::sync::Mutex<LauncherConfig>>,
|
||||
app_handle: tauri::AppHandle,
|
||||
game_name: String,
|
||||
) -> Result<(), ()> {
|
||||
let mut config_lock = config.lock().await;
|
||||
|
@ -53,6 +56,7 @@ pub async fn uninstall_game(
|
|||
std::fs::remove_dir_all(data_folder.join("iso_data"));
|
||||
std::fs::remove_dir_all(data_folder.join("out"));
|
||||
config_lock.update_installed_game_version(game_name, false);
|
||||
app_handle.emit_all("gameUninstalled", {}).unwrap();
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,18 +1,28 @@
|
|||
<script lang="ts">
|
||||
import bgVideoJak1 from "$assets/videos/background-jak1.mp4";
|
||||
// TODO - remake the poster images to be the actual first frame, at the same dimensions
|
||||
// TODO - remake the poster images to be the actual first frame, with the same dimensions
|
||||
import bgVideoPosterJak1 from "$assets/images/background-jak1-fallback.webp";
|
||||
import bgVideoJak2 from "$assets/videos/background-jak2.webm";
|
||||
import bgVideoPosterJak2 from "$assets/images/background-jak2-fallback.png";
|
||||
import { useLocation } from "svelte-navigator";
|
||||
import { isGameInstalled } from "$lib/rpc/config";
|
||||
import { onMount } from "svelte";
|
||||
import { listen } from "@tauri-apps/api/event";
|
||||
|
||||
const location = useLocation();
|
||||
$: $location.pathname, updateStyle();
|
||||
// TODO - also update once installation completes (store / dispatch?)
|
||||
|
||||
let style = "";
|
||||
|
||||
onMount(async () => {
|
||||
const unlistenInstalled = await listen("gameInstalled", (event) => {
|
||||
updateStyle();
|
||||
});
|
||||
const unlistenUninstalled = await listen("gameUninstalled", (event) => {
|
||||
updateStyle();
|
||||
});
|
||||
});
|
||||
|
||||
async function updateStyle(): Promise<void> {
|
||||
let newStyle = "absolute -z-50 object-fill h-screen";
|
||||
let pathname = $location.pathname;
|
||||
|
|
Loading…
Reference in a new issue