mirror of
https://github.com/Grasscutters/GrassClipper.git
synced 2024-11-22 07:08:11 +00:00
fix and finish optional server launch
This commit is contained in:
parent
ee73186016
commit
b89861fc38
@ -98,7 +98,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div id="thirdPanel" style="display: none;">
|
||||
<button class="playBtn" id="serverLaunch">Launch Local Server</button>
|
||||
<button class="playBtn" id="serverLaunch" onclick="launchLocalServer()">Launch Local Server</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -109,7 +109,7 @@
|
||||
<span id="genshinPath" style="margin-top: 4px;"></span>
|
||||
</div>
|
||||
<div>
|
||||
<button class="smolBtn" onclick="setGrassCutterFolder()">Set "GrassCutter" folder</button>
|
||||
<button class="smolBtn" onclick="setGrassCutterFolder()">Set "GrassCutter" .jar file</button>
|
||||
<span id="serverPath" style="margin-top: 4px;"></span>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -25,6 +25,10 @@ document.addEventListener('DOMContentLoaded', async () => {
|
||||
handleServerNotSet()
|
||||
}
|
||||
|
||||
if (config.serverLaunchPanel) {
|
||||
displayServerLaunchSection()
|
||||
}
|
||||
|
||||
// Set last connect
|
||||
document.querySelector('#ip').value = config.lastConnect
|
||||
|
||||
@ -396,8 +400,12 @@ async function openSettings() {
|
||||
|
||||
// Fill setting options with what is currently set in config
|
||||
const killSwitch = document.querySelector('#killswitchOption')
|
||||
const serverLaunch = document.querySelector('#serverLaunchOption')
|
||||
|
||||
killSwitch.checked = config.enableKillswitch
|
||||
serverLaunch.checked = config.serverLaunchPanel
|
||||
|
||||
console.log(config)
|
||||
|
||||
// Check for updates
|
||||
//checkForUpdatesAndShow()
|
||||
@ -458,15 +466,20 @@ async function checkForUpdatesAndShow() {
|
||||
}
|
||||
}
|
||||
|
||||
async function toggleServerLaunchSection() {
|
||||
async function displayServerLaunchSection() {
|
||||
const serverPanel = document.querySelector('#thirdPanel')
|
||||
const config = await getCfg()
|
||||
|
||||
if (serverPanel.style.display === 'none') {
|
||||
serverPanel.style.removeProperty('display')
|
||||
} else {
|
||||
serverPanel.style.display = 'none'
|
||||
}
|
||||
}
|
||||
|
||||
async function toggleServerLaunchSection() {
|
||||
const config = await getCfg()
|
||||
|
||||
displayServerLaunchSection()
|
||||
|
||||
// Save setting
|
||||
config.serverLaunchPanel = !config.serverLaunchPanel
|
||||
@ -502,7 +515,11 @@ async function setGenshinImpactFolder() {
|
||||
}
|
||||
|
||||
async function setGrassCutterFolder() {
|
||||
const folder = await Neutralino.os.showFolderDialog('Select GrassCutter folder')
|
||||
const folder = await Neutralino.os.showOpenDialog('Select GrassCutter server jar', {
|
||||
filters: [
|
||||
{ name: 'Jar files', extensions: ['jar'] }
|
||||
]
|
||||
})
|
||||
|
||||
// Set the folder in our configuration
|
||||
const config = await getCfg()
|
||||
@ -557,6 +574,12 @@ async function launchPrivate() {
|
||||
Neutralino.os.execCommand(`${NL_CWD}/scripts/private_server_launch.cmd ${ip} "${config.genshinImpactFolder}/${await getGenshinExecName()}" "${NL_CWD}" ${config.enableKillswitch}`).catch(e => console.log(e))
|
||||
}
|
||||
|
||||
async function launchLocalServer() {
|
||||
const config = await getCfg()
|
||||
|
||||
Neutralino.os.execCommand(`${NL_CWD}/scripts/local_server_launch.cmd "${config.serverFolder}"`).catch(e => console.log(e))
|
||||
}
|
||||
|
||||
/**
|
||||
* Minimize the window
|
||||
*/
|
||||
|
14
scripts/local_server_launch.cmd
Normal file
14
scripts/local_server_launch.cmd
Normal file
@ -0,0 +1,14 @@
|
||||
@echo off
|
||||
|
||||
set GRASSCUTTER_JAR=%1
|
||||
set GRASSCUTTER_JAR=%GRASSCUTTER_JAR:"=%
|
||||
|
||||
:: Ensure admin
|
||||
>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"", "", "runas", 1 >> "%temp%\getadmin.vbs" && "%temp%\getadmin.vbs" && exit /B )
|
||||
)
|
||||
|
||||
echo Starting local Grasscutter server...
|
||||
|
||||
start /b java -jar %GRASSCUTTER_JAR%
|
Loading…
Reference in New Issue
Block a user