Launch args from settings

This commit is contained in:
Thoronium
2023-09-16 19:41:18 -06:00
parent d849ea32c9
commit a1571ad800
4 changed files with 35 additions and 2 deletions

View File

@@ -36,7 +36,8 @@
"redirect_more": "Also redirect other MHY games", "redirect_more": "Also redirect other MHY games",
"check_aagl": "For more options, check the other launcher", "check_aagl": "For more options, check the other launcher",
"grasscutter_elevation": "Method of running GC on restricted ports", "grasscutter_elevation": "Method of running GC on restricted ports",
"web_cache": "Delete webCaches folder" "web_cache": "Delete webCaches folder",
"launch_args": "Launch Args"
}, },
"downloads": { "downloads": {
"grasscutter_fullbuild": "Download Grasscutter All-in-One", "grasscutter_fullbuild": "Download Grasscutter All-in-One",

View File

@@ -41,6 +41,7 @@ interface IState {
migotoSet: boolean migotoSet: boolean
unElevated: boolean unElevated: boolean
launchArgs: string
} }
export default class ServerLaunchSection extends React.Component<IProps, IState> { export default class ServerLaunchSection extends React.Component<IProps, IState> {
@@ -64,6 +65,7 @@ export default class ServerLaunchSection extends React.Component<IProps, IState>
akebiSet: false, akebiSet: false,
migotoSet: false, migotoSet: false,
unElevated: false, unElevated: false,
launchArgs: '',
} }
this.toggleGrasscutter = this.toggleGrasscutter.bind(this) this.toggleGrasscutter = this.toggleGrasscutter.bind(this)
@@ -95,6 +97,7 @@ export default class ServerLaunchSection extends React.Component<IProps, IState>
akebiSet: config.akebi_path !== '', akebiSet: config.akebi_path !== '',
migotoSet: config.migoto_path !== '', migotoSet: config.migoto_path !== '',
unElevated: config.un_elevated || false, unElevated: config.un_elevated || false,
launchArgs: config.launch_args || '',
}) })
} }
@@ -214,9 +217,13 @@ export default class ServerLaunchSection extends React.Component<IProps, IState>
if (config.un_elevated) { if (config.un_elevated) {
await invoke('run_un_elevated', { await invoke('run_un_elevated', {
path: config.game_install_path, path: config.game_install_path,
args: config.launch_args,
}) })
} else { } else {
await invoke('run_program_relative', { path: exe || config.game_install_path }) await invoke('run_program_relative', {
path: exe || config.game_install_path,
args: config.launch_args,
})
} }
else alert('Game not found! At: ' + (exe || config.game_install_path)) else alert('Game not found! At: ' + (exe || config.game_install_path))
} }

View File

@@ -17,6 +17,7 @@ import * as meta from '../../../utils/rsa'
import HelpButton from '../common/HelpButton' import HelpButton from '../common/HelpButton'
import SmallButton from '../common/SmallButton' import SmallButton from '../common/SmallButton'
import { confirm } from '@tauri-apps/api/dialog' import { confirm } from '@tauri-apps/api/dialog'
import TextInput from '../common/TextInput'
export enum GrasscutterElevation { export enum GrasscutterElevation {
None = 'None', None = 'None',
@@ -50,6 +51,7 @@ interface IState {
platform: string platform: string
un_elevated: boolean un_elevated: boolean
redirect_more: boolean redirect_more: boolean
launch_args: string
// Linux stuff // Linux stuff
grasscutter_elevation: string grasscutter_elevation: string
@@ -85,6 +87,7 @@ export default class Options extends React.Component<IProps, IState> {
platform: '', platform: '',
un_elevated: false, un_elevated: false,
redirect_more: false, redirect_more: false,
launch_args: '',
// Linux stuff // Linux stuff
grasscutter_elevation: GrasscutterElevation.None, grasscutter_elevation: GrasscutterElevation.None,
@@ -107,6 +110,7 @@ export default class Options extends React.Component<IProps, IState> {
this.deleteWebCache = this.deleteWebCache.bind(this) this.deleteWebCache = this.deleteWebCache.bind(this)
this.addMigotoDelay = this.addMigotoDelay.bind(this) this.addMigotoDelay = this.addMigotoDelay.bind(this)
this.toggleUnElevatedGame = this.toggleUnElevatedGame.bind(this) this.toggleUnElevatedGame = this.toggleUnElevatedGame.bind(this)
this.setLaunchArgs = this.setLaunchArgs.bind(this)
} }
async componentDidMount() { async componentDidMount() {
@@ -145,6 +149,7 @@ export default class Options extends React.Component<IProps, IState> {
platform, platform,
un_elevated: config.un_elevated || false, un_elevated: config.un_elevated || false,
redirect_more: config.redirect_more || false, redirect_more: config.redirect_more || false,
launch_args: config.launch_args || '',
// Linux stuff // Linux stuff
grasscutter_elevation: config.grasscutter_elevation || GrasscutterElevation.None, grasscutter_elevation: config.grasscutter_elevation || GrasscutterElevation.None,
@@ -374,6 +379,14 @@ export default class Options extends React.Component<IProps, IState> {
}) })
} }
async setLaunchArgs(value: string) {
await setConfigOption('launch_args', value)
this.setState({
launch_args: value,
})
}
render() { render() {
return ( return (
<Menu closeFn={this.props.closeFn} className="Options" heading="Options"> <Menu closeFn={this.props.closeFn} className="Options" heading="Options">
@@ -685,6 +698,16 @@ export default class Options extends React.Component<IProps, IState> {
<Tr text="components.delete" /> <Tr text="components.delete" />
</BigButton> </BigButton>
</div> </div>
<div className="OptionLabel" id="menuOptionsLaunchArgs">
<Tr text="options.launch_args" />
</div>
<TextInput
id="launch_args"
key="launch_args"
placeholder={'-arg=value'}
onChange={this.setLaunchArgs}
initalValue={this.state.launch_args}
/>
</div> </div>
</Menu> </Menu>
) )

View File

@@ -28,6 +28,7 @@ let defaultConfig: Configuration
auto_mongodb: false, auto_mongodb: false,
un_elevated: false, un_elevated: false,
redirect_more: false, redirect_more: false,
launch_args: '',
// Linux stuff // Linux stuff
grasscutter_elevation: 'None', grasscutter_elevation: 'None',
@@ -62,6 +63,7 @@ export interface Configuration {
auto_mongodb: boolean auto_mongodb: boolean
un_elevated: boolean un_elevated: boolean
redirect_more: boolean redirect_more: boolean
launch_args: string
// Linux stuff // Linux stuff
grasscutter_elevation: string grasscutter_elevation: string