fix game opening

This commit is contained in:
SpikeHD 2022-05-13 20:27:48 -07:00
parent 642405b888
commit a6b5891857
6 changed files with 27 additions and 23 deletions

View File

@ -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..."

14
src-tauri/Cargo.lock generated
View File

@ -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"

View File

@ -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"

View File

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

View File

@ -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<IProps, IState> {
<div className="CheckboxDisplay">
{this.state.checked ? <img src={checkmark} alt='Checkmark' /> : null}
</div>
<span>{this.props.label}</span>
<span>{this.props.label || ''}</span>
</label>
</div>
)

View File

@ -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<IProps, IState> {
@ -20,7 +22,8 @@ export default class Options extends React.Component<IProps, IState> {
this.state = {
game_path: '',
grasscutter_path: ''
grasscutter_path: '',
grasscutter_with_game: false
}
}
@ -28,7 +31,8 @@ export default class Options extends React.Component<IProps, IState> {
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<IProps, IState> {
setConfigOption('grasscutter_path', value)
}
async toggleGrasscutterWithGame() {
setConfigOption('grasscutter_with_game', !(await getConfigOption('grasscutter_with_game')))
}
render() {
return (
<Menu closeFn={this.props.closeFn} className="Options" heading="Options">
@ -62,6 +70,14 @@ export default class Options extends React.Component<IProps, IState> {
<DirInput onChange={this.setGrasscutterJar} value={this.state?.grasscutter_path} extensions={['jar']} />
</div>
</div>
<div className='OptionSection'>
<div className='OptionLabel'>
<Tr text="options.grasscutter_with_game" />
</div>
<div className='OptionValue'>
<Checkbox onChange={this.toggleGrasscutterWithGame} checked={this.state?.grasscutter_with_game} id="gcWithGame" />
</div>
</div>
</Menu>
)
}