bitburner-src/src/Settings/Settings.ts

290 lines
8.0 KiB
TypeScript
Raw Normal View History

import { ISelfInitializer, ISelfLoading } from "../types";
2021-09-09 05:47:34 +02:00
import { OwnedAugmentationsOrderSetting, PurchaseAugmentationsOrderSetting } from "./SettingEnums";
import { defaultTheme, ITheme } from "../Themes/Themes";
import { defaultStyles } from "../Themes/Styles";
import { WordWrapOptions } from "../ScriptEditor/ui/Options";
import { OverviewSettings } from "../ui/React/Overview";
import { IStyleSettings } from "../ScriptEditor/NetscriptDefinitions";
2022-01-30 02:27:49 +01:00
import { defaultMonacoTheme, IScriptEditorTheme } from "../ScriptEditor/ui/themes";
/**
* Represents the default settings the player could customize.
*/
interface IDefaultSettings {
2021-09-22 02:30:00 +02:00
/**
* How many servers per page
*/
ActiveScriptsServerPageSize: number;
/**
* How many scripts per page
*/
ActiveScriptsScriptPageSize: number;
2021-09-05 01:09:30 +02:00
/**
* How often the game should autosave the player's progress, in seconds.
*/
AutosaveInterval: number;
/**
* How many milliseconds between execution points for Netscript 1 statements.
*/
CodeInstructionRunTime: number;
/**
* Render city as list of buttons.
*/
DisableASCIIArt: boolean;
/**
* Whether global keyboard shortcuts should be recognized throughout the game.
*/
DisableHotkeys: boolean;
/**
* Whether text effects such as corruption should be visible.
*/
DisableTextEffects: boolean;
/**
* Whether overview progress bars should be visible.
*/
DisableOverviewProgressBars: boolean;
2021-09-22 07:36:17 +02:00
/**
* Enable bash hotkeys
*/
EnableBashHotkeys: boolean;
/**
* Timestamps format
2021-09-22 07:36:17 +02:00
*/
TimestampsFormat: string;
2021-09-22 07:36:17 +02:00
2021-09-05 01:09:30 +02:00
/**
* Locale used for display numbers
*/
Locale: string;
2022-01-19 08:04:48 +01:00
/**
* Limit the number of recently killed script entries being tracked.
*/
MaxRecentScriptsCapacity: number;
2021-09-05 01:09:30 +02:00
/**
* Limit the number of log entries for each script being executed on each server.
*/
MaxLogCapacity: number;
/**
* Limit how many entries can be written to a Netscript Port before entries start to get pushed out.
*/
MaxPortCapacity: number;
/**
* Limit the number of entries in the terminal.
*/
MaxTerminalCapacity: number;
2021-10-11 23:57:17 +02:00
/**
* Save the game when you save any file.
*/
SaveGameOnFileSave: boolean;
2021-09-05 01:09:30 +02:00
/**
* Whether the player should be asked to confirm purchasing each and every augmentation.
*/
SuppressBuyAugmentationConfirmation: boolean;
/**
* Whether the user should be prompted to join each faction via a dialog box.
*/
SuppressFactionInvites: boolean;
/**
* Whether the user should be shown a dialog box whenever they receive a new message file.
*/
SuppressMessages: boolean;
/**
* Whether the user should be asked to confirm travelling between cities.
*/
SuppressTravelConfirmation: boolean;
/**
* Whether the user should be displayed a popup message when his Bladeburner actions are cancelled.
*/
SuppressBladeburnerPopup: boolean;
2021-09-22 08:20:29 +02:00
2021-12-05 00:58:26 +01:00
/**
* Whether the user should be displayed a popup message on stock market actions.
*/
SuppressTIXPopup: boolean;
/**
* Whether the user should be displayed a toast alert when the game is saved.
*/
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
*/
ExcludeRunningScriptsFromSave: boolean;
2021-09-22 08:20:29 +02:00
/*
* Theme colors
*/
theme: ITheme;
2022-01-09 13:46:28 +01:00
/*
* Interface styles
*/
styles: IStyleSettings;
/*
* Use GiB instead of GB
*/
UseIEC60027_2: boolean;
/*
* Character overview settings
*/
overview: OverviewSettings;
/**
* If the game's sidebar is opened
*/
IsSidebarOpened: boolean;
2022-01-30 02:27:49 +01:00
/**
* Script editor theme data
*/
EditorTheme: IScriptEditorTheme;
}
/**
* Represents all possible settings the player wants to customize to their play style.
*/
interface ISettings extends IDefaultSettings {
2021-09-05 01:09:30 +02:00
/**
* What order the player's owned Augmentations/Source Files should be displayed in
*/
OwnedAugmentationsOrder: OwnedAugmentationsOrderSetting;
2021-09-05 01:09:30 +02:00
/**
* What order the Augmentations should be displayed in when purchasing from a Faction
*/
PurchaseAugmentationsOrder: PurchaseAugmentationsOrderSetting;
2021-05-18 05:59:45 +02:00
2021-09-05 01:09:30 +02:00
MonacoTheme: string;
2021-08-21 06:17:26 +02:00
2021-09-05 01:09:30 +02:00
MonacoInsertSpaces: boolean;
2021-10-05 03:06:55 +02:00
MonacoFontSize: number;
MonacoVim: boolean;
2022-01-04 15:41:44 +01:00
MonacoWordWrap: WordWrapOptions;
}
2021-09-22 08:20:29 +02:00
export const defaultSettings: IDefaultSettings = {
2021-09-22 02:30:00 +02:00
ActiveScriptsServerPageSize: 10,
ActiveScriptsScriptPageSize: 10,
2021-09-05 01:09:30 +02:00
AutosaveInterval: 60,
CodeInstructionRunTime: 50,
DisableASCIIArt: false,
DisableHotkeys: false,
DisableTextEffects: false,
DisableOverviewProgressBars: false,
2021-09-22 07:36:17 +02:00
EnableBashHotkeys: false,
2021-11-11 23:00:36 +01:00
TimestampsFormat: "",
2021-09-05 01:09:30 +02:00
Locale: "en",
2022-01-19 08:04:48 +01:00
MaxRecentScriptsCapacity: 50,
2021-09-05 01:09:30 +02:00
MaxLogCapacity: 50,
MaxPortCapacity: 50,
2021-12-16 00:10:29 +01:00
MaxTerminalCapacity: 500,
2021-10-11 23:57:17 +02:00
SaveGameOnFileSave: true,
2021-09-05 01:09:30 +02:00
SuppressBuyAugmentationConfirmation: false,
SuppressFactionInvites: false,
SuppressMessages: false,
SuppressTravelConfirmation: false,
SuppressBladeburnerPopup: false,
2021-12-05 00:58:26 +01:00
SuppressTIXPopup: false,
SuppressSavedGameToast: false,
SuppressAutosaveDisabledWarnings: false,
UseIEC60027_2: false,
ExcludeRunningScriptsFromSave: false,
IsSidebarOpened: true,
2021-09-22 08:20:29 +02:00
theme: defaultTheme,
2022-01-09 13:46:28 +01:00
styles: defaultStyles,
overview: { x: 0, y: 0, opened: true },
2022-01-30 02:27:49 +01:00
EditorTheme: defaultMonacoTheme,
};
/**
* The current options the player has customized to their play style.
*/
// tslint:disable-next-line:variable-name
export const Settings: ISettings & ISelfInitializer & ISelfLoading = {
2021-09-22 02:30:00 +02:00
ActiveScriptsServerPageSize: defaultSettings.ActiveScriptsServerPageSize,
ActiveScriptsScriptPageSize: defaultSettings.ActiveScriptsScriptPageSize,
2021-09-05 01:09:30 +02:00
AutosaveInterval: defaultSettings.AutosaveInterval,
CodeInstructionRunTime: 25,
DisableASCIIArt: defaultSettings.DisableASCIIArt,
DisableHotkeys: defaultSettings.DisableHotkeys,
DisableTextEffects: defaultSettings.DisableTextEffects,
DisableOverviewProgressBars: defaultSettings.DisableOverviewProgressBars,
2021-09-22 07:36:17 +02:00
EnableBashHotkeys: defaultSettings.EnableBashHotkeys,
TimestampsFormat: defaultSettings.TimestampsFormat,
2021-09-05 01:09:30 +02:00
Locale: "en",
2022-01-19 08:04:48 +01:00
MaxRecentScriptsCapacity: defaultSettings.MaxRecentScriptsCapacity,
2021-09-05 01:09:30 +02:00
MaxLogCapacity: defaultSettings.MaxLogCapacity,
MaxPortCapacity: defaultSettings.MaxPortCapacity,
MaxTerminalCapacity: defaultSettings.MaxTerminalCapacity,
2021-09-05 01:09:30 +02:00
OwnedAugmentationsOrder: OwnedAugmentationsOrderSetting.AcquirementTime,
PurchaseAugmentationsOrder: PurchaseAugmentationsOrderSetting.Default,
2021-10-11 23:57:17 +02:00
SaveGameOnFileSave: defaultSettings.SaveGameOnFileSave,
2021-09-09 05:47:34 +02:00
SuppressBuyAugmentationConfirmation: defaultSettings.SuppressBuyAugmentationConfirmation,
2021-09-05 01:09:30 +02:00
SuppressFactionInvites: defaultSettings.SuppressFactionInvites,
SuppressMessages: defaultSettings.SuppressMessages,
SuppressTravelConfirmation: defaultSettings.SuppressTravelConfirmation,
SuppressBladeburnerPopup: defaultSettings.SuppressBladeburnerPopup,
2021-12-05 00:58:26 +01:00
SuppressTIXPopup: defaultSettings.SuppressTIXPopup,
SuppressSavedGameToast: defaultSettings.SuppressSavedGameToast,
SuppressAutosaveDisabledWarnings: defaultSettings.SuppressAutosaveDisabledWarnings,
UseIEC60027_2: defaultSettings.UseIEC60027_2,
ExcludeRunningScriptsFromSave: defaultSettings.ExcludeRunningScriptsFromSave,
IsSidebarOpened: defaultSettings.IsSidebarOpened,
MonacoTheme: "monokai",
2021-09-05 01:09:30 +02:00
MonacoInsertSpaces: false,
2021-10-12 06:29:16 +02:00
MonacoFontSize: 20,
MonacoVim: false,
MonacoWordWrap: "off",
2022-04-13 21:42:07 +02:00
theme: { ...defaultTheme },
2022-01-09 13:46:28 +01:00
styles: { ...defaultStyles },
overview: defaultSettings.overview,
2022-01-30 02:27:49 +01:00
EditorTheme: { ...defaultMonacoTheme },
2021-09-05 01:09:30 +02:00
init() {
Object.assign(Settings, defaultSettings);
},
load(saveString: string) {
const save = JSON.parse(saveString);
Object.assign(Settings.theme, save.theme);
delete save.theme;
2022-01-09 13:46:28 +01:00
Object.assign(Settings.styles, save.styles);
delete save.styles;
Object.assign(Settings.overview, save.overview);
delete save.overview;
2022-01-30 02:27:49 +01:00
Object.assign(Settings.EditorTheme, save.EditorTheme);
delete save.EditorTheme;
Object.assign(Settings, save);
2021-09-05 01:09:30 +02:00
},
};