mirror of
https://github.com/Grasscutters/Cultivation.git
synced 2025-12-12 23:24:35 +01:00
fix game opening
This commit is contained in:
@@ -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>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user