mirror of
https://github.com/Grasscutters/Cultivation.git
synced 2025-12-14 16:14:48 +01:00
grasscutter jar config option
This commit is contained in:
@@ -6,7 +6,8 @@
|
||||
"gc_enable": "Connect via Grasscutter"
|
||||
},
|
||||
"options": {
|
||||
"game_exec": "Set Game Executable"
|
||||
"game_exec": "Set Game Executable",
|
||||
"grasscutter_jar": "Set Grasscutter Jar"
|
||||
},
|
||||
"components": {
|
||||
"select_file": "Select file or folder..."
|
||||
|
||||
@@ -9,6 +9,7 @@ import './DirInput.css'
|
||||
interface IProps {
|
||||
value?: string
|
||||
onChange?: (value: string) => void
|
||||
extensions?: string[]
|
||||
}
|
||||
|
||||
interface IState {
|
||||
@@ -44,7 +45,7 @@ export default class DirInput extends React.Component<IProps, IState> {
|
||||
async handleIconClick() {
|
||||
let path = await open({
|
||||
filters: [
|
||||
{ name: 'Executable files', extensions: ['exe'] }
|
||||
{ name: 'Files', extensions: this.props.extensions || ['*'] }
|
||||
]
|
||||
})
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import DirInput from '../common/DirInput'
|
||||
import Menu from './Menu'
|
||||
import Tr from '../../../utils/language'
|
||||
import './Options.css'
|
||||
import { getConfigOption, setConfigOption } from '../../../utils/configuration'
|
||||
import { setConfigOption, getConfig } from '../../../utils/configuration'
|
||||
|
||||
interface IProps {
|
||||
closeFn: () => void;
|
||||
@@ -11,6 +11,7 @@ interface IProps {
|
||||
|
||||
interface IState {
|
||||
game_path: string
|
||||
grasscutter_path: string
|
||||
}
|
||||
|
||||
export default class Options extends React.Component<IProps, IState> {
|
||||
@@ -19,13 +20,15 @@ export default class Options extends React.Component<IProps, IState> {
|
||||
|
||||
this.state = {
|
||||
game_path: '',
|
||||
grasscutter_path: ''
|
||||
}
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
getConfigOption('game_path').then((value: string) => {
|
||||
getConfig().then(config => {
|
||||
this.setState({
|
||||
game_path: value || ''
|
||||
game_path: config.game_path || '',
|
||||
grasscutter_path: config.grasscutter_path || ''
|
||||
})
|
||||
})
|
||||
|
||||
@@ -36,6 +39,10 @@ export default class Options extends React.Component<IProps, IState> {
|
||||
setConfigOption('game_path', value)
|
||||
}
|
||||
|
||||
setGrasscutterJar(value: string) {
|
||||
setConfigOption('grasscutter_path', value)
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<Menu closeFn={this.props.closeFn} className="Options" heading="Options">
|
||||
@@ -44,7 +51,15 @@ export default class Options extends React.Component<IProps, IState> {
|
||||
<Tr text="options.game_exec" />
|
||||
</div>
|
||||
<div className='OptionValue'>
|
||||
<DirInput onChange={this.setGameExec} value={this.state?.game_path}/>
|
||||
<DirInput onChange={this.setGameExec} value={this.state?.game_path} extensions={['exe']} />
|
||||
</div>
|
||||
</div>
|
||||
<div className='OptionSection'>
|
||||
<div className='OptionLabel'>
|
||||
<Tr text="options.grasscutter_jar" />
|
||||
</div>
|
||||
<div className='OptionValue'>
|
||||
<DirInput onChange={this.setGrasscutterJar} value={this.state?.grasscutter_path} extensions={['jar']} />
|
||||
</div>
|
||||
</div>
|
||||
</Menu>
|
||||
|
||||
Reference in New Issue
Block a user