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

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