From 404e946e7c7cc2196af5a5bd1c03f6c07fa1a116 Mon Sep 17 00:00:00 2001 From: SpikeHD Date: Sun, 4 Sep 2022 14:00:27 -0700 Subject: [PATCH] change path/command option based on platform --- .github/workflows/build.yml | 10 +++++++++- src-tauri/lang/en.json | 1 + src-tauri/src/main.rs | 1 + src-tauri/src/system_helpers.rs | 5 +++++ src/ui/components/menu/Options.tsx | 30 ++++++++++++++++++++++++------ 5 files changed, 40 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 552fb80..160c0b3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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 }} diff --git a/src-tauri/lang/en.json b/src-tauri/lang/en.json index f7cf2d3..c068d4d 100644 --- a/src-tauri/lang/en.json +++ b/src-tauri/lang/en.json @@ -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", diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 0cab243..42a9e07 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -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, diff --git a/src-tauri/src/system_helpers.rs b/src-tauri/src/system_helpers.rs index 9200776..d619934 100644 --- a/src-tauri/src/system_helpers.rs +++ b/src-tauri/src/system_helpers.rs @@ -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 +} diff --git a/src/ui/components/menu/Options.tsx b/src/ui/components/menu/Options.tsx index 7e5b1b8..689f7dd 100644 --- a/src/ui/components/menu/Options.tsx +++ b/src/ui/components/menu/Options.tsx @@ -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 { wipe_login: false, horny_mode: false, swag: false, + platform: '', // Swag stuff akebi_path: '', @@ -85,12 +88,15 @@ export default class Options extends React.Component { 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 { 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 { render() { return ( -