mirror of
https://github.com/Grasscutters/GrassClipper.git
synced 2024-08-14 13:11:48 +08:00
handle bgs differently
This commit is contained in:
parent
0584bf5ed7
commit
3a522fb124
@ -34,7 +34,7 @@
|
|||||||
|
|
||||||
<div id="bottomBar">
|
<div id="bottomBar">
|
||||||
<div class="bottomSection">
|
<div class="bottomSection">
|
||||||
<button class="smolBtn" onclick="setGenshinImpactFolder()">Set Genshin Impact folder</button>
|
<button class="smolBtn" onclick="setGenshinImpactFolder()">Set "Genshin Impact Game" folder</button>
|
||||||
<span id="genshinPath" style="margin-top: 4px;"></span>
|
<span id="genshinPath" style="margin-top: 4px;"></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -90,22 +90,33 @@ async function setBackgroundImage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (config.genshinImpactFolder) {
|
if (config.genshinImpactFolder) {
|
||||||
const officialImages = (await Neutralino.filesystem.readDirectory(config.genshinImpactFolder + '/bg')).filter(file => file.type === 'FILE')
|
const officialImages = (await Neutralino.filesystem.readDirectory(config.genshinImpactFolder + '/../bg')).filter(file => file.type === 'FILE')
|
||||||
|
|
||||||
// Pick one of the images
|
if (officialImages.length > 0) {
|
||||||
const image = officialImages[Math.floor(Math.random() * officialImages.length)].entry
|
|
||||||
const path = config.genshinImpactFolder.replace('\\', '/') + '/bg/' + image
|
// Copy to backgrounds folder
|
||||||
|
const officialBgs = (await Neutralino.filesystem.readDirectory(NL_CWD + '/resources/bg/official/')).filter(file => file.type === 'FILE')
|
||||||
// Copy to backgrounds folder
|
|
||||||
const officialBgs = (await Neutralino.filesystem.readDirectory(NL_CWD + '/resources/bg/official/')).filter(file => file.type === 'FILE')
|
officialBgs.forEach(async bg => {
|
||||||
if (!officialBgs.find(file => file.entry === image)) {
|
const path = config.genshinImpactFolder.replace('\\', '/') + '/../bg/' + bg.entry
|
||||||
await Neutralino.filesystem.copyFile(path, NL_CWD + '/resources/bg/official/' + image).catch(e => {
|
|
||||||
// TODO: Handle error
|
// See if the file exists already
|
||||||
|
const currentBgs = (await Neutralino.filesystem.readDirectory(NL_CWD + '/resources/bg/official/')).filter(file => file.type === 'FILE')
|
||||||
|
|
||||||
|
if (!currentBgs.find(file => file.entry === bg.entry)) {
|
||||||
|
await Neutralino.filesystem.copyFile(path, NL_CWD + '/resources/bg/official/' + bg.entry).catch(e => {
|
||||||
|
// TODO: Handle error
|
||||||
|
})
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
|
||||||
|
|
||||||
// Set background image
|
// Pick one of the images
|
||||||
document.querySelector('#firstHalf').style.backgroundImage = `url("../bg/official/${image}")`
|
const localImg = (await Neutralino.filesystem.readDirectory(NL_CWD + '/resources/bg/official')).filter(file => file.type === 'FILE')
|
||||||
|
const image = localImg[Math.floor(Math.random() * localImg.length)].entry
|
||||||
|
|
||||||
|
// Set background image
|
||||||
|
document.querySelector('#firstHalf').style.backgroundImage = `url("../bg/official/${image}")`
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const privImages = (await Neutralino.filesystem.readDirectory(NL_CWD + '/resources/bg/private')).filter(file => file.type === 'FILE' && !file.entry.includes('default'))
|
const privImages = (await Neutralino.filesystem.readDirectory(NL_CWD + '/resources/bg/private')).filter(file => file.type === 'FILE' && !file.entry.includes('default'))
|
||||||
@ -116,7 +127,7 @@ async function setBackgroundImage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function setGenshinImpactFolder() {
|
async function setGenshinImpactFolder() {
|
||||||
const folder = await Neutralino.os.showFolderDialog('Select Genshin Impact folder')
|
const folder = await Neutralino.os.showFolderDialog('Select Genshin Impact Game folder')
|
||||||
|
|
||||||
// Set the folder in our configuration
|
// Set the folder in our configuration
|
||||||
const config = await getCfg()
|
const config = await getCfg()
|
||||||
@ -133,7 +144,7 @@ async function setGenshinImpactFolder() {
|
|||||||
async function getGenshinExecName() {
|
async function getGenshinExecName() {
|
||||||
// Scan genshin dir
|
// Scan genshin dir
|
||||||
const config = await getCfg()
|
const config = await getCfg()
|
||||||
const genshinDir = await Neutralino.filesystem.readDirectory(config.genshinImpactFolder + '/Genshin Impact Game')
|
const genshinDir = await Neutralino.filesystem.readDirectory(config.genshinImpactFolder)
|
||||||
|
|
||||||
// Find the executable
|
// Find the executable
|
||||||
const genshinExec = genshinDir.find(file => file.entry.endsWith('.exe'))
|
const genshinExec = genshinDir.find(file => file.entry.endsWith('.exe'))
|
||||||
@ -144,7 +155,7 @@ async function getGenshinExecName() {
|
|||||||
async function launchOfficial() {
|
async function launchOfficial() {
|
||||||
const config = await getCfg()
|
const config = await getCfg()
|
||||||
|
|
||||||
Neutralino.os.execCommand(config.genshinImpactFolder + '/Genshin Impact Game/' + await getGenshinExecName())
|
Neutralino.os.execCommand(config.genshinImpactFolder + '/' + await getGenshinExecName())
|
||||||
}
|
}
|
||||||
|
|
||||||
async function launchPrivate() {
|
async function launchPrivate() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user