mirror of
https://github.com/Grasscutters/Cultivation.git
synced 2025-12-15 00:24:45 +01:00
resource button is enabled after repo download
This commit is contained in:
@@ -10,6 +10,7 @@ import './Downloads.css'
|
|||||||
import Divider from './Divider'
|
import Divider from './Divider'
|
||||||
import { getConfigOption, setConfigOption } from '../../../utils/configuration'
|
import { getConfigOption, setConfigOption } from '../../../utils/configuration'
|
||||||
import { invoke } from '@tauri-apps/api'
|
import { invoke } from '@tauri-apps/api'
|
||||||
|
import { listen } from '@tauri-apps/api/event'
|
||||||
|
|
||||||
const STABLE_REPO_DOWNLOAD = 'https://github.com/Grasscutters/Grasscutter/archive/refs/heads/stable.zip'
|
const STABLE_REPO_DOWNLOAD = 'https://github.com/Grasscutters/Grasscutter/archive/refs/heads/stable.zip'
|
||||||
const DEV_REPO_DOWNLOAD = 'https://github.com/Grasscutters/Grasscutter/archive/refs/heads/development.zip'
|
const DEV_REPO_DOWNLOAD = 'https://github.com/Grasscutters/Grasscutter/archive/refs/heads/development.zip'
|
||||||
@@ -48,12 +49,16 @@ export default class Downloads extends React.Component<IProps, IState> {
|
|||||||
this.downloadGrasscutterStable = this.downloadGrasscutterStable.bind(this)
|
this.downloadGrasscutterStable = this.downloadGrasscutterStable.bind(this)
|
||||||
this.downloadGrasscutterLatest = this.downloadGrasscutterLatest.bind(this)
|
this.downloadGrasscutterLatest = this.downloadGrasscutterLatest.bind(this)
|
||||||
this.downloadResources = this.downloadResources.bind(this)
|
this.downloadResources = this.downloadResources.bind(this)
|
||||||
this.disableButtons = this.disableButtons.bind(this)
|
this.toggleButtons = this.toggleButtons.bind(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
async componentDidMount() {
|
async componentDidMount() {
|
||||||
const gc_path = await getConfigOption('grasscutter_path')
|
const gc_path = await getConfigOption('grasscutter_path')
|
||||||
|
|
||||||
|
listen('jar_extracted', () => {
|
||||||
|
this.setState({ grasscutter_set: true }, this.forceUpdate)
|
||||||
|
})
|
||||||
|
|
||||||
if (!gc_path || gc_path === '') {
|
if (!gc_path || gc_path === '') {
|
||||||
this.setState({
|
this.setState({
|
||||||
grasscutter_set: false,
|
grasscutter_set: false,
|
||||||
@@ -102,43 +107,43 @@ export default class Downloads extends React.Component<IProps, IState> {
|
|||||||
async downloadGrasscutterStableRepo() {
|
async downloadGrasscutterStableRepo() {
|
||||||
const folder = await this.getGrasscutterFolder()
|
const folder = await this.getGrasscutterFolder()
|
||||||
this.props.downloadManager.addDownload(STABLE_REPO_DOWNLOAD, folder + '\\grasscutter_repo.zip', () =>{
|
this.props.downloadManager.addDownload(STABLE_REPO_DOWNLOAD, folder + '\\grasscutter_repo.zip', () =>{
|
||||||
unzip(folder + '\\grasscutter_repo.zip', folder + '\\')
|
unzip(folder + '\\grasscutter_repo.zip', folder + '\\', this.toggleButtons)
|
||||||
})
|
})
|
||||||
|
|
||||||
this.disableButtons()
|
this.toggleButtons()
|
||||||
}
|
}
|
||||||
|
|
||||||
async downloadGrasscutterDevRepo() {
|
async downloadGrasscutterDevRepo() {
|
||||||
const folder = await this.getGrasscutterFolder()
|
const folder = await this.getGrasscutterFolder()
|
||||||
this.props.downloadManager.addDownload(DEV_REPO_DOWNLOAD, folder + '\\grasscutter_repo.zip', () =>{
|
this.props.downloadManager.addDownload(DEV_REPO_DOWNLOAD, folder + '\\grasscutter_repo.zip', () =>{
|
||||||
unzip(folder + '\\grasscutter_repo.zip', folder + '\\')
|
unzip(folder + '\\grasscutter_repo.zip', folder + '\\', this.toggleButtons)
|
||||||
})
|
})
|
||||||
|
|
||||||
this.disableButtons()
|
this.toggleButtons()
|
||||||
}
|
}
|
||||||
|
|
||||||
async downloadGrasscutterStable() {
|
async downloadGrasscutterStable() {
|
||||||
const folder = await this.getGrasscutterFolder()
|
const folder = await this.getGrasscutterFolder()
|
||||||
this.props.downloadManager.addDownload(STABLE_DOWNLOAD, folder + '\\grasscutter.zip', () =>{
|
this.props.downloadManager.addDownload(STABLE_DOWNLOAD, folder + '\\grasscutter.zip', () =>{
|
||||||
unzip(folder + '\\grasscutter.zip', folder + '\\')
|
unzip(folder + '\\grasscutter.zip', folder + '\\', this.toggleButtons)
|
||||||
})
|
})
|
||||||
|
|
||||||
// Also add repo download
|
// Also add repo download
|
||||||
this.downloadGrasscutterStableRepo()
|
this.downloadGrasscutterStableRepo()
|
||||||
|
|
||||||
this.disableButtons()
|
this.toggleButtons()
|
||||||
}
|
}
|
||||||
|
|
||||||
async downloadGrasscutterLatest() {
|
async downloadGrasscutterLatest() {
|
||||||
const folder = await this.getGrasscutterFolder()
|
const folder = await this.getGrasscutterFolder()
|
||||||
this.props.downloadManager.addDownload(DEV_DOWNLOAD, folder + '\\grasscutter.zip', () =>{
|
this.props.downloadManager.addDownload(DEV_DOWNLOAD, folder + '\\grasscutter.zip', () =>{
|
||||||
unzip(folder + '\\grasscutter.zip', folder + '\\')
|
unzip(folder + '\\grasscutter.zip', folder + '\\', this.toggleButtons)
|
||||||
})
|
})
|
||||||
|
|
||||||
// Also add repo download
|
// Also add repo download
|
||||||
this.downloadGrasscutterDevRepo()
|
this.downloadGrasscutterDevRepo()
|
||||||
|
|
||||||
this.disableButtons()
|
this.toggleButtons()
|
||||||
}
|
}
|
||||||
|
|
||||||
async downloadResources() {
|
async downloadResources() {
|
||||||
@@ -150,18 +155,23 @@ export default class Downloads extends React.Component<IProps, IState> {
|
|||||||
path: folder + '\\Resources',
|
path: folder + '\\Resources',
|
||||||
newName: 'resources'
|
newName: 'resources'
|
||||||
})
|
})
|
||||||
|
|
||||||
|
this.toggleButtons()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
this.disableButtons()
|
this.toggleButtons()
|
||||||
}
|
}
|
||||||
|
|
||||||
disableButtons() {
|
async toggleButtons() {
|
||||||
|
const gc_path = await getConfigOption('grasscutter_path')
|
||||||
|
|
||||||
// Set states since we know we are downloading something if this is called
|
// Set states since we know we are downloading something if this is called
|
||||||
this.setState({
|
this.setState({
|
||||||
grasscutter_downloading: this.props.downloadManager.downloadingJar(),
|
grasscutter_downloading: this.props.downloadManager.downloadingJar(),
|
||||||
resources_downloading: this.props.downloadManager.downloadingResources(),
|
resources_downloading: this.props.downloadManager.downloadingResources(),
|
||||||
repo_downloading: this.props.downloadManager.downloadingRepo()
|
repo_downloading: this.props.downloadManager.downloadingRepo(),
|
||||||
|
grasscutter_set: gc_path && gc_path !== '',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user