mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-26 09:33:49 +01:00
Refactor
This commit is contained in:
parent
b4a78c26f3
commit
bc50f5180a
@ -34,6 +34,7 @@ import Link from "@mui/material/Link";
|
|||||||
import Box from "@mui/material/Box";
|
import Box from "@mui/material/Box";
|
||||||
import SettingsIcon from "@mui/icons-material/Settings";
|
import SettingsIcon from "@mui/icons-material/Settings";
|
||||||
import SyncIcon from '@mui/icons-material/Sync';
|
import SyncIcon from '@mui/icons-material/Sync';
|
||||||
|
import CloseIcon from '@mui/icons-material/Close';
|
||||||
import Table from "@mui/material/Table";
|
import Table from "@mui/material/Table";
|
||||||
import TableCell from "@mui/material/TableCell";
|
import TableCell from "@mui/material/TableCell";
|
||||||
import TableRow from "@mui/material/TableRow";
|
import TableRow from "@mui/material/TableRow";
|
||||||
@ -42,6 +43,7 @@ import { PromptEvent } from "../../ui/React/PromptManager";
|
|||||||
import { Modal } from "../../ui/React/Modal";
|
import { Modal } from "../../ui/React/Modal";
|
||||||
|
|
||||||
import libSource from "!!raw-loader!../NetscriptDefinitions.d.ts";
|
import libSource from "!!raw-loader!../NetscriptDefinitions.d.ts";
|
||||||
|
import { Tooltip } from "@mui/material";
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
// Map of filename -> code
|
// Map of filename -> code
|
||||||
@ -700,7 +702,7 @@ export function Root(props: IProps): React.ReactElement {
|
|||||||
|
|
||||||
if (openScript.code !== serverScriptCode) {
|
if (openScript.code !== serverScriptCode) {
|
||||||
PromptEvent.emit({
|
PromptEvent.emit({
|
||||||
txt: "Do you want to overwrite " + openScript.fileName + " with the contents saved on the server?",
|
txt: "Do you want to overwrite " + openScript.fileName + " with the contents saved on the server? This cannot be undone.",
|
||||||
resolve: (result: boolean) => {
|
resolve: (result: boolean) => {
|
||||||
if (result) {
|
if (result) {
|
||||||
// Save changes
|
// Save changes
|
||||||
@ -718,7 +720,6 @@ export function Root(props: IProps): React.ReactElement {
|
|||||||
updateRAM(openScript.code);
|
updateRAM(openScript.code);
|
||||||
editorRef.current.focus();
|
editorRef.current.focus();
|
||||||
}
|
}
|
||||||
rerender();
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@ -773,79 +774,74 @@ export function Root(props: IProps): React.ReactElement {
|
|||||||
overflowX: "scroll",
|
overflowX: "scroll",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{openScripts.map(({ fileName, hostname }, index) => (
|
{openScripts.map(({ fileName, hostname }, index) => {
|
||||||
<Draggable
|
const iconButtonStyle = {
|
||||||
key={fileName + hostname}
|
maxWidth: "25px",
|
||||||
draggableId={fileName + hostname}
|
minWidth: "25px",
|
||||||
index={index}
|
minHeight: '38.5px',
|
||||||
disableInteractiveElementBlocking={true}
|
maxHeight: '38.5px',
|
||||||
>
|
...(currentScript?.fileName === openScripts[index].fileName ? {
|
||||||
{(provided) => (
|
background: Settings.theme.button,
|
||||||
<div
|
borderColor: Settings.theme.button,
|
||||||
ref={provided.innerRef}
|
color: Settings.theme.primary
|
||||||
{...provided.draggableProps}
|
} : {
|
||||||
{...provided.dragHandleProps}
|
background: Settings.theme.backgroundsecondary,
|
||||||
style={{
|
borderColor: Settings.theme.backgroundsecondary,
|
||||||
...provided.draggableProps.style,
|
color: Settings.theme.secondary
|
||||||
marginRight: "5px",
|
})
|
||||||
flexShrink: 0,
|
};
|
||||||
}}
|
return (
|
||||||
>
|
<Draggable
|
||||||
<Button
|
key={fileName + hostname}
|
||||||
onClick={() => onTabClick(index)}
|
draggableId={fileName + hostname}
|
||||||
onMouseDown={e => {
|
index={index}
|
||||||
e.preventDefault();
|
disableInteractiveElementBlocking={true}
|
||||||
if (e.button === 1) onTabClose(index);
|
>
|
||||||
|
{(provided) => (
|
||||||
|
<div
|
||||||
|
ref={provided.innerRef}
|
||||||
|
{...provided.draggableProps}
|
||||||
|
{...provided.dragHandleProps}
|
||||||
|
style={{
|
||||||
|
...provided.draggableProps.style,
|
||||||
|
marginRight: "5px",
|
||||||
|
flexShrink: 0,
|
||||||
|
border: '1px solid ' + Settings.theme.well,
|
||||||
}}
|
}}
|
||||||
style={
|
>
|
||||||
currentScript?.fileName === openScripts[index].fileName ? {
|
<Button
|
||||||
background: Settings.theme.button,
|
onClick={() => onTabClick(index)}
|
||||||
color: Settings.theme.primary
|
onMouseDown={e => {
|
||||||
} : {
|
e.preventDefault();
|
||||||
background: Settings.theme.backgroundsecondary,
|
if (e.button === 1) onTabClose(index);
|
||||||
color: Settings.theme.secondary
|
|
||||||
}}
|
}}
|
||||||
>
|
style={{
|
||||||
{hostname}:~/{fileName} {dirty(index)}
|
...(currentScript?.fileName === openScripts[index].fileName ? {
|
||||||
</Button>
|
background: Settings.theme.button,
|
||||||
<Button
|
borderColor: Settings.theme.button,
|
||||||
onClick={() => onTabClose(index)}
|
color: Settings.theme.primary
|
||||||
style={{
|
} : {
|
||||||
maxWidth: "20px",
|
background: Settings.theme.backgroundsecondary,
|
||||||
minWidth: "20px",
|
borderColor: Settings.theme.backgroundsecondary,
|
||||||
...(currentScript?.fileName === openScripts[index].fileName ? {
|
color: Settings.theme.secondary
|
||||||
background: Settings.theme.button,
|
})
|
||||||
color: Settings.theme.primary
|
}}
|
||||||
} : {
|
>
|
||||||
background: Settings.theme.backgroundsecondary,
|
{hostname}:~/{fileName} {dirty(index)}
|
||||||
color: Settings.theme.secondary
|
</Button>
|
||||||
})
|
<Tooltip title="Overwrite editor content with saved file content">
|
||||||
}}
|
<Button onClick={() => onTabUpdate(index)} style={iconButtonStyle} >
|
||||||
>
|
<SyncIcon fontSize='small' />
|
||||||
x
|
</Button>
|
||||||
</Button>
|
</Tooltip>
|
||||||
<Button
|
<Button onClick={() => onTabClose(index)} style={iconButtonStyle}>
|
||||||
onClick={() => onTabUpdate(index)}
|
<CloseIcon fontSize='small' />
|
||||||
style={{
|
</Button>
|
||||||
maxWidth: "20px",
|
</div>
|
||||||
minWidth: "20px",
|
)}
|
||||||
minHeight: '38.5px',
|
</Draggable>
|
||||||
maxHeight: '38.5px',
|
)
|
||||||
...(currentScript?.fileName === openScripts[index].fileName ? {
|
})}
|
||||||
background: Settings.theme.button,
|
|
||||||
color: Settings.theme.primary
|
|
||||||
} : {
|
|
||||||
background: Settings.theme.backgroundsecondary,
|
|
||||||
color: Settings.theme.secondary
|
|
||||||
})
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<SyncIcon fontSize='small' />
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</Draggable>
|
|
||||||
))}
|
|
||||||
{provided.placeholder}
|
{provided.placeholder}
|
||||||
</Box>
|
</Box>
|
||||||
)}
|
)}
|
||||||
|
Loading…
Reference in New Issue
Block a user