mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-26 09:33:49 +01:00
Add a warning triggered while auto-saves are off
The check auto-save engine loop will show a warning toast if the auto-saves are disabled (at 0s) and not suppressed. This warning includes a button to re-enable them. Adds a user setting to suppress those warnings. Adds information to save button tooltip.
This commit is contained in:
parent
1c801c5651
commit
2262d6d8dd
@ -118,6 +118,11 @@ interface IDefaultSettings {
|
||||
*/
|
||||
SuppressSavedGameToast: boolean;
|
||||
|
||||
/**
|
||||
* Whether the user should be displayed a toast warning when the autosave is disabled.
|
||||
*/
|
||||
SuppressAutosaveDisabledWarnings: boolean;
|
||||
|
||||
/*
|
||||
* Whether the game should skip saving the running scripts for late game
|
||||
*/
|
||||
@ -197,6 +202,7 @@ export const defaultSettings: IDefaultSettings = {
|
||||
SuppressBladeburnerPopup: false,
|
||||
SuppressTIXPopup: false,
|
||||
SuppressSavedGameToast: false,
|
||||
SuppressAutosaveDisabledWarnings: false,
|
||||
UseIEC60027_2: false,
|
||||
ExcludeRunningScriptsFromSave: false,
|
||||
IsSidebarOpened: true,
|
||||
@ -235,6 +241,7 @@ export const Settings: ISettings & ISelfInitializer & ISelfLoading = {
|
||||
SuppressBladeburnerPopup: defaultSettings.SuppressBladeburnerPopup,
|
||||
SuppressTIXPopup: defaultSettings.SuppressTIXPopup,
|
||||
SuppressSavedGameToast: defaultSettings.SuppressSavedGameToast,
|
||||
SuppressAutosaveDisabledWarnings: defaultSettings.SuppressAutosaveDisabledWarnings,
|
||||
UseIEC60027_2: defaultSettings.UseIEC60027_2,
|
||||
ExcludeRunningScriptsFromSave: defaultSettings.ExcludeRunningScriptsFromSave,
|
||||
IsSidebarOpened: defaultSettings.IsSidebarOpened,
|
||||
|
@ -15,6 +15,7 @@ import { Factions, initFactions } from "./Faction/Factions";
|
||||
import { staneksGift } from "./CotMG/Helper";
|
||||
import { processPassiveFactionRepGain, inviteToFaction } from "./Faction/FactionHelpers";
|
||||
import { Router } from "./ui/GameRoot";
|
||||
import { Page } from "./ui/Router";
|
||||
import { SetupTextEditor } from "./ScriptEditor/ui/ScriptEditorRoot";
|
||||
|
||||
import {
|
||||
@ -48,7 +49,8 @@ import { calculateAchievements } from "./Achievements/Achievements";
|
||||
|
||||
import React from "react";
|
||||
import { setupUncaughtPromiseHandler } from "./UncaughtPromiseHandler";
|
||||
import { Typography } from "@mui/material";
|
||||
import { Button, Typography } from "@mui/material";
|
||||
import { SnackbarEvents } from "./ui/React/Snackbar";
|
||||
|
||||
const Engine: {
|
||||
_lastUpdate: number;
|
||||
@ -187,7 +189,8 @@ const Engine: {
|
||||
Settings.AutosaveInterval = 60;
|
||||
}
|
||||
if (Settings.AutosaveInterval === 0) {
|
||||
Engine.Counters.autoSaveCounter = Infinity;
|
||||
warnAutosaveDisabled();
|
||||
Engine.Counters.autoSaveCounter = 60 * 5; // Let's check back in a bit
|
||||
} else {
|
||||
Engine.Counters.autoSaveCounter = Settings.AutosaveInterval * 5;
|
||||
saveObject.saveGame(!Settings.SuppressSavedGameToast);
|
||||
@ -459,4 +462,35 @@ const Engine: {
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Shows a toast warning that lets the player know that auto-saves are disabled, with an button to re-enable them.
|
||||
*/
|
||||
function warnAutosaveDisabled(): void {
|
||||
// If the player has suppressed those warnings let's just exit right away.
|
||||
if (Settings.SuppressAutosaveDisabledWarnings) return;
|
||||
|
||||
// We don't want this warning to show up on certain pages.
|
||||
// When in recovery or importing we want to keep autosave disabled.
|
||||
const ignoredPages = [Page.Recovery, Page.ImportSave];
|
||||
if (ignoredPages.includes(Router.page())) return;
|
||||
|
||||
const warningToast = (
|
||||
<>
|
||||
Auto-saves are <strong>disabled</strong>!
|
||||
<Button
|
||||
sx={{ ml: 1 }}
|
||||
color="warning"
|
||||
size="small"
|
||||
onClick={() => {
|
||||
// We reset the value to a default
|
||||
Settings.AutosaveInterval = 60;
|
||||
}}
|
||||
>
|
||||
Enable
|
||||
</Button>
|
||||
</>
|
||||
);
|
||||
SnackbarEvents.emit(warningToast, "warning", 5000);
|
||||
}
|
||||
|
||||
export { Engine };
|
||||
|
@ -465,7 +465,7 @@ export function CharacterOverview({ save, killScripts }: IProps): React.ReactEle
|
||||
<Box sx={{ display: "flex", borderTop: `1px solid ${Settings.theme.welllight}` }}>
|
||||
<Box sx={{ display: "flex", flex: 1, justifyContent: "flex-start", alignItems: "center" }}>
|
||||
<IconButton aria-label="save game" onClick={save}>
|
||||
<Tooltip title="Save game">
|
||||
<Tooltip title={Settings.AutosaveInterval !== 0 ? "Save game" : "Save game (auto-saves are disabled!)"}>
|
||||
<SaveIcon color={Settings.AutosaveInterval !== 0 ? "primary" : "error"} />
|
||||
</Tooltip>
|
||||
</IconButton>
|
||||
|
@ -328,6 +328,14 @@ export function GameOptionsRoot(props: IProps): React.ReactElement {
|
||||
tooltip={<>If this is set, there will be no "Game Saved!" toast appearing after an auto-save.</>}
|
||||
/>
|
||||
</ListItem>
|
||||
<ListItem>
|
||||
<OptionSwitch
|
||||
checked={Settings.SuppressAutosaveDisabledWarnings}
|
||||
onChange={(newValue) => (Settings.SuppressAutosaveDisabledWarnings = newValue)}
|
||||
text="Suppress Auto-Save Disabled Warning"
|
||||
tooltip={<>If this is set, there will be no warning triggered when auto-save is disabled (at 0).</>}
|
||||
/>
|
||||
</ListItem>
|
||||
<ListItem>
|
||||
<OptionSwitch
|
||||
checked={Settings.DisableHotkeys}
|
||||
|
Loading…
Reference in New Issue
Block a user