mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-29 04:17:05 +02:00
ENUMS: Initial Enum Helper rework + Reorganization (#596)
This commit is contained in:
+16
-10
@@ -13,7 +13,18 @@ import {
|
||||
import { netscriptCanGrow, netscriptCanWeaken } from "./Hacking/netscriptCanHack";
|
||||
import { Terminal } from "./Terminal";
|
||||
import { Player } from "@player";
|
||||
import { CompletedProgramName } from "./Programs/Programs";
|
||||
import {
|
||||
CityName,
|
||||
CompletedProgramName,
|
||||
CrimeType,
|
||||
FactionWorkType,
|
||||
GymType,
|
||||
JobName,
|
||||
LiteratureName,
|
||||
LocationName,
|
||||
ToastVariant,
|
||||
UniversityClassType,
|
||||
} from "@enums";
|
||||
import { PromptEvent } from "./ui/React/PromptManager";
|
||||
import { GetServer, DeleteServer, AddToAllServers, createUniqueRandomIp } from "./Server/AllServers";
|
||||
import {
|
||||
@@ -68,8 +79,7 @@ import { NS, RecentScript, BasicHGWOptions, ProcessInfo, NSEnums } from "@nsdefs
|
||||
import { NetscriptSingularity } from "./NetscriptFunctions/Singularity";
|
||||
|
||||
import { dialogBoxCreate } from "./ui/React/DialogBox";
|
||||
import { SnackbarEvents, ToastVariant } from "./ui/React/Snackbar";
|
||||
import { checkEnum } from "./utils/helpers/enum";
|
||||
import { SnackbarEvents } from "./ui/React/Snackbar";
|
||||
import { matchScriptPathExact } from "./utils/helpers/scriptKey";
|
||||
|
||||
import { Flags } from "./NetscriptFunctions/Flags";
|
||||
@@ -81,26 +91,24 @@ import { INetscriptExtra } from "./NetscriptFunctions/Extra";
|
||||
import { ScriptDeath } from "./Netscript/ScriptDeath";
|
||||
import { getBitNodeMultipliers } from "./BitNode/BitNode";
|
||||
import { assert, arrayAssert, stringAssert, objectAssert } from "./utils/helpers/typeAssertion";
|
||||
import { CityName, JobName, CrimeType, GymType, LocationName, UniversityClassType } from "./Enums";
|
||||
import { cloneDeep, escapeRegExp } from "lodash";
|
||||
import { FactionWorkType } from "./Enums";
|
||||
import numeral from "numeral";
|
||||
import { clearPort, peekPort, portHandle, readPort, tryWritePort, writePort } from "./NetscriptPort";
|
||||
import { FilePath, resolveFilePath } from "./Paths/FilePath";
|
||||
import { hasScriptExtension } from "./Paths/ScriptFilePath";
|
||||
import { hasTextExtension } from "./Paths/TextFilePath";
|
||||
import { ContentFilePath } from "./Paths/ContentFile";
|
||||
import { LiteratureName } from "./Literature/data/LiteratureNames";
|
||||
import { hasContractExtension } from "./Paths/ContractFilePath";
|
||||
import { getRamCost } from "./Netscript/RamCostGenerator";
|
||||
import { getEnumHelper } from "./utils/EnumHelper";
|
||||
|
||||
export const enums: NSEnums = {
|
||||
CityName,
|
||||
CrimeType,
|
||||
FactionWorkType,
|
||||
GymType,
|
||||
LocationName,
|
||||
JobName,
|
||||
LocationName,
|
||||
ToastVariant,
|
||||
UniversityClassType,
|
||||
};
|
||||
@@ -1600,10 +1608,8 @@ export const ns: InternalAPI<NSFull> = {
|
||||
(ctx) =>
|
||||
(_message, _variant = ToastVariant.SUCCESS, _duration = 2000) => {
|
||||
const message = helpers.string(ctx, "message", _message);
|
||||
const variant = helpers.string(ctx, "variant", _variant);
|
||||
const variant = getEnumHelper("ToastVariant").nsGetMember(ctx, _variant);
|
||||
const duration = _duration === null ? null : helpers.number(ctx, "duration", _duration);
|
||||
if (!checkEnum(ToastVariant, variant))
|
||||
throw new Error(`variant must be one of ${Object.values(ToastVariant).join(", ")}`);
|
||||
SnackbarEvents.emit(message, variant as ToastVariant, duration);
|
||||
},
|
||||
prompt: (ctx) => (_txt, _options) => {
|
||||
|
||||
Reference in New Issue
Block a user