always unpatch game on close

This commit is contained in:
SpikeHD 2022-07-13 18:55:06 -07:00
parent 33c733ce97
commit 7cbb600a7f
2 changed files with 11 additions and 0 deletions

View File

@ -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;
}
}

View File

@ -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<IProps, IState> {
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