refactor temrinal input for more performace

This commit is contained in:
Olivier Gagnon
2021-09-16 15:37:01 -04:00
parent 07721e1cc5
commit 22648df857
5 changed files with 412 additions and 333 deletions
+28
View File
@@ -50,6 +50,8 @@ export function GameOptionsRoot(props: IProps): React.ReactElement {
const [execTime, setExecTime] = useState(Settings.CodeInstructionRunTime);
const [logSize, setLogSize] = useState(Settings.MaxLogCapacity);
const [portSize, setPortSize] = useState(Settings.MaxPortCapacity);
const [terminalSize, setTerminalSize] = useState(Settings.MaxTerminalCapacity);
const [autosaveInterval, setAutosaveInterval] = useState(Settings.AutosaveInterval);
const [suppressMessages, setSuppressMessages] = useState(Settings.SuppressMessages);
@@ -86,6 +88,11 @@ export function GameOptionsRoot(props: IProps): React.ReactElement {
Settings.MaxPortCapacity = newValue as number;
}
function handleTerminalSizeChange(event: any, newValue: number | number[]): void {
setTerminalSize(newValue as number);
Settings.MaxTerminalCapacity = newValue as number;
}
function handleAutosaveIntervalChange(event: any, newValue: number | number[]): void {
setAutosaveInterval(newValue as number);
Settings.AutosaveInterval = newValue as number;
@@ -209,6 +216,27 @@ export function GameOptionsRoot(props: IProps): React.ReactElement {
valueLabelDisplay="auto"
/>
</ListItem>
<ListItem>
<Tooltip
title={
<Typography>
The maximum number of entries that can be written to a the terminal. Setting this too high can cause
the game to use a lot of memory.
</Typography>
}
>
<Typography>Terminal capacity</Typography>
</Tooltip>
<Slider
value={terminalSize}
onChange={handleTerminalSizeChange}
step={50}
min={50}
max={500}
valueLabelDisplay="auto"
marks
/>
</ListItem>
<ListItem>
<Tooltip
title={