From b402cc7f6ed0d67f4eb43918f17ee4ff9cb50af1 Mon Sep 17 00:00:00 2001 From: Martin Fournier Date: Fri, 31 Dec 2021 04:22:04 -0500 Subject: [PATCH] Add warning on game close if user launched browser --- electron/gameWindow.js | 2 ++ electron/main.js | 14 +++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/electron/gameWindow.js b/electron/gameWindow.js index 71854def6..39fdaea0e 100644 --- a/electron/gameWindow.js +++ b/electron/gameWindow.js @@ -32,6 +32,8 @@ async function createWindow(killall) { // and open every other protocols on the browser e.preventDefault(); shell.openExternal(url); + + global.app_playerOpenedExternalLink = true; }); window.webContents.backgroundThrottling = false; diff --git a/electron/main.js b/electron/main.js index b1f95e6bd..489f5b078 100644 --- a/electron/main.js +++ b/electron/main.js @@ -1,6 +1,6 @@ /* eslint-disable no-process-exit */ /* eslint-disable @typescript-eslint/no-var-requires */ -const { app } = require("electron"); +const { app, dialog } = require("electron"); const log = require("electron-log"); const greenworks = require("./greenworks"); const api = require("./api-server"); @@ -32,6 +32,18 @@ function setStopProcessHandler(app, window, enabled) { // Shutdown the http server api.disable(); + // Because of a steam limitation, if the player has launched an external browser, + // steam will keep displaying the game as "Running" in their UI as long as the browser is up. + // So we'll alert the player to close their browser. + if (global.app_playerOpenedExternalLink) { + await dialog.showMessageBox({ + title: 'Bitburner', + message: 'You may have to close your browser to properly exit the game.', + detail: 'Steam will keep tracking Bitburner as "Running" if any process started within the game is still running.' + + ' This includes launching an external link, which opens up your browser.', + type: 'warning', buttons: ['OK'] + }); + } // We'll try to execute javascript on the page to see if we're stuck let canRunJS = false; window.webContents.executeJavaScript('window.stop(); document.close()', true)