mirror of
https://github.com/Grasscutters/Cultivation.git
synced 2025-12-15 16:44:43 +01:00
fix config stuff
This commit is contained in:
@@ -74,7 +74,7 @@ export default class ServerLaunchSection extends React.Component<IProps, IState>
|
|||||||
async playGame() {
|
async playGame() {
|
||||||
const config = await getConfig()
|
const config = await getConfig()
|
||||||
|
|
||||||
if (!config.game_path) return
|
if (!config.game_install_path) return
|
||||||
|
|
||||||
// Connect to proxy
|
// Connect to proxy
|
||||||
if (config.toggle_grasscutter) {
|
if (config.toggle_grasscutter) {
|
||||||
@@ -87,7 +87,7 @@ export default class ServerLaunchSection extends React.Component<IProps, IState>
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Launch the program
|
// Launch the program
|
||||||
await invoke('run_program', { path: config.game_path })
|
await invoke('run_program', { path: config.game_install_path })
|
||||||
}
|
}
|
||||||
|
|
||||||
async launchServer() {
|
async launchServer() {
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ interface IProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface IState {
|
interface IState {
|
||||||
game_path: string
|
game_install_path: string
|
||||||
grasscutter_path: string
|
grasscutter_path: string
|
||||||
grasscutter_with_game: boolean
|
grasscutter_with_game: boolean
|
||||||
}
|
}
|
||||||
@@ -21,7 +21,7 @@ export default class Options extends React.Component<IProps, IState> {
|
|||||||
super(props)
|
super(props)
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
game_path: '',
|
game_install_path: '',
|
||||||
grasscutter_path: '',
|
grasscutter_path: '',
|
||||||
grasscutter_with_game: false
|
grasscutter_with_game: false
|
||||||
}
|
}
|
||||||
@@ -30,7 +30,7 @@ export default class Options extends React.Component<IProps, IState> {
|
|||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
getConfig().then(config => {
|
getConfig().then(config => {
|
||||||
this.setState({
|
this.setState({
|
||||||
game_path: config.game_path || '',
|
game_install_path: config.game_install_path || '',
|
||||||
grasscutter_path: config.grasscutter_path || '',
|
grasscutter_path: config.grasscutter_path || '',
|
||||||
grasscutter_with_game: config.grasscutter_with_game || false
|
grasscutter_with_game: config.grasscutter_with_game || false
|
||||||
})
|
})
|
||||||
@@ -40,7 +40,7 @@ export default class Options extends React.Component<IProps, IState> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setGameExec(value: string) {
|
setGameExec(value: string) {
|
||||||
setConfigOption('game_path', value)
|
setConfigOption('game_install_path', value)
|
||||||
}
|
}
|
||||||
|
|
||||||
setGrasscutterJar(value: string) {
|
setGrasscutterJar(value: string) {
|
||||||
@@ -59,7 +59,7 @@ 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} extensions={['exe']} />
|
<DirInput onChange={this.setGameExec} value={this.state?.game_install_path} extensions={['exe']} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className='OptionSection'>
|
<div className='OptionSection'>
|
||||||
|
|||||||
@@ -14,10 +14,26 @@ let defaultConfig: Configuration
|
|||||||
grasscutter_with_game: false,
|
grasscutter_with_game: false,
|
||||||
grasscutter_path: roamingAppData + '\\cultivation\\grasscutter.jar',
|
grasscutter_path: roamingAppData + '\\cultivation\\grasscutter.jar',
|
||||||
close_action: 0,
|
close_action: 0,
|
||||||
startup_launch: false
|
startup_launch: false,
|
||||||
|
last_ip: '',
|
||||||
|
last_port: '',
|
||||||
}
|
}
|
||||||
})()
|
})()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 'close_action': 0 = close, 1 = tray
|
||||||
|
*/
|
||||||
|
export interface Configuration {
|
||||||
|
toggle_grasscutter: boolean
|
||||||
|
game_install_path: string
|
||||||
|
grasscutter_with_game: boolean
|
||||||
|
grasscutter_path: string
|
||||||
|
close_action: number
|
||||||
|
startup_launch: boolean
|
||||||
|
last_ip: string
|
||||||
|
last_port: string
|
||||||
|
}
|
||||||
|
|
||||||
export async function setConfigOption(key: string, value: any): Promise<void> {
|
export async function setConfigOption(key: string, value: any): Promise<void> {
|
||||||
const config = await getConfig()
|
const config = await getConfig()
|
||||||
|
|
||||||
@@ -91,15 +107,3 @@ async function writeConfigFile(raw: string) {
|
|||||||
contents: raw
|
contents: raw
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 'close_action': 0 = close, 1 = tray
|
|
||||||
*/
|
|
||||||
export interface Configuration {
|
|
||||||
toggle_grasscutter: boolean
|
|
||||||
game_install_path: string
|
|
||||||
grasscutter_with_game: boolean
|
|
||||||
grasscutter_path: string
|
|
||||||
close_action: number
|
|
||||||
startup_launch: boolean
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user