mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-27 01:53:48 +01:00
Merge pull request #2570 from MartinFournier/feature/save-exclude-running-scripts
Add option to exclude running scripts from save
This commit is contained in:
commit
b7fb59691b
@ -43,10 +43,10 @@ class BitburnerSaveObject {
|
|||||||
StaneksGiftSave = "";
|
StaneksGiftSave = "";
|
||||||
SaveTimestamp = "";
|
SaveTimestamp = "";
|
||||||
|
|
||||||
getSaveString(): string {
|
getSaveString(excludeRunningScripts = false): string {
|
||||||
this.PlayerSave = JSON.stringify(Player);
|
this.PlayerSave = JSON.stringify(Player);
|
||||||
|
|
||||||
this.AllServersSave = saveAllServers();
|
this.AllServersSave = saveAllServers(excludeRunningScripts);
|
||||||
this.CompaniesSave = JSON.stringify(Companies);
|
this.CompaniesSave = JSON.stringify(Companies);
|
||||||
this.FactionsSave = JSON.stringify(Factions);
|
this.FactionsSave = JSON.stringify(Factions);
|
||||||
this.AliasesSave = JSON.stringify(Aliases);
|
this.AliasesSave = JSON.stringify(Aliases);
|
||||||
@ -68,7 +68,7 @@ class BitburnerSaveObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
saveGame(emitToastEvent = true): void {
|
saveGame(emitToastEvent = true): void {
|
||||||
const saveString = this.getSaveString();
|
const saveString = this.getSaveString(Settings.ExcludeRunningScriptsFromSave);
|
||||||
|
|
||||||
save(saveString)
|
save(saveString)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
@ -80,7 +80,7 @@ class BitburnerSaveObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
exportGame(): void {
|
exportGame(): void {
|
||||||
const saveString = this.getSaveString();
|
const saveString = this.getSaveString(Settings.ExcludeRunningScriptsFromSave);
|
||||||
|
|
||||||
// Save file name is based on current timestamp and BitNode
|
// Save file name is based on current timestamp and BitNode
|
||||||
const epochTime = Math.round(Date.now() / 1000);
|
const epochTime = Math.round(Date.now() / 1000);
|
||||||
|
@ -204,10 +204,14 @@ export function loadAllServers(saveString: string): void {
|
|||||||
AllServers = JSON.parse(saveString, Reviver);
|
AllServers = JSON.parse(saveString, Reviver);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function saveAllServers(): string {
|
export function saveAllServers(excludeRunningScripts = false): string {
|
||||||
const TempAllServers = JSON.parse(JSON.stringify(AllServers), Reviver);
|
const TempAllServers = JSON.parse(JSON.stringify(AllServers), Reviver);
|
||||||
for (const key in TempAllServers) {
|
for (const key in TempAllServers) {
|
||||||
const server = TempAllServers[key];
|
const server = TempAllServers[key];
|
||||||
|
if (excludeRunningScripts) {
|
||||||
|
server.runningScripts = [];
|
||||||
|
continue;
|
||||||
|
}
|
||||||
for (let i = 0; i < server.runningScripts.length; ++i) {
|
for (let i = 0; i < server.runningScripts.length; ++i) {
|
||||||
const runningScriptObj = server.runningScripts[i];
|
const runningScriptObj = server.runningScripts[i];
|
||||||
runningScriptObj.logs.length = 0;
|
runningScriptObj.logs.length = 0;
|
||||||
|
@ -117,6 +117,11 @@ interface IDefaultSettings {
|
|||||||
*/
|
*/
|
||||||
SuppressSavedGameToast: boolean;
|
SuppressSavedGameToast: boolean;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Whether the game should skip saving the running scripts for late game
|
||||||
|
*/
|
||||||
|
ExcludeRunningScriptsFromSave: boolean;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Theme colors
|
* Theme colors
|
||||||
*/
|
*/
|
||||||
@ -187,6 +192,7 @@ export const defaultSettings: IDefaultSettings = {
|
|||||||
SuppressTIXPopup: false,
|
SuppressTIXPopup: false,
|
||||||
SuppressSavedGameToast: false,
|
SuppressSavedGameToast: false,
|
||||||
UseIEC60027_2: false,
|
UseIEC60027_2: false,
|
||||||
|
ExcludeRunningScriptsFromSave: false,
|
||||||
|
|
||||||
theme: defaultTheme,
|
theme: defaultTheme,
|
||||||
styles: defaultStyles,
|
styles: defaultStyles,
|
||||||
@ -223,6 +229,7 @@ export const Settings: ISettings & ISelfInitializer & ISelfLoading = {
|
|||||||
SuppressTIXPopup: defaultSettings.SuppressTIXPopup,
|
SuppressTIXPopup: defaultSettings.SuppressTIXPopup,
|
||||||
SuppressSavedGameToast: defaultSettings.SuppressSavedGameToast,
|
SuppressSavedGameToast: defaultSettings.SuppressSavedGameToast,
|
||||||
UseIEC60027_2: defaultSettings.UseIEC60027_2,
|
UseIEC60027_2: defaultSettings.UseIEC60027_2,
|
||||||
|
ExcludeRunningScriptsFromSave: defaultSettings.ExcludeRunningScriptsFromSave,
|
||||||
MonacoTheme: "monokai",
|
MonacoTheme: "monokai",
|
||||||
MonacoInsertSpaces: false,
|
MonacoInsertSpaces: false,
|
||||||
MonacoFontSize: 20,
|
MonacoFontSize: 20,
|
||||||
|
@ -426,6 +426,14 @@ export function GameOptionsRoot(props: IProps): React.ReactElement {
|
|||||||
If this is set all references to memory will use GiB instead of GB, in accordance with IEC 60027-2.
|
If this is set all references to memory will use GiB instead of GB, in accordance with IEC 60027-2.
|
||||||
</>} />
|
</>} />
|
||||||
</ListItem>
|
</ListItem>
|
||||||
|
<ListItem>
|
||||||
|
<OptionSwitch checked={Settings.ExcludeRunningScriptsFromSave}
|
||||||
|
onChange={(newValue) => Settings.ExcludeRunningScriptsFromSave = newValue}
|
||||||
|
text="Exclude Running Scripts from Save"
|
||||||
|
tooltip={<>
|
||||||
|
If this is set, the save file will exclude all running scripts. This is only useful if your save is lagging a lot. You'll have to restart your script every time you launch the game.
|
||||||
|
</>} />
|
||||||
|
</ListItem>
|
||||||
<ListItem>
|
<ListItem>
|
||||||
<Tooltip
|
<Tooltip
|
||||||
title={
|
title={
|
||||||
|
Loading…
Reference in New Issue
Block a user