change path/command option based on platform

This commit is contained in:
SpikeHD
2022-09-04 14:00:27 -07:00
parent 94c1bfd104
commit 404e946e7c
5 changed files with 40 additions and 7 deletions

View File

@@ -1,6 +1,14 @@
name: Build
on: [push, pull-request]
on:
push:
paths:
- '.github/workflows/build.yml'
- 'src-tauri/**'
pull_request:
paths:
- '.github/workflows/build.yml'
- 'src-tauri/**'
concurrency:
group: ${{ github.ref }}-${{ github.workflow }}

View File

@@ -14,6 +14,7 @@
"enabled": "Enabled",
"disabled": "Disabled",
"game_path": "Set Game Install Path",
"game_command": "Game Launch Command",
"game_executable": "Set Game Executable",
"recover_metadata": "Emergency Metadata Recovery",
"grasscutter_jar": "Set Grasscutter JAR",

View File

@@ -94,6 +94,7 @@ fn main() {
system_helpers::is_elevated,
system_helpers::set_migoto_target,
system_helpers::wipe_registry,
system_helpers::get_platform,
proxy::set_proxy_addr,
proxy::generate_ca_files,
unzip::unzip,

View File

@@ -168,3 +168,8 @@ pub fn is_elevated() -> bool {
pub fn is_elevated() -> bool {
sudo::check() == sudo::RunningAs::Root
}
#[tauri::command]
pub fn get_platform() -> &'static str {
std::env::consts::OS
}

View File

@@ -15,6 +15,7 @@ import BigButton from '../common/BigButton'
import DownloadHandler from '../../../utils/download'
import * as meta from '../../../utils/metadata'
import HelpButton from '../common/HelpButton'
import TextInput from '../common/TextInput'
interface IProps {
closeFn: () => void
@@ -37,6 +38,7 @@ interface IState {
wipe_login: boolean
horny_mode: boolean
swag: boolean
platform: string
// Swag stuff
akebi_path: string
@@ -64,6 +66,7 @@ export default class Options extends React.Component<IProps, IState> {
wipe_login: false,
horny_mode: false,
swag: false,
platform: '',
// Swag stuff
akebi_path: '',
@@ -85,12 +88,15 @@ export default class Options extends React.Component<IProps, IState> {
async componentDidMount() {
const config = await getConfig()
const languages = await getLanguages()
const platform: string = await invoke('get_platform')
// Remove jar from path
const path = config.grasscutter_path.replace(/\\/g, '/')
const folderPath = path.substring(0, path.lastIndexOf('/'))
const encEnabled = await server.encryptionEnabled(folderPath + '/config.json')
console.log(platform)
this.setState({
game_install_path: config.game_install_path || '',
grasscutter_path: config.grasscutter_path || '',
@@ -107,6 +113,7 @@ export default class Options extends React.Component<IProps, IState> {
wipe_login: config.wipe_login || false,
horny_mode: config.horny_mode || false,
swag: config.swag_mode || false,
platform,
// Swag stuff
akebi_path: config.akebi_path || '',
@@ -271,14 +278,25 @@ export default class Options extends React.Component<IProps, IState> {
render() {
return (
<Menu closeFn={this.props.closeFn} className="Options" heading="Options">
<div className="OptionSection" id="menuOptionsContainerGamePath">
<div className="OptionLabel" id="menuOptionsLabelGamePath">
<Tr text="options.game_path" />
{!this.state.platform || this.state.platform === 'windows' ? (
<div className="OptionSection" id="menuOptionsContainerGamePath">
<div className="OptionLabel" id="menuOptionsLabelGamePath">
<Tr text="options.game_path" />
</div>
<div className="OptionValue" id="menuOptionsDirGamePath">
<DirInput onChange={this.setGameExecutable} value={this.state?.game_install_path} extensions={['exe']} />
</div>
</div>
<div className="OptionValue" id="menuOptionsDirGamePath">
<DirInput onChange={this.setGameExecutable} value={this.state?.game_install_path} extensions={['exe']} />
) : (
<div className="OptionSection" id="menuOptionsContainerGameCommand">
<div className="OptionLabel" id="menuOptionsLabelGameCommand">
<Tr text="options.game_command" />
</div>
<div className="OptionValue" id="menuOptionsGameCommand">
<TextInput />
</div>
</div>
</div>
)}
<div className="OptionSection" id="menuOptionsContainermetaDownload">
<div className="OptionLabel" id="menuOptionsLabelmetaDownload">
<Tr text="options.recover_metadata" />