diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index e1c2831..055516d 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -101,6 +101,7 @@ fn enable_process_watcher(window: tauri::Window,process: String) { *WATCH_GAME_PROCESS.lock().unwrap() = "".to_string(); disconnect(); + window.emit("game_closed", &()).unwrap(); break; } } diff --git a/src/ui/App.tsx b/src/ui/App.tsx index 92277a4..79eb54a 100644 --- a/src/ui/App.tsx +++ b/src/ui/App.tsx @@ -22,6 +22,7 @@ import { dataDir } from '@tauri-apps/api/path' import { appWindow } from '@tauri-apps/api/window' import { convertFileSrc } from '@tauri-apps/api/tauri' import { getTheme, loadTheme } from '../utils/themes' +import { unpatchGame } from '../utils/metadata' interface IProps { [key: string]: never; @@ -60,6 +61,15 @@ class App extends React.Component { setConfigOption('grasscutter_path', payload) }) + // Emitted for metadata replacing-purposes + listen('game_closed', async () => { + const unpatched = await unpatchGame() + + if (!unpatched) { + alert(`Could not unpatch game! (You should be able to find your metadata backup in ${await dataDir()}\\cultivation\\)`) + } + }) + let min = false // periodically check if we need to min/max based on whether the game is open