diff --git a/lang/en.json b/lang/en.json index ea6ea05..99deb31 100644 --- a/lang/en.json +++ b/lang/en.json @@ -7,7 +7,8 @@ }, "options": { "game_exec": "Set Game Executable", - "grasscutter_jar": "Set Grasscutter Jar" + "grasscutter_jar": "Set Grasscutter Jar", + "grasscutter_with_game": "Automatically launch Grasscutter with the game" }, "components": { "select_file": "Select file or folder..." diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 927897b..6052185 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -258,9 +258,7 @@ version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ba3569f383e8f1598449f1a423e72e99569137b47740b1da11ef19af3d5c3223" dependencies = [ - "lazy_static", "memchr", - "regex-automata", ] [[package]] @@ -644,7 +642,7 @@ dependencies = [ "futures-util", "hudsucker", "lazy_static", - "opener", + "open", "registry", "reqwest", "rustls-pemfile", @@ -2242,16 +2240,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "opener" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ea3ebcd72a54701f56345f16785a6d3ac2df7e986d273eb4395c0b01db17952" -dependencies = [ - "bstr", - "winapi", -] - [[package]] name = "openssl" version = "0.10.40" diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 00e9a32..f5bc100 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -25,7 +25,7 @@ lazy_static = "1.4.0" # Access to the Windows Registry. registry = "1.2.1" # Program opener. -opener = "0.5.0" +open = "2.1.2" # Dependencies for the HTTP(S) proxy. hudsucker = "0.17.2" diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 59d341b..2727613 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -3,7 +3,7 @@ all(not(debug_assertions), target_os = "windows"), windows_subsystem = "windows" )] -use opener; +use open; mod downloader; mod lang; @@ -44,6 +44,5 @@ fn disconnect() { #[tauri::command] fn run_program(path: String) { // Open the program from the specified path. - opener::open(path.clone()) - .expect("Failed to open program"); + open::that(path).expect("Failed to open program"); } \ No newline at end of file diff --git a/src/ui/components/common/Checkbox.tsx b/src/ui/components/common/Checkbox.tsx index 5a1a19a..7733053 100644 --- a/src/ui/components/common/Checkbox.tsx +++ b/src/ui/components/common/Checkbox.tsx @@ -4,7 +4,7 @@ import checkmark from '../../../resources/icons/check.svg' import './Checkbox.css' interface IProps { - label: string, + label?: string, checked: boolean, onChange: () => void, id: string @@ -36,7 +36,7 @@ export default class Checkbox extends React.Component {
{this.state.checked ? Checkmark : null}
- {this.props.label} + {this.props.label || ''} ) diff --git a/src/ui/components/menu/Options.tsx b/src/ui/components/menu/Options.tsx index d093ade..42ff2a4 100644 --- a/src/ui/components/menu/Options.tsx +++ b/src/ui/components/menu/Options.tsx @@ -3,7 +3,8 @@ import DirInput from '../common/DirInput' import Menu from './Menu' import Tr from '../../../utils/language' import './Options.css' -import { setConfigOption, getConfig } from '../../../utils/configuration' +import { setConfigOption, getConfig, getConfigOption } from '../../../utils/configuration' +import Checkbox from '../common/Checkbox' interface IProps { closeFn: () => void; @@ -12,6 +13,7 @@ interface IProps { interface IState { game_path: string grasscutter_path: string + grasscutter_with_game: boolean } export default class Options extends React.Component { @@ -20,7 +22,8 @@ export default class Options extends React.Component { this.state = { game_path: '', - grasscutter_path: '' + grasscutter_path: '', + grasscutter_with_game: false } } @@ -28,7 +31,8 @@ export default class Options extends React.Component { getConfig().then(config => { this.setState({ game_path: config.game_path || '', - grasscutter_path: config.grasscutter_path || '' + grasscutter_path: config.grasscutter_path || '', + grasscutter_with_game: config.grasscutter_with_game || false }) }) @@ -43,6 +47,10 @@ export default class Options extends React.Component { setConfigOption('grasscutter_path', value) } + async toggleGrasscutterWithGame() { + setConfigOption('grasscutter_with_game', !(await getConfigOption('grasscutter_with_game'))) + } + render() { return ( @@ -62,6 +70,14 @@ export default class Options extends React.Component { +
+
+ +
+
+ +
+
) }