mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-23 22:52:29 +01:00
Removed closePid(fn, host, ...args) and fixed closePid(pid)
This commit is contained in:
parent
e17fe6f618
commit
8903cd2a8b
@ -987,37 +987,14 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
|
|
||||||
LogBoxEvents.emit(runningScriptObj);
|
LogBoxEvents.emit(runningScriptObj);
|
||||||
},
|
},
|
||||||
closeTail: function (fn: any, hostname: any = workerScript.hostname, ...scriptArgs: any[]): void {
|
closeTail: function (pid?: number): void {
|
||||||
updateDynamicRam("closeTail", getRamCost(Player, "closeTail"));
|
updateDynamicRam("closeTail", getRamCost(Player, "closeTail"));
|
||||||
//Get the script details
|
//Get the pid of the calling script if no pid is given
|
||||||
let server;
|
if (pid === undefined) {
|
||||||
let filename;
|
pid = workerScript.scriptRef.pid;
|
||||||
let args;
|
|
||||||
if (arguments.length === 0) {
|
|
||||||
//Get the details from the script calling the function
|
|
||||||
const runningScriptObj = workerScript.scriptRef;
|
|
||||||
server = runningScriptObj.server;
|
|
||||||
filename = runningScriptObj.filename;
|
|
||||||
args = runningScriptObj.args;
|
|
||||||
} else if (typeof fn === "number") {
|
|
||||||
//Get the details via the pid of a running script
|
|
||||||
const runningScriptObj = getRunningScriptByPid(fn, "tail");
|
|
||||||
if (runningScriptObj == null) {
|
|
||||||
workerScript.log("closeTail", () => getCannotFindRunningScriptErrorMessage(`${fn}`, hostname, scriptArgs));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
server = runningScriptObj.server;
|
|
||||||
filename = runningScriptObj.filename;
|
|
||||||
args = runningScriptObj.args;
|
|
||||||
} else {
|
|
||||||
//Get the details from the input directly
|
|
||||||
server = hostname;
|
|
||||||
filename = fn;
|
|
||||||
args = scriptArgs;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Emit an event to tell the game to close the tail window if it exists
|
//Emit an event to tell the game to close the tail window if it exists
|
||||||
LogBoxCloserEvents.emit(server, filename, args.map((x: any): string => `${x}`));
|
LogBoxCloserEvents.emit(pid);
|
||||||
},
|
},
|
||||||
nuke: function (_hostname: unknown): boolean {
|
nuke: function (_hostname: unknown): boolean {
|
||||||
updateDynamicRam("nuke", getRamCost(Player, "nuke"));
|
updateDynamicRam("nuke", getRamCost(Player, "nuke"));
|
||||||
|
@ -23,7 +23,7 @@ import { Settings } from "../../Settings/Settings";
|
|||||||
let layerCounter = 0;
|
let layerCounter = 0;
|
||||||
|
|
||||||
export const LogBoxEvents = new EventEmitter<[RunningScript]>();
|
export const LogBoxEvents = new EventEmitter<[RunningScript]>();
|
||||||
export const LogBoxCloserEvents = new EventEmitter<[any, any, any[]]>();
|
export const LogBoxCloserEvents = new EventEmitter<[number]>();
|
||||||
export const LogBoxClearEvents = new EventEmitter<[]>();
|
export const LogBoxClearEvents = new EventEmitter<[]>();
|
||||||
|
|
||||||
interface Log {
|
interface Log {
|
||||||
@ -55,9 +55,8 @@ export function LogBoxManager(): React.ReactElement {
|
|||||||
//Event used by ns.closeTail to close tail windows
|
//Event used by ns.closeTail to close tail windows
|
||||||
useEffect(
|
useEffect(
|
||||||
() =>
|
() =>
|
||||||
LogBoxCloserEvents.subscribe((hostname: any, filename: any, stringArgs: any[]) => {
|
LogBoxCloserEvents.subscribe((pid: number) => {
|
||||||
const id = hostname + "-" + filename + stringArgs.map((x: any): string => `${x}`).join("-");
|
closePid(pid);
|
||||||
close(id);
|
|
||||||
}),
|
}),
|
||||||
[],
|
[],
|
||||||
);
|
);
|
||||||
@ -69,11 +68,18 @@ export function LogBoxManager(): React.ReactElement {
|
|||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//Close tail windows by their id
|
||||||
function close(id: string): void {
|
function close(id: string): void {
|
||||||
logs = logs.filter((l) => l.id !== id);
|
logs = logs.filter((l) => l.id !== id);
|
||||||
rerender();
|
rerender();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Close tail windows by their pid
|
||||||
|
function closePid(pid: number): void {
|
||||||
|
logs = logs.filter((log) => log.script.pid != pid);
|
||||||
|
rerender();
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{logs.map((log) => (
|
{logs.map((log) => (
|
||||||
@ -249,14 +255,14 @@ function LogWindow(props: IProps): React.ReactElement {
|
|||||||
minHeight: `${minConstraints[1]}px`,
|
minHeight: `${minConstraints[1]}px`,
|
||||||
...(minimized
|
...(minimized
|
||||||
? {
|
? {
|
||||||
border: "none",
|
border: "none",
|
||||||
margin: 0,
|
margin: 0,
|
||||||
maxHeight: 0,
|
maxHeight: 0,
|
||||||
padding: 0,
|
padding: 0,
|
||||||
}
|
}
|
||||||
: {
|
: {
|
||||||
border: `1px solid ${Settings.theme.welllight}`,
|
border: `1px solid ${Settings.theme.welllight}`,
|
||||||
}),
|
}),
|
||||||
}}
|
}}
|
||||||
ref={container}
|
ref={container}
|
||||||
>
|
>
|
||||||
|
Loading…
Reference in New Issue
Block a user