mirror of
https://github.com/Grasscutters/Cultivation.git
synced 2025-12-17 01:24:36 +01:00
meta download button
This commit is contained in:
@@ -14,6 +14,8 @@
|
|||||||
"enabled": "Enabled",
|
"enabled": "Enabled",
|
||||||
"disabled": "Disabled",
|
"disabled": "Disabled",
|
||||||
"game_exec": "Set Game Executable",
|
"game_exec": "Set Game Executable",
|
||||||
|
"game_version": "Set Game Version",
|
||||||
|
"emergency_metadata": "Emergency Metadata Replacement",
|
||||||
"grasscutter_jar": "Set Grasscutter JAR",
|
"grasscutter_jar": "Set Grasscutter JAR",
|
||||||
"toggle_encryption": "Toggle Encryption",
|
"toggle_encryption": "Toggle Encryption",
|
||||||
"java_path": "Set Custom Java Path",
|
"java_path": "Set Custom Java Path",
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import * as server from '../../../utils/server'
|
|||||||
|
|
||||||
import './Options.css'
|
import './Options.css'
|
||||||
import BigButton from '../common/BigButton'
|
import BigButton from '../common/BigButton'
|
||||||
import { cacheLauncherResources, getVersions } from '../../../utils/resources'
|
import { cacheLauncherResources, getVersionCache, getVersions } from '../../../utils/resources'
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
closeFn: () => void;
|
closeFn: () => void;
|
||||||
@@ -22,6 +22,7 @@ interface IState {
|
|||||||
game_install_path: string
|
game_install_path: string
|
||||||
grasscutter_path: string
|
grasscutter_path: string
|
||||||
client_version: string
|
client_version: string
|
||||||
|
meta_download: string | null | undefined
|
||||||
java_path: string
|
java_path: string
|
||||||
grasscutter_with_game: boolean
|
grasscutter_with_game: boolean
|
||||||
language_options: { [key: string]: string }[],
|
language_options: { [key: string]: string }[],
|
||||||
@@ -44,6 +45,7 @@ export default class Options extends React.Component<IProps, IState> {
|
|||||||
game_install_path: '',
|
game_install_path: '',
|
||||||
grasscutter_path: '',
|
grasscutter_path: '',
|
||||||
client_version: '',
|
client_version: '',
|
||||||
|
meta_download: '',
|
||||||
java_path: '',
|
java_path: '',
|
||||||
grasscutter_with_game: false,
|
grasscutter_with_game: false,
|
||||||
language_options: [],
|
language_options: [],
|
||||||
@@ -82,6 +84,7 @@ export default class Options extends React.Component<IProps, IState> {
|
|||||||
grasscutter_path: config.grasscutter_path || '',
|
grasscutter_path: config.grasscutter_path || '',
|
||||||
java_path: config.java_path || '',
|
java_path: config.java_path || '',
|
||||||
client_version: config.client_version || '',
|
client_version: config.client_version || '',
|
||||||
|
meta_download: (await getVersionCache())?.metadata_backup_link || '',
|
||||||
grasscutter_with_game: config.grasscutter_with_game || false,
|
grasscutter_with_game: config.grasscutter_with_game || false,
|
||||||
language_options: languages,
|
language_options: languages,
|
||||||
current_language: config.language || 'en',
|
current_language: config.language || 'en',
|
||||||
@@ -109,10 +112,11 @@ export default class Options extends React.Component<IProps, IState> {
|
|||||||
async setClientVersion(value: string) {
|
async setClientVersion(value: string) {
|
||||||
await setConfigOption('client_version', value)
|
await setConfigOption('client_version', value)
|
||||||
|
|
||||||
await cacheLauncherResources()
|
const newCache = await cacheLauncherResources()
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
client_version: value
|
client_version: value,
|
||||||
|
meta_download: newCache?.metadata_backup_link
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -216,7 +220,7 @@ export default class Options extends React.Component<IProps, IState> {
|
|||||||
</div>
|
</div>
|
||||||
<div className='OptionSection' id="menuOptionsContainerClientVersion">
|
<div className='OptionSection' id="menuOptionsContainerClientVersion">
|
||||||
<div className='OptionLabel' id="menuOptionsLabelClientVersion">
|
<div className='OptionLabel' id="menuOptionsLabelClientVersion">
|
||||||
<Tr text="options.game_exec" />
|
<Tr text="options.game_version" />
|
||||||
</div>
|
</div>
|
||||||
<div className='OptionValue' id="menuOptionsDirClientVersion">
|
<div className='OptionValue' id="menuOptionsDirClientVersion">
|
||||||
<select value={this.state.client_version} id="menuOptionsSelectMenuThemes" onChange={(event) => {
|
<select value={this.state.client_version} id="menuOptionsSelectMenuThemes" onChange={(event) => {
|
||||||
@@ -233,8 +237,20 @@ export default class Options extends React.Component<IProps, IState> {
|
|||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div className='OptionSection' id="menuOptionsContainerMetadataDownload">
|
||||||
|
<div className='OptionLabel' id="menuOptionsLabelMetadataDownload">
|
||||||
|
<Tr text="options.emergency_metadata" />
|
||||||
|
</div>
|
||||||
|
<div className='OptionValue' id="menuOptionsButtonMetadataDownload">
|
||||||
|
<BigButton disabled={this.state.meta_download === ''} onClick={this.toggleEncryption} id="toggleEnc">
|
||||||
|
<Tr text='components.download' />
|
||||||
|
</BigButton>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
{
|
{
|
||||||
this.state.swag && (
|
this.state.swag && (
|
||||||
|
<>
|
||||||
|
<Divider />
|
||||||
<div className='OptionSection' id="menuOptionsContainerAkebi">
|
<div className='OptionSection' id="menuOptionsContainerAkebi">
|
||||||
<div className='OptionLabel' id="menuOptionsLabelAkebi">
|
<div className='OptionLabel' id="menuOptionsLabelAkebi">
|
||||||
<Tr text="swag.akebi" />
|
<Tr text="swag.akebi" />
|
||||||
@@ -243,6 +259,8 @@ export default class Options extends React.Component<IProps, IState> {
|
|||||||
<DirInput onChange={this.setAkebi} value={this.state?.akebi_path} extensions={['exe']} />
|
<DirInput onChange={this.setAkebi} value={this.state?.akebi_path} extensions={['exe']} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<Divider />
|
||||||
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
<div className='OptionSection' id="menuOptionsContainerGCJar">
|
<div className='OptionSection' id="menuOptionsContainerGCJar">
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ export async function cacheLauncherResources() {
|
|||||||
|
|
||||||
if (!versions || versions.retcode !== 0) {
|
if (!versions || versions.retcode !== 0) {
|
||||||
console.log('Failed to get versions from API')
|
console.log('Failed to get versions from API')
|
||||||
return false
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
const selectedVersion = config.client_version
|
const selectedVersion = config.client_version
|
||||||
@@ -71,7 +71,7 @@ export async function cacheLauncherResources() {
|
|||||||
|
|
||||||
if (!selectedVersionData) {
|
if (!selectedVersionData) {
|
||||||
console.log('Failed to get version for selected version')
|
console.log('Failed to get version for selected version')
|
||||||
return false
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
const latest = versions.data.game.latest
|
const latest = versions.data.game.latest
|
||||||
@@ -87,6 +87,9 @@ export async function cacheLauncherResources() {
|
|||||||
path: await dataDir() + 'cultivation/resources.json',
|
path: await dataDir() + 'cultivation/resources.json',
|
||||||
contents: JSON.stringify(selectedVersionData)
|
contents: JSON.stringify(selectedVersionData)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// In case we want to get it right away too
|
||||||
|
return selectedVersionData
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getVersionCache() {
|
export async function getVersionCache() {
|
||||||
|
|||||||
Reference in New Issue
Block a user