mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-26 17:43:48 +01:00
Merge pull request #2624 from MartinFournier/fix/allow-no-steam
Handle greenworks.init() errors gracefully
This commit is contained in:
commit
d1f145a6c2
@ -3,6 +3,9 @@ const greenworks = require("./greenworks");
|
||||
const log = require("electron-log");
|
||||
|
||||
function enableAchievementsInterval(window) {
|
||||
// If the Steam API could not be initialized on game start, we'll abort this.
|
||||
if (global.greenworksError) return;
|
||||
|
||||
// This is backward but the game fills in an array called `document.achievements` and we retrieve it from
|
||||
// here. Hey if it works it works.
|
||||
const steamAchievements = greenworks.getAchievementNames();
|
||||
|
@ -16,10 +16,18 @@ process.on('uncaughtException', function () {
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
if (greenworks.init()) {
|
||||
// We want to fail gracefully if we cannot connect to Steam
|
||||
try {
|
||||
if (greenworks.init()) {
|
||||
log.info("Steam API has been initialized.");
|
||||
} else {
|
||||
log.warn("Steam API has failed to initialize.");
|
||||
} else {
|
||||
const error = "Steam API has failed to initialize.";
|
||||
log.warn(error);
|
||||
global.greenworksError = error;
|
||||
}
|
||||
} catch (ex) {
|
||||
log.warn(ex.message);
|
||||
global.greenworksError = ex.message;
|
||||
}
|
||||
|
||||
function setStopProcessHandler(app, window, enabled) {
|
||||
@ -113,4 +121,13 @@ app.whenReady().then(async () => {
|
||||
} else {
|
||||
startWindow(process.argv.includes("--no-scripts"));
|
||||
}
|
||||
|
||||
if (global.greenworksError) {
|
||||
dialog.showMessageBox({
|
||||
title: 'Bitburner',
|
||||
message: 'Could not connect to Steam',
|
||||
detail: `${global.greenworksError}\n\nYou won't be able to receive achievements until this is resolved and you restart the game.`,
|
||||
type: 'warning', buttons: ['OK']
|
||||
});
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user