Skip to content

Commit

Permalink
SETTINGS: add tailRenderInterval (bitburner-official#1107)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Caldwell-74 authored Feb 19, 2024
1 parent e6755af commit 47cf5c1
Show file tree
Hide file tree
Showing 15 changed files with 43 additions and 34 deletions.
1 change: 0 additions & 1 deletion markdown/bitburner.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) | |
Expand Down
2 changes: 1 addition & 1 deletion markdown/bitburner.netscriptport.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. |
Expand Down
2 changes: 1 addition & 1 deletion markdown/bitburner.netscriptport.nextwrite.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## NetscriptPort.nextWrite() method

Sleeps until the port is written to.
Waits until the port is written to.

**Signature:**

Expand Down
4 changes: 2 additions & 2 deletions markdown/bitburner.netscriptport.peek.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions markdown/bitburner.netscriptport.read.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
4 changes: 2 additions & 2 deletions markdown/bitburner.netscriptport.trywrite.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:**

Expand Down
6 changes: 3 additions & 3 deletions markdown/bitburner.netscriptport.write.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
4 changes: 2 additions & 2 deletions markdown/bitburner.ns.peek.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -20,7 +20,7 @@ peek(portNumber: number): PortData;

**Returns:**

[PortData](./bitburner.portdata.md)
any

Data in the specified port.

Expand Down
4 changes: 2 additions & 2 deletions markdown/bitburner.ns.readport.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Read data from a port.
**Signature:**

```typescript
readPort(portNumber: number): PortData;
readPort(portNumber: number): any;
```

## Parameters
Expand All @@ -20,7 +20,7 @@ readPort(portNumber: number): PortData;

**Returns:**

[PortData](./bitburner.portdata.md)
any

The data read.

Expand Down
4 changes: 2 additions & 2 deletions markdown/bitburner.ns.trywriteport.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ Attempt to write to a port.
**Signature:**

```typescript
tryWritePort(portNumber: number, data: string | number): boolean;
tryWritePort(portNumber: number, data: any): boolean;
```

## Parameters

| 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:**

Expand Down
6 changes: 3 additions & 3 deletions markdown/bitburner.ns.writeport.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@ Write data to a port.
**Signature:**

```typescript
writePort(portNumber: number, data: string | number): PortData | null;
writePort(portNumber: number, data: any): any;
```

## Parameters

| 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.

Expand Down
12 changes: 0 additions & 12 deletions markdown/bitburner.portdata.md

This file was deleted.

20 changes: 20 additions & 0 deletions src/GameOptions/ui/SystemPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/Settings/Settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down
2 changes: 1 addition & 1 deletion src/ui/React/LogBoxManager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 47cf5c1

Please sign in to comment.