This commit is contained in:
Olivier Gagnon 2022-01-18 19:20:16 -05:00
parent 69cf98ff34
commit 53727f6222

@ -21,7 +21,7 @@ import TextField from "@mui/material/TextField";
import DownloadIcon from "@mui/icons-material/Download"; import DownloadIcon from "@mui/icons-material/Download";
import UploadIcon from "@mui/icons-material/Upload"; import UploadIcon from "@mui/icons-material/Upload";
import SaveIcon from '@mui/icons-material/Save'; import SaveIcon from "@mui/icons-material/Save";
import { FileDiagnosticModal } from "../../Diagnostic/FileDiagnosticModal"; import { FileDiagnosticModal } from "../../Diagnostic/FileDiagnosticModal";
import { dialogBoxCreate } from "./DialogBox"; import { dialogBoxCreate } from "./DialogBox";
@ -152,7 +152,7 @@ export function GameOptionsRoot(props: IProps): React.ReactElement {
console.log(error); // We'll handle below console.log(error); // We'll handle below
} }
if (!newSave || newSave === '') { if (!newSave || newSave === "") {
SnackbarEvents.emit("Save game had not content or was not base64 encoded", "error", 5000); SnackbarEvents.emit("Save game had not content or was not base64 encoded", "error", 5000);
return; return;
} }
@ -164,7 +164,7 @@ export function GameOptionsRoot(props: IProps): React.ReactElement {
console.log(error); // We'll handle below console.log(error); // We'll handle below
} }
if (!parsedSave || parsedSave.ctor !== 'BitburnerSaveObject' || !parsedSave.data) { if (!parsedSave || parsedSave.ctor !== "BitburnerSaveObject" || !parsedSave.data) {
SnackbarEvents.emit("Save game did not seem valid", "error", 5000); SnackbarEvents.emit("Save game did not seem valid", "error", 5000);
return; return;
} }
@ -172,14 +172,14 @@ export function GameOptionsRoot(props: IProps): React.ReactElement {
const data: ImportData = { const data: ImportData = {
base64: contents, base64: contents,
parsed: parsedSave, parsed: parsedSave,
} };
const timestamp = parsedSave.data.SaveTimestamp; const timestamp = parsedSave.data.SaveTimestamp;
if (timestamp && timestamp !== '0') { if (timestamp && timestamp !== "0") {
data.exportDate = new Date(parseInt(timestamp, 10)) data.exportDate = new Date(parseInt(timestamp, 10));
} }
setImportData(data) setImportData(data);
setImportSaveOpen(true); setImportSaveOpen(true);
}; };
reader.readAsText(file); reader.readAsText(file);
@ -191,7 +191,7 @@ export function GameOptionsRoot(props: IProps): React.ReactElement {
setImportSaveOpen(false); setImportSaveOpen(false);
save(importData.base64).then(() => { save(importData.base64).then(() => {
setImportData(null); setImportData(null);
setTimeout(() => location.reload(), 1000) setTimeout(() => location.reload(), 1000);
}); });
} }
@ -213,7 +213,7 @@ export function GameOptionsRoot(props: IProps): React.ReactElement {
</Typography> </Typography>
} }
> >
<Typography>Netscript exec time (ms)</Typography> <Typography>.script exec time (ms)</Typography>
</Tooltip> </Tooltip>
<Slider <Slider
value={execTime} value={execTime}
@ -304,128 +304,165 @@ export function GameOptionsRoot(props: IProps): React.ReactElement {
/> />
</ListItem> </ListItem>
<ListItem> <ListItem>
<OptionSwitch checked={Settings.SuppressMessages} <OptionSwitch
onChange={(newValue) => Settings.SuppressMessages = newValue} checked={Settings.SuppressMessages}
onChange={(newValue) => (Settings.SuppressMessages = newValue)}
text="Suppress story messages" text="Suppress story messages"
tooltip={<> tooltip={
<>
If this is set, then any messages you receive will not appear as popups on the screen. They will If this is set, then any messages you receive will not appear as popups on the screen. They will
still get sent to your home computer as '.msg' files and can be viewed with the 'cat' Terminal still get sent to your home computer as '.msg' files and can be viewed with the 'cat' Terminal
command. command.
</>} /> </>
}
/>
</ListItem> </ListItem>
<ListItem> <ListItem>
<OptionSwitch checked={Settings.SuppressFactionInvites} <OptionSwitch
onChange={(newValue) => Settings.SuppressFactionInvites = newValue} checked={Settings.SuppressFactionInvites}
onChange={(newValue) => (Settings.SuppressFactionInvites = newValue)}
text="Suppress faction invites" text="Suppress faction invites"
tooltip={<> tooltip={
If this is set, then any faction invites you receive will not appear as popups on the screen. <>
Your outstanding faction invites can be viewed in the 'Factions' page. If this is set, then any faction invites you receive will not appear as popups on the screen. Your
</>} /> outstanding faction invites can be viewed in the 'Factions' page.
</>
}
/>
</ListItem> </ListItem>
<ListItem> <ListItem>
<OptionSwitch checked={Settings.SuppressTravelConfirmation} <OptionSwitch
onChange={(newValue) => Settings.SuppressTravelConfirmation = newValue} checked={Settings.SuppressTravelConfirmation}
onChange={(newValue) => (Settings.SuppressTravelConfirmation = newValue)}
text="Suppress travel confirmations" text="Suppress travel confirmations"
tooltip={<> tooltip={
If this is set, the confirmation message before traveling will not show up. You will <>
automatically be deducted the travel cost as soon as you click. If this is set, the confirmation message before traveling will not show up. You will automatically
</>} /> be deducted the travel cost as soon as you click.
</>
}
/>
</ListItem> </ListItem>
<ListItem> <ListItem>
<OptionSwitch checked={Settings.SuppressBuyAugmentationConfirmation} <OptionSwitch
onChange={(newValue) => Settings.SuppressBuyAugmentationConfirmation = newValue} checked={Settings.SuppressBuyAugmentationConfirmation}
onChange={(newValue) => (Settings.SuppressBuyAugmentationConfirmation = newValue)}
text="Suppress augmentations confirmation" text="Suppress augmentations confirmation"
tooltip={<> tooltip={<>If this is set, the confirmation message before buying augmentation will not show up.</>}
If this is set, the confirmation message before buying augmentation will not show up. />
</>} />
</ListItem> </ListItem>
<ListItem> <ListItem>
<OptionSwitch checked={Settings.SuppressTIXPopup} <OptionSwitch
onChange={(newValue) => Settings.SuppressTIXPopup = newValue} checked={Settings.SuppressTIXPopup}
onChange={(newValue) => (Settings.SuppressTIXPopup = newValue)}
text="Suppress TIX messages" text="Suppress TIX messages"
tooltip={<> tooltip={<>If this is set, the stock market will never create any popup.</>}
If this is set, the stock market will never create any popup. />
</>} />
</ListItem> </ListItem>
{!!props.player.bladeburner && ( {!!props.player.bladeburner && (
<ListItem> <ListItem>
<OptionSwitch checked={Settings.SuppressBladeburnerPopup} <OptionSwitch
onChange={(newValue) => Settings.SuppressBladeburnerPopup = newValue} checked={Settings.SuppressBladeburnerPopup}
onChange={(newValue) => (Settings.SuppressBladeburnerPopup = newValue)}
text="Suppress bladeburner popup" text="Suppress bladeburner popup"
tooltip={<> tooltip={
If this is set, then having your Bladeburner actions interrupted by being busy with something <>
else will not display a popup message. If this is set, then having your Bladeburner actions interrupted by being busy with something else
</>} /> will not display a popup message.
</>
}
/>
</ListItem> </ListItem>
)} )}
<ListItem> <ListItem>
<OptionSwitch checked={Settings.SuppressSavedGameToast} <OptionSwitch
onChange={(newValue) => Settings.SuppressSavedGameToast = newValue} checked={Settings.SuppressSavedGameToast}
onChange={(newValue) => (Settings.SuppressSavedGameToast = newValue)}
text="Suppress Auto-Save Game Toast" text="Suppress Auto-Save Game Toast"
tooltip={<> tooltip={<>If this is set, there will be no "Game Saved!" toast appearing after an auto-save.</>}
If this is set, there will be no "Game Saved!" toast appearing after an auto-save. />
</>} />
</ListItem> </ListItem>
<ListItem> <ListItem>
<OptionSwitch checked={Settings.DisableHotkeys} <OptionSwitch
onChange={(newValue) => Settings.DisableHotkeys = newValue} checked={Settings.DisableHotkeys}
onChange={(newValue) => (Settings.DisableHotkeys = newValue)}
text="Disable hotkeys" text="Disable hotkeys"
tooltip={<> tooltip={
<>
If this is set, then most hotkeys (keyboard shortcuts) in the game are disabled. This includes If this is set, then most hotkeys (keyboard shortcuts) in the game are disabled. This includes
Terminal commands, hotkeys to navigate between different parts of the game, and the "Save and Terminal commands, hotkeys to navigate between different parts of the game, and the "Save and Close
Close (Ctrl + b)" hotkey in the Text Editor. (Ctrl + b)" hotkey in the Text Editor.
</>} /> </>
}
/>
</ListItem> </ListItem>
<ListItem> <ListItem>
<OptionSwitch checked={Settings.DisableASCIIArt} <OptionSwitch
onChange={(newValue) => Settings.DisableASCIIArt = newValue} checked={Settings.DisableASCIIArt}
onChange={(newValue) => (Settings.DisableASCIIArt = newValue)}
text="Disable ascii art" text="Disable ascii art"
tooltip={<> tooltip={<>If this is set all ASCII art will be disabled.</>}
If this is set all ASCII art will be disabled. />
</>} />
</ListItem> </ListItem>
<ListItem> <ListItem>
<OptionSwitch checked={Settings.DisableTextEffects} <OptionSwitch
onChange={(newValue) => Settings.DisableTextEffects = newValue} checked={Settings.DisableTextEffects}
onChange={(newValue) => (Settings.DisableTextEffects = newValue)}
text="Disable text effects" text="Disable text effects"
tooltip={<> tooltip={
If this is set, text effects will not be displayed. This can help if text is difficult to read <>
in certain areas. If this is set, text effects will not be displayed. This can help if text is difficult to read in
</>} /> certain areas.
</>
}
/>
</ListItem> </ListItem>
<ListItem> <ListItem>
<OptionSwitch checked={Settings.DisableOverviewProgressBars} <OptionSwitch
onChange={(newValue) => Settings.DisableOverviewProgressBars = newValue} checked={Settings.DisableOverviewProgressBars}
onChange={(newValue) => (Settings.DisableOverviewProgressBars = newValue)}
text="Disable Overview Progress Bars" text="Disable Overview Progress Bars"
tooltip={<> tooltip={<>If this is set, the progress bars in the character overview will be hidden.</>}
If this is set, the progress bars in the character overview will be hidden. />
</>} />
</ListItem> </ListItem>
<ListItem> <ListItem>
<OptionSwitch checked={Settings.EnableBashHotkeys} <OptionSwitch
onChange={(newValue) => Settings.EnableBashHotkeys = newValue} checked={Settings.EnableBashHotkeys}
onChange={(newValue) => (Settings.EnableBashHotkeys = newValue)}
text="Enable bash hotkeys" text="Enable bash hotkeys"
tooltip={<> tooltip={
Improved Bash emulation mode. Setting this to 1 enables several new Terminal shortcuts and <>
features that more closely resemble a real Bash-style shell. Note that when this mode is Improved Bash emulation mode. Setting this to 1 enables several new Terminal shortcuts and features
enabled, the default browser shortcuts are overriden by the new Bash shortcuts. that more closely resemble a real Bash-style shell. Note that when this mode is enabled, the default
</>} /> browser shortcuts are overriden by the new Bash shortcuts.
</>
}
/>
</ListItem> </ListItem>
<ListItem> <ListItem>
<OptionSwitch checked={Settings.UseIEC60027_2} <OptionSwitch
onChange={(newValue) => Settings.UseIEC60027_2 = newValue} checked={Settings.UseIEC60027_2}
onChange={(newValue) => (Settings.UseIEC60027_2 = newValue)}
text="Use GiB instead of GB" text="Use GiB instead of GB"
tooltip={<> tooltip={
<>
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> <ListItem>
<OptionSwitch checked={Settings.ExcludeRunningScriptsFromSave} <OptionSwitch
onChange={(newValue) => Settings.ExcludeRunningScriptsFromSave = newValue} checked={Settings.ExcludeRunningScriptsFromSave}
onChange={(newValue) => (Settings.ExcludeRunningScriptsFromSave = newValue)}
text="Exclude Running Scripts from Save" text="Exclude Running Scripts from Save"
tooltip={<> 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. <>
</>} /> 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> <ListItem>
<Tooltip <Tooltip
@ -460,12 +497,12 @@ export function GameOptionsRoot(props: IProps): React.ReactElement {
</ListItem> </ListItem>
<ListItem> <ListItem>
<OptionSwitch checked={Settings.SaveGameOnFileSave} <OptionSwitch
onChange={(newValue) => Settings.SaveGameOnFileSave = newValue} checked={Settings.SaveGameOnFileSave}
onChange={(newValue) => (Settings.SaveGameOnFileSave = newValue)}
text="Save game on file save" text="Save game on file save"
tooltip={<> tooltip={<>Save your game any time a file is saved in the script editor.</>}
Save your game any time a file is saved in the script editor. />
</>} />
</ListItem> </ListItem>
<ListItem> <ListItem>
@ -522,20 +559,28 @@ export function GameOptionsRoot(props: IProps): React.ReactElement {
</> </>
)} )}
</Grid> </Grid>
<Box sx={{ display: 'grid', width: 'fit-content', height: 'fit-content' }}> <Box sx={{ display: "grid", width: "fit-content", height: "fit-content" }}>
<Box sx={{ display: 'grid', gridTemplateColumns: '1fr 1fr' }}> <Box sx={{ display: "grid", gridTemplateColumns: "1fr 1fr" }}>
<Button onClick={() => props.save()} startIcon={<SaveIcon />}> <Button onClick={() => props.save()} startIcon={<SaveIcon />}>
Save Game Save Game
</Button> </Button>
<DeleteGameButton /> <DeleteGameButton />
</Box> </Box>
<Box sx={{ display: 'grid', gridTemplateColumns: '1fr 1fr' }}> <Box sx={{ display: "grid", gridTemplateColumns: "1fr 1fr" }}>
<Tooltip title={<Typography>Export your game to a text file.</Typography>}> <Tooltip title={<Typography>Export your game to a text file.</Typography>}>
<Button onClick={() => props.export()} startIcon={<DownloadIcon />}> <Button onClick={() => props.export()} startIcon={<DownloadIcon />}>
Export Game Export Game
</Button> </Button>
</Tooltip> </Tooltip>
<Tooltip title={<Typography>Import your game from a text file.<br />This will <strong>overwrite</strong> your current game. Back it up first!</Typography>}> <Tooltip
title={
<Typography>
Import your game from a text file.
<br />
This will <strong>overwrite</strong> your current game. Back it up first!
</Typography>
}
>
<Button onClick={startImport} startIcon={<UploadIcon />}> <Button onClick={startImport} startIcon={<UploadIcon />}>
Import Game Import Game
<input ref={importInput} id="import-game-file-selector" type="file" hidden onChange={onImport} /> <input ref={importInput} id="import-game-file-selector" type="file" hidden onChange={onImport} />
@ -555,16 +600,18 @@ export function GameOptionsRoot(props: IProps): React.ReactElement {
The file you are attempting to import seems valid. The file you are attempting to import seems valid.
<br /> <br />
<br /> <br />
{importData?.exportDate && (<> {importData?.exportDate && (
<>
The export date of the save file is <strong>{importData?.exportDate.toString()}</strong> The export date of the save file is <strong>{importData?.exportDate.toString()}</strong>
<br /> <br />
<br /> <br />
</>)} </>
)}
</> </>
} }
/> />
</Box> </Box>
<Box sx={{ display: 'grid' }}> <Box sx={{ display: "grid" }}>
<Tooltip <Tooltip
title={ title={
<Typography> <Typography>
@ -579,8 +626,11 @@ export function GameOptionsRoot(props: IProps): React.ReactElement {
<Button onClick={() => props.forceKill()}>Force kill all active scripts</Button> <Button onClick={() => props.forceKill()}>Force kill all active scripts</Button>
</Tooltip> </Tooltip>
</Box> </Box>
<Box sx={{ display: 'grid', gridTemplateColumns: '1fr 1fr' }}> <Box sx={{ display: "grid", gridTemplateColumns: "1fr 1fr" }}>
<SoftResetButton noConfirmation={Settings.SuppressBuyAugmentationConfirmation} onTriggered={props.softReset} /> <SoftResetButton
noConfirmation={Settings.SuppressBuyAugmentationConfirmation}
onTriggered={props.softReset}
/>
<Tooltip <Tooltip
title={ title={
<Typography> <Typography>
@ -592,7 +642,7 @@ export function GameOptionsRoot(props: IProps): React.ReactElement {
<Button onClick={() => setDiagnosticOpen(true)}>Diagnose files</Button> <Button onClick={() => setDiagnosticOpen(true)}>Diagnose files</Button>
</Tooltip> </Tooltip>
</Box> </Box>
<Box sx={{ display: 'grid', gridTemplateColumns: '1fr 1fr' }}> <Box sx={{ display: "grid", gridTemplateColumns: "1fr 1fr" }}>
<Button onClick={() => setThemeEditorOpen(true)}>Theme editor</Button> <Button onClick={() => setThemeEditorOpen(true)}>Theme editor</Button>
<Button onClick={() => setStyleEditorOpen(true)}>Style editor</Button> <Button onClick={() => setStyleEditorOpen(true)}>Style editor</Button>
</Box> </Box>