This repository has been archived by the owner on Jul 5, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 166
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
830 additions
and
830 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,45 @@ | ||
let alertTimeout, alertCooldown = 3000 | ||
|
||
async function displayLoginAlert(message, type, cooldown = null) { | ||
displayAlert(message, type, cooldown, 'login') | ||
displayAlert(message, type, cooldown, 'login') | ||
} | ||
|
||
async function displayRegisterAlert(message, type, cooldown = null) { | ||
displayAlert(message, type, cooldown, 'register') | ||
displayAlert(message, type, cooldown, 'register') | ||
} | ||
|
||
function displayAlert(message, type, cooldown, name) { | ||
const elm = document.getElementById(`${name}Alert`) | ||
const text = document.getElementById(`${name}AlertText`) | ||
const elm = document.getElementById(`${name}Alert`) | ||
const text = document.getElementById(`${name}AlertText`) | ||
|
||
elm.style.removeProperty('display') | ||
elm.style.removeProperty('display') | ||
|
||
// Remove classification classes | ||
elm.classList.remove('error') | ||
elm.classList.remove('success') | ||
elm.classList.remove('warn') | ||
|
||
switch(type) { | ||
case 'error': | ||
elm.classList.add('error') | ||
break | ||
|
||
case 'success': | ||
elm.classList.add('success') | ||
break | ||
|
||
case 'warn': | ||
default: | ||
elm.classList.add('warn') | ||
break | ||
} | ||
|
||
text.innerText = message | ||
|
||
clearTimeout(alertTimeout) | ||
|
||
// Disappear after cooldown | ||
alertTimeout = setTimeout(() => { | ||
elm.style.display = 'none' | ||
}, cooldown || alertCooldown) | ||
// Remove classification classes | ||
elm.classList.remove('error') | ||
elm.classList.remove('success') | ||
elm.classList.remove('warn') | ||
|
||
switch(type) { | ||
case 'error': | ||
elm.classList.add('error') | ||
break | ||
|
||
case 'success': | ||
elm.classList.add('success') | ||
break | ||
|
||
case 'warn': | ||
default: | ||
elm.classList.add('warn') | ||
break | ||
} | ||
|
||
text.innerText = message | ||
|
||
clearTimeout(alertTimeout) | ||
|
||
// Disappear after cooldown | ||
alertTimeout = setTimeout(() => { | ||
elm.style.display = 'none' | ||
}, cooldown || alertCooldown) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,102 +1,102 @@ | ||
async function clearGCInstallation() { | ||
Neutralino.os.execCommand('del /s /q "./gc"') | ||
Neutralino.os.execCommand('del /s /q "./gc"') | ||
} | ||
|
||
async function setDownloadButtonsToLoading() { | ||
const stableBtn = document.querySelector('#stableInstall') | ||
const devBtn = document.querySelector('#devInstall') | ||
const stableBtn = document.querySelector('#stableInstall') | ||
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 | ||
stableBtn.disabled = true | ||
stableBtn.classList.add('disabled') | ||
// Set btns to disabled | ||
stableBtn.disabled = true | ||
stableBtn.classList.add('disabled') | ||
|
||
devBtn.disabled = true | ||
devBtn.classList.add('disabled') | ||
devBtn.disabled = true | ||
devBtn.classList.add('disabled') | ||
} | ||
|
||
async function resetDownloadButtons() { | ||
const stableBtn = document.querySelector('#stableInstall') | ||
const devBtn = document.querySelector('#devInstall') | ||
const stableBtn = document.querySelector('#stableInstall') | ||
const devBtn = document.querySelector('#devInstall') | ||
|
||
stableBtn.innerText = localeObj.stableInstall || 'Download' | ||
devBtn.innerText = localeObj.devInstall || 'Download' | ||
stableBtn.innerText = localeObj.stableInstall || 'Download' | ||
devBtn.innerText = localeObj.devInstall || 'Download' | ||
|
||
// Set btns to enabled | ||
stableBtn.disabled = false | ||
stableBtn.classList.remove('disabled') | ||
// Set btns to enabled | ||
stableBtn.disabled = false | ||
stableBtn.classList.remove('disabled') | ||
|
||
devBtn.disabled = false | ||
devBtn.classList.remove('disabled') | ||
devBtn.disabled = false | ||
devBtn.classList.remove('disabled') | ||
} | ||
|
||
async function downloadGC(branch) { | ||
const config = await getCfg() | ||
const config = await getCfg() | ||
|
||
// If we are pulling from a new branch, delete the old installation | ||
if (config.grasscutterBranch !== branch) await clearGCInstallation() | ||
// If we are pulling from a new branch, delete the old installation | ||
if (config.grasscutterBranch !== branch) await clearGCInstallation() | ||
|
||
// Set current installation in config | ||
config.grasscutterBranch = branch | ||
// Set current installation in config | ||
config.grasscutterBranch = branch | ||
|
||
// Set gc path for people with launcher enabled | ||
config.serverFolder = `${NL_CWD}/gc-${branch}/grasscutter.jar` | ||
// Set gc path for people with launcher enabled | ||
config.serverFolder = `${NL_CWD}/gc-${branch}/grasscutter.jar` | ||
|
||
// Enable server launcher | ||
config.serverLaunchPanel = true | ||
// Enable server launcher | ||
config.serverLaunchPanel = true | ||
|
||
Neutralino.storage.setData('config', JSON.stringify(config)) | ||
Neutralino.storage.setData('config', JSON.stringify(config)) | ||
|
||
setDownloadButtonsToLoading() | ||
setDownloadButtonsToLoading() | ||
|
||
// Keystore for branch (since they can differ) | ||
const keystoreUrl = `https://github.com/Grasscutters/Grasscutter/raw/${branch}/keystore.p12` | ||
// Keystore for branch (since they can differ) | ||
const keystoreUrl = `https://github.com/Grasscutters/Grasscutter/raw/${branch}/keystore.p12` | ||
|
||
// External service that allows un-authed artifact downloading | ||
const artiUrl = `https://nightly.link/Grasscutters/Grasscutter/workflows/build/${branch}/Grasscutter.zip` | ||
// External service that allows un-authed artifact downloading | ||
const artiUrl = `https://nightly.link/Grasscutters/Grasscutter/workflows/build/${branch}/Grasscutter.zip` | ||
|
||
// For data files | ||
const dataFiles = await axios.get(`https://api.github.com/repos/Grasscutters/Grasscutter/contents/data?ref=${branch}`) | ||
const dataList = dataFiles.data | ||
.map(file => ({ path: file.path, filename: file.name })) | ||
.map(o => ({ url: `https://raw.githubusercontent.com/Grasscutters/Grasscutter/${branch}/${o.path}`, filename: o.filename })) | ||
// For data files | ||
const dataFiles = await axios.get(`https://api.github.com/repos/Grasscutters/Grasscutter/contents/data?ref=${branch}`) | ||
const dataList = dataFiles.data | ||
.map(file => ({ path: file.path, filename: file.name })) | ||
.map(o => ({ url: `https://raw.githubusercontent.com/Grasscutters/Grasscutter/${branch}/${o.path}`, filename: o.filename })) | ||
|
||
// For key files | ||
const keyFiles = await axios.get(`https://api.github.com/repos/Grasscutters/Grasscutter/contents/keys?ref=${branch}`) | ||
const keyList = keyFiles.data | ||
.map(file => ({ path: file.path, filename: file.name })) | ||
.map(o => ({ url: `https://raw.githubusercontent.com/Grasscutters/Grasscutter/${branch}/${o.path}`, filename: o.filename })) | ||
// For key files | ||
const keyFiles = await axios.get(`https://api.github.com/repos/Grasscutters/Grasscutter/contents/keys?ref=${branch}`) | ||
const keyList = keyFiles.data | ||
.map(file => ({ path: file.path, filename: file.name })) | ||
.map(o => ({ url: `https://raw.githubusercontent.com/Grasscutters/Grasscutter/${branch}/${o.path}`, filename: o.filename })) | ||
|
||
const serverFolderFixed = config.serverFolder.match(/.*\\|.*\//g, '')[0].replace(/\//g, '\\') | ||
const serverFolderFixed = config.serverFolder.match(/.*\\|.*\//g, '')[0].replace(/\//g, '\\') | ||
|
||
// Ensure data and key folders exist | ||
// Ensure data and key folders exist | ||
|
||
await Neutralino.os.execCommand(`mkdir ${serverFolderFixed}\\data`) | ||
await Neutralino.os.execCommand(`mkdir ${serverFolderFixed}\\keys`) | ||
await Neutralino.os.execCommand(`mkdir ${serverFolderFixed}\\data`) | ||
await Neutralino.os.execCommand(`mkdir ${serverFolderFixed}\\keys`) | ||
|
||
// Download data files | ||
for (const o of dataList) { | ||
const folder = 'data' | ||
await Neutralino.os.execCommand(`powershell Invoke-WebRequest -Uri ${o.url} -OutFile "${serverFolderFixed}\\${folder}\\${o.filename}"`) | ||
} | ||
// Download data files | ||
for (const o of dataList) { | ||
const folder = 'data' | ||
await Neutralino.os.execCommand(`powershell Invoke-WebRequest -Uri ${o.url} -OutFile "${serverFolderFixed}\\${folder}\\${o.filename}"`) | ||
} | ||
|
||
// Download key files | ||
for (const o of keyList) { | ||
const folder = 'keys' | ||
await Neutralino.os.execCommand(`powershell Invoke-WebRequest -Uri ${o.url} -OutFile "${serverFolderFixed}\\${folder}\\${o.filename}"`) | ||
} | ||
// Download key files | ||
for (const o of keyList) { | ||
const folder = 'keys' | ||
await Neutralino.os.execCommand(`powershell Invoke-WebRequest -Uri ${o.url} -OutFile "${serverFolderFixed}\\${folder}\\${o.filename}"`) | ||
} | ||
|
||
// Run installer | ||
createCmdWindow(`.\\scripts\\gc_download.cmd ${artiUrl} ${keystoreUrl} ${branch}`) | ||
// Run installer | ||
createCmdWindow(`.\\scripts\\gc_download.cmd ${artiUrl} ${keystoreUrl} ${branch}`) | ||
|
||
// Fix buttons | ||
resetDownloadButtons() | ||
// Fix buttons | ||
resetDownloadButtons() | ||
|
||
// Display folder after saving config | ||
displayServerFolder() | ||
enableServerButton() | ||
displayServerLaunchSection() | ||
// Display folder after saving config | ||
displayServerFolder() | ||
enableServerButton() | ||
displayServerLaunchSection() | ||
} |
Oops, something went wrong.