mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-28 02:23:53 +01:00
saving file now saves game
This commit is contained in:
parent
30554560da
commit
06775b20fa
@ -22,6 +22,7 @@ import { WorkerScript } from "../../Netscript/WorkerScript";
|
||||
import { Settings } from "../../Settings/Settings";
|
||||
import { iTutorialNextStep, ITutorial, iTutorialSteps } from "../../InteractiveTutorial";
|
||||
import { debounce } from "lodash";
|
||||
import { saveObject } from "../../SaveObject";
|
||||
|
||||
import Button from "@mui/material/Button";
|
||||
import Typography from "@mui/material/Typography";
|
||||
@ -176,6 +177,7 @@ export function Root(props: IProps): React.ReactElement {
|
||||
for (let i = 0; i < server.scripts.length; i++) {
|
||||
if (filename == server.scripts[i].filename) {
|
||||
server.scripts[i].saveScript(filename, code, props.player.currentServer, server.scripts);
|
||||
saveObject.saveGame();
|
||||
props.router.toTerminal();
|
||||
return;
|
||||
}
|
||||
@ -189,6 +191,7 @@ export function Root(props: IProps): React.ReactElement {
|
||||
for (let i = 0; i < server.textFiles.length; ++i) {
|
||||
if (server.textFiles[i].fn === filename) {
|
||||
server.textFiles[i].write(code);
|
||||
saveObject.saveGame();
|
||||
props.router.toTerminal();
|
||||
return;
|
||||
}
|
||||
@ -199,6 +202,8 @@ export function Root(props: IProps): React.ReactElement {
|
||||
dialogBoxCreate("Invalid filename. Must be either a script (.script, .js, or .ns) or " + " or text file (.txt)");
|
||||
return;
|
||||
}
|
||||
|
||||
saveObject.saveGame();
|
||||
props.router.toTerminal();
|
||||
}
|
||||
|
||||
|
@ -68,6 +68,11 @@ interface IDefaultSettings {
|
||||
*/
|
||||
MaxTerminalCapacity: number;
|
||||
|
||||
/**
|
||||
* Save the game when you save any file.
|
||||
*/
|
||||
SaveGameOnFileSave: boolean;
|
||||
|
||||
/**
|
||||
* Whether the player should be asked to confirm purchasing each and every augmentation.
|
||||
*/
|
||||
@ -168,6 +173,7 @@ export const defaultSettings: IDefaultSettings = {
|
||||
MaxLogCapacity: 50,
|
||||
MaxPortCapacity: 50,
|
||||
MaxTerminalCapacity: 200,
|
||||
SaveGameOnFileSave: true,
|
||||
SuppressBuyAugmentationConfirmation: false,
|
||||
SuppressFactionInvites: false,
|
||||
SuppressHospitalizationPopup: false,
|
||||
@ -226,6 +232,7 @@ export const Settings: ISettings & ISelfInitializer & ISelfLoading = {
|
||||
MaxTerminalCapacity: defaultSettings.MaxTerminalCapacity,
|
||||
OwnedAugmentationsOrder: OwnedAugmentationsOrderSetting.AcquirementTime,
|
||||
PurchaseAugmentationsOrder: PurchaseAugmentationsOrderSetting.Default,
|
||||
SaveGameOnFileSave: defaultSettings.SaveGameOnFileSave,
|
||||
SuppressBuyAugmentationConfirmation: defaultSettings.SuppressBuyAugmentationConfirmation,
|
||||
SuppressFactionInvites: defaultSettings.SuppressFactionInvites,
|
||||
SuppressHospitalizationPopup: defaultSettings.SuppressHospitalizationPopup,
|
||||
|
@ -77,6 +77,7 @@ export function GameOptionsRoot(props: IProps): React.ReactElement {
|
||||
const [disableTextEffects, setDisableTextEffects] = useState(Settings.DisableTextEffects);
|
||||
const [enableBashHotkeys, setEnableBashHotkeys] = useState(Settings.EnableBashHotkeys);
|
||||
const [enableTimestamps, setEnableTimestamps] = useState(Settings.EnableTimestamps);
|
||||
const [saveGameOnFileSave, setSaveGameOnFileSave] = useState(Settings.SaveGameOnFileSave);
|
||||
|
||||
const [locale, setLocale] = useState(Settings.Locale);
|
||||
const [diagnosticOpen, setDiagnosticOpen] = useState(false);
|
||||
@ -165,6 +166,10 @@ export function GameOptionsRoot(props: IProps): React.ReactElement {
|
||||
setEnableTimestamps(event.target.checked);
|
||||
Settings.EnableTimestamps = event.target.checked;
|
||||
}
|
||||
function handleSaveGameOnFile(event: React.ChangeEvent<HTMLInputElement>): void {
|
||||
setSaveGameOnFileSave(event.target.checked);
|
||||
Settings.SaveGameOnFileSave = event.target.checked;
|
||||
}
|
||||
|
||||
function startImport(): void {
|
||||
if (!window.File || !window.FileReader || !window.FileList || !window.Blob) return;
|
||||
@ -505,6 +510,19 @@ export function GameOptionsRoot(props: IProps): React.ReactElement {
|
||||
/>
|
||||
</ListItem>
|
||||
|
||||
<ListItem>
|
||||
<FormControlLabel
|
||||
control={<Switch checked={saveGameOnFileSave} onChange={handleSaveGameOnFile} />}
|
||||
label={
|
||||
<Tooltip
|
||||
title={<Typography>Save your game any time a file is saved in the script editor.</Typography>}
|
||||
>
|
||||
<Typography>Save game on file save</Typography>
|
||||
</Tooltip>
|
||||
}
|
||||
/>
|
||||
</ListItem>
|
||||
|
||||
<ListItem>
|
||||
<Tooltip title={<Typography>Sets the locale for displaying numbers.</Typography>}>
|
||||
<Typography>Locale </Typography>
|
||||
|
Loading…
Reference in New Issue
Block a user