disable/enable server button

This commit is contained in:
SpikeHD 2022-04-22 19:43:50 -07:00
parent 8c9ca55dae
commit ee73186016
2 changed files with 55 additions and 2 deletions

View File

@ -9,6 +9,7 @@ const filesystem = Neutralino.filesystem
document.addEventListener('DOMContentLoaded', async () => { document.addEventListener('DOMContentLoaded', async () => {
setBackgroundImage(); setBackgroundImage();
displayGenshinFolder(); displayGenshinFolder();
displayServerFolder();
// Set title version // Set title version
document.querySelector('#version').innerHTML = NL_APPVERSION document.querySelector('#version').innerHTML = NL_APPVERSION
@ -20,6 +21,10 @@ document.addEventListener('DOMContentLoaded', async () => {
handleGenshinFolderNotSet() handleGenshinFolderNotSet()
} }
if (!config.serverFolder) {
handleServerNotSet()
}
// Set last connect // Set last connect
document.querySelector('#ip').value = config.lastConnect document.querySelector('#ip').value = config.lastConnect
@ -92,6 +97,7 @@ async function getFavIps() {
async function getCfg() { async function getCfg() {
const defaultConf = { const defaultConf = {
genshinImpactFolder: '', genshinImpactFolder: '',
serverFolder: '',
lastConnect: '', lastConnect: '',
enableKillswitch: false, enableKillswitch: false,
serverLaunchPanel: false serverLaunchPanel: false
@ -126,6 +132,16 @@ async function enableButtons() {
} }
} }
/**
* Enable server launch button
*/
async function enableServerButton() {
const serverBtn = document.querySelector('#serverLaunch')
serverBtn.classList.remove('disabled')
serverBtn.disabled = false
}
/** /**
* Disable buttons when the game folder is not set * Disable buttons when the game folder is not set
*/ */
@ -148,6 +164,19 @@ async function handleGenshinFolderNotSet() {
// TODO show a dialog of sorts // TODO show a dialog of sorts
} }
async function handleServerNotSet() {
// Set buttons to greyed out and disable
document.querySelector('#serverPath').innerHTML = 'Not set'
// Set official server background to default
// document.querySelector('#firstPanel').style.backgroundImage = `url("../bg/private/default.png")`
const privBtn = document.querySelector('#serverLaunch')
privBtn.classList.add('disabled')
privBtn.disabled = true
}
async function proxyIsInstalled() { async function proxyIsInstalled() {
// Check if the proxy server is installed // Check if the proxy server is installed
const curDirList = await filesystem.readDirectory(NL_CWD) const curDirList = await filesystem.readDirectory(NL_CWD)
@ -173,6 +202,16 @@ async function displayGenshinFolder() {
elm.innerHTML = config.genshinImpactFolder elm.innerHTML = config.genshinImpactFolder
} }
/**
* Show the server folder under the select button
*/
async function displayServerFolder() {
const elm = document.querySelector('#serverPath')
const config = await getCfg()
elm.innerHTML = config.serverFolder
}
/** /**
* Set the background images of both the private and public sections * Set the background images of both the private and public sections
*/ */
@ -366,11 +405,12 @@ async function openSettings() {
async function closeSettings() { async function closeSettings() {
const settings = document.querySelector('#settingsPanel') const settings = document.querySelector('#settingsPanel')
const config = await getCfg()
settings.style.display = 'none' settings.style.display = 'none'
// In case we installed the proxy server // In case we installed the proxy server
if (await proxyIsInstalled()) { if (await proxyIsInstalled() && config.genshinImpactFolder) {
const playPriv = document.querySelector('#playPrivate') const playPriv = document.querySelector('#playPrivate')
playPriv.classList.remove('disabled') playPriv.classList.remove('disabled')
@ -461,6 +501,19 @@ async function setGenshinImpactFolder() {
enableButtons() enableButtons()
} }
async function setGrassCutterFolder() {
const folder = await Neutralino.os.showFolderDialog('Select GrassCutter folder')
// Set the folder in our configuration
const config = await getCfg()
config.serverFolder = folder
Neutralino.storage.setData('config', JSON.stringify(config))
displayServerFolder()
enableServerButton()
}
/** /**
* Get the name of the game executable * Get the name of the game executable
* *

View File

@ -298,7 +298,7 @@ body {
height: 10%; height: 10%;
} }
#genshinPath { #genshinPath, #serverPath {
color: white; color: white;
font-size: 14px; font-size: 14px;
} }