mirror of
https://github.com/Grasscutters/Cultivation.git
synced 2026-02-04 17:32:10 +01:00
client download
This commit is contained in:
@@ -115,9 +115,9 @@ export default class TopBar extends React.Component<IProps, IState> {
|
|||||||
<div id="downloadsBtn" className='TopButton' onClick={this.props.downFunc}>
|
<div id="downloadsBtn" className='TopButton' onClick={this.props.downFunc}>
|
||||||
<img src={downBtn} alt="downloads" />
|
<img src={downBtn} alt="downloads" />
|
||||||
</div>
|
</div>
|
||||||
{/* <div id="gameBtn" className="TopButton" onClick={this.props.gameFunc}>
|
<div id="gameBtn" className="TopButton" onClick={this.props.gameFunc}>
|
||||||
<img src={gameBtn} alt="game" />
|
<img src={gameBtn} alt="game" />
|
||||||
</div> */}
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -8,8 +8,7 @@ import DirInput from '../common/DirInput'
|
|||||||
import BigButton from '../common/BigButton'
|
import BigButton from '../common/BigButton'
|
||||||
import HelpButton from '../common/HelpButton'
|
import HelpButton from '../common/HelpButton'
|
||||||
import { unzip } from '../../../utils/zipUtils'
|
import { unzip } from '../../../utils/zipUtils'
|
||||||
|
import { getVersionCache } from '../../../utils/resources'
|
||||||
const GAME_DOWNLOAD = ''
|
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
closeFn: () => void;
|
closeFn: () => void;
|
||||||
@@ -20,6 +19,7 @@ interface IState {
|
|||||||
gameDownloading: boolean;
|
gameDownloading: boolean;
|
||||||
gameDownloadFolder: string;
|
gameDownloadFolder: string;
|
||||||
dirPlaceholder: string;
|
dirPlaceholder: string;
|
||||||
|
clientDownloadLink: string | null | undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class Downloads extends React.Component<IProps, IState> {
|
export default class Downloads extends React.Component<IProps, IState> {
|
||||||
@@ -29,23 +29,25 @@ export default class Downloads extends React.Component<IProps, IState> {
|
|||||||
this.state = {
|
this.state = {
|
||||||
gameDownloading: false,
|
gameDownloading: false,
|
||||||
gameDownloadFolder: '',
|
gameDownloadFolder: '',
|
||||||
dirPlaceholder: ''
|
dirPlaceholder: '',
|
||||||
|
clientDownloadLink: ''
|
||||||
}
|
}
|
||||||
|
|
||||||
this.downloadGame = this.downloadGame.bind(this)
|
this.downloadGame = this.downloadGame.bind(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
async componentDidMount() {
|
async componentDidMount() {
|
||||||
this.setState({
|
const versionCache = await getVersionCache()
|
||||||
dirPlaceholder: await translate('components.select_folder')
|
|
||||||
})
|
|
||||||
|
|
||||||
console.log(this.state)
|
this.setState({
|
||||||
|
dirPlaceholder: await translate('components.select_folder'),
|
||||||
|
clientDownloadLink: versionCache?.client_download_link
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async downloadGame() {
|
async downloadGame() {
|
||||||
const folder = this.state.gameDownloadFolder
|
const folder = this.state.gameDownloadFolder
|
||||||
this.props.downloadManager.addDownload(GAME_DOWNLOAD, folder + '\\game.zip', () =>{
|
this.props.downloadManager.addDownload(this.state.clientDownloadLink, folder + '\\game.zip', () =>{
|
||||||
unzip(folder + '\\game.zip', folder + '\\', () => {
|
unzip(folder + '\\game.zip', folder + '\\', () => {
|
||||||
this.setState({
|
this.setState({
|
||||||
gameDownloading: false
|
gameDownloading: false
|
||||||
@@ -63,7 +65,7 @@ export default class Downloads extends React.Component<IProps, IState> {
|
|||||||
<Menu heading='Download Game' closeFn={this.props.closeFn} className="GameDownloadMenu">
|
<Menu heading='Download Game' closeFn={this.props.closeFn} className="GameDownloadMenu">
|
||||||
<div className="GameDownload">
|
<div className="GameDownload">
|
||||||
{
|
{
|
||||||
this.state.gameDownloadFolder !== '' && !this.state.gameDownloading ?
|
this.state.gameDownloadFolder !== '' && !this.state.gameDownloading && this.state.clientDownloadLink ?
|
||||||
<BigButton id="downloadGameBtn" onClick={this.downloadGame}>Download Game</BigButton>
|
<BigButton id="downloadGameBtn" onClick={this.downloadGame}>Download Game</BigButton>
|
||||||
: <BigButton id="disabledGameBtn" onClick={() => null} disabled>Download Game</BigButton>
|
: <BigButton id="disabledGameBtn" onClick={() => null} disabled>Download Game</BigButton>
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user