mirror of
https://github.com/Gabi-Zar/Silk-Fly-Launcher.git
synced 2026-04-17 05:26:04 +02:00
fix and improve auto game path detection
This commit is contained in:
5
main.js
5
main.js
@@ -4,6 +4,7 @@ const Store = require('electron-store').default;
|
|||||||
const fs = require('fs/promises');
|
const fs = require('fs/promises');
|
||||||
|
|
||||||
const store = new Store();
|
const store = new Store();
|
||||||
|
const userSavePath = app.getPath('userData')
|
||||||
|
|
||||||
const createWindow = () => {
|
const createWindow = () => {
|
||||||
const win = new BrowserWindow({
|
const win = new BrowserWindow({
|
||||||
@@ -52,4 +53,8 @@ async function fileExists(filePath) {
|
|||||||
|
|
||||||
ipcMain.handle('file-exists', async (_, filePath) => {
|
ipcMain.handle('file-exists', async (_, filePath) => {
|
||||||
return await fileExists(filePath);
|
return await fileExists(filePath);
|
||||||
|
});
|
||||||
|
|
||||||
|
ipcMain.handle('get-userSavePath', () => {
|
||||||
|
return userSavePath
|
||||||
});
|
});
|
||||||
@@ -4,15 +4,16 @@ contextBridge.exposeInMainWorld('versions', {
|
|||||||
node: () => process.versions.node,
|
node: () => process.versions.node,
|
||||||
chrome: () => process.versions.chrome,
|
chrome: () => process.versions.chrome,
|
||||||
electron: () => process.versions.electron
|
electron: () => process.versions.electron
|
||||||
})
|
});
|
||||||
|
|
||||||
contextBridge.exposeInMainWorld('save', {
|
contextBridge.exposeInMainWorld('save', {
|
||||||
saveSilksongPath: (path) =>
|
saveSilksongPath: (path) =>
|
||||||
ipcRenderer.invoke('save-path', path),
|
ipcRenderer.invoke('save-path', path),
|
||||||
loadSilksongPath: () =>
|
loadSilksongPath: () =>
|
||||||
ipcRenderer.invoke('load-path')
|
ipcRenderer.invoke('load-path')
|
||||||
})
|
});
|
||||||
|
|
||||||
contextBridge.exposeInMainWorld('files', {
|
contextBridge.exposeInMainWorld('files', {
|
||||||
fileExists: (path) => ipcRenderer.invoke('file-exists', path)
|
fileExists: (path) => ipcRenderer.invoke('file-exists', path),
|
||||||
|
userSavePath: () => ipcRenderer.invoke('get-userSavePath')
|
||||||
});
|
});
|
||||||
@@ -9,7 +9,15 @@ const settingsTemplate = document.getElementById("settings-template");
|
|||||||
const versionText = HomeTemplate.content.getElementById("version-text")
|
const versionText = HomeTemplate.content.getElementById("version-text")
|
||||||
|
|
||||||
navigate("home")
|
navigate("home")
|
||||||
autoDetectGamePath()
|
|
||||||
|
files.userSavePath().then(path => {
|
||||||
|
path = `${path}\\config.json`
|
||||||
|
files.fileExists(path).then(result => {
|
||||||
|
if(!result) {
|
||||||
|
autoDetectGamePath()
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
async function navigate(page) {
|
async function navigate(page) {
|
||||||
view.replaceChildren()
|
view.replaceChildren()
|
||||||
@@ -55,7 +63,7 @@ function launch(mode) {
|
|||||||
|
|
||||||
async function autoDetectGamePath() {
|
async function autoDetectGamePath() {
|
||||||
const defaultSilksongPath = "C:/Program Files (x86)/Steam/steamapps/common/Hollow Knight Silksong/Hollow Knight Silksong.exe"
|
const defaultSilksongPath = "C:/Program Files (x86)/Steam/steamapps/common/Hollow Knight Silksong/Hollow Knight Silksong.exe"
|
||||||
if (files.fileExists(defaultSilksongPath)) {
|
if (await files.fileExists(defaultSilksongPath)) {
|
||||||
await save.saveSilksongPath(defaultSilksongPath)
|
await save.saveSilksongPath(defaultSilksongPath)
|
||||||
if (document.getElementById("silksong-path-input")) {
|
if (document.getElementById("silksong-path-input")) {
|
||||||
document.getElementById("silksong-path-input").value = await save.loadSilksongPath()
|
document.getElementById("silksong-path-input").value = await save.loadSilksongPath()
|
||||||
|
|||||||
Reference in New Issue
Block a user