diff options
author | 0neGal <mail@0negal.com> | 2024-12-20 13:09:12 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-12-20 13:09:12 +0100 |
commit | 28130f46eb9c167671994b47b77b926386002ac2 (patch) | |
tree | 26185cbcba747df98e6de6d7e225777093c6720c /src/index.js | |
parent | 8fddf38701f50015ee8f61ce7bc8978f1dcebfd3 (diff) | |
parent | b9c0243d6433550784116fac7eec462cc5ae2a79 (diff) | |
download | Viper-28130f46eb9c167671994b47b77b926386002ac2.tar.gz Viper-28130f46eb9c167671994b47b77b926386002ac2.zip |
Merge pull request #248 from Jan200101/PR/protocol
feat: support thunderstore ror2mm protocol for installing mods
Diffstat (limited to 'src/index.js')
-rw-r--r-- | src/index.js | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/src/index.js b/src/index.js index 9321598..c6a7ba8 100644 --- a/src/index.js +++ b/src/index.js @@ -1,5 +1,5 @@ const path = require("path"); -const { app, BrowserWindow } = require("electron"); +const { app, BrowserWindow, dialog } = require("electron"); // makes it so Electron cache doesn't get stored in your system's config // folder, and instead changing it over to using the system's cache @@ -10,11 +10,13 @@ app.setPath("userData", path.join(app.getPath("cache"), app.name)); process.chdir(app.getPath("appData")); const cli = require("./cli"); +const lang = require("./lang"); const mods = require("./modules/mods"); const update = require("./modules/update"); const version = require("./modules/version"); const settings = require("./modules/settings"); +const protocol = require("./modules/protocol"); // loads `ipcMain` events that dont fit in any of the modules directly require("./modules/ipc"); @@ -88,6 +90,7 @@ function start() { // load list of mods on initial load win.webContents.on("dom-ready", () => { + protocol(); send("mods", mods.list()); }) @@ -103,6 +106,7 @@ function start() { } } + // starts the GUI or CLI if (cli.hasArgs()) { if (cli.hasParam("update-viper")) { @@ -112,9 +116,29 @@ if (cli.hasArgs()) { cli.init(); } } else { + app.setAsDefaultProtocolClient("ror2mm"); + + const app_lock = app.requestSingleInstanceLock() + // start the window/GUI app.on("ready", () => { + if (!app_lock) { + // Viper is already running + if (process.argv.length <= (app.isPackaged ? 1 : 2)) + { + dialog.showMessageBoxSync({ + title: lang("viper.menu.main"), + message: lang("viper.already_running") + }); + } + app.quit(); + } start(); }) + + app.on('second-instance', (event, commandLine, workingDirectory, additionalData) => { + protocol(commandLine); + }) + } |