mirror of
https://github.com/Grasscutters/Cultivation.git
synced 2025-12-12 23:24:35 +01:00
make metadata optional
This commit is contained in:
@@ -23,7 +23,8 @@
|
||||
"grasscutter_with_game": "Automatically launch Grasscutter with game",
|
||||
"language": "Select Language",
|
||||
"background": "Set Custom Background (link or image file)",
|
||||
"theme": "Set Theme"
|
||||
"theme": "Set Theme",
|
||||
"patch_metadata": "Automatically Patch Metadata"
|
||||
},
|
||||
"downloads": {
|
||||
"grasscutter_stable_data": "Download Grasscutter Stable Data",
|
||||
|
||||
@@ -100,11 +100,13 @@ export default class ServerLaunchSection extends React.Component<{}, IState> {
|
||||
|
||||
// Connect to proxy
|
||||
if (config.toggle_grasscutter) {
|
||||
const patched = await patchGame()
|
||||
if (config.patch_metadata) {
|
||||
const patched = await patchGame()
|
||||
|
||||
if (!patched) {
|
||||
alert('Could not patch game!')
|
||||
return
|
||||
if (!patched) {
|
||||
alert('Could not patch game!')
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
const game_exe = await getGameExecutable()
|
||||
|
||||
@@ -31,6 +31,7 @@ interface IState {
|
||||
themes: string[]
|
||||
theme: string
|
||||
encryption: boolean
|
||||
patch_metadata: boolean
|
||||
swag: boolean
|
||||
|
||||
// Swag stuff
|
||||
@@ -52,6 +53,7 @@ export default class Options extends React.Component<IProps, IState> {
|
||||
themes: ['default'],
|
||||
theme: '',
|
||||
encryption: false,
|
||||
patch_metadata: false,
|
||||
swag: false,
|
||||
|
||||
// Swag stuff
|
||||
@@ -66,6 +68,7 @@ export default class Options extends React.Component<IProps, IState> {
|
||||
this.setCustomBackground = this.setCustomBackground.bind(this)
|
||||
this.toggleEncryption = this.toggleEncryption.bind(this)
|
||||
this.restoreMetadata = this.restoreMetadata.bind(this)
|
||||
this.toggleMetadata = this.toggleMetadata.bind(this)
|
||||
}
|
||||
|
||||
async componentDidMount() {
|
||||
@@ -88,6 +91,7 @@ export default class Options extends React.Component<IProps, IState> {
|
||||
themes: (await getThemeList()).map((t) => t.name),
|
||||
theme: config.theme || 'default',
|
||||
encryption: await translate(encEnabled ? 'options.enabled' : 'options.disabled'),
|
||||
patch_metadata: config.patch_metadata || false,
|
||||
swag: config.swag_mode || false,
|
||||
|
||||
// Swag stuff
|
||||
@@ -205,6 +209,16 @@ export default class Options extends React.Component<IProps, IState> {
|
||||
})
|
||||
}
|
||||
|
||||
async toggleMetadata() {
|
||||
const changedVal = !(await getConfigOption('patch_metadata'))
|
||||
|
||||
await setConfigOption('patch_metadata', changedVal)
|
||||
|
||||
this.setState({
|
||||
patch_metadata: changedVal,
|
||||
})
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<Menu closeFn={this.props.closeFn} className="Options" heading="Options">
|
||||
@@ -226,6 +240,21 @@ export default class Options extends React.Component<IProps, IState> {
|
||||
</BigButton>
|
||||
</div>
|
||||
</div>
|
||||
<div className="OptionSection" id="menuOptionsContainerPatchMeta">
|
||||
<div className="OptionLabel" id="menuOptionsLabelPatchMeta">
|
||||
<Tr text="options.patch_metadata" />
|
||||
</div>
|
||||
<div className="OptionValue" id="menuOptionsCheckboxPatchMeta">
|
||||
<Checkbox
|
||||
onChange={this.toggleMetadata}
|
||||
checked={this.state?.patch_metadata}
|
||||
id="patchMeta"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Divider />
|
||||
|
||||
<div className='OptionSection' id="menuOptionsContainerGCJar">
|
||||
<div className='OptionLabel' id="menuOptionsLabelGCJar">
|
||||
<Tr text="options.grasscutter_jar" />
|
||||
|
||||
@@ -20,7 +20,8 @@ let defaultConfig: Configuration
|
||||
cert_generated: false,
|
||||
theme: 'default',
|
||||
https_enabled: false,
|
||||
debug_enabled: false
|
||||
debug_enabled: false,
|
||||
patch_metadata: true,
|
||||
}
|
||||
})()
|
||||
|
||||
@@ -43,6 +44,7 @@ export interface Configuration {
|
||||
theme: string
|
||||
https_enabled: boolean
|
||||
debug_enabled: boolean
|
||||
patch_metadata: boolean
|
||||
swag_mode?: boolean
|
||||
|
||||
// Swag stuff
|
||||
@@ -60,7 +62,7 @@ export async function getConfigOption<K extends keyof Configuration>(key: K): Pr
|
||||
const config = await getConfig()
|
||||
const defaults = defaultConfig
|
||||
|
||||
return config[key] || defaults[key]
|
||||
return config[key] === null || config[key] === undefined ? defaults[key] : config[key]
|
||||
}
|
||||
|
||||
export async function getConfig() {
|
||||
|
||||
Reference in New Issue
Block a user