mirror of
https://github.com/Grasscutters/Cultivation.git
synced 2025-12-15 00:24:45 +01:00
fix game opening
This commit is contained in:
@@ -7,7 +7,8 @@
|
|||||||
},
|
},
|
||||||
"options": {
|
"options": {
|
||||||
"game_exec": "Set Game Executable",
|
"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": {
|
"components": {
|
||||||
"select_file": "Select file or folder..."
|
"select_file": "Select file or folder..."
|
||||||
|
|||||||
14
src-tauri/Cargo.lock
generated
14
src-tauri/Cargo.lock
generated
@@ -258,9 +258,7 @@ version = "0.2.17"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ba3569f383e8f1598449f1a423e72e99569137b47740b1da11ef19af3d5c3223"
|
checksum = "ba3569f383e8f1598449f1a423e72e99569137b47740b1da11ef19af3d5c3223"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"lazy_static",
|
|
||||||
"memchr",
|
"memchr",
|
||||||
"regex-automata",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -644,7 +642,7 @@ dependencies = [
|
|||||||
"futures-util",
|
"futures-util",
|
||||||
"hudsucker",
|
"hudsucker",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"opener",
|
"open",
|
||||||
"registry",
|
"registry",
|
||||||
"reqwest",
|
"reqwest",
|
||||||
"rustls-pemfile",
|
"rustls-pemfile",
|
||||||
@@ -2242,16 +2240,6 @@ dependencies = [
|
|||||||
"winapi",
|
"winapi",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "opener"
|
|
||||||
version = "0.5.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "4ea3ebcd72a54701f56345f16785a6d3ac2df7e986d273eb4395c0b01db17952"
|
|
||||||
dependencies = [
|
|
||||||
"bstr",
|
|
||||||
"winapi",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "openssl"
|
name = "openssl"
|
||||||
version = "0.10.40"
|
version = "0.10.40"
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ lazy_static = "1.4.0"
|
|||||||
# Access to the Windows Registry.
|
# Access to the Windows Registry.
|
||||||
registry = "1.2.1"
|
registry = "1.2.1"
|
||||||
# Program opener.
|
# Program opener.
|
||||||
opener = "0.5.0"
|
open = "2.1.2"
|
||||||
|
|
||||||
# Dependencies for the HTTP(S) proxy.
|
# Dependencies for the HTTP(S) proxy.
|
||||||
hudsucker = "0.17.2"
|
hudsucker = "0.17.2"
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ all(not(debug_assertions), target_os = "windows"),
|
|||||||
windows_subsystem = "windows"
|
windows_subsystem = "windows"
|
||||||
)]
|
)]
|
||||||
|
|
||||||
use opener;
|
use open;
|
||||||
|
|
||||||
mod downloader;
|
mod downloader;
|
||||||
mod lang;
|
mod lang;
|
||||||
@@ -44,6 +44,5 @@ fn disconnect() {
|
|||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
fn run_program(path: String) {
|
fn run_program(path: String) {
|
||||||
// Open the program from the specified path.
|
// Open the program from the specified path.
|
||||||
opener::open(path.clone())
|
open::that(path).expect("Failed to open program");
|
||||||
.expect("Failed to open program");
|
|
||||||
}
|
}
|
||||||
@@ -4,7 +4,7 @@ import checkmark from '../../../resources/icons/check.svg'
|
|||||||
import './Checkbox.css'
|
import './Checkbox.css'
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
label: string,
|
label?: string,
|
||||||
checked: boolean,
|
checked: boolean,
|
||||||
onChange: () => void,
|
onChange: () => void,
|
||||||
id: string
|
id: string
|
||||||
@@ -36,7 +36,7 @@ export default class Checkbox extends React.Component<IProps, IState> {
|
|||||||
<div className="CheckboxDisplay">
|
<div className="CheckboxDisplay">
|
||||||
{this.state.checked ? <img src={checkmark} alt='Checkmark' /> : null}
|
{this.state.checked ? <img src={checkmark} alt='Checkmark' /> : null}
|
||||||
</div>
|
</div>
|
||||||
<span>{this.props.label}</span>
|
<span>{this.props.label || ''}</span>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -3,7 +3,8 @@ import DirInput from '../common/DirInput'
|
|||||||
import Menu from './Menu'
|
import Menu from './Menu'
|
||||||
import Tr from '../../../utils/language'
|
import Tr from '../../../utils/language'
|
||||||
import './Options.css'
|
import './Options.css'
|
||||||
import { setConfigOption, getConfig } from '../../../utils/configuration'
|
import { setConfigOption, getConfig, getConfigOption } from '../../../utils/configuration'
|
||||||
|
import Checkbox from '../common/Checkbox'
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
closeFn: () => void;
|
closeFn: () => void;
|
||||||
@@ -12,6 +13,7 @@ interface IProps {
|
|||||||
interface IState {
|
interface IState {
|
||||||
game_path: string
|
game_path: string
|
||||||
grasscutter_path: string
|
grasscutter_path: string
|
||||||
|
grasscutter_with_game: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class Options extends React.Component<IProps, IState> {
|
export default class Options extends React.Component<IProps, IState> {
|
||||||
@@ -20,7 +22,8 @@ export default class Options extends React.Component<IProps, IState> {
|
|||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
game_path: '',
|
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 => {
|
getConfig().then(config => {
|
||||||
this.setState({
|
this.setState({
|
||||||
game_path: config.game_path || '',
|
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)
|
setConfigOption('grasscutter_path', value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async toggleGrasscutterWithGame() {
|
||||||
|
setConfigOption('grasscutter_with_game', !(await getConfigOption('grasscutter_with_game')))
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<Menu closeFn={this.props.closeFn} className="Options" heading="Options">
|
<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']} />
|
<DirInput onChange={this.setGrasscutterJar} value={this.state?.grasscutter_path} extensions={['jar']} />
|
||||||
</div>
|
</div>
|
||||||
</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>
|
</Menu>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user