do button stuff

This commit is contained in:
SpikeHD 2022-05-07 20:08:55 -07:00
parent 4a32d1fb41
commit 5f81ced09f
2 changed files with 17 additions and 9 deletions

View File

@ -182,6 +182,15 @@
Downloads Grasscutter resources into the currently set Grasscutter folder. This should be done unless you plan on getting resources externally. Downloads Grasscutter resources into the currently set Grasscutter folder. This should be done unless you plan on getting resources externally.
</span> </span>
</div> </div>
<div class="downloadRow">
<div class="downloadSection">
<span class="downloadLabel" id="downloadData">Download Data Files</span>
<button class="smolBtn" onclick="downloadDataFiles()" id="resourceInstall">Download</button>
</div>
<span class="downloadSubtitle" id="resourceSubtitle">
Downloads Grasscutter resources into the currently set Grasscutter folder. This should be done unless you plan on getting resources externally.
</span>
</div>
</div> </div>
</div> </div>

View File

@ -3,7 +3,6 @@ async function setDownloadButtonsToLoading() {
const devBtn = document.querySelector('#devInstall') const devBtn = document.querySelector('#devInstall')
stableBtn.innerText = localeObj.gcScriptRunning || 'Running...' stableBtn.innerText = localeObj.gcScriptRunning || 'Running...'
devBtn.innerText = localeObj.gcScriptRunning || 'Running...' devBtn.innerText = localeObj.gcScriptRunning || 'Running...'
// Set btns to disabled // Set btns to disabled
@ -32,6 +31,10 @@ async function resetDownloadButtons() {
async function downloadDataFiles(branch) { async function downloadDataFiles(branch) {
const config = await getCfg() const config = await getCfg()
if (!branch) branch = config.grasscutterBranch || 'development'
setDownloadButtonsToLoading()
// For data files // For data files
const dataFiles = await axios.get(`https://api.github.com/repos/Grasscutters/Grasscutter/contents/data?ref=${branch}`) const dataFiles = await axios.get(`https://api.github.com/repos/Grasscutters/Grasscutter/contents/data?ref=${branch}`)
const dataList = dataFiles.data const dataList = dataFiles.data
@ -65,7 +68,10 @@ async function downloadDataFiles(branch) {
const folder = 'keys' const folder = 'keys'
const e = await Neutralino.os.execCommand(`powershell Invoke-WebRequest -Uri ${o.url} -OutFile "${serverFolderFixed}\\${folder}\\${o.filename}"`) const e = await Neutralino.os.execCommand(`powershell Invoke-WebRequest -Uri ${o.url} -OutFile "${serverFolderFixed}\\${folder}\\${o.filename}"`)
console.log(e) console.log(e)
} }
// Fix buttons
resetDownloadButtons()
} }
async function downloadGC(branch) { async function downloadGC(branch) {
@ -82,8 +88,6 @@ async function downloadGC(branch) {
Neutralino.storage.setData('config', JSON.stringify(config)) Neutralino.storage.setData('config', JSON.stringify(config))
setDownloadButtonsToLoading()
// Download data files // Download data files
downloadDataFiles(branch) downloadDataFiles(branch)
@ -97,14 +101,9 @@ async function downloadGC(branch) {
// Keystore for branch (since they can differ) // Keystore for branch (since they can differ)
const keystoreUrl = `https://github.com/Grasscutters/Grasscutter/raw/${branch}/keystore.p12` const keystoreUrl = `https://github.com/Grasscutters/Grasscutter/raw/${branch}/keystore.p12`
// Run installer // Run installer
createCmdWindow(`.\\scripts\\gc_download.cmd ${artiUrl} ${keystoreUrl} ${branch}`) createCmdWindow(`.\\scripts\\gc_download.cmd ${artiUrl} ${keystoreUrl} ${branch}`)
// Fix buttons
resetDownloadButtons()
// Display folder after saving config // Display folder after saving config
displayServerFolder() displayServerFolder()
enableServerButton() enableServerButton()