SETTINGS: add tailRenderInterval (#1107)

currently tails are on a static rerender time of 1000ms
there are ways to force a rerender with ns.moveTail / ns.resizeTail
but i dont know why this shouldnt be a setting set by the player

currently its static set on creation of the tail window but that could be expanded to allow setting it per script
and maybe through a ns function
This commit is contained in:
Caldwell
2024-02-19 20:19:03 +01:00
committed by GitHub
parent e6755afcb3
commit 47cf5c1610
15 changed files with 43 additions and 34 deletions

View File

@ -159,7 +159,6 @@
| [GoOpponent](./bitburner.goopponent.md) | |
| [NSEnums](./bitburner.nsenums.md) | |
| [PlayerRequirement](./bitburner.playerrequirement.md) | Structured interface to requirements for joining a faction or company. For fields with numerical value &gt; 0, the player must have at least this value. For fields with numerical value &lt;<!-- -->= 0, the player must have at most this value. For "not", the sub-condition must be failed instead of passed. For "someCondition", at least one sub-condition must be passed. |
| [PortData](./bitburner.portdata.md) | |
| [ReactNode](./bitburner.reactnode.md) | <p>A stand-in for the real React.ReactNode. A [ReactElement](./bitburner.reactelement.md) is rendered dynamically with React. number and string are displayed directly. boolean, null, and undefined are ignored and not rendered. An array of ReactNodes will display all members of that array sequentially.</p><p>Use React.createElement to make the ReactElement type, see [creating an element without jsx](https://react.dev/reference/react/createElement#creating-an-element-without-jsx) from the official React documentation.</p> |
| [ScriptArg](./bitburner.scriptarg.md) | |
| [SleeveBladeburnerTask](./bitburner.sleevebladeburnertask.md) | |

View File

@ -19,7 +19,7 @@ export interface NetscriptPort
| [clear()](./bitburner.netscriptport.clear.md) | Empties all data from the port. |
| [empty()](./bitburner.netscriptport.empty.md) | Check if the port is empty. |
| [full()](./bitburner.netscriptport.full.md) | Check if the port is full. |
| [nextWrite()](./bitburner.netscriptport.nextwrite.md) | Sleeps until the port is written to. |
| [nextWrite()](./bitburner.netscriptport.nextwrite.md) | Waits until the port is written to. |
| [peek()](./bitburner.netscriptport.peek.md) | Retrieve the first element from the port without removing it. |
| [read()](./bitburner.netscriptport.read.md) | Shift an element out of the port. |
| [tryWrite(value)](./bitburner.netscriptport.trywrite.md) | Attempt to write data to the port. |

View File

@ -4,7 +4,7 @@
## NetscriptPort.nextWrite() method
Sleeps until the port is written to.
Waits until the port is written to.
**Signature:**

View File

@ -9,11 +9,11 @@ Retrieve the first element from the port without removing it.
**Signature:**
```typescript
peek(): PortData;
peek(): any;
```
**Returns:**
[PortData](./bitburner.portdata.md)
any
the data read

View File

@ -9,11 +9,11 @@ Shift an element out of the port.
**Signature:**
```typescript
read(): PortData;
read(): any;
```
**Returns:**
[PortData](./bitburner.portdata.md)
any
the data read.

View File

@ -9,14 +9,14 @@ Attempt to write data to the port.
**Signature:**
```typescript
tryWrite(value: string | number): boolean;
tryWrite(value: any): boolean;
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| value | string \| number | |
| value | any | Data to write, it's cloned with structuredClone(). |
**Returns:**

View File

@ -9,18 +9,18 @@ Write data to a port.
**Signature:**
```typescript
write(value: string | number): PortData | null;
write(value: any): any;
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| value | string \| number | |
| value | any | Data to write, it's cloned with structuredClone(). |
**Returns:**
[PortData](./bitburner.portdata.md) \| null
any
The data popped off the queue if it was full.

View File

@ -9,7 +9,7 @@ Get a copy of the data from a port without popping it.
**Signature:**
```typescript
peek(portNumber: number): PortData;
peek(portNumber: number): any;
```
## Parameters
@ -20,7 +20,7 @@ peek(portNumber: number): PortData;
**Returns:**
[PortData](./bitburner.portdata.md)
any
Data in the specified port.

View File

@ -9,7 +9,7 @@ Read data from a port.
**Signature:**
```typescript
readPort(portNumber: number): PortData;
readPort(portNumber: number): any;
```
## Parameters
@ -20,7 +20,7 @@ readPort(portNumber: number): PortData;
**Returns:**
[PortData](./bitburner.portdata.md)
any
The data read.

View File

@ -9,7 +9,7 @@ Attempt to write to a port.
**Signature:**
```typescript
tryWritePort(portNumber: number, data: string | number): boolean;
tryWritePort(portNumber: number, data: any): boolean;
```
## Parameters
@ -17,7 +17,7 @@ tryWritePort(portNumber: number, data: string | number): boolean;
| Parameter | Type | Description |
| --- | --- | --- |
| portNumber | number | Port to attempt to write to. Must be a positive integer. |
| data | string \| number | Data to write. |
| data | any | Data to write, it's cloned with structuredClone(). |
**Returns:**

View File

@ -9,7 +9,7 @@ Write data to a port.
**Signature:**
```typescript
writePort(portNumber: number, data: string | number): PortData | null;
writePort(portNumber: number, data: any): any;
```
## Parameters
@ -17,11 +17,11 @@ writePort(portNumber: number, data: string | number): PortData | null;
| Parameter | Type | Description |
| --- | --- | --- |
| portNumber | number | Port to write to. Must be a positive integer. |
| data | string \| number | Data to write. |
| data | any | Data to write, it's cloned with structuredClone(). |
**Returns:**
[PortData](./bitburner.portdata.md) \| null
any
The data popped off the queue if it was full, or null if it was not full.

View File

@ -1,12 +0,0 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [bitburner](./bitburner.md) &gt; [PortData](./bitburner.portdata.md)
## PortData type
**Signature:**
```typescript
type PortData = string | number;
```

View File

@ -12,6 +12,7 @@ export const SystemPage = (): React.ReactElement => {
const [portSize, setPortSize] = useState(Settings.MaxPortCapacity);
const [terminalSize, setTerminalSize] = useState(Settings.MaxTerminalCapacity);
const [autosaveInterval, setAutosaveInterval] = useState(Settings.AutosaveInterval);
const [tailrenderInterval, setTailRenderInterval] = useState(Settings.TailRenderInterval);
function handlePortSizeChange(_event: Event | React.SyntheticEvent, newValue: number | number[]): void {
setPortSize(newValue as number);
@ -28,6 +29,11 @@ export const SystemPage = (): React.ReactElement => {
Settings.CodeInstructionRunTime = newValue as number;
}
function handleTailIntervalChange(_event: Event | React.SyntheticEvent, newValue: number | number[]): void {
setTailRenderInterval(newValue as number);
Settings.TailRenderInterval = newValue as number;
}
function handleRecentScriptsSizeChange(_event: Event | React.SyntheticEvent, newValue: number | number[]): void {
setRecentScriptsSize(newValue as number);
Settings.MaxRecentScriptsCapacity = newValue as number;
@ -132,6 +138,20 @@ export const SystemPage = (): React.ReactElement => {
tooltip={<>The time (in seconds) between each autosave. Set to 0 to disable autosave.</>}
marks
/>
<OptionsSlider
label="Tail render interval (ms)"
initialValue={tailrenderInterval}
callback={handleTailIntervalChange}
step={200}
min={50}
max={5 * 1000}
tooltip={
<>
The minimum number of milliseconds between tail rerenders. Setting this too low can result in poor
performance if you have many tail windows open.
</>
}
/>
</>
<OptionSwitch

View File

@ -72,6 +72,8 @@ export const Settings = {
ExcludeRunningScriptsFromSave: false,
/** Whether the game's sidebar is opened. */
IsSidebarOpened: true,
/** Tail rendering intervall in ms */
TailRenderInterval: 1000,
/** Theme colors. */
theme: { ...defaultTheme },
/** Interface styles. */

View File

@ -171,7 +171,7 @@ function LogWindow({ hidden, script, onClose }: LogWindowProps): React.ReactElem
const classes = useStyles();
const container = useRef<HTMLDivElement>(null);
const textArea = useRef<HTMLDivElement>(null);
const rerender = useRerender(1000);
const rerender = useRerender(Settings.TailRenderInterval);
const propsRef = useRef(new LogBoxProperties(rerender, rootRef));
script.tailProps = propsRef.current;
const [minimized, setMinimized] = useState(false);