Add full build download to menu

This commit is contained in:
Thoronium
2023-02-25 18:12:08 -07:00
committed by GitHub
parent 86d15cd335
commit 7831bd48dc
5 changed files with 42 additions and 5 deletions

View File

@@ -63,6 +63,7 @@
"port_help_text": "Ensure this is the Dispatch server port, not the Game server port. This is almost always '443'.",
"game_help_text": "You do not need to use a separate copy to play with Grasscutter. This is for either downgrading to 2.6 or if you do not have the game installed.",
"gc_stable_jar": "Download the current stable Grasscutter build, which includes jar file and data files.",
"gc_full_build": "Download a full Grasscutter build, including repo, jar, and resources. Is fully set up and does not require any other downloads from this menu.",
"gc_dev_jar": "Download the latest development Grasscutter build, which includes jar file and data files.",
"gc_stable_data": "Download the current stable Grasscutter data files, which does not come with a jar file. This is useful for updating.",
"gc_dev_data": "Download the latest development Grasscutter data files, which does not come with a jar file. This is useful for updating.",

View File

@@ -7,7 +7,7 @@
},
"package": {
"productName": "Cultivation",
"version": "1.0.10"
"version": "1.0.11-Thorny"
},
"tauri": {
"allowlist": {

View File

@@ -13,6 +13,7 @@ import { invoke } from '@tauri-apps/api'
import { listen } from '@tauri-apps/api/event'
import HelpButton from '../common/HelpButton'
const FULL_BUILD_DOWNLOAD = 'https://download1074.mediafire.com/cpryvy2flqggXpX7N6jastZ9nGMMZZCNnTmIXpHLqT6hEcRNsylllBgRuQG3of04A0LqOwHR4D59G7RtfqQMwMZdVg/qtmkrdicdnr4d37/GrasscutterCulti3.4.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 STABLE_DOWNLOAD = 'https://nightly.link/Grasscutters/Grasscutter/workflows/build/stable/Grasscutter.zip'
@@ -25,6 +26,7 @@ interface IProps {
}
interface IState {
fullbuild_downloading: boolean
grasscutter_downloading: boolean
resources_downloading: boolean
repo_downloading: boolean
@@ -37,6 +39,7 @@ export default class Downloads extends React.Component<IProps, IState> {
super(props)
this.state = {
fullbuild_downloading: this.props.downloadManager.downloadingFullBuild(),
grasscutter_downloading: this.props.downloadManager.downloadingJar(),
resources_downloading: this.props.downloadManager.downloadingResources(),
repo_downloading: this.props.downloadManager.downloadingRepo(),
@@ -45,6 +48,7 @@ export default class Downloads extends React.Component<IProps, IState> {
}
this.getGrasscutterFolder = this.getGrasscutterFolder.bind(this)
this.downloadGrasscutterFullBuild = this.downloadGrasscutterFullBuild.bind(this)
this.downloadGrasscutterStableRepo = this.downloadGrasscutterStableRepo.bind(this)
this.downloadGrasscutterDevRepo = this.downloadGrasscutterDevRepo.bind(this)
this.downloadGrasscutterStable = this.downloadGrasscutterStable.bind(this)
@@ -109,6 +113,16 @@ export default class Downloads extends React.Component<IProps, IState> {
return folderPath
}
async downloadGrasscutterFullBuild() {
const folder = await this.getGrasscutterFolder()
this.props.downloadManager.addDownload(FULL_BUILD_DOWNLOAD, folder + '\\GrasscutterCulti3.4.zip', async () => {
await unzip(folder + '\\GrasscutterCulti3.4.zip', folder + '\\', true)
this.toggleButtons()
})
this.toggleButtons()
}
async downloadGrasscutterStableRepo() {
const folder = await this.getGrasscutterFolder()
this.props.downloadManager.addDownload(STABLE_REPO_DOWNLOAD, folder + '\\grasscutter_repo.zip', async () => {
@@ -187,6 +201,7 @@ export default class Downloads extends React.Component<IProps, IState> {
// Set states since we know we are downloading something if this is called
this.setState({
fullbuild_downloading: this.props.downloadManager.downloadingFullBuild(),
grasscutter_downloading: this.props.downloadManager.downloadingJar(),
resources_downloading: this.props.downloadManager.downloadingResources(),
repo_downloading: this.props.downloadManager.downloadingRepo(),
@@ -197,6 +212,23 @@ export default class Downloads extends React.Component<IProps, IState> {
render() {
return (
<Menu closeFn={this.props.closeFn} className="Downloads" heading="Downloads">
<div className="DownloadMenuSection" id="downloadMenuContainerGCFullBuild">
<div className="DownloadLabel" id="downloadMenuLabelGCFullBuild">
<Tr
text={this.state.grasscutter_set ? 'downloads.grasscutter_full_build' : 'downloads.grasscutter_full_build_update'}
/>
<HelpButton contents="help.gc_full_build" />
</div>
<div className="DownloadValue" id="downloadMenuButtonGCFullBuild">
<BigButton
disabled={this.state.grasscutter_downloading}
onClick={this.downloadGrasscutterFullBuild}
id="grasscutterFullBuildBtn"
>
<Tr text="components.download" />
</BigButton>
</div>
</div>
<div className="DownloadMenuSection" id="downloadMenuContainerGCStable">
<div className="DownloadLabel" id="downloadMenuLabelGCStable">
<Tr

View File

@@ -40,7 +40,8 @@ export default class NewsSection extends React.Component<IProps, IState> {
super(props)
this.state = {
selected: props.selected || 'commits',
// Set to commits since latest doesn't show any real info anyways
selected: 'commits',
}
this.setSelected = this.setSelected.bind(this)
@@ -59,7 +60,6 @@ export default class NewsSection extends React.Component<IProps, IState> {
}
async showLatestCommits() {
if (!this.state.commitList) {
// Just use official API
const response: string = await invoke('req_get', {
url: 'https://api.github.com/repos/Grasscutters/Grasscutter/commits',
@@ -105,7 +105,6 @@ export default class NewsSection extends React.Component<IProps, IState> {
commitList: commitsListHtml,
news: <>{commitsListHtml}</>,
})
}
return this.state.commitList
}
@@ -125,7 +124,7 @@ export default class NewsSection extends React.Component<IProps, IState> {
case 'latest_version':
news = (
<tr>
<td>Latest version</td>
<td>Latest version: Grasscutter 1.4.6 - Cultivation 1.0.10</td>
</tr>
)
break

View File

@@ -104,6 +104,11 @@ export default class DownloadHandler {
return this.downloads.some((d) => d.path.includes('grasscutter.zip'))
}
downloadingFullBuild() {
// Kinda hacky but it works
return this.downloads.some((d) => d.path.includes('GrasscutterCulti3.4.zip'))
}
downloadingResources() {
// Kinda hacky but it works
return this.downloads.some((d) => d.path.includes('resources'))