diff options
author | 0neGal <mail@0negal.com> | 2021-12-26 19:06:09 +0100 |
---|---|---|
committer | 0neGal <mail@0negal.com> | 2021-12-26 19:06:09 +0100 |
commit | e6a3c962330289e02276b0fafe4629598933e54e (patch) | |
tree | 1bbd399e922bc475e6a092013a16fc903f2bcf3e /src/index.js | |
parent | 3c4dc8d62d2ccbc4e40c26a4c99475fcd7e75036 (diff) | |
download | Viper-e6a3c962330289e02276b0fafe4629598933e54e.tar.gz Viper-e6a3c962330289e02276b0fafe4629598933e54e.zip |
you can now set the game path in the UI
Diffstat (limited to 'src/index.js')
-rw-r--r-- | src/index.js | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/index.js b/src/index.js index ebea48f..0babcea 100644 --- a/src/index.js +++ b/src/index.js @@ -1,5 +1,6 @@ +const fs = require("fs"); const path = require("path"); -const { app, BrowserWindow } = require("electron"); +const { app, dialog, ipcMain, BrowserWindow } = require("electron"); function start() { win = new BrowserWindow({ @@ -16,6 +17,14 @@ function start() { win.removeMenu(); win.loadFile(__dirname + "/app/index.html"); win.webContents.once("dom-ready", () => {win.show()}); + + ipcMain.on("setpath", (event) => { + dialog.showOpenDialog({properties: ["openDirectory"]}).then(res => { + fs.writeFileSync(app.getPath("appData") + "/viper.json", JSON.stringify({path: res.filePaths[0]})) + + win.webContents.send("newpath", res.filePaths[0]); + }).catch(err => {console.error(err)}) + }) } app.on("ready", () => { @@ -23,4 +32,3 @@ app.on("ready", () => { app.setPath("userData", path.join(app.getPath("cache"), app.name)); start(); }) - |