mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-26 17:43:48 +01:00
Various log box improvements
This commit is contained in:
parent
bc9bce0d2c
commit
d4e97d786c
@ -80,21 +80,12 @@ interface IProps {
|
|||||||
|
|
||||||
const useStyles = makeStyles((_theme: Theme) =>
|
const useStyles = makeStyles((_theme: Theme) =>
|
||||||
createStyles({
|
createStyles({
|
||||||
title: {
|
|
||||||
"&.is-minimized + *": {
|
|
||||||
border: "none",
|
|
||||||
margin: 0,
|
|
||||||
"max-height": 0,
|
|
||||||
padding: 0,
|
|
||||||
"pointer-events": "none",
|
|
||||||
visibility: "hidden",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
logs: {
|
logs: {
|
||||||
overflowY: "scroll",
|
overflowY: "scroll",
|
||||||
overflowX: "hidden",
|
overflowX: "hidden",
|
||||||
scrollbarWidth: "auto",
|
scrollbarWidth: "auto",
|
||||||
flexDirection: "column-reverse",
|
flexDirection: "column-reverse",
|
||||||
|
whiteSpace: "pre-wrap",
|
||||||
},
|
},
|
||||||
titleButton: {
|
titleButton: {
|
||||||
padding: "1px 0",
|
padding: "1px 0",
|
||||||
@ -176,7 +167,7 @@ function LogWindow(props: IProps): React.ReactElement {
|
|||||||
setMinimized(!minimized);
|
setMinimized(!minimized);
|
||||||
}
|
}
|
||||||
|
|
||||||
function lineClass(s: string): string {
|
function lineColor(s: string): string {
|
||||||
if (s.match(/(^\[[^\]]+\] )?ERROR/) || s.match(/(^\[[^\]]+\] )?FAIL/)) {
|
if (s.match(/(^\[[^\]]+\] )?ERROR/) || s.match(/(^\[[^\]]+\] )?FAIL/)) {
|
||||||
return Settings.theme.error;
|
return Settings.theme.error;
|
||||||
}
|
}
|
||||||
@ -228,31 +219,63 @@ function LogWindow(props: IProps): React.ReactElement {
|
|||||||
if (e.clientX < 0 || e.clientY < 0 || e.clientX > innerWidth || e.clientY > innerHeight) return false;
|
if (e.clientX < 0 || e.clientY < 0 || e.clientX > innerWidth || e.clientY > innerHeight) return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Max [width, height]
|
||||||
|
const minConstraints: [number, number] = [250, 33];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Draggable handle=".drag" onDrag={boundToBody} ref={rootRef}>
|
<Draggable handle=".drag" onDrag={boundToBody} ref={rootRef} onMouseDown={updateLayer}>
|
||||||
<Paper
|
<Box
|
||||||
style={{
|
display="flex"
|
||||||
display: "flex",
|
sx={{
|
||||||
flexFlow: "column",
|
flexFlow: "column",
|
||||||
position: "fixed",
|
position: "fixed",
|
||||||
left: "40%",
|
left: "40%",
|
||||||
top: "30%",
|
top: "30%",
|
||||||
zIndex: 1400,
|
zIndex: 1400,
|
||||||
|
minWidth: `${minConstraints[0]}px`,
|
||||||
|
minHeight: `${minConstraints[1]}px`,
|
||||||
|
...(minimized
|
||||||
|
? {
|
||||||
|
border: "none",
|
||||||
|
margin: 0,
|
||||||
|
maxHeight: 0,
|
||||||
|
padding: 0,
|
||||||
|
}
|
||||||
|
: {
|
||||||
|
border: `1px solid ${Settings.theme.welllight}`,
|
||||||
|
}),
|
||||||
}}
|
}}
|
||||||
ref={container}
|
ref={container}
|
||||||
>
|
>
|
||||||
<div onMouseDown={updateLayer}>
|
<ResizableBox
|
||||||
<Paper
|
height={500}
|
||||||
className={classes.title + " " + (minimized ? "is-minimized" : "")}
|
width={500}
|
||||||
|
minConstraints={minConstraints}
|
||||||
|
handle={
|
||||||
|
<span
|
||||||
style={{
|
style={{
|
||||||
cursor: "grab",
|
position: "absolute",
|
||||||
|
right: "-10px",
|
||||||
|
bottom: "-13px",
|
||||||
|
cursor: "nw-resize",
|
||||||
|
display: minimized ? "none" : "inline-block",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Box className="drag" display="flex" alignItems="center" ref={draggableRef}>
|
<ArrowForwardIosIcon color="primary" style={{ transform: "rotate(45deg)", fontSize: "1.75rem" }} />
|
||||||
<Typography color="primary" variant="h6" sx={{ marginRight: "auto" }} title={title(true)}>
|
</span>
|
||||||
{title()}
|
}
|
||||||
|
>
|
||||||
|
<>
|
||||||
|
<Paper className="drag" sx={{ display: "flex", alignItems: "center", cursor: "grab" }} ref={draggableRef}>
|
||||||
|
<Typography
|
||||||
|
variant="h6"
|
||||||
|
sx={{ marginRight: "auto", textOverflow: "ellipsis", whiteSpace: "nowrap", overflow: "hidden" }}
|
||||||
|
title={title(true)}
|
||||||
|
>
|
||||||
|
{title(true)}
|
||||||
</Typography>
|
</Typography>
|
||||||
|
|
||||||
|
<span style={{ minWidth: "fit-content", height: `${minConstraints[1]}px` }}>
|
||||||
{!workerScripts.has(script.pid) ? (
|
{!workerScripts.has(script.pid) ? (
|
||||||
<Button className={classes.titleButton} onClick={run} onTouchEnd={run}>
|
<Button className={classes.titleButton} onClick={run} onTouchEnd={run}>
|
||||||
Run
|
Run
|
||||||
@ -268,34 +291,27 @@ function LogWindow(props: IProps): React.ReactElement {
|
|||||||
<Button className={classes.titleButton} onClick={props.onClose} onTouchEnd={props.onClose}>
|
<Button className={classes.titleButton} onClick={props.onClose} onTouchEnd={props.onClose}>
|
||||||
Close
|
Close
|
||||||
</Button>
|
</Button>
|
||||||
</Box>
|
|
||||||
</Paper>
|
|
||||||
<Paper sx={{ overflow: "scroll", overflowWrap: "break-word", whiteSpace: "pre-wrap" }}>
|
|
||||||
<ResizableBox
|
|
||||||
className={classes.logs}
|
|
||||||
height={500}
|
|
||||||
width={500}
|
|
||||||
minConstraints={[250, 30]}
|
|
||||||
handle={
|
|
||||||
<span style={{ position: "absolute", right: "-10px", bottom: "-13px", cursor: "nw-resize" }}>
|
|
||||||
<ArrowForwardIosIcon color="primary" style={{ transform: "rotate(45deg)" }} />
|
|
||||||
</span>
|
</span>
|
||||||
}
|
</Paper>
|
||||||
|
|
||||||
|
<Paper
|
||||||
|
className={classes.logs}
|
||||||
|
sx={{ height: `calc(100% - ${minConstraints[1]}px)`, display: minimized ? "none" : "flex" }}
|
||||||
>
|
>
|
||||||
<Box>
|
<span style={{ display: "flex", flexDirection: "column" }}>
|
||||||
{script.logs.map(
|
{script.logs.map(
|
||||||
(line: string, i: number): JSX.Element => (
|
(line: string, i: number): JSX.Element => (
|
||||||
<Typography key={i} className={lineClass(line)}>
|
<Typography key={i} sx={{ color: lineColor(line) }}>
|
||||||
{line}
|
{line}
|
||||||
<br />
|
<br />
|
||||||
</Typography>
|
</Typography>
|
||||||
),
|
),
|
||||||
)}
|
)}
|
||||||
</Box>
|
</span>
|
||||||
|
</Paper>
|
||||||
|
</>
|
||||||
</ResizableBox>
|
</ResizableBox>
|
||||||
</Paper>
|
</Box>
|
||||||
</div>
|
|
||||||
</Paper>
|
|
||||||
</Draggable>
|
</Draggable>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user