Commit Graph

74 Commits

Author SHA1 Message Date
Martin Fournier
d386528627 Add support for Steam Cloud & local filesystem
Adds actions to save the game's data directly in the filesystem and/or
into Steam Cloud. Them game will push an event with the save data
whenever the game is saved. Electron will use that data to persist it
into the User Data folder, until the folder reaches a certain size.
Once over the quota, it's going to remove previous saves.

Files are grouped according the the player's identifier, ensuring
backups off different playthroughs if importing.

Optionally, the file will be gzipped before saving to disk, largely
reducing file size.

Adds a way to save & load from Steam Cloud, currently manually only.

When loading a save, it'll trigger the new "Import Data Comparison" page
to accept or cancel the import.

When saving the game, it will save to Steam Cloud & to filesystem if the
options are enabled.

Add automatic game restore

Detects when the player has access to a newer game that has been saved
more recently than the one being loaded. It checks both in the Steam
Cloud and on the local filesystem. Adds an option to disable the
feature.

- Adds a "Save Game" menu item that triggers the game's save.
- Adds a "Export Game" menu item that triggers the download file popup.
- Adds a "Export Scripts" menu item that triggers the "download *"
terminal command.
- Adds a "Load Last Save" menu item that loads the latest file modified
in the user data folder.
- Adds a "Load from Steam Cloud" menu item.
- Adds a "Load From File" menu item that popups a file selector & loads
the file.
- Adds settings for "Saves Compression (.gz)", "Auto-save Backups" &
"Auto-save to Steam", toggleable through the menu.
- Adds a "Open Game Data","Open Saves", "Open Logs" & "Open User Data" menu items.
- Adds a "Quit" menu item.
2022-01-26 03:56:19 -05:00
Martin Fournier
855a4e622d Add Electron preload script to allow communication
Adds a channel to communicate between the main process & the renderer
process, so that the game can easily ship data back to the main process.

It uses the Electron contextBridge & ipcRenderer/ipcMain.

Connects those events to various save functions. Adds triggered events
on game save, game load, and imported game. Adds way for the Electron
app to ask for certain actions or data.

Hook handlers to disable automatic restore

Allows to temporarily disable restore when the game just did an import
or deleted a save game. Prevents looping screens.
2022-01-26 03:56:19 -05:00
Martin Fournier
5c1504d7e4 Include lodash in Electron
Will be used to debounce function calls. Is a prerequisite for a few
other fixes.
2022-01-26 03:40:22 -05:00
hydroflame
d27bac9be6
Merge pull request #2716 from lordducky/enhance-api-server
Enhance api server
2022-01-26 00:53:17 -05:00
hydroflame
2c9302ee53
Merge pull request #2778 from MartinFournier/feat/electron-build-script
Modify electron build script to allow platform selection
2022-01-26 00:40:49 -05:00
hydroflame
862835e452
Merge pull request #2777 from MartinFournier/feat/electron-linux-icon
Add missing steam app icon for linux
2022-01-26 00:40:18 -05:00
hydroflame
de122eca73
Merge pull request #2779 from MartinFournier/fix/electron-mac-crash
Fix 'Steam not running' popup causing crash on MacOS
2022-01-26 00:36:57 -05:00
Martin Fournier
df0a86966a Add icon for linux 2022-01-23 16:52:19 -05:00
Martin Fournier
abfb2127f2 Fix 'Steam not running' popup causing crash on Mac 2022-01-23 13:04:19 -05:00
Martin Fournier
ee416dc06e Set nativeWindowOpen to fix deprecation warning 2022-01-23 13:01:40 -05:00
Martin Fournier
1d118cc8be Modify electron build script to select platforms
Allows to build only mac windows or linux for a quicker build time while
developping.
2022-01-23 12:58:20 -05:00
Xi-Lin Yeh
935f4718e0 Fix type in delete function 2022-01-21 08:52:53 -08:00
Xi-Lin Yeh
861fcf70c4 Clean invocation of get/delete 2022-01-20 09:39:50 -08:00
Xi-Lin Yeh
5386f8e027 Commonalize Api-server response handling
- Fixed issue with error headers
- Aggregated response handling
2022-01-20 00:14:42 -08:00
Xi-Lin Yeh
4a3ee95b63 Enhanced API Server interface
- Used restful patterns for handling server calls (GET/PUT/DELETE)

- Utilized Server interface for saves rather than reimplementing code

- Exposed operations for getting codebase of scripts on the home server and deleting files.

- Added a common response structure
2022-01-20 00:03:07 -08:00
Heikki Aitakangas
f8e64a1b4f Reduce log level for the all achievements and player achievements listings 2022-01-14 23:41:01 +02:00
Heikki Aitakangas
c7c303c551 Handle Steam achievement status check failure by logging them 2022-01-14 23:41:01 +02:00
Heikki Aitakangas
521889b027 Fix Steam version trying to record every achievement player has every second 2022-01-14 23:40:59 +02:00
Martin Fournier
8192ab09ef Handle greenworks.init() errors gracefully
Since we are only using it to track achievements, we can still launch
the game if it fails to initialize, we just have to not run the
achievements interval.

Adds a dialog that tells the user to fix the issue & restart the game to
enable achievements.
2022-01-14 06:06:59 -05:00
Martin Fournier
63413a646a Prevent external files to be opened by electron 2022-01-11 11:04:58 -05:00
Olivier Gagnon
ab15481cd6 try to fix the game hanging 2022-01-09 14:11:33 -05:00
hydroflame
060224182f
Merge pull request #2365 from MartinFournier/fix/achievements-timer
Include electron-log in achievements file
2022-01-06 11:26:27 -05:00
Martin Fournier
674d8a3f06 Include electron-log in achievements file
When the timer throws an exception, it tried to log the error but log
was not defined.
2022-01-05 14:17:54 -05:00
Martin Fournier
1d89dd9d41 Add 'host' config for electron api server
Only tweakable through the config, this can allow external
access to the server (ie - if running through a VM or WSL)
2022-01-05 14:15:40 -05:00
Martin Fournier
0b88922ab7 Add zoom to electron app 2022-01-04 21:20:42 -05:00
Martin Fournier
de8e5ef441 Fix unresponsive handler being attached many times 2022-01-04 18:16:07 -05:00
Martin Fournier
6d8df6744e Add toasts & terminal funcs to electron app
Attach functions to the window object so that the wrapper can executeJs
to display messages to the player
2022-01-03 10:32:01 -05:00
Martin Fournier
bdef14b029 Add API server information menu item 2022-01-03 10:29:56 -05:00
hydroflame
a2d75ae10c
Merge branch 'dev' into feature/alert-close-browser 2022-01-02 11:44:47 -05:00
Martin Fournier
b402cc7f6e Add warning on game close if user launched browser 2021-12-31 04:22:04 -05:00
Martin Fournier
bc0791840f Add launch option to directly export save game
If --export-save is set, it will not launch the index.html and instead
launch a blank page. It then reads from the IndexedDb to fetch the
bitburnerSave value and prompts a save file dialog.
2021-12-30 11:51:15 -05:00
Martin Fournier
bf1a2b56ba Use global references for electron event handlers
I messed up the handlers reference in the last commit so the events
were not properly attached. Changed it to use global variables for now.
2021-12-30 09:12:55 -05:00
Martin Fournier
a098289856 Refactor electron app into multiple files
Gracefully handle http-server start error & cleanup logs
2021-12-29 08:46:56 -05:00
Martin Fournier
5d7d72a3e2 Add authorization token to file system api 2021-12-28 15:37:22 -05:00
Martin Fournier
ea03889082 Crash render process when javascript won't execute
Prevents the renderer process staying up when the user scripts are
waiting for an unresolved promise.
2021-12-23 07:48:01 -05:00
hydroflame
bfdfee2a68
Merge branch 'dev' into mychanges 2021-12-22 16:16:24 -05:00
Olivier Gagnon
d2d6c33fc8 mychanges 2021-12-22 16:15:56 -05:00
Martin Fournier
6363c704db Handle electron process uncaught exceptions
Handling the exceptions and closing the app seem to properly kill the
dangling processes that appear at launch in Windows 10. Without this, if
an exception is throw before the window is active (ie: no
steamapp_id.txt file), there will be remaining processes.

Added electron-log to additionally log to a text file.
2021-12-22 15:28:55 -05:00
Martin Fournier
9ce8bdd29b Add dialog when app is unresponsive to reload
Checks the electron event 'unresponsive' and triggers a reload / cancel
dialog. Allows all scripts to be killed, checked by default.
Also adds a warning to the terminal when noScript has been executed.
2021-12-22 15:14:03 -05:00
Olivier Gagnon
b2b682fa04 fix editor not loading files 2021-12-21 13:44:18 -05:00
Martin Fournier
3b99da8474 Lint current problems & fix ignore paths 2021-12-19 13:17:44 -05:00
Olivier Gagnon
21191e0b8d re-add noscripts 2021-12-18 10:44:22 -05:00
Olivier Gagnon
1368e468bb Merge branch 'dev' of github.com:danielyxie/bitburner into dev 2021-12-18 10:31:59 -05:00
Olivier Gagnon
5bb304caff rm console log 2021-12-17 16:33:55 -05:00
hydroflame
b122cebc98
Merge pull request #1972 from MartinFournier/feature/electron-background-color
Fix #1902: Set default electron color to black
2021-12-17 12:55:32 -05:00
hydroflame
c6843b231a Merge pull request #1962 from MartinFournier/feature/exit-process
Attempt to fix processes that stay up after closing app
2021-12-17 12:13:50 -05:00
hydroflame
196086cc13
Merge branch 'dev' into feature/exit-process 2021-12-17 11:49:58 -05:00
Olivier Gagnon
36fd3c5d68 try kill again 2021-12-17 11:38:00 -05:00
Martin Fournier
6d94ee0c2c Fix #1902: Set default electron color to black
If loading of the index.html is slow, there should be no white
background anymore.
2021-12-17 05:52:31 -05:00
Olivier Gagnon
6c5842d2e7 noscripts backup 2021-12-17 01:33:35 -05:00