diff --git a/src/Settings/Settings.ts b/src/Settings/Settings.ts index 77c29fdb9..978365639 100644 --- a/src/Settings/Settings.ts +++ b/src/Settings/Settings.ts @@ -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, diff --git a/src/engine.tsx b/src/engine.tsx index 0f52b571c..4b4a38e52 100644 --- a/src/engine.tsx +++ b/src/engine.tsx @@ -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 disabled! + + + ); + SnackbarEvents.emit(warningToast, "warning", 5000); +} + export { Engine }; diff --git a/src/ui/React/CharacterOverview.tsx b/src/ui/React/CharacterOverview.tsx index f57f3b1bb..f653df270 100644 --- a/src/ui/React/CharacterOverview.tsx +++ b/src/ui/React/CharacterOverview.tsx @@ -465,7 +465,7 @@ export function CharacterOverview({ save, killScripts }: IProps): React.ReactEle - + diff --git a/src/ui/React/GameOptionsRoot.tsx b/src/ui/React/GameOptionsRoot.tsx index d327ade58..504494752 100644 --- a/src/ui/React/GameOptionsRoot.tsx +++ b/src/ui/React/GameOptionsRoot.tsx @@ -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.} /> + + (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).} + /> +