removed some of fconf

This commit is contained in:
Olivier Gagnon 2021-09-22 01:36:17 -04:00
parent 96f0879230
commit f9a4eadb71
13 changed files with 110 additions and 44 deletions

@ -2,7 +2,7 @@ import React, { useState } from "react";
import { SourceFileFlags } from "../../SourceFile/SourceFileFlags"; import { SourceFileFlags } from "../../SourceFile/SourceFileFlags";
import { IRouter } from "../../ui/Router"; import { IRouter } from "../../ui/Router";
import { BitNodes } from "../BitNode"; import { BitNodes } from "../BitNode";
import { enterBitNode } from "../../RedPill"; import { enterBitNode, setRedPillFlag } from "../../RedPill";
import { PortalPopup } from "./PortalPopup"; import { PortalPopup } from "./PortalPopup";
import { createPopup } from "../../ui/React/createPopup"; import { createPopup } from "../../ui/React/createPopup";
import { CinematicText } from "../../ui/React/CinematicText"; import { CinematicText } from "../../ui/React/CinematicText";
@ -71,6 +71,7 @@ interface IProps {
} }
export function BitverseRoot(props: IProps): React.ReactElement { export function BitverseRoot(props: IProps): React.ReactElement {
setRedPillFlag(true);
const player = use.Player(); const player = use.Player();
const enter = enterBitNode; const enter = enterBitNode;
const destroyed = player.bitNodeN; const destroyed = player.bitNodeN;

@ -48,17 +48,18 @@ function addMessageToServer(msg, serverHostname) {
//Checks if any of the 'timed' messages should be sent //Checks if any of the 'timed' messages should be sent
function checkForMessagesToSend() { function checkForMessagesToSend() {
var jumper0 = Messages[MessageFilenames.Jumper0]; if (redPillFlag) return;
var jumper1 = Messages[MessageFilenames.Jumper1]; const jumper0 = Messages[MessageFilenames.Jumper0];
var jumper2 = Messages[MessageFilenames.Jumper2]; const jumper1 = Messages[MessageFilenames.Jumper1];
var jumper3 = Messages[MessageFilenames.Jumper3]; const jumper2 = Messages[MessageFilenames.Jumper2];
var jumper4 = Messages[MessageFilenames.Jumper4]; const jumper3 = Messages[MessageFilenames.Jumper3];
var cybersecTest = Messages[MessageFilenames.CyberSecTest]; const jumper4 = Messages[MessageFilenames.Jumper4];
var nitesecTest = Messages[MessageFilenames.NiteSecTest]; const cybersecTest = Messages[MessageFilenames.CyberSecTest];
var bitrunnersTest = Messages[MessageFilenames.BitRunnersTest]; const nitesecTest = Messages[MessageFilenames.NiteSecTest];
var redpill = Messages[MessageFilenames.RedPill]; const bitrunnersTest = Messages[MessageFilenames.BitRunnersTest];
const redpill = Messages[MessageFilenames.RedPill];
var redpillOwned = false; const redpillOwned = false;
if (Augmentations[AugmentationNames.TheRedPill].owned) { if (Augmentations[AugmentationNames.TheRedPill].owned) {
redpillOwned = true; redpillOwned = true;
} }

1
src/RedPill.d.ts vendored

@ -1,2 +1,3 @@
export declare let redPillFlag: boolean; export declare let redPillFlag: boolean;
export declare function enterBitNode(router: IRouter, flume: boolean, destroyedBitNode: number, newBitNode: number); export declare function enterBitNode(router: IRouter, flume: boolean, destroyedBitNode: number, newBitNode: number);
export declare function setRedPillFlag(b: boolean): void;

@ -9,7 +9,11 @@ import { SourceFiles } from "./SourceFile/SourceFiles";
import { dialogBoxCreate } from "../utils/DialogBox"; import { dialogBoxCreate } from "../utils/DialogBox";
let redPillFlag = false; export let redPillFlag = false;
export function setRedPillFlag(b) {
redPillFlag = b;
}
function giveSourceFile(bitNodeNumber) { function giveSourceFile(bitNodeNumber) {
var sourceFileKey = "SourceFile" + bitNodeNumber.toString(); var sourceFileKey = "SourceFile" + bitNodeNumber.toString();
@ -81,5 +85,3 @@ export function enterBitNode(router, flume, destroyedBitNode, newBitNode) {
} }
prestigeSourceFile(flume); prestigeSourceFile(flume);
} }
export { redPillFlag };

@ -3,8 +3,6 @@ import { Companies, loadCompanies } from "./Company/Companies";
import { CONSTANTS } from "./Constants"; import { CONSTANTS } from "./Constants";
import { Engine } from "./engine"; import { Engine } from "./engine";
import { Factions, loadFactions } from "./Faction/Factions"; import { Factions, loadFactions } from "./Faction/Factions";
import { loadFconf } from "./Fconf/Fconf";
import { FconfSettings } from "./Fconf/FconfSettings";
import { loadAllGangs, AllGangs } from "./Gang/AllGangs"; import { loadAllGangs, AllGangs } from "./Gang/AllGangs";
import { loadMessages, initMessages, Messages } from "./Message/MessageHelpers"; import { loadMessages, initMessages, Messages } from "./Message/MessageHelpers";
import { Player, loadPlayer } from "./Player"; import { Player, loadPlayer } from "./Player";
@ -42,7 +40,6 @@ function BitburnerSaveObject() {
this.MessagesSave = ""; this.MessagesSave = "";
this.StockMarketSave = ""; this.StockMarketSave = "";
this.SettingsSave = ""; this.SettingsSave = "";
this.FconfSettingsSave = "";
this.VersionSave = ""; this.VersionSave = "";
this.AllGangsSave = ""; this.AllGangsSave = "";
this.LastExportBonus = ""; this.LastExportBonus = "";
@ -74,7 +71,6 @@ BitburnerSaveObject.prototype.getSaveString = function () {
this.MessagesSave = JSON.stringify(Messages); this.MessagesSave = JSON.stringify(Messages);
this.StockMarketSave = JSON.stringify(StockMarket); this.StockMarketSave = JSON.stringify(StockMarket);
this.SettingsSave = JSON.stringify(Settings); this.SettingsSave = JSON.stringify(Settings);
this.FconfSettingsSave = JSON.stringify(FconfSettings);
this.VersionSave = JSON.stringify(CONSTANTS.Version); this.VersionSave = JSON.stringify(CONSTANTS.Version);
this.LastExportBonus = JSON.stringify(ExportBonus.LastExportBonus); this.LastExportBonus = JSON.stringify(ExportBonus.LastExportBonus);
if (Player.inGang()) { if (Player.inGang()) {

@ -75,7 +75,7 @@ export class RunningScript {
} }
let logEntry = txt; let logEntry = txt;
if (FconfSettings.ENABLE_TIMESTAMPS) { if (Settings.EnableTimestamps) {
logEntry = "[" + getTimestamp() + "] " + logEntry; logEntry = "[" + getTimestamp() + "] " + logEntry;
} }

@ -38,6 +38,16 @@ interface IDefaultSettings {
*/ */
DisableTextEffects: boolean; DisableTextEffects: boolean;
/**
* Enable bash hotkeys
*/
EnableBashHotkeys: boolean;
/**
* Enable timestamps
*/
EnableTimestamps: boolean;
/** /**
* Locale used for display numbers * Locale used for display numbers
*/ */
@ -116,6 +126,8 @@ const defaultSettings: IDefaultSettings = {
DisableASCIIArt: false, DisableASCIIArt: false,
DisableHotkeys: false, DisableHotkeys: false,
DisableTextEffects: false, DisableTextEffects: false,
EnableBashHotkeys: false,
EnableTimestamps: false,
Locale: "en", Locale: "en",
MaxLogCapacity: 50, MaxLogCapacity: 50,
MaxPortCapacity: 50, MaxPortCapacity: 50,
@ -140,6 +152,8 @@ export const Settings: ISettings & ISelfInitializer & ISelfLoading = {
DisableASCIIArt: defaultSettings.DisableASCIIArt, DisableASCIIArt: defaultSettings.DisableASCIIArt,
DisableHotkeys: defaultSettings.DisableHotkeys, DisableHotkeys: defaultSettings.DisableHotkeys,
DisableTextEffects: defaultSettings.DisableTextEffects, DisableTextEffects: defaultSettings.DisableTextEffects,
EnableBashHotkeys: defaultSettings.EnableBashHotkeys,
EnableTimestamps: defaultSettings.EnableTimestamps,
Locale: "en", Locale: "en",
MaxLogCapacity: defaultSettings.MaxLogCapacity, MaxLogCapacity: defaultSettings.MaxLogCapacity,
MaxPortCapacity: defaultSettings.MaxPortCapacity, MaxPortCapacity: defaultSettings.MaxPortCapacity,

@ -52,7 +52,6 @@ import { redPillFlag } from "../../RedPill";
import { inMission } from "../../Missions"; import { inMission } from "../../Missions";
import { KEY } from "../../../utils/helpers/keyCodes"; import { KEY } from "../../../utils/helpers/keyCodes";
import { FconfSettings } from "../../Fconf/FconfSettings";
const openedMixin = (theme: Theme): CSSObject => ({ const openedMixin = (theme: Theme): CSSObject => ({
width: theme.spacing(31), width: theme.spacing(31),
@ -297,7 +296,7 @@ export function SidebarRoot(props: IProps): React.ReactElement {
clickCreateProgram(); clickCreateProgram();
} else if (event.keyCode === KEY.F && event.altKey) { } else if (event.keyCode === KEY.F && event.altKey) {
// Overriden by Fconf // Overriden by Fconf
if (props.page == Page.Terminal && FconfSettings.ENABLE_BASH_HOTKEYS) { if (props.page == Page.Terminal && Settings.EnableBashHotkeys) {
return; return;
} }
event.preventDefault(); event.preventDefault();

@ -2,6 +2,8 @@ import { TextFile } from "../TextFile";
import { Script } from "../Script/Script"; import { Script } from "../Script/Script";
import { IPlayer } from "../PersonObjects/IPlayer"; import { IPlayer } from "../PersonObjects/IPlayer";
import { IRouter } from "../ui/Router"; import { IRouter } from "../ui/Router";
import { Settings } from "../Settings/Settings";
import { getTimestamp } from "../../utils/helpers/getTimestamp";
export class Output { export class Output {
text: string; text: string;
@ -10,6 +12,7 @@ export class Output {
text: string, text: string,
color: "inherit" | "initial" | "primary" | "secondary" | "error" | "textPrimary" | "textSecondary" | undefined, color: "inherit" | "initial" | "primary" | "secondary" | "error" | "textPrimary" | "textSecondary" | undefined,
) { ) {
if (Settings.EnableTimestamps) text = "[" + getTimestamp() + "] " + text;
this.text = text; this.text = text;
this.color = color; this.color = color;
} }
@ -18,6 +21,7 @@ export class Output {
export class Link { export class Link {
hostname: string; hostname: string;
constructor(hostname: string) { constructor(hostname: string) {
if (Settings.EnableTimestamps) hostname = "[" + getTimestamp() + "] " + hostname;
this.hostname = hostname; this.hostname = hostname;
} }
} }

@ -12,7 +12,7 @@ import { IRouter } from "../../ui/Router";
import { IPlayer } from "../../PersonObjects/IPlayer"; import { IPlayer } from "../../PersonObjects/IPlayer";
import { determineAllPossibilitiesForTabCompletion } from "../determineAllPossibilitiesForTabCompletion"; import { determineAllPossibilitiesForTabCompletion } from "../determineAllPossibilitiesForTabCompletion";
import { tabCompletion } from "../tabCompletion"; import { tabCompletion } from "../tabCompletion";
import { FconfSettings } from "../../Fconf/FconfSettings"; import { Settings } from "../../Settings/Settings";
const useStyles = makeStyles((theme: Theme) => const useStyles = makeStyles((theme: Theme) =>
createStyles({ createStyles({
@ -230,11 +230,8 @@ export function TerminalInput({ terminal, router, player }: IProps): React.React
} }
// Select previous command. // Select previous command.
if ( if (event.keyCode === KEY.UPARROW || (Settings.EnableBashHotkeys && event.keyCode === KEY.P && event.ctrlKey)) {
event.keyCode === KEY.UPARROW || if (Settings.EnableBashHotkeys) {
(FconfSettings.ENABLE_BASH_HOTKEYS && event.keyCode === KEY.P && event.ctrlKey)
) {
if (FconfSettings.ENABLE_BASH_HOTKEYS) {
event.preventDefault(); event.preventDefault();
} }
const i = terminal.commandHistoryIndex; const i = terminal.commandHistoryIndex;
@ -261,11 +258,8 @@ export function TerminalInput({ terminal, router, player }: IProps): React.React
} }
// Select next command // Select next command
if ( if (event.keyCode === KEY.DOWNARROW || (Settings.EnableBashHotkeys && event.keyCode === KEY.M && event.ctrlKey)) {
event.keyCode === KEY.DOWNARROW || if (Settings.EnableBashHotkeys) {
(FconfSettings.ENABLE_BASH_HOTKEYS && event.keyCode === KEY.M && event.ctrlKey)
) {
if (FconfSettings.ENABLE_BASH_HOTKEYS) {
event.preventDefault(); event.preventDefault();
} }
const i = terminal.commandHistoryIndex; const i = terminal.commandHistoryIndex;
@ -290,7 +284,7 @@ export function TerminalInput({ terminal, router, player }: IProps): React.React
} }
// Extra Bash Emulation Hotkeys, must be enabled through .fconf // Extra Bash Emulation Hotkeys, must be enabled through .fconf
if (FconfSettings.ENABLE_BASH_HOTKEYS) { if (Settings.EnableBashHotkeys) {
if (event.keyCode === KEY.A && event.ctrlKey) { if (event.keyCode === KEY.A && event.ctrlKey) {
event.preventDefault(); event.preventDefault();
moveTextCursor("home"); moveTextCursor("home");

@ -1,7 +1,7 @@
import React from "react"; import React from "react";
import ReactDOM from "react-dom"; import ReactDOM from "react-dom";
import { TTheme as Theme, colors } from "./ui/React/Theme"; import { TTheme as Theme, ThemeEvents } from "./ui/React/Theme";
import { LoadingScreen } from "./ui/LoadingScreen"; import { LoadingScreen } from "./ui/LoadingScreen";
import "./engineStyle"; import "./engineStyle";
@ -12,13 +12,15 @@ ReactDOM.render(
document.getElementById("mainmenu-container"), document.getElementById("mainmenu-container"),
); );
// setTimeout(() => { function rerender() {
// colors.primary = "#fff"; ReactDOM.render(
// refreshTheme(); <Theme>
// ReactDOM.render( <LoadingScreen />
// <Theme> </Theme>,
// <LoadingScreen /> document.getElementById("mainmenu-container"),
// </Theme>, );
// document.getElementById("mainmenu-container"), }
// );
// }, 5000); (function () {
ThemeEvents.subscribe(rerender);
})();

@ -74,6 +74,9 @@ export function GameOptionsRoot(props: IProps): React.ReactElement {
const [disableHotkeys, setDisableHotkeys] = useState(Settings.DisableHotkeys); const [disableHotkeys, setDisableHotkeys] = useState(Settings.DisableHotkeys);
const [disableASCIIArt, setDisableASCIIArt] = useState(Settings.DisableASCIIArt); const [disableASCIIArt, setDisableASCIIArt] = useState(Settings.DisableASCIIArt);
const [disableTextEffects, setDisableTextEffects] = useState(Settings.DisableTextEffects); const [disableTextEffects, setDisableTextEffects] = useState(Settings.DisableTextEffects);
const [enableBashHotkeys, setEnableBashHotkeys] = useState(Settings.EnableBashHotkeys);
const [enableTimestamps, setEnableTimestamps] = useState(Settings.EnableTimestamps);
const [locale, setLocale] = useState(Settings.Locale); const [locale, setLocale] = useState(Settings.Locale);
const [diagnosticOpen, setDiagnosticOpen] = useState(false); const [diagnosticOpen, setDiagnosticOpen] = useState(false);
const [deleteGameOpen, setDeleteOpen] = useState(false); const [deleteGameOpen, setDeleteOpen] = useState(false);
@ -152,6 +155,15 @@ export function GameOptionsRoot(props: IProps): React.ReactElement {
Settings.Locale = event.target.value as string; Settings.Locale = event.target.value as string;
} }
function handleEnableBashHotkeysChange(event: React.ChangeEvent<HTMLInputElement>): void {
setEnableBashHotkeys(event.target.checked);
Settings.EnableBashHotkeys = event.target.checked;
}
function handleEnableTimestampsChange(event: React.ChangeEvent<HTMLInputElement>): void {
setEnableTimestamps(event.target.checked);
Settings.EnableTimestamps = event.target.checked;
}
function startImport(): void { function startImport(): void {
if (!window.File || !window.FileReader || !window.FileList || !window.Blob) return; if (!window.File || !window.FileReader || !window.FileList || !window.Blob) return;
const ii = importInput.current; const ii = importInput.current;
@ -454,6 +466,43 @@ export function GameOptionsRoot(props: IProps): React.ReactElement {
} }
/> />
</ListItem> </ListItem>
<ListItem>
<FormControlLabel
control={<Switch checked={enableBashHotkeys} onChange={handleEnableBashHotkeysChange} />}
label={
<Tooltip
title={
<Typography>
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
enabled, the default browser shortcuts are overriden by the new Bash shortcuts.
</Typography>
}
>
<Typography>Enable bash hotkeys</Typography>
</Tooltip>
}
/>
</ListItem>
<ListItem>
<FormControlLabel
control={<Switch checked={enableTimestamps} onChange={handleEnableTimestampsChange} />}
label={
<Tooltip
title={
<Typography>
Terminal commands and log entries will be timestamped. The timestamp will have the format: M/D
h:m
</Typography>
}
>
<Typography>Enable timestamps</Typography>
</Tooltip>
}
/>
</ListItem>
<ListItem> <ListItem>
<Tooltip title={<Typography>Sets the locale for displaying numbers.</Typography>}> <Tooltip title={<Typography>Sets the locale for displaying numbers.</Typography>}>
<Typography>Locale&nbsp;</Typography> <Typography>Locale&nbsp;</Typography>

@ -1,5 +1,8 @@
import React from "react"; import React from "react";
import { createTheme, ThemeProvider, Theme, StyledEngineProvider } from "@mui/material/styles"; import { createTheme, ThemeProvider, Theme, StyledEngineProvider } from "@mui/material/styles";
import { EventEmitter } from "../../utils/EventEmitter";
export const ThemeEvents = new EventEmitter<[]>();
declare module "@mui/material/styles" { declare module "@mui/material/styles" {
interface Theme { interface Theme {