From b222601cf1e44871e7cd7b64ab03d376a27810ad Mon Sep 17 00:00:00 2001 From: Thoronium <107363768+NotThorny@users.noreply.github.com> Date: Sat, 9 Sep 2023 22:11:45 -0600 Subject: [PATCH] Close handling --- src/ui/components/TopBar.tsx | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/ui/components/TopBar.tsx b/src/ui/components/TopBar.tsx index 42edddd..1b19d42 100644 --- a/src/ui/components/TopBar.tsx +++ b/src/ui/components/TopBar.tsx @@ -1,12 +1,14 @@ import React from 'react' -import { app } from '@tauri-apps/api' +import { app, invoke } from '@tauri-apps/api' import { appWindow } from '@tauri-apps/api/window' import { getConfig, setConfigOption } from '../../utils/configuration' import Tr from '../../utils/language' +import { confirm } from '@tauri-apps/api/dialog' import './TopBar.css' import closeIcon from '../../resources/icons/close.svg' import minIcon from '../../resources/icons/min.svg' +import { unpatchGame } from '../../utils/rsa' interface IProps { children?: React.ReactNode | React.ReactNode[] @@ -36,7 +38,19 @@ export default class TopBar extends React.Component { this.setState({ version }) } - handleClose() { + async handleClose() { + if (await invoke('is_game_running')) { + const confirmed = await confirm( + 'Game is running. You WILL NOT be unpatched. Would you like to exit?', + 'WARNING!!' + ) + if (!confirmed) { + return + } + } + + await invoke('disconnect') + unpatchGame() appWindow.close() }