diff --git a/markdown/bitburner.userinterface.resizetail.md b/markdown/bitburner.userinterface.resizetail.md index 0a6ae2af6..f46e54e21 100644 --- a/markdown/bitburner.userinterface.resizetail.md +++ b/markdown/bitburner.userinterface.resizetail.md @@ -42,7 +42,7 @@ number -Width of the window. +Width of the window. The minimum value is 150. @@ -58,7 +58,7 @@ number -Height of the window. +Height of the window. The minimum value is 30. diff --git a/src/ScriptEditor/NetscriptDefinitions.d.ts b/src/ScriptEditor/NetscriptDefinitions.d.ts index 884bc4384..02229b97e 100644 --- a/src/ScriptEditor/NetscriptDefinitions.d.ts +++ b/src/ScriptEditor/NetscriptDefinitions.d.ts @@ -6744,8 +6744,8 @@ interface UserInterface { * * Resize a tail window. Size are in pixel. * - * @param width - Width of the window. - * @param height - Height of the window. + * @param width - Width of the window. The minimum value is 150. + * @param height - Height of the window. The minimum value is 30. * @param pid - Optional. PID of the script having its tail resized. If omitted, the current script is used. */ resizeTail(width: number, height: number, pid?: number): void; diff --git a/src/ui/React/LogBoxManager.tsx b/src/ui/React/LogBoxManager.tsx index aff7fdf65..df4105c64 100644 --- a/src/ui/React/LogBoxManager.tsx +++ b/src/ui/React/LogBoxManager.tsx @@ -27,12 +27,17 @@ import { useRerender } from "./hooks"; import { dialogBoxCreate } from "./DialogBox"; import { makeStyles } from "tss-react/mui"; import { logBoxBaseZIndex } from "./Constants"; +import { clampNumber } from "../../utils/helpers/clampNumber"; + let layerCounter = 0; export const LogBoxEvents = new EventEmitter<[RunningScript]>(); export const LogBoxCloserEvents = new EventEmitter<[number]>(); export const LogBoxClearEvents = new EventEmitter<[]>(); +// Min width/height of a log window +const minWindowSize: [number, number] = [150, 33]; + // Dynamic properties (size, position) bound to a specific rendered instance of a LogBox export class LogBoxProperties { x = window.innerWidth * 0.4; @@ -64,8 +69,8 @@ export class LogBoxProperties { } setSize(width: number, height: number): void { - this.width = width; - this.height = height; + this.width = clampNumber(width, minWindowSize[0]); + this.height = clampNumber(height, minWindowSize[1]); this.rerender(); } @@ -330,9 +335,6 @@ function LogWindow({ hidden, script, onClose }: LogWindowProps): React.ReactElem } }; - // Max [width, height] - const minConstraints: [number, number] = [150, 33]; - return ( {title()} - + {!workerScripts.has(script.pid) ? ( @@ -405,7 +407,7 @@ function LogWindow({ hidden, script, onClose }: LogWindowProps): React.ReactElem