mirror of
https://github.com/Grasscutters/GrassClipper.git
synced 2024-11-16 04:45:34 +00:00
Merge pull request #40 from Grasscutters/gc_downloader
Grasscutter Downloader
This commit is contained in:
commit
f0210cdbfe
1
.gitignore
vendored
1
.gitignore
vendored
@ -4,6 +4,7 @@ bin/
|
||||
dist/
|
||||
ext/
|
||||
temp/
|
||||
gc*/
|
||||
resources/js/neutralino.js
|
||||
resources/bg/official
|
||||
|
||||
|
@ -63,5 +63,21 @@
|
||||
"alertAuthNoRegister": "Authentication is disabled, no need to register!",
|
||||
"alertRegisterSuccess": "Registration successful!",
|
||||
|
||||
"downloadTitle": "Downloads",
|
||||
"grassclipperTitle": "GrassClipper",
|
||||
"grasscutterTitle": "Grasscutter",
|
||||
"installerTitle": "Installer",
|
||||
"installerSubtitle": "Installs proxy and other tools. Required for Grasscutter servers.",
|
||||
"downloadStable": "Download Grasscutter Stable Build",
|
||||
"stableSubtitle": "Install Grasscutter stable branch. This build usually has less bugs, but also less features.",
|
||||
"downloadDev": "Download Grasscutter Development Build",
|
||||
"downloadSubtitle": "Install Grasscutter development branch. This build sometimes has bugs, and is frequently updated. Use at your own risk.",
|
||||
"downloadResources": "Download Grasscutter Resources",
|
||||
"devSubtitle": "Downloads Grasscutter resources into the currently set Grasscutter folder. This should be done unless you plan on getting resources externally.",
|
||||
|
||||
"gcScriptRunning": "Running...",
|
||||
"stableInstall": "Download",
|
||||
"devInstall": "Download",
|
||||
|
||||
"updateNotifText": "A new update is available! Newest version: "
|
||||
}
|
||||
|
11
resources/icons/download.svg
Normal file
11
resources/icons/download.svg
Normal file
@ -0,0 +1,11 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="256" height="256" viewBox="0 0 256 256" xml:space="preserve">
|
||||
<desc>Created with Fabric.js 1.7.22</desc>
|
||||
<defs>
|
||||
</defs>
|
||||
<g transform="translate(128 128) scale(0.72 0.72)" style="">
|
||||
<g style="stroke: none; stroke-width: 0; stroke-dasharray: none; stroke-linecap: butt; stroke-linejoin: miter; stroke-miterlimit: 10; fill: none; fill-rule: nonzero; opacity: 1;" transform="translate(-175.05 -175.05) scale(3.89 3.89)" >
|
||||
<path d="M 66.848 42.103 c -2.111 -1.782 -5.266 -1.512 -7.046 0.599 L 50 54.325 V 5 c 0 -2.761 -2.238 -5 -5 -5 c -2.761 0 -5 2.239 -5 5 v 49.325 l -9.802 -11.623 c -1.78 -2.111 -4.934 -2.378 -7.046 -0.599 c -2.111 1.78 -2.379 4.935 -0.599 7.046 l 18.624 22.085 c 0.075 0.088 0.156 0.168 0.236 0.251 c 0.028 0.029 0.054 0.059 0.083 0.088 c 0.2 0.196 0.416 0.372 0.643 0.531 c 0.044 0.031 0.088 0.061 0.133 0.091 c 0.23 0.15 0.471 0.282 0.722 0.392 c 0.05 0.022 0.101 0.04 0.151 0.061 c 0.264 0.105 0.534 0.193 0.813 0.252 c 0.035 0.007 0.071 0.011 0.106 0.018 c 0.306 0.058 0.618 0.094 0.935 0.094 c 0.317 0 0.628 -0.036 0.934 -0.094 c 0.035 -0.007 0.071 -0.01 0.106 -0.018 c 0.279 -0.059 0.549 -0.147 0.812 -0.252 c 0.052 -0.021 0.103 -0.039 0.154 -0.062 c 0.25 -0.11 0.49 -0.241 0.719 -0.39 c 0.047 -0.03 0.092 -0.061 0.137 -0.093 c 0.226 -0.158 0.441 -0.333 0.64 -0.528 c 0.03 -0.029 0.057 -0.061 0.086 -0.091 c 0.079 -0.082 0.161 -0.161 0.234 -0.249 l 18.624 -22.085 C 69.227 47.037 68.958 43.883 66.848 42.103 z" style="stroke: none; stroke-width: 1; stroke-dasharray: none; stroke-linecap: butt; stroke-linejoin: miter; stroke-miterlimit: 10; fill: rgb(0,0,0); fill-rule: nonzero; opacity: 1;" transform=" matrix(1 0 0 1 0 0) " stroke-linecap="round" />
|
||||
<path d="M 79.692 90 H 10.307 c -2.761 0 -5 -2.239 -5 -5 l 0 -20.352 c 0 -2.611 1.909 -4.943 4.508 -5.191 c 2.982 -0.285 5.492 2.053 5.492 4.976 v 14.528 c 0 0.574 0.465 1.039 1.039 1.039 h 57.308 c 0.574 0 1.039 -0.465 1.039 -1.039 V 64.648 c 0 -2.612 1.91 -4.943 4.509 -5.191 c 2.982 -0.284 5.491 2.053 5.491 4.977 V 85 C 84.692 87.761 82.454 90 79.692 90 z" style="stroke: none; stroke-width: 1; stroke-dasharray: none; stroke-linecap: butt; stroke-linejoin: miter; stroke-miterlimit: 10; fill: rgb(0,0,0); fill-rule: nonzero; opacity: 1;" transform=" matrix(1 0 0 1 0 0) " stroke-linecap="round" />
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 2.3 KiB |
@ -8,6 +8,7 @@
|
||||
<script src="js/hoverEvt.js"></script>
|
||||
<script src="js/helpers.js"></script>
|
||||
<script src="js/index.js"></script>
|
||||
<script src="js/gcdownloader.js"></script>
|
||||
<script src="js/onLoad.js"></script>
|
||||
<script src="js/options.js"></script>
|
||||
<script src="js/login.js"></script>
|
||||
@ -114,6 +115,59 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="downloadPanel" style="display: none;">
|
||||
<div id="downloadTitleBar">
|
||||
<span id="downloadTitle">Downloads</span>
|
||||
<div id="downloadClose" onclick="closeDownloads()">
|
||||
<img src="icons/close.svg" />
|
||||
</div>
|
||||
</div>
|
||||
<div id="downloadPanelInner">
|
||||
<div class="downloadTitle", id="grassclipperTitle">
|
||||
GrassClipper
|
||||
</div>
|
||||
<div class="downloadRow">
|
||||
<div class="downloadSection">
|
||||
<span class="downloadLabel" id="installerTitle">Installer</span>
|
||||
<button class="smolBtn" onclick="runInstallScript()" id="proxyInstall">Install</button>
|
||||
</div>
|
||||
<span class="downloadSubtitle" id="installerSubtitle">
|
||||
Installs proxy and other tools. Required for Grasscutter servers.
|
||||
</span>
|
||||
</div>
|
||||
<div class="downloadTitle", id="grasscutterTitle">
|
||||
Grasscutter
|
||||
</div>
|
||||
<div class="downloadRow">
|
||||
<div class="downloadSection">
|
||||
<span class="downloadLabel" id="downloadStable">Download Grasscutter Stable Build</span>
|
||||
<button class="smolBtn" onclick="downloadGC('stable')" id="stableInstall">Download</button>
|
||||
</div>
|
||||
<span class="downloadSubtitle" id="stableSubtitle">
|
||||
Install Grasscutter stable branch. This build usually has less bugs, but also less features.
|
||||
</span>
|
||||
</div>
|
||||
<div class="downloadRow">
|
||||
<div class="downloadSection">
|
||||
<span class="downloadLabel" id="downloadDev">Download Grasscutter Development Build</span>
|
||||
<button class="smolBtn" onclick="downloadGC('development')" id="devInstall">Download</button>
|
||||
</div>
|
||||
<span class="downloadSubtitle" id="devSubtitle">
|
||||
Install Grasscutter development branch. This build sometimes has bugs, and is frequently updated. Use at your own risk.
|
||||
</span>
|
||||
</div>
|
||||
<div class="downloadRow">
|
||||
<div class="downloadSection">
|
||||
<span class="downloadLabel" id="downloadResources">Download Grasscutter Resources</span>
|
||||
<button class="smolBtn" onclick="downloadGC('development')" id="resourceInstall">Download</button>
|
||||
</div>
|
||||
<span class="downloadSubtitle" id="devSubtitle">
|
||||
Downloads Grasscutter resources into the currently set Grasscutter folder. This should be done unless you plan on getting resources externally.
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Setting panel -->
|
||||
<div id="settingsPanel" style="display: none;">
|
||||
<div id="settingsTitleBar">
|
||||
@ -194,6 +248,9 @@
|
||||
<div id="refreshBtn" onclick="window.location.reload()">
|
||||
<img src="icons/refresh.svg" />
|
||||
</div>
|
||||
<div id="downloadBtn" onclick="openDownloads()">
|
||||
<img src="icons/download.svg" />
|
||||
</div>
|
||||
<div id="settingsBtn" onclick="openSettings()">
|
||||
<img src="icons/cog.svg" />
|
||||
</div>
|
||||
@ -204,6 +261,8 @@
|
||||
<img src="icons/close.svg" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Main content -->
|
||||
<div id="panelContainer">
|
||||
<!-- Official play btn -->
|
||||
<div id="firstPanel">
|
||||
|
102
resources/js/gcdownloader.js
Normal file
102
resources/js/gcdownloader.js
Normal file
@ -0,0 +1,102 @@
|
||||
async function clearGCInstallation() {
|
||||
Neutralino.os.execCommand(`del /s /q "./gc"`)
|
||||
}
|
||||
|
||||
async function setDownloadButtonsToLoading() {
|
||||
const stableBtn = document.querySelector('#stableInstall')
|
||||
const devBtn = document.querySelector('#devInstall')
|
||||
|
||||
stableBtn.innerText = localeObj.gcScriptRunning || 'Running...'
|
||||
|
||||
devBtn.innerText = localeObj.gcScriptRunning || 'Running...'
|
||||
|
||||
// Set btns to disabled
|
||||
stableBtn.disabled = true
|
||||
stableBtn.classList.add('disabled')
|
||||
|
||||
devBtn.disabled = true
|
||||
devBtn.classList.add('disabled')
|
||||
}
|
||||
|
||||
async function resetDownloadButtons() {
|
||||
const stableBtn = document.querySelector('#stableInstall')
|
||||
const devBtn = document.querySelector('#devInstall')
|
||||
|
||||
stableBtn.innerText = localeObj.stableInstall || 'Download'
|
||||
devBtn.innerText = localeObj.devInstall || 'Download'
|
||||
|
||||
// Set btns to enabled
|
||||
stableBtn.disabled = false
|
||||
stableBtn.classList.remove('disabled')
|
||||
|
||||
devBtn.disabled = false
|
||||
devBtn.classList.remove('disabled')
|
||||
}
|
||||
|
||||
async function downloadGC(branch) {
|
||||
const config = await getCfg()
|
||||
|
||||
// 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 gc path for people with launcher enabled
|
||||
config.serverFolder = `${NL_CWD}/gc-${branch}/grasscutter.jar`
|
||||
|
||||
// Enable server launcher
|
||||
config.serverLaunchPanel = true
|
||||
|
||||
Neutralino.storage.setData('config', JSON.stringify(config))
|
||||
|
||||
setDownloadButtonsToLoading()
|
||||
|
||||
// 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`
|
||||
|
||||
// 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 }))
|
||||
|
||||
const serverFolderFixed = config.serverFolder.match(/.*\\|.*\//g, '')[0].replace(/\//g, '\\')
|
||||
|
||||
// Ensure data and key folders exist
|
||||
|
||||
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 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}`)
|
||||
|
||||
// Fix buttons
|
||||
resetDownloadButtons()
|
||||
|
||||
// Display folder after saving config
|
||||
displayServerFolder()
|
||||
enableServerButton()
|
||||
displayServerLaunchSection()
|
||||
}
|
@ -12,6 +12,7 @@
|
||||
serverLaunchPanel: false,
|
||||
language: 'en',
|
||||
useHttps: true,
|
||||
grasscutterBranch: '',
|
||||
}
|
||||
const cfgStr = await Neutralino.storage.getData('config').catch(e => {
|
||||
// The data isn't set, so this is our first time opening
|
||||
@ -97,7 +98,7 @@ async function openGameFolder() {
|
||||
|
||||
async function openGrasscutterFolder() {
|
||||
const config = await getCfg()
|
||||
const folder = config.serverFolder.match(/.*\\/g, '')[0]
|
||||
const folder = config.serverFolder.match(/.*\\|.*\//g, '')[0]
|
||||
|
||||
openInExplorer(folder)
|
||||
}
|
||||
|
@ -246,6 +246,30 @@ async function handleFavoriteList() {
|
||||
}
|
||||
}
|
||||
|
||||
async function openDownloads() {
|
||||
const downloads = document.querySelector('#downloadPanel')
|
||||
const config = await getCfg()
|
||||
|
||||
if (downloads.style.display === 'none') {
|
||||
downloads.style.removeProperty('display')
|
||||
}
|
||||
|
||||
// Disable the resource download button if a serverFolder path is not set
|
||||
if (!config.serverFolder) {
|
||||
document.querySelector('#resourceInstall').disabled = true
|
||||
document.querySelector('#resourceInstall').classList.add('disabled')
|
||||
} else {
|
||||
document.querySelector('#resourceInstall').disabled = false
|
||||
document.querySelector('#resourceInstall').classList.remove('disabled')
|
||||
}
|
||||
}
|
||||
|
||||
async function closeDownloads() {
|
||||
const downloads = document.querySelector('#downloadPanel')
|
||||
|
||||
downloads.style.display = 'none'
|
||||
}
|
||||
|
||||
async function openSettings() {
|
||||
const settings = document.querySelector('#settingsPanel')
|
||||
const config = await getCfg()
|
||||
@ -387,6 +411,8 @@ async function setGameExe() {
|
||||
]
|
||||
})
|
||||
|
||||
if (!gameExe[0]) return;
|
||||
|
||||
// Set the folder in our configuration
|
||||
const config = await getCfg()
|
||||
|
||||
@ -408,6 +434,8 @@ async function setGrasscutterFolder() {
|
||||
]
|
||||
})
|
||||
|
||||
if (!folder[0]) return;
|
||||
|
||||
// Set the folder in our configuration
|
||||
const config = await getCfg()
|
||||
|
||||
|
@ -38,6 +38,7 @@
|
||||
window.addEventListener("click", function(e) {
|
||||
const favList = document.querySelector('#ipList')
|
||||
const settingsPanel = document.querySelector('#settingsPanel')
|
||||
const downloadPanel = document.querySelector('#downloadPanel')
|
||||
|
||||
// This will close the favorites list no matter what is clicked
|
||||
if (favList.style.display !== 'none') {
|
||||
@ -46,23 +47,32 @@
|
||||
}
|
||||
|
||||
// This will close the settings panel no matter what is clicked
|
||||
let settingCheckElm = e.target
|
||||
let checkElm = e.target
|
||||
|
||||
while(settingCheckElm.tagName !== 'BODY') {
|
||||
if (settingCheckElm.id === 'settingsPanel'
|
||||
|| settingCheckElm.id === 'settingsBtn') {
|
||||
while(checkElm.tagName !== 'BODY') {
|
||||
if (checkElm.id === 'settingsPanel'
|
||||
|| checkElm.id === 'settingsBtn') {
|
||||
return
|
||||
}
|
||||
|
||||
settingCheckElm = settingCheckElm.parentElement
|
||||
if (checkElm.id === 'downloadPanel' ||
|
||||
checkElm.id === 'downloadBtn') {
|
||||
return
|
||||
}
|
||||
|
||||
checkElm = checkElm.parentElement
|
||||
}
|
||||
|
||||
// We travelled through the parents, so if we are at the body, we clicked outside of the settings panel
|
||||
if (settingCheckElm.tagName === 'BODY') {
|
||||
if (checkElm.tagName === 'BODY') {
|
||||
// This will close the settings panel only when something outside of it is clicked
|
||||
if (settingsPanel.style.display !== 'none') {
|
||||
settingsPanel.style.display = 'none'
|
||||
}
|
||||
|
||||
if (downloadPanel.style.display !== 'none') {
|
||||
downloadPanel.style.display = 'none'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -90,6 +90,21 @@ async function doTranslation() {
|
||||
set('loginPopupContentBodyBtnRegister', 'authRegisterBtn')
|
||||
set('noLoginBtn', 'launchWithoutAuth')
|
||||
|
||||
// Downloads section
|
||||
set('downloadTitle', 'downloadTitle')
|
||||
set('grassclipperTitle', 'grassclipperTitle')
|
||||
set('grasscutterTitle', 'grasscutterTitle')
|
||||
set('installerTitle', 'installerTitle')
|
||||
set('installerSubtitle', 'installerSubtitle')
|
||||
set('downloadStable', 'downloadStable')
|
||||
set('stableSubtitle', 'stableSubtitle')
|
||||
set('downloadDev', 'downloadDev')
|
||||
set('devSubtitle', 'downloadSubtitle')
|
||||
set('downloadResources', 'downloadResources')
|
||||
set('devSubtitle', 'devSubtitle')
|
||||
set('stableInstall', 'stableInstall')
|
||||
set('devInstall', 'devInstall')
|
||||
|
||||
// update notification
|
||||
set('updateNotifText', 'updateNotifText')
|
||||
}
|
@ -11,6 +11,10 @@ a {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
img {
|
||||
height: 20px;
|
||||
}
|
||||
|
||||
.darken {
|
||||
filter: brightness(0.6);
|
||||
}
|
||||
@ -157,6 +161,7 @@ a {
|
||||
|
||||
#firstTimeNotice,
|
||||
#loginPanel,
|
||||
#downloadPanel,
|
||||
#settingsPanel {
|
||||
display: block;
|
||||
position: absolute;
|
||||
@ -172,18 +177,21 @@ a {
|
||||
font-family: system-ui;
|
||||
}
|
||||
|
||||
#downloadPanel,
|
||||
#settingsPanel {
|
||||
width: 35%;
|
||||
height: 80%;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
#downloadTitle,
|
||||
#fullSettingsTitle {
|
||||
font-size: 1.5em;
|
||||
font-weight: bold;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
#downloadPanelInner,
|
||||
#settingsPanelInner {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@ -192,16 +200,23 @@ a {
|
||||
padding: 10px 10%;
|
||||
}
|
||||
|
||||
.downloadRow,
|
||||
.settingsRow {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.downloadTitle,
|
||||
.settingTitle {
|
||||
font-size: 1.2em;
|
||||
font-weight: bold;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.downloadTitle {
|
||||
margin: 6px;
|
||||
}
|
||||
|
||||
.downloadLabel,
|
||||
.settingLabel {
|
||||
display:inline-block;
|
||||
font-size: 1em;
|
||||
@ -209,12 +224,14 @@ a {
|
||||
margin: 10px 0px;
|
||||
}
|
||||
|
||||
.downloadSubtitle,
|
||||
.settingSubtitle {
|
||||
color: rgb(165, 165, 165);
|
||||
font-size: 0.8em;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
.downloadSection,
|
||||
.settingSection {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
@ -222,10 +239,12 @@ a {
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.downloadSection .smolBtn,
|
||||
.settingSection .smolBtn {
|
||||
height: 30px;
|
||||
}
|
||||
|
||||
#downloadTitleBar,
|
||||
#settingsTitleBar {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
@ -233,15 +252,18 @@ a {
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
#downloadClose,
|
||||
#settingsClose {
|
||||
display: inline-block;
|
||||
transition: filter 0.1s ease-in-out;
|
||||
}
|
||||
|
||||
#downloadClose img,
|
||||
#settingsClose img {
|
||||
height: 20px;
|
||||
}
|
||||
|
||||
#downloadClose:hover,
|
||||
#settingsClose:hover {
|
||||
filter: invert(85%) sepia(31%) saturate(560%) hue-rotate(329deg) brightness(100%) contrast(92%);
|
||||
cursor: pointer;
|
||||
|
58
scripts/gc_download.cmd
Normal file
58
scripts/gc_download.cmd
Normal file
@ -0,0 +1,58 @@
|
||||
@echo off
|
||||
|
||||
set KEYSTORE_URL=%1
|
||||
set ARTIFACT_URL=%2
|
||||
set BRANCH=%3
|
||||
set FOLDER_NAME=".\gc-%BRANCH%"
|
||||
set FOLDER_NAME=%FOLDER_NAME:"=%
|
||||
|
||||
title GC Download Script
|
||||
|
||||
if not exist "%FOLDER_NAME%" mkdir "%FOLDER_NAME%"
|
||||
if not exist ".\temp" mkdir ".\temp"
|
||||
|
||||
echo Downloading Grasscutter prebuilt jar...
|
||||
|
||||
:: Download the jar
|
||||
powershell Invoke-WebRequest -Uri %KEYSTORE_URL% -OutFile "./temp/gcjar.zip"
|
||||
|
||||
echo Extracting...
|
||||
|
||||
:: Delete old file if there is one there
|
||||
if exist "%FOLDER_NAME%\grasscutter.jar" del "%FOLDER_NAME%\grasscutter.jar"
|
||||
|
||||
powershell Expand-Archive -Path "./temp/gcjar.zip" -DestinationPath "%FOLDER_NAME%" -Force
|
||||
|
||||
:: Find the jar file name and rename it, just in case
|
||||
for %%i in (%FOLDER_NAME%/*) do (
|
||||
:: If the extension is jar, rename the file
|
||||
if %%~xi equ .jar rename "%FOLDER_NAME%\%%i" grasscutter.jar
|
||||
)
|
||||
|
||||
echo Downloading keystore.p12...
|
||||
|
||||
:: Download the keystore.p12 file
|
||||
powershell Invoke-WebRequest -Uri %ARTIFACT_URL% -OutFile "./%FOLDER_NAME%/keystore.p12"
|
||||
|
||||
:: Check java version, this will automatically output some tuff
|
||||
call .\scripts\javaver.cmd %BRANCH%
|
||||
|
||||
:: Allow resource downloading to be optional, since it takes a while
|
||||
set REPLY=y
|
||||
set /p "REPLY=Download server resources? (This can take a while) [y|n]:"
|
||||
if /i not "%reply%" == "y" goto :finish
|
||||
|
||||
call .\scripts\resources_download.cmd %FOLDER_NAME%
|
||||
|
||||
goto :finish
|
||||
|
||||
:finish
|
||||
:: Remove temp stuff
|
||||
del /s /q "./temp"
|
||||
|
||||
echo Done, latest Grasscutter %BRANCH% now downloaded in %FOLDER_NAME%
|
||||
|
||||
pause
|
||||
|
||||
taskkill /f /fi "WINDOWTITLE eq GC Download Script"
|
||||
|
@ -3,6 +3,8 @@
|
||||
set ORIGIN=%1
|
||||
set ORIGIN=%ORIGIN:"=%
|
||||
|
||||
title Grassclipper Installer
|
||||
|
||||
echo Downloading proxy server...
|
||||
|
||||
:: Make sure we are in the right directory
|
||||
@ -35,12 +37,12 @@ taskkill /f /im mitmdump.exe
|
||||
echo Adding ceritifcate...
|
||||
|
||||
:: Ensure we are elevated for certs
|
||||
>nul 2>&1 certutil -addstore root %USERPROFILE%\.mitmproxy\mitmproxy-ca-cert.cer || (
|
||||
>nul 2>&1 certutil -addstore root "%USERPROFILE%\.mitmproxy\mitmproxy-ca-cert.cer" || (
|
||||
echo ============================================================================================================
|
||||
echo !! Certificate install failed !!
|
||||
echo.
|
||||
echo Please manually run this command as Administrator:
|
||||
echo certutil -addstore root %USERPROFILE%\.mitmproxy\mitmproxy-ca-cert.cer
|
||||
echo certutil -addstore root "%USERPROFILE%\.mitmproxy\mitmproxy-ca-cert.cer"
|
||||
echo ============================================================================================================
|
||||
)
|
||||
|
||||
@ -48,4 +50,4 @@ echo Done! You can now open GrassClipper.exe!
|
||||
|
||||
pause
|
||||
|
||||
exit /b
|
||||
taskkill /f /fi "WINDOWTITLE eq Grassclipper Installer"
|
70
scripts/javaver.cmd
Normal file
70
scripts/javaver.cmd
Normal file
@ -0,0 +1,70 @@
|
||||
@echo off
|
||||
|
||||
set BRANCH=%1
|
||||
|
||||
echo Checking java version...
|
||||
|
||||
where java >nul 2>nul
|
||||
if %errorlevel%==1 (
|
||||
echo =======================================================================================
|
||||
echo No version of Java was found!
|
||||
|
||||
if %BRANCH% EQU stable (
|
||||
echo To launch the stable branch server, you must install Java 8
|
||||
)
|
||||
|
||||
if %BRANCH% EQU development (
|
||||
echo To launch the development branch server, you must install Java 17
|
||||
)
|
||||
|
||||
echo =======================================================================================
|
||||
|
||||
exit /b
|
||||
)
|
||||
|
||||
:: https://stackoverflow.com/questions/5675459/how-to-get-java-version-from-batch-script
|
||||
for /f "tokens=3" %%g in ('java -version 2^>^&1 ^| findstr /i "version"') do (
|
||||
@echo Output: %%g
|
||||
set JAVAVER=%%g
|
||||
)
|
||||
set JAVAVER=%JAVAVER:"=%
|
||||
|
||||
for /f "delims=. tokens=1-3" %%v in ("%JAVAVER%") do (
|
||||
set MAJOR=%%v
|
||||
set MINOR=%%w
|
||||
set BUILD=%%x
|
||||
)
|
||||
|
||||
if %BRANCH% EQU stable (
|
||||
:: Ensure java 8
|
||||
if %MAJOR% EQU 1 (
|
||||
if %MINOR% LSS 8 (
|
||||
echo =======================================================================================
|
||||
echo !! Java version is less than 8 !!
|
||||
echo Please download Java 8 to ensure %BRANCH% branch server launches correctly.
|
||||
echo =======================================================================================
|
||||
exit /b
|
||||
)
|
||||
)
|
||||
|
||||
if %MAJOR% NEQ 1 (
|
||||
echo =======================================================================================
|
||||
echo !! Java version is not 8 !!
|
||||
echo Please download Java 8 to ensure %BRANCH% branch server launches correctly.
|
||||
echo =======================================================================================
|
||||
exit /b
|
||||
)
|
||||
)
|
||||
|
||||
if %BRANCH% EQU development (
|
||||
:: Ensure java 17
|
||||
if %MAJOR% LSS 17 (
|
||||
echo =======================================================================================
|
||||
echo !! Java version is less than 17 !!
|
||||
echo Please download Java 17 to ensure %BRANCH% branch server launches correctly.
|
||||
echo =======================================================================================
|
||||
exit /b
|
||||
)
|
||||
)
|
||||
|
||||
echo Java version is compatible
|
@ -3,15 +3,23 @@
|
||||
set GRASSCUTTER_JAR=%1
|
||||
set GRASSCUTTER_JAR=%GRASSCUTTER_JAR:"=%
|
||||
|
||||
title Grasscutter
|
||||
|
||||
:: Get folder the jar is in
|
||||
set "X=%GRASSCUTTER_JAR%"
|
||||
:l
|
||||
if "%X:~-1%"=="\" goto al
|
||||
set "X=%X:~0,-1%"
|
||||
goto l
|
||||
set IS_SLASH=false
|
||||
|
||||
if "%X:~-1%"=="\" set IS_SLASH=true
|
||||
if "%X:~-1%"=="/" set IS_SLASH=true
|
||||
|
||||
if %IS_SLASH% equ true goto al
|
||||
|
||||
set "X=%X:~0,-1%"
|
||||
goto l
|
||||
:al
|
||||
set "X=%X:~0,-1%"
|
||||
set "GRASSCUTTER_ROOT=%X%"
|
||||
set "X=%X:~0,-1%"
|
||||
set "GRASSCUTTER_ROOT=%X%"
|
||||
|
||||
echo Starting local Grasscutter server...
|
||||
|
||||
|
@ -27,7 +27,7 @@ if "%ENABLE_KILLSWITCH%" EQU "true" (
|
||||
:: Restart in elevated if need be
|
||||
>nul 2>&1 reg query "HKU\S-1-5-19" || (
|
||||
set params = %*:"="""%
|
||||
cd /d "%~dp0" && ( if exist "%temp%\getadmin.vbs" del "%temp%\getadmin.vbs" ) && fsutil dirty query %systemdrive% 1>nul 2>nul || ( echo Set UAC = CreateObject^("Shell.Application"^) : UAC.ShellExecute "cmd.exe", "/k cd ""%~sdp0"" && %~s0 %1 %2 %3 "%4" ""%cd%/../"" %6", "", "runas", 1 >> "%temp%\getadmin.vbs" && "%temp%\getadmin.vbs" && taskkill /f /fi "WINDOWTITLE eq PS Launcher Script" && exit /b )
|
||||
cd /d "%~dp0" && ( if exist "%temp%\getadmin.vbs" del "%temp%\getadmin.vbs" ) && fsutil dirty query %systemdrive% 1>nul 2>nul || ( echo Set UAC = CreateObject^("Shell.Application"^) : UAC.ShellExecute "cmd.exe", "/k cd ""%~sdp0"" && %~s0 %1 %2 %3 "%4" ""%cd%"" %6", "", "runas", 1 >> "%temp%\getadmin.vbs" && "%temp%\getadmin.vbs" && taskkill /f /fi "WINDOWTITLE eq PS Launcher Script" && exit /b )
|
||||
)
|
||||
)
|
||||
|
||||
@ -41,7 +41,7 @@ reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v Pr
|
||||
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyServer /d "127.0.0.1:8080" /f >nul 2>nul
|
||||
|
||||
:: Start proxy server
|
||||
start "Proxy Server" "%ORIGIN%/ext/mitmdump.exe" -s "%ORIGIN%/proxy/proxy.py" -k --allow-hosts ".*\.yuanshen\.com|.*\.mihoyo\.com|.*\.hoyoverse\.com" --ssl-insecure --set ip=%IP% --set port=%PORT% --set use_https=%USE_HTTPS%
|
||||
start "Proxy Server" "%ORIGIN%\ext\mitmdump.exe" -s "%ORIGIN%/proxy/proxy.py" -k --allow-hosts ".*\.yuanshen\.com|.*\.mihoyo\.com|.*\.hoyoverse\.com" --ssl-insecure --set ip=%IP% --set port=%PORT% --set use_https=%USE_HTTPS%
|
||||
|
||||
echo Opening %GAME_PATH%
|
||||
|
||||
|
29
scripts/resources_download.cmd
Normal file
29
scripts/resources_download.cmd
Normal file
@ -0,0 +1,29 @@
|
||||
@echo off
|
||||
|
||||
set FOLDER_NAME=%1
|
||||
set FOLDER_NAME=%FOLDER_NAME:"=%
|
||||
|
||||
if not exist ".\temp" mkdir ".\temp"
|
||||
if not exist ".\resources" mkdir ".\resources"
|
||||
|
||||
echo Downloading resources, this can take a while...
|
||||
|
||||
:: Grab the giant ass resource zip
|
||||
powershell Invoke-WebRequest -Uri https://github.com/Koko-boya/Grasscutter_Resources/archive/refs/heads/main.zip -OutFile "./temp/resources.zip"
|
||||
|
||||
echo Extracting...
|
||||
|
||||
:: Extract resources to the folder
|
||||
powershell Expand-Archive -Path "./temp/resources.zip" -DestinationPath "%FOLDER_NAME%" -Force
|
||||
|
||||
:: Delete old resources folder if there is one there
|
||||
del /s /q "%FOLDER_NAME%\resources">nul
|
||||
|
||||
echo Moving resources to folder...
|
||||
|
||||
robocopy "%FOLDER_NAME%\Grasscutter_Resources-main\Resources" "%FOLDER_NAME%\resources" /E /MOVE>nul
|
||||
|
||||
:: Delete straggling files
|
||||
del /s /q "%FOLDER_NAME%\Grasscutter_Resources-main"
|
||||
|
||||
echo Done, resources should be properly extracted
|
Loading…
Reference in New Issue
Block a user