From 92f51cc306f59fd74eb6eb2be0d006a15badd7fc Mon Sep 17 00:00:00 2001 From: SpikeHD Date: Sun, 29 May 2022 22:04:17 -0700 Subject: [PATCH 1/2] do not show prog bar when not downloading --- src/ui/App.tsx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/ui/App.tsx b/src/ui/App.tsx index 510a776..b12f3fe 100644 --- a/src/ui/App.tsx +++ b/src/ui/App.tsx @@ -83,6 +83,15 @@ class App extends React.Component { await setConfigOption('cert_generated', true) } + + // Period check to only show progress bar when downloading files + setInterval(() => { + this.setState({ + isDownloading: downloadHandler.getDownloads().filter(d => d.status !== 'finished')?.length > 0 + }) + + console.log(downloadHandler.getDownloads()) + }, 1000) } render() { @@ -156,7 +165,9 @@ class App extends React.Component {
this.setState({ miniDownloadsOpen: !this.state.miniDownloadsOpen })} > - + { this.state.isDownloading ? + + : null }
From 28c55812158a6a3ddf98528465ddb71908e8fd53 Mon Sep 17 00:00:00 2001 From: SpikeHD Date: Sun, 29 May 2022 22:30:10 -0700 Subject: [PATCH 2/2] minimize/maximize on game open/close --- src-tauri/src/main.rs | 9 +++++++++ src/ui/App.tsx | 18 ++++++++++++++++-- src/ui/components/ServerLaunchSection.tsx | 3 --- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 7995859..e2bce0b 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -37,6 +37,7 @@ fn main() { req_get, get_bg_file, base64_decode, + is_game_running, system_helpers::run_command, system_helpers::run_program, system_helpers::run_jar, @@ -91,6 +92,14 @@ fn process_watcher() { }); } +#[tauri::command] +fn is_game_running() -> bool { + // Grab the game process name + let proc = WATCH_GAME_PROCESS.lock().unwrap().to_string(); + + return !&proc.is_empty(); +} + #[tauri::command] fn enable_process_watcher(process: String) { *WATCH_GAME_PROCESS.lock().unwrap() = process; diff --git a/src/ui/App.tsx b/src/ui/App.tsx index b12f3fe..7446667 100644 --- a/src/ui/App.tsx +++ b/src/ui/App.tsx @@ -19,6 +19,7 @@ import RightBar from './components/RightBar' import { getConfigOption, setConfigOption } from '../utils/configuration' import { invoke } from '@tauri-apps/api' import { dataDir } from '@tauri-apps/api/path' +import { appWindow } from '@tauri-apps/api/window' interface IProps { [key: string]: never; @@ -54,6 +55,21 @@ class App extends React.Component { listen('jar_extracted', ({ payload }) => { setConfigOption('grasscutter_path', payload) }) + + let min = false + + // periodically check if we need to min/max based on whether the game is open + setInterval(async () => { + const gameOpen = await invoke('is_game_running') + + if (gameOpen && !min) { + appWindow.minimize() + min = true + } else if (!gameOpen && min) { + appWindow.unminimize() + min = false + } + }, 1000) } async componentDidMount() { @@ -89,8 +105,6 @@ class App extends React.Component { this.setState({ isDownloading: downloadHandler.getDownloads().filter(d => d.status !== 'finished')?.length > 0 }) - - console.log(downloadHandler.getDownloads()) }, 1000) } diff --git a/src/ui/components/ServerLaunchSection.tsx b/src/ui/components/ServerLaunchSection.tsx index 609b309..e4953c5 100644 --- a/src/ui/components/ServerLaunchSection.tsx +++ b/src/ui/components/ServerLaunchSection.tsx @@ -52,9 +52,6 @@ export default class ServerLaunchSection extends React.Component async componentDidMount() { const config = await getConfig() - console.log(config.last_ip) - console.log(config.last_port) - this.setState({ grasscutterEnabled: config.toggle_grasscutter, buttonLabel: await translate('main.launch_button'),