mirror of
https://github.com/Grasscutters/Cultivation.git
synced 2025-12-13 07:34:36 +01:00
change path/command option based on platform
This commit is contained in:
10
.github/workflows/build.yml
vendored
10
.github/workflows/build.yml
vendored
@@ -1,6 +1,14 @@
|
|||||||
name: Build
|
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:
|
concurrency:
|
||||||
group: ${{ github.ref }}-${{ github.workflow }}
|
group: ${{ github.ref }}-${{ github.workflow }}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
"enabled": "Enabled",
|
"enabled": "Enabled",
|
||||||
"disabled": "Disabled",
|
"disabled": "Disabled",
|
||||||
"game_path": "Set Game Install Path",
|
"game_path": "Set Game Install Path",
|
||||||
|
"game_command": "Game Launch Command",
|
||||||
"game_executable": "Set Game Executable",
|
"game_executable": "Set Game Executable",
|
||||||
"recover_metadata": "Emergency Metadata Recovery",
|
"recover_metadata": "Emergency Metadata Recovery",
|
||||||
"grasscutter_jar": "Set Grasscutter JAR",
|
"grasscutter_jar": "Set Grasscutter JAR",
|
||||||
|
|||||||
@@ -94,6 +94,7 @@ fn main() {
|
|||||||
system_helpers::is_elevated,
|
system_helpers::is_elevated,
|
||||||
system_helpers::set_migoto_target,
|
system_helpers::set_migoto_target,
|
||||||
system_helpers::wipe_registry,
|
system_helpers::wipe_registry,
|
||||||
|
system_helpers::get_platform,
|
||||||
proxy::set_proxy_addr,
|
proxy::set_proxy_addr,
|
||||||
proxy::generate_ca_files,
|
proxy::generate_ca_files,
|
||||||
unzip::unzip,
|
unzip::unzip,
|
||||||
|
|||||||
@@ -168,3 +168,8 @@ pub fn is_elevated() -> bool {
|
|||||||
pub fn is_elevated() -> bool {
|
pub fn is_elevated() -> bool {
|
||||||
sudo::check() == sudo::RunningAs::Root
|
sudo::check() == sudo::RunningAs::Root
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn get_platform() -> &'static str {
|
||||||
|
std::env::consts::OS
|
||||||
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import BigButton from '../common/BigButton'
|
|||||||
import DownloadHandler from '../../../utils/download'
|
import DownloadHandler from '../../../utils/download'
|
||||||
import * as meta from '../../../utils/metadata'
|
import * as meta from '../../../utils/metadata'
|
||||||
import HelpButton from '../common/HelpButton'
|
import HelpButton from '../common/HelpButton'
|
||||||
|
import TextInput from '../common/TextInput'
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
closeFn: () => void
|
closeFn: () => void
|
||||||
@@ -37,6 +38,7 @@ interface IState {
|
|||||||
wipe_login: boolean
|
wipe_login: boolean
|
||||||
horny_mode: boolean
|
horny_mode: boolean
|
||||||
swag: boolean
|
swag: boolean
|
||||||
|
platform: string
|
||||||
|
|
||||||
// Swag stuff
|
// Swag stuff
|
||||||
akebi_path: string
|
akebi_path: string
|
||||||
@@ -64,6 +66,7 @@ export default class Options extends React.Component<IProps, IState> {
|
|||||||
wipe_login: false,
|
wipe_login: false,
|
||||||
horny_mode: false,
|
horny_mode: false,
|
||||||
swag: false,
|
swag: false,
|
||||||
|
platform: '',
|
||||||
|
|
||||||
// Swag stuff
|
// Swag stuff
|
||||||
akebi_path: '',
|
akebi_path: '',
|
||||||
@@ -85,12 +88,15 @@ export default class Options extends React.Component<IProps, IState> {
|
|||||||
async componentDidMount() {
|
async componentDidMount() {
|
||||||
const config = await getConfig()
|
const config = await getConfig()
|
||||||
const languages = await getLanguages()
|
const languages = await getLanguages()
|
||||||
|
const platform: string = await invoke('get_platform')
|
||||||
|
|
||||||
// Remove jar from path
|
// Remove jar from path
|
||||||
const path = config.grasscutter_path.replace(/\\/g, '/')
|
const path = config.grasscutter_path.replace(/\\/g, '/')
|
||||||
const folderPath = path.substring(0, path.lastIndexOf('/'))
|
const folderPath = path.substring(0, path.lastIndexOf('/'))
|
||||||
const encEnabled = await server.encryptionEnabled(folderPath + '/config.json')
|
const encEnabled = await server.encryptionEnabled(folderPath + '/config.json')
|
||||||
|
|
||||||
|
console.log(platform)
|
||||||
|
|
||||||
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 || '',
|
||||||
@@ -107,6 +113,7 @@ export default class Options extends React.Component<IProps, IState> {
|
|||||||
wipe_login: config.wipe_login || false,
|
wipe_login: config.wipe_login || false,
|
||||||
horny_mode: config.horny_mode || false,
|
horny_mode: config.horny_mode || false,
|
||||||
swag: config.swag_mode || false,
|
swag: config.swag_mode || false,
|
||||||
|
platform,
|
||||||
|
|
||||||
// Swag stuff
|
// Swag stuff
|
||||||
akebi_path: config.akebi_path || '',
|
akebi_path: config.akebi_path || '',
|
||||||
@@ -271,14 +278,25 @@ export default class Options extends React.Component<IProps, IState> {
|
|||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<Menu closeFn={this.props.closeFn} className="Options" heading="Options">
|
<Menu closeFn={this.props.closeFn} className="Options" heading="Options">
|
||||||
<div className="OptionSection" id="menuOptionsContainerGamePath">
|
{!this.state.platform || this.state.platform === 'windows' ? (
|
||||||
<div className="OptionLabel" id="menuOptionsLabelGamePath">
|
<div className="OptionSection" id="menuOptionsContainerGamePath">
|
||||||
<Tr text="options.game_path" />
|
<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>
|
||||||
<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>
|
)}
|
||||||
<div className="OptionSection" id="menuOptionsContainermetaDownload">
|
<div className="OptionSection" id="menuOptionsContainermetaDownload">
|
||||||
<div className="OptionLabel" id="menuOptionsLabelmetaDownload">
|
<div className="OptionLabel" id="menuOptionsLabelmetaDownload">
|
||||||
<Tr text="options.recover_metadata" />
|
<Tr text="options.recover_metadata" />
|
||||||
|
|||||||
Reference in New Issue
Block a user