diff --git a/main.js b/main.js
index c8eaacc..a9d9d0a 100644
--- a/main.js
+++ b/main.js
@@ -1,6 +1,7 @@
const { app, BrowserWindow , ipcMain} = require('electron/main');
const path = require('node:path');
const Store = require('electron-store').default;
+const fs = require('fs/promises');
const store = new Store();
@@ -38,4 +39,17 @@ ipcMain.handle('save-path', (event, path) => {
ipcMain.handle('load-path', () => {
return store.get('silksong-path');
+});
+
+async function fileExists(filePath) {
+ try {
+ await fs.access(filePath);
+ return true;
+ } catch {
+ return false;
+ }
+}
+
+ipcMain.handle('file-exists', async (_, filePath) => {
+ return await fileExists(filePath);
});
\ No newline at end of file
diff --git a/preload.js b/preload.js
index 9aa5eae..36fa8a4 100644
--- a/preload.js
+++ b/preload.js
@@ -11,4 +11,8 @@ contextBridge.exposeInMainWorld('save', {
ipcRenderer.invoke('save-path', path),
loadSilksongPath: () =>
ipcRenderer.invoke('load-path')
-})
\ No newline at end of file
+})
+
+contextBridge.exposeInMainWorld('files', {
+ fileExists: (path) => ipcRenderer.invoke('file-exists', path)
+});
\ No newline at end of file
diff --git a/renderer/index.html b/renderer/index.html
index 6c8d2c2..b5be715 100644
--- a/renderer/index.html
+++ b/renderer/index.html
@@ -83,7 +83,7 @@
General settings
-
+
diff --git a/renderer/renderer.js b/renderer/renderer.js
index 6b10458..9200056 100644
--- a/renderer/renderer.js
+++ b/renderer/renderer.js
@@ -9,6 +9,7 @@ const settingsTemplate = document.getElementById("settings-template");
const versionText = HomeTemplate.content.getElementById("version-text")
navigate("home")
+autoDetectGamePath()
async function navigate(page) {
view.replaceChildren()
@@ -37,13 +38,11 @@ async function navigate(page) {
const settingsTemplateCopy = settingsTemplate.content.cloneNode(true)
const silksongPathInput = settingsTemplateCopy.getElementById("silksong-path-input")
- silksongPathInput.value = await window.save.loadSilksongPath()
+ silksongPathInput.value = await save.loadSilksongPath()
silksongPathInput.addEventListener('input', async function(event) {
let silksongPath = silksongPathInput.value
- console.log(silksongPath)
- await window.save.saveSilksongPath(silksongPath)
- console.log(await window.save.loadSilksongPath())
+ await save.saveSilksongPath(silksongPath)
});
view.appendChild(settingsTemplateCopy)
@@ -52,4 +51,11 @@ async function navigate(page) {
function launch(mode) {
alert(`Launching the game in ${mode} mode.`);
+}
+
+async function autoDetectGamePath() {
+ const defaultSilksongPath = "C:/Program Files (x86)/Steam/steamapps/common/Hollow Knight Silksong/Hollow Knight Silksong.exe"
+ if (files.fileExists(defaultSilksongPath)) {
+ await save.saveSilksongPath(defaultSilksongPath)
+ }
}
\ No newline at end of file
diff --git a/renderer/style.css b/renderer/style.css
index 47e5a3c..a07d823 100644
--- a/renderer/style.css
+++ b/renderer/style.css
@@ -133,4 +133,12 @@ body {
input[type="range"] {
width: 100%;
+}
+
+.default-button {
+
+}
+
+.default-button:hover {
+
}
\ No newline at end of file