mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2025-02-17 02:22:23 +01:00
v1.0.2 part 1
This commit is contained in:
@ -293,6 +293,7 @@ export const CONSTANTS: {
|
|||||||
|
|
||||||
** Misc. **
|
** Misc. **
|
||||||
|
|
||||||
|
* scripts logs are colorized.
|
||||||
* documentation for scp not say string | string[]
|
* documentation for scp not say string | string[]
|
||||||
* nerf noodle bar
|
* nerf noodle bar
|
||||||
`,
|
`,
|
||||||
|
@ -670,10 +670,45 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
if (args.length === 0) {
|
if (args.length === 0) {
|
||||||
throw makeRuntimeErrorMsg("tprint", "Takes at least 1 argument.");
|
throw makeRuntimeErrorMsg("tprint", "Takes at least 1 argument.");
|
||||||
}
|
}
|
||||||
Terminal.print(`${workerScript.scriptRef.filename}: ${argsToString(args)}`);
|
const str = argsToString(args);
|
||||||
|
if (str.startsWith("ERROR") || str.startsWith("FAIL")) {
|
||||||
|
Terminal.error(`${workerScript.scriptRef.filename}: ${str}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (str.startsWith("SUCCESS")) {
|
||||||
|
Terminal.success(`${workerScript.scriptRef.filename}: ${str}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (str.startsWith("WARN")) {
|
||||||
|
Terminal.warn(`${workerScript.scriptRef.filename}: ${str}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (str.startsWith("INFO")) {
|
||||||
|
Terminal.info(`${workerScript.scriptRef.filename}: ${str}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Terminal.print(`${workerScript.scriptRef.filename}: ${str}`);
|
||||||
},
|
},
|
||||||
tprintf: function (format: any, ...args: any): any {
|
tprintf: function (format: any, ...args: any): any {
|
||||||
Terminal.print(vsprintf(format, args));
|
const str = vsprintf(format, args);
|
||||||
|
|
||||||
|
if (str.startsWith("ERROR") || str.startsWith("FAIL")) {
|
||||||
|
Terminal.error(`${workerScript.scriptRef.filename}: ${str}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (str.startsWith("SUCCESS")) {
|
||||||
|
Terminal.success(`${workerScript.scriptRef.filename}: ${str}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (str.startsWith("WARN")) {
|
||||||
|
Terminal.warn(`${workerScript.scriptRef.filename}: ${str}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (str.startsWith("INFO")) {
|
||||||
|
Terminal.info(`${workerScript.scriptRef.filename}: ${str}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Terminal.print(`${workerScript.scriptRef.filename}: ${str}`);
|
||||||
},
|
},
|
||||||
clearLog: function (): any {
|
clearLog: function (): any {
|
||||||
workerScript.scriptRef.clearLog();
|
workerScript.scriptRef.clearLog();
|
||||||
|
@ -872,7 +872,6 @@ export function startFactionFieldWork(this: IPlayer, router: IRouter, faction: F
|
|||||||
this.workAgiExpGainRate = 0.1 * this.agility_exp_mult * BitNodeMultipliers.FactionWorkExpGain;
|
this.workAgiExpGainRate = 0.1 * this.agility_exp_mult * BitNodeMultipliers.FactionWorkExpGain;
|
||||||
this.workChaExpGainRate = 0.1 * this.charisma_exp_mult * BitNodeMultipliers.FactionWorkExpGain;
|
this.workChaExpGainRate = 0.1 * this.charisma_exp_mult * BitNodeMultipliers.FactionWorkExpGain;
|
||||||
this.workRepGainRate = getFactionFieldWorkRepGain(this, faction);
|
this.workRepGainRate = getFactionFieldWorkRepGain(this, faction);
|
||||||
console.log(this.workRepGainRate);
|
|
||||||
|
|
||||||
this.factionWorkType = CONSTANTS.FactionWorkField;
|
this.factionWorkType = CONSTANTS.FactionWorkField;
|
||||||
this.currentWorkFactionDescription = "carrying out field missions";
|
this.currentWorkFactionDescription = "carrying out field missions";
|
||||||
@ -907,7 +906,6 @@ export function workForFaction(this: IPlayer, numCycles: number): boolean {
|
|||||||
break;
|
break;
|
||||||
case CONSTANTS.FactionWorkField:
|
case CONSTANTS.FactionWorkField:
|
||||||
this.workRepGainRate = getFactionFieldWorkRepGain(this, faction);
|
this.workRepGainRate = getFactionFieldWorkRepGain(this, faction);
|
||||||
console.log(this.workRepGainRate);
|
|
||||||
break;
|
break;
|
||||||
case CONSTANTS.FactionWorkSecurity:
|
case CONSTANTS.FactionWorkSecurity:
|
||||||
this.workRepGainRate = getFactionSecurityWorkRepGain(this, faction);
|
this.workRepGainRate = getFactionSecurityWorkRepGain(this, faction);
|
||||||
@ -1484,7 +1482,7 @@ export function finishCrime(this: IPlayer, cancelled: boolean): string {
|
|||||||
if (this.committingCrimeThruSingFn && ws !== null) {
|
if (this.committingCrimeThruSingFn && ws !== null) {
|
||||||
if (ws.disableLogs.ALL == null && ws.disableLogs.commitCrime == null) {
|
if (ws.disableLogs.ALL == null && ws.disableLogs.commitCrime == null) {
|
||||||
ws.scriptRef.log(
|
ws.scriptRef.log(
|
||||||
"Crime successful! Gained " +
|
"SUCCESS: Crime successful! Gained " +
|
||||||
numeralWrapper.formatMoney(this.workMoneyGained) +
|
numeralWrapper.formatMoney(this.workMoneyGained) +
|
||||||
", " +
|
", " +
|
||||||
numeralWrapper.formatExp(this.workHackExpGained) +
|
numeralWrapper.formatExp(this.workHackExpGained) +
|
||||||
@ -1536,7 +1534,7 @@ export function finishCrime(this: IPlayer, cancelled: boolean): string {
|
|||||||
if (this.committingCrimeThruSingFn && ws !== null) {
|
if (this.committingCrimeThruSingFn && ws !== null) {
|
||||||
if (ws.disableLogs.ALL == null && ws.disableLogs.commitCrime == null) {
|
if (ws.disableLogs.ALL == null && ws.disableLogs.commitCrime == null) {
|
||||||
ws.scriptRef.log(
|
ws.scriptRef.log(
|
||||||
"Crime failed! Gained " +
|
"FAIL: Crime failed! Gained " +
|
||||||
numeralWrapper.formatExp(this.workHackExpGained) +
|
numeralWrapper.formatExp(this.workHackExpGained) +
|
||||||
" hack exp, " +
|
" hack exp, " +
|
||||||
numeralWrapper.formatExp(this.workStrExpGained) +
|
numeralWrapper.formatExp(this.workStrExpGained) +
|
||||||
|
@ -106,6 +106,9 @@ interface IDefaultSettings {
|
|||||||
primarylight: string;
|
primarylight: string;
|
||||||
primary: string;
|
primary: string;
|
||||||
primarydark: string;
|
primarydark: string;
|
||||||
|
successlight: string;
|
||||||
|
success: string;
|
||||||
|
successdark: string;
|
||||||
errorlight: string;
|
errorlight: string;
|
||||||
error: string;
|
error: string;
|
||||||
errordark: string;
|
errordark: string;
|
||||||
@ -182,6 +185,9 @@ export const defaultSettings: IDefaultSettings = {
|
|||||||
primarylight: "#0f0",
|
primarylight: "#0f0",
|
||||||
primary: "#0c0",
|
primary: "#0c0",
|
||||||
primarydark: "#090",
|
primarydark: "#090",
|
||||||
|
successlight: "#0f0",
|
||||||
|
success: "#0c0",
|
||||||
|
successdark: "#090",
|
||||||
errorlight: "#f00",
|
errorlight: "#f00",
|
||||||
error: "#c00",
|
error: "#c00",
|
||||||
errordark: "#900",
|
errordark: "#900",
|
||||||
@ -246,6 +252,9 @@ export const Settings: ISettings & ISelfInitializer & ISelfLoading = {
|
|||||||
primarylight: defaultSettings.theme.primarylight,
|
primarylight: defaultSettings.theme.primarylight,
|
||||||
primary: defaultSettings.theme.primary,
|
primary: defaultSettings.theme.primary,
|
||||||
primarydark: defaultSettings.theme.primarydark,
|
primarydark: defaultSettings.theme.primarydark,
|
||||||
|
successlight: defaultSettings.theme.successlight,
|
||||||
|
success: defaultSettings.theme.success,
|
||||||
|
successdark: defaultSettings.theme.successdark,
|
||||||
errorlight: defaultSettings.theme.errorlight,
|
errorlight: defaultSettings.theme.errorlight,
|
||||||
error: defaultSettings.theme.error,
|
error: defaultSettings.theme.error,
|
||||||
errordark: defaultSettings.theme.errordark,
|
errordark: defaultSettings.theme.errordark,
|
||||||
|
@ -8,11 +8,8 @@ import { formatTime } from "../utils/helpers/formatTime";
|
|||||||
|
|
||||||
export class Output {
|
export class Output {
|
||||||
text: string;
|
text: string;
|
||||||
color: "inherit" | "initial" | "primary" | "secondary" | "error" | "textPrimary" | "textSecondary" | undefined;
|
color: "primary" | "error" | "success" | "info" | "warn";
|
||||||
constructor(
|
constructor(text: string, color: "primary" | "error" | "success" | "info" | "warn") {
|
||||||
text: string,
|
|
||||||
color: "inherit" | "initial" | "primary" | "secondary" | "error" | "textPrimary" | "textSecondary" | undefined,
|
|
||||||
) {
|
|
||||||
if (Settings.TimestampsFormat) text = "[" + formatTime(Settings.TimestampsFormat) + "] " + text;
|
if (Settings.TimestampsFormat) text = "[" + formatTime(Settings.TimestampsFormat) + "] " + text;
|
||||||
this.text = text;
|
this.text = text;
|
||||||
this.color = color;
|
this.color = color;
|
||||||
@ -72,6 +69,9 @@ export interface ITerminal {
|
|||||||
print(s: string): void;
|
print(s: string): void;
|
||||||
printRaw(node: React.ReactNode): void;
|
printRaw(node: React.ReactNode): void;
|
||||||
error(s: string): void;
|
error(s: string): void;
|
||||||
|
success(s: string): void;
|
||||||
|
info(s: string): void;
|
||||||
|
warn(s: string): void;
|
||||||
|
|
||||||
clear(): void;
|
clear(): void;
|
||||||
startAnalyze(): void;
|
startAnalyze(): void;
|
||||||
|
@ -113,6 +113,18 @@ export class Terminal implements ITerminal {
|
|||||||
this.append(new Output(s, "error"));
|
this.append(new Output(s, "error"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
success(s: string): void {
|
||||||
|
this.append(new Output(s, "success"));
|
||||||
|
}
|
||||||
|
|
||||||
|
info(s: string): void {
|
||||||
|
this.append(new Output(s, "info"));
|
||||||
|
}
|
||||||
|
|
||||||
|
warn(s: string): void {
|
||||||
|
this.append(new Output(s, "warn"));
|
||||||
|
}
|
||||||
|
|
||||||
startHack(player: IPlayer): void {
|
startHack(player: IPlayer): void {
|
||||||
// Hacking through Terminal should be faster than hacking through a script
|
// Hacking through Terminal should be faster than hacking through a script
|
||||||
const server = player.getCurrentServer();
|
const server = player.getCurrentServer();
|
||||||
|
@ -43,6 +43,37 @@ const useStyles = makeStyles((theme: Theme) =>
|
|||||||
padding: theme.spacing(0),
|
padding: theme.spacing(0),
|
||||||
height: "100%",
|
height: "100%",
|
||||||
},
|
},
|
||||||
|
|
||||||
|
success: {
|
||||||
|
whiteSpace: "pre-wrap",
|
||||||
|
overflowWrap: "anywhere",
|
||||||
|
margin: theme.spacing(0),
|
||||||
|
color: theme.colors.success,
|
||||||
|
},
|
||||||
|
error: {
|
||||||
|
whiteSpace: "pre-wrap",
|
||||||
|
overflowWrap: "anywhere",
|
||||||
|
margin: theme.spacing(0),
|
||||||
|
color: theme.palette.error.main,
|
||||||
|
},
|
||||||
|
primary: {
|
||||||
|
whiteSpace: "pre-wrap",
|
||||||
|
overflowWrap: "anywhere",
|
||||||
|
margin: theme.spacing(0),
|
||||||
|
color: theme.palette.primary.main,
|
||||||
|
},
|
||||||
|
info: {
|
||||||
|
whiteSpace: "pre-wrap",
|
||||||
|
overflowWrap: "anywhere",
|
||||||
|
margin: theme.spacing(0),
|
||||||
|
color: theme.palette.info.main,
|
||||||
|
},
|
||||||
|
warning: {
|
||||||
|
whiteSpace: "pre-wrap",
|
||||||
|
overflowWrap: "anywhere",
|
||||||
|
margin: theme.spacing(0),
|
||||||
|
color: theme.palette.warning.main,
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -80,6 +111,23 @@ export function TerminalRoot({ terminal, router, player }: IProps): React.ReactE
|
|||||||
setTimeout(doScroll, 50);
|
setTimeout(doScroll, 50);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
function lineClass(s: string): string {
|
||||||
|
if (s === "error") {
|
||||||
|
return classes.error;
|
||||||
|
}
|
||||||
|
if (s === "success") {
|
||||||
|
return classes.success;
|
||||||
|
}
|
||||||
|
if (s === "info") {
|
||||||
|
return classes.info;
|
||||||
|
}
|
||||||
|
if (s === "warn") {
|
||||||
|
return classes.warning;
|
||||||
|
}
|
||||||
|
|
||||||
|
return classes.primary;
|
||||||
|
}
|
||||||
|
|
||||||
const classes = useStyles();
|
const classes = useStyles();
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@ -89,7 +137,7 @@ export function TerminalRoot({ terminal, router, player }: IProps): React.ReactE
|
|||||||
if (item instanceof Output)
|
if (item instanceof Output)
|
||||||
return (
|
return (
|
||||||
<ListItem key={i} classes={{ root: classes.nopadding }}>
|
<ListItem key={i} classes={{ root: classes.nopadding }}>
|
||||||
<Typography classes={{ root: classes.preformatted }} color={item.color} paragraph={false}>
|
<Typography classes={{ root: lineClass(item.color) }} paragraph={false}>
|
||||||
{item.text}
|
{item.text}
|
||||||
</Typography>
|
</Typography>
|
||||||
</ListItem>
|
</ListItem>
|
||||||
|
@ -14,6 +14,7 @@ import ArrowForwardIosIcon from "@mui/icons-material/ArrowForwardIos";
|
|||||||
import { workerScripts } from "../../Netscript/WorkerScripts";
|
import { workerScripts } from "../../Netscript/WorkerScripts";
|
||||||
import { startWorkerScript } from "../../NetscriptWorker";
|
import { startWorkerScript } from "../../NetscriptWorker";
|
||||||
import { GetServer } from "../../Server/AllServers";
|
import { GetServer } from "../../Server/AllServers";
|
||||||
|
import { Theme } from "@mui/material";
|
||||||
|
|
||||||
let layerCounter = 0;
|
let layerCounter = 0;
|
||||||
|
|
||||||
@ -65,7 +66,7 @@ interface IProps {
|
|||||||
onClose: () => void;
|
onClose: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const useStyles = makeStyles(() =>
|
const useStyles = makeStyles((theme: Theme) =>
|
||||||
createStyles({
|
createStyles({
|
||||||
logs: {
|
logs: {
|
||||||
overflowY: "scroll",
|
overflowY: "scroll",
|
||||||
@ -74,6 +75,21 @@ const useStyles = makeStyles(() =>
|
|||||||
display: "flex",
|
display: "flex",
|
||||||
flexDirection: "column-reverse",
|
flexDirection: "column-reverse",
|
||||||
},
|
},
|
||||||
|
success: {
|
||||||
|
color: theme.colors.success,
|
||||||
|
},
|
||||||
|
error: {
|
||||||
|
color: theme.palette.error.main,
|
||||||
|
},
|
||||||
|
primary: {
|
||||||
|
color: theme.palette.primary.main,
|
||||||
|
},
|
||||||
|
info: {
|
||||||
|
color: theme.palette.info.main,
|
||||||
|
},
|
||||||
|
warning: {
|
||||||
|
color: theme.palette.warning.main,
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -117,6 +133,22 @@ function LogWindow(props: IProps): React.ReactElement {
|
|||||||
return t.slice(0, maxLength - 3) + "...";
|
return t.slice(0, maxLength - 3) + "...";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function lineClass(s: string): string {
|
||||||
|
if (s.startsWith("ERROR") || s.startsWith("FAIL")) {
|
||||||
|
return classes.error;
|
||||||
|
}
|
||||||
|
if (s.startsWith("SUCCESS")) {
|
||||||
|
return classes.success;
|
||||||
|
}
|
||||||
|
if (s.startsWith("WARN")) {
|
||||||
|
return classes.warning;
|
||||||
|
}
|
||||||
|
if (s.startsWith("INFO")) {
|
||||||
|
return classes.info;
|
||||||
|
}
|
||||||
|
return classes.primary;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Draggable handle=".drag">
|
<Draggable handle=".drag">
|
||||||
<Paper
|
<Paper
|
||||||
@ -162,7 +194,7 @@ function LogWindow(props: IProps): React.ReactElement {
|
|||||||
<Box>
|
<Box>
|
||||||
{props.script.logs.map(
|
{props.script.logs.map(
|
||||||
(line: string, i: number): JSX.Element => (
|
(line: string, i: number): JSX.Element => (
|
||||||
<Typography key={i}>
|
<Typography key={i} className={lineClass(line)}>
|
||||||
{line}
|
{line}
|
||||||
<br />
|
<br />
|
||||||
</Typography>
|
</Typography>
|
||||||
|
@ -18,6 +18,9 @@ declare module "@mui/material/styles" {
|
|||||||
backgroundprimary: React.CSSProperties["color"];
|
backgroundprimary: React.CSSProperties["color"];
|
||||||
backgroundsecondary: React.CSSProperties["color"];
|
backgroundsecondary: React.CSSProperties["color"];
|
||||||
button: React.CSSProperties["color"];
|
button: React.CSSProperties["color"];
|
||||||
|
successlight: React.CSSProperties["color"];
|
||||||
|
success: React.CSSProperties["color"];
|
||||||
|
successdark: React.CSSProperties["color"];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
interface ThemeOptions {
|
interface ThemeOptions {
|
||||||
@ -32,6 +35,9 @@ declare module "@mui/material/styles" {
|
|||||||
backgroundprimary: React.CSSProperties["color"];
|
backgroundprimary: React.CSSProperties["color"];
|
||||||
backgroundsecondary: React.CSSProperties["color"];
|
backgroundsecondary: React.CSSProperties["color"];
|
||||||
button: React.CSSProperties["color"];
|
button: React.CSSProperties["color"];
|
||||||
|
successlight: React.CSSProperties["color"];
|
||||||
|
success: React.CSSProperties["color"];
|
||||||
|
successdark: React.CSSProperties["color"];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -51,6 +57,9 @@ export function refreshTheme(): void {
|
|||||||
backgroundprimary: Settings.theme.backgroundprimary,
|
backgroundprimary: Settings.theme.backgroundprimary,
|
||||||
backgroundsecondary: Settings.theme.backgroundsecondary,
|
backgroundsecondary: Settings.theme.backgroundsecondary,
|
||||||
button: Settings.theme.button,
|
button: Settings.theme.button,
|
||||||
|
successlight: Settings.theme.successlight,
|
||||||
|
success: Settings.theme.success,
|
||||||
|
successdark: Settings.theme.successdark,
|
||||||
},
|
},
|
||||||
palette: {
|
palette: {
|
||||||
primary: {
|
primary: {
|
||||||
|
@ -132,6 +132,27 @@ export function ThemeEditorModal(props: IProps): React.ReactElement {
|
|||||||
defaultColor={defaultSettings.theme["primarydark"]}
|
defaultColor={defaultSettings.theme["primarydark"]}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<br />
|
||||||
|
|
||||||
|
<ColorEditor
|
||||||
|
name="successlight"
|
||||||
|
onColorChange={onColorChange}
|
||||||
|
color={customTheme["successlight"]}
|
||||||
|
defaultColor={defaultSettings.theme["successlight"]}
|
||||||
|
/>
|
||||||
|
<ColorEditor
|
||||||
|
name="success"
|
||||||
|
onColorChange={onColorChange}
|
||||||
|
color={customTheme["success"]}
|
||||||
|
defaultColor={defaultSettings.theme["success"]}
|
||||||
|
/>
|
||||||
|
<ColorEditor
|
||||||
|
name="successdark"
|
||||||
|
onColorChange={onColorChange}
|
||||||
|
color={customTheme["successdark"]}
|
||||||
|
defaultColor={defaultSettings.theme["successdark"]}
|
||||||
|
/>
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
<ColorEditor
|
<ColorEditor
|
||||||
name="errorlight"
|
name="errorlight"
|
||||||
|
Reference in New Issue
Block a user