mirror of
https://github.com/Grasscutters/Cultivation.git
synced 2025-12-15 16:44:43 +01:00
allow custom java set
This commit is contained in:
@@ -12,6 +12,7 @@
|
|||||||
"options": {
|
"options": {
|
||||||
"game_exec": "Set Game Executable",
|
"game_exec": "Set Game Executable",
|
||||||
"grasscutter_jar": "Set Grasscutter Jar",
|
"grasscutter_jar": "Set Grasscutter Jar",
|
||||||
|
"java_path": "Set Custom Java Path",
|
||||||
"grasscutter_with_game": "Automatically launch Grasscutter with game"
|
"grasscutter_with_game": "Automatically launch Grasscutter with game"
|
||||||
},
|
},
|
||||||
"downloads": {
|
"downloads": {
|
||||||
|
|||||||
@@ -71,9 +71,15 @@ fn run_program(path: String) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
fn run_jar(path: String, execute_in: String) {
|
fn run_jar(path: String, execute_in: String, java_path: String) {
|
||||||
|
let mut command = if java_path.is_empty() {
|
||||||
|
format!("java -jar {}", path)
|
||||||
|
} else {
|
||||||
|
format!("\"{}\" -jar {}", java_path, path)
|
||||||
|
};
|
||||||
|
|
||||||
// Open the program from the specified path.
|
// Open the program from the specified path.
|
||||||
match open::with(format!("/k cd /D \"{}\" & java -jar {}", &execute_in, &path).to_string(), "C:\\Windows\\System32\\cmd.exe") {
|
match open::with(format!("/k cd /D \"{}\" & {}", &execute_in, &command).to_string(), "C:\\Windows\\System32\\cmd.exe") {
|
||||||
Ok(_) => (),
|
Ok(_) => (),
|
||||||
Err(e) => println!("Failed to open jar ({} from {}): {}", &path, &execute_in, e),
|
Err(e) => println!("Failed to open jar ({} from {}): {}", &path, &execute_in, e),
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -106,7 +106,8 @@ export default class ServerLaunchSection extends React.Component<IProps, IState>
|
|||||||
// Launch the jar
|
// Launch the jar
|
||||||
await invoke('run_jar', {
|
await invoke('run_jar', {
|
||||||
path: config.grasscutter_path,
|
path: config.grasscutter_path,
|
||||||
executeIn: jarFolder
|
executeIn: jarFolder,
|
||||||
|
javaPath: config.java_path || ''
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ interface IProps {
|
|||||||
interface IState {
|
interface IState {
|
||||||
game_install_path: string
|
game_install_path: string
|
||||||
grasscutter_path: string
|
grasscutter_path: string
|
||||||
|
java_path: string
|
||||||
grasscutter_with_game: boolean
|
grasscutter_with_game: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -24,6 +25,7 @@ export default class Options extends React.Component<IProps, IState> {
|
|||||||
this.state = {
|
this.state = {
|
||||||
game_install_path: '',
|
game_install_path: '',
|
||||||
grasscutter_path: '',
|
grasscutter_path: '',
|
||||||
|
java_path: '',
|
||||||
grasscutter_with_game: false
|
grasscutter_with_game: false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -33,6 +35,7 @@ export default class Options extends React.Component<IProps, IState> {
|
|||||||
this.setState({
|
this.setState({
|
||||||
game_install_path: config.game_install_path || '',
|
game_install_path: config.game_install_path || '',
|
||||||
grasscutter_path: config.grasscutter_path || '',
|
grasscutter_path: config.grasscutter_path || '',
|
||||||
|
java_path: config.java_path || '',
|
||||||
grasscutter_with_game: config.grasscutter_with_game || false
|
grasscutter_with_game: config.grasscutter_with_game || false
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -48,6 +51,10 @@ export default class Options extends React.Component<IProps, IState> {
|
|||||||
setConfigOption('grasscutter_path', value)
|
setConfigOption('grasscutter_path', value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setJavaPath(value: string) {
|
||||||
|
setConfigOption('java_path', value)
|
||||||
|
}
|
||||||
|
|
||||||
async toggleGrasscutterWithGame() {
|
async toggleGrasscutterWithGame() {
|
||||||
setConfigOption('grasscutter_with_game', !(await getConfigOption('grasscutter_with_game')))
|
setConfigOption('grasscutter_with_game', !(await getConfigOption('grasscutter_with_game')))
|
||||||
}
|
}
|
||||||
@@ -82,6 +89,17 @@ export default class Options extends React.Component<IProps, IState> {
|
|||||||
<Checkbox onChange={this.toggleGrasscutterWithGame} checked={this.state?.grasscutter_with_game} id="gcWithGame" />
|
<Checkbox onChange={this.toggleGrasscutterWithGame} checked={this.state?.grasscutter_with_game} id="gcWithGame" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<Divider />
|
||||||
|
|
||||||
|
<div className='OptionSection'>
|
||||||
|
<div className='OptionLabel'>
|
||||||
|
<Tr text="options.java_path" />
|
||||||
|
</div>
|
||||||
|
<div className='OptionValue'>
|
||||||
|
<DirInput onChange={this.setJavaPath} value={this.state?.java_path} extensions={['exe']} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</Menu>
|
</Menu>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,8 @@ let defaultConfig: Configuration
|
|||||||
toggle_grasscutter: false,
|
toggle_grasscutter: false,
|
||||||
game_install_path: 'C:\\Program Files\\Genshin Impact\\Genshin Impact game\\Genshin Impact.exe',
|
game_install_path: 'C:\\Program Files\\Genshin Impact\\Genshin Impact game\\Genshin Impact.exe',
|
||||||
grasscutter_with_game: false,
|
grasscutter_with_game: false,
|
||||||
grasscutter_path: roamingAppData + '\\cultivation\\grasscutter.jar',
|
grasscutter_path: roamingAppData + '\\cultivation\\grasscutter\\grasscutter.jar',
|
||||||
|
java_path: '',
|
||||||
close_action: 0,
|
close_action: 0,
|
||||||
startup_launch: false,
|
startup_launch: false,
|
||||||
last_ip: '',
|
last_ip: '',
|
||||||
@@ -28,6 +29,7 @@ export interface Configuration {
|
|||||||
game_install_path: string
|
game_install_path: string
|
||||||
grasscutter_with_game: boolean
|
grasscutter_with_game: boolean
|
||||||
grasscutter_path: string
|
grasscutter_path: string
|
||||||
|
java_path: string
|
||||||
close_action: number
|
close_action: number
|
||||||
startup_launch: boolean
|
startup_launch: boolean
|
||||||
last_ip: string
|
last_ip: string
|
||||||
|
|||||||
Reference in New Issue
Block a user