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