mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-29 19:13:49 +01:00
working on timestamps and make netscript function highlight more specific.
This commit is contained in:
parent
1e7da4c610
commit
3f28b066b0
@ -8,7 +8,7 @@ import { IMap } from "../types";
|
|||||||
import { Terminal } from "../Terminal";
|
import { Terminal } from "../Terminal";
|
||||||
|
|
||||||
import { Generic_fromJSON, Generic_toJSON, Reviver } from "../utils/JSONReviver";
|
import { Generic_fromJSON, Generic_toJSON, Reviver } from "../utils/JSONReviver";
|
||||||
import { getTimestamp } from "../utils/helpers/getTimestamp";
|
import { formatTime } from "../utils/helpers/formatTime";
|
||||||
|
|
||||||
export class RunningScript {
|
export class RunningScript {
|
||||||
// Script arguments
|
// Script arguments
|
||||||
@ -74,8 +74,8 @@ export class RunningScript {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let logEntry = txt;
|
let logEntry = txt;
|
||||||
if (Settings.EnableTimestamps) {
|
if (Settings.TimestampsFormat) {
|
||||||
logEntry = "[" + getTimestamp() + "] " + logEntry;
|
logEntry = "[" + formatTime(Settings.TimestampsFormat) + "] " + logEntry;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.logs.push(logEntry);
|
this.logs.push(logEntry);
|
||||||
|
@ -354,7 +354,8 @@ export function Root(props: IProps): React.ReactElement {
|
|||||||
.find((l: any) => l.id === "javascript")
|
.find((l: any) => l.id === "javascript")
|
||||||
.loader();
|
.loader();
|
||||||
l.language.tokenizer.root.unshift(["ns", { token: "ns" }]);
|
l.language.tokenizer.root.unshift(["ns", { token: "ns" }]);
|
||||||
for (const symbol of symbols) l.language.tokenizer.root.unshift([symbol, { token: "netscriptfunction" }]);
|
for (const symbol of symbols)
|
||||||
|
l.language.tokenizer.root.unshift(["[^a-zA-Z]" + symbol + "[^a-zA-Z]", { token: "netscriptfunction" }]);
|
||||||
const otherKeywords = ["let", "const", "var", "function"];
|
const otherKeywords = ["let", "const", "var", "function"];
|
||||||
const otherKeyvars = ["true", "false", "null", "undefined"];
|
const otherKeyvars = ["true", "false", "null", "undefined"];
|
||||||
otherKeywords.forEach((k) => l.language.tokenizer.root.unshift([k, { token: "otherkeywords" }]));
|
otherKeywords.forEach((k) => l.language.tokenizer.root.unshift([k, { token: "otherkeywords" }]));
|
||||||
|
@ -44,9 +44,9 @@ interface IDefaultSettings {
|
|||||||
EnableBashHotkeys: boolean;
|
EnableBashHotkeys: boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enable timestamps
|
* Timestamps format
|
||||||
*/
|
*/
|
||||||
EnableTimestamps: boolean;
|
TimestampsFormat: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Locale used for display numbers
|
* Locale used for display numbers
|
||||||
@ -166,7 +166,7 @@ export const defaultSettings: IDefaultSettings = {
|
|||||||
DisableHotkeys: false,
|
DisableHotkeys: false,
|
||||||
DisableTextEffects: false,
|
DisableTextEffects: false,
|
||||||
EnableBashHotkeys: false,
|
EnableBashHotkeys: false,
|
||||||
EnableTimestamps: false,
|
TimestampsFormat: "YYYY-MM-DD HH:MM:SS",
|
||||||
Locale: "en",
|
Locale: "en",
|
||||||
MaxLogCapacity: 50,
|
MaxLogCapacity: 50,
|
||||||
MaxPortCapacity: 50,
|
MaxPortCapacity: 50,
|
||||||
@ -225,7 +225,7 @@ export const Settings: ISettings & ISelfInitializer & ISelfLoading = {
|
|||||||
DisableHotkeys: defaultSettings.DisableHotkeys,
|
DisableHotkeys: defaultSettings.DisableHotkeys,
|
||||||
DisableTextEffects: defaultSettings.DisableTextEffects,
|
DisableTextEffects: defaultSettings.DisableTextEffects,
|
||||||
EnableBashHotkeys: defaultSettings.EnableBashHotkeys,
|
EnableBashHotkeys: defaultSettings.EnableBashHotkeys,
|
||||||
EnableTimestamps: defaultSettings.EnableTimestamps,
|
TimestampsFormat: defaultSettings.TimestampsFormat,
|
||||||
Locale: "en",
|
Locale: "en",
|
||||||
MaxLogCapacity: defaultSettings.MaxLogCapacity,
|
MaxLogCapacity: defaultSettings.MaxLogCapacity,
|
||||||
MaxPortCapacity: defaultSettings.MaxPortCapacity,
|
MaxPortCapacity: defaultSettings.MaxPortCapacity,
|
||||||
@ -282,5 +282,6 @@ export const Settings: ISettings & ISelfInitializer & ISelfLoading = {
|
|||||||
Object.assign(Settings.theme, save.theme);
|
Object.assign(Settings.theme, save.theme);
|
||||||
delete save.theme;
|
delete save.theme;
|
||||||
Object.assign(Settings, save);
|
Object.assign(Settings, save);
|
||||||
|
console.log(Settings.TimestampsFormat);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -4,7 +4,7 @@ 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 { Settings } from "../Settings/Settings";
|
||||||
import { getTimestamp } from "../utils/helpers/getTimestamp";
|
import { formatTime } from "../utils/helpers/formatTime";
|
||||||
|
|
||||||
export class Output {
|
export class Output {
|
||||||
text: string;
|
text: string;
|
||||||
@ -13,7 +13,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;
|
if (Settings.TimestampsFormat) text = "[" + formatTime(Settings.TimestampsFormat) + "] " + text;
|
||||||
this.text = text;
|
this.text = text;
|
||||||
this.color = color;
|
this.color = color;
|
||||||
}
|
}
|
||||||
@ -22,10 +22,10 @@ export class Output {
|
|||||||
export class RawOutput {
|
export class RawOutput {
|
||||||
raw: React.ReactNode;
|
raw: React.ReactNode;
|
||||||
constructor(node: React.ReactNode) {
|
constructor(node: React.ReactNode) {
|
||||||
if (Settings.EnableTimestamps)
|
if (Settings.TimestampsFormat)
|
||||||
node = (
|
node = (
|
||||||
<>
|
<>
|
||||||
[{getTimestamp()}] {node}
|
[{formatTime(Settings.TimestampsFormat)}] {node}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
this.raw = node;
|
this.raw = node;
|
||||||
@ -36,7 +36,7 @@ export class Link {
|
|||||||
hostname: string;
|
hostname: string;
|
||||||
dashes: string;
|
dashes: string;
|
||||||
constructor(dashes: string, hostname: string) {
|
constructor(dashes: string, hostname: string) {
|
||||||
if (Settings.EnableTimestamps) dashes = "[" + getTimestamp() + "] " + dashes;
|
if (Settings.TimestampsFormat) dashes = "[" + formatTime(Settings.TimestampsFormat) + "] " + dashes;
|
||||||
this.hostname = hostname;
|
this.hostname = hostname;
|
||||||
this.dashes = dashes;
|
this.dashes = dashes;
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@ export function GameOptionsRoot(props: IProps): React.ReactElement {
|
|||||||
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 [enableBashHotkeys, setEnableBashHotkeys] = useState(Settings.EnableBashHotkeys);
|
||||||
const [enableTimestamps, setEnableTimestamps] = useState(Settings.EnableTimestamps);
|
const [enableTimestamps, setEnableTimestamps] = useState(!!Settings.TimestampsFormat);
|
||||||
const [saveGameOnFileSave, setSaveGameOnFileSave] = useState(Settings.SaveGameOnFileSave);
|
const [saveGameOnFileSave, setSaveGameOnFileSave] = useState(Settings.SaveGameOnFileSave);
|
||||||
|
|
||||||
const [locale, setLocale] = useState(Settings.Locale);
|
const [locale, setLocale] = useState(Settings.Locale);
|
||||||
@ -156,7 +156,7 @@ export function GameOptionsRoot(props: IProps): React.ReactElement {
|
|||||||
}
|
}
|
||||||
function handleEnableTimestampsChange(event: React.ChangeEvent<HTMLInputElement>): void {
|
function handleEnableTimestampsChange(event: React.ChangeEvent<HTMLInputElement>): void {
|
||||||
setEnableTimestamps(event.target.checked);
|
setEnableTimestamps(event.target.checked);
|
||||||
Settings.EnableTimestamps = event.target.checked;
|
Settings.TimestampsFormat = event.target.checked ? "YYYY-MM-DD HH:MM:SS" : "";
|
||||||
}
|
}
|
||||||
function handleSaveGameOnFile(event: React.ChangeEvent<HTMLInputElement>): void {
|
function handleSaveGameOnFile(event: React.ChangeEvent<HTMLInputElement>): void {
|
||||||
setSaveGameOnFileSave(event.target.checked);
|
setSaveGameOnFileSave(event.target.checked);
|
||||||
|
3
src/utils/helpers/formatTime.ts
Normal file
3
src/utils/helpers/formatTime.ts
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
export function formatTime(format: string): string {
|
||||||
|
return "";
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user