mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-30 03:23:48 +01:00
Hide SF display when no SFs owned
This commit is contained in:
parent
81f971b52e
commit
a4bc793cf1
@ -65,99 +65,94 @@ export function SourceFilesElement(): React.ReactElement {
|
|||||||
|
|
||||||
const [selectedSf, setSelectedSf] = useState<any>(sourceSfs[0]);
|
const [selectedSf, setSelectedSf] = useState<any>(sourceSfs[0]);
|
||||||
|
|
||||||
|
if (sourceSfs.length === 0) {
|
||||||
|
return <></>;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box sx={{ width: "100%", mt: 1 }}>
|
<Box sx={{ width: "100%", mt: 1 }}>
|
||||||
<Paper sx={{ p: 1 }}>
|
<Paper sx={{ p: 1 }}>
|
||||||
<Typography variant="h5">Source Files</Typography>
|
<Typography variant="h5">Source Files</Typography>
|
||||||
</Paper>
|
</Paper>
|
||||||
{sourceSfs.length > 0 ? (
|
<Paper sx={{ display: "grid", gridTemplateColumns: "1fr 3fr" }}>
|
||||||
<Paper sx={{ display: "grid", gridTemplateColumns: "1fr 3fr" }}>
|
<Box>
|
||||||
<Box>
|
<List
|
||||||
<List
|
sx={{ height: 400, overflowY: "scroll", borderRight: `1px solid ${Settings.theme.welllight}` }}
|
||||||
sx={{ height: 400, overflowY: "scroll", borderRight: `1px solid ${Settings.theme.welllight}` }}
|
disablePadding
|
||||||
disablePadding
|
>
|
||||||
>
|
{exploits.length > 0 && (
|
||||||
{exploits.length > 0 && (
|
<ListItemButton
|
||||||
<ListItemButton
|
key={-1}
|
||||||
key={-1}
|
onClick={() => setSelectedSf({ n: -1, lvl: exploits.length })}
|
||||||
onClick={() => setSelectedSf({ n: -1, lvl: exploits.length })}
|
selected={selectedSf.n === -1}
|
||||||
selected={selectedSf.n === -1}
|
sx={{ py: 0 }}
|
||||||
sx={{ py: 0 }}
|
>
|
||||||
>
|
<ListItemText
|
||||||
|
disableTypography
|
||||||
|
primary={<Typography>Source-File -1: Exploits in the BitNodes</Typography>}
|
||||||
|
secondary={
|
||||||
|
<Typography>
|
||||||
|
Level {exploits.length} / {Object.keys(Exploit).length}
|
||||||
|
</Typography>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</ListItemButton>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{sourceSfs.map((e, i) => {
|
||||||
|
const sfObj = safeGetSf(e.n);
|
||||||
|
if (!sfObj) return;
|
||||||
|
const maxLevel = sfObj?.n === 12 ? "∞" : "3";
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ListItemButton key={i + 1} onClick={() => setSelectedSf(e)} selected={selectedSf === e} sx={{ py: 0 }}>
|
||||||
<ListItemText
|
<ListItemText
|
||||||
disableTypography
|
disableTypography
|
||||||
primary={<Typography>Source-File -1: Exploits in the BitNodes</Typography>}
|
primary={<Typography>{sfObj.name}</Typography>}
|
||||||
secondary={
|
secondary={
|
||||||
<Typography>
|
<Typography>
|
||||||
Level {exploits.length} / {Object.keys(Exploit).length}
|
Level {e.lvl} / {maxLevel}
|
||||||
</Typography>
|
</Typography>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
</ListItemButton>
|
</ListItemButton>
|
||||||
)}
|
);
|
||||||
|
})}
|
||||||
|
</List>
|
||||||
|
</Box>
|
||||||
|
<Box sx={{ m: 1 }}>
|
||||||
|
<Typography variant="h6" sx={{ display: "flex", alignItems: "center", flexWrap: "wrap" }}>
|
||||||
|
{safeGetSf(selectedSf.n)?.name}
|
||||||
|
</Typography>
|
||||||
|
<Typography sx={{ maxHeight: 350, overflowY: "scroll" }}>
|
||||||
|
{(() => {
|
||||||
|
const sfObj = safeGetSf(selectedSf.n);
|
||||||
|
if (!sfObj) return;
|
||||||
|
|
||||||
{sourceSfs.map((e, i) => {
|
let maxLevel;
|
||||||
const sfObj = safeGetSf(e.n);
|
switch (sfObj?.n) {
|
||||||
if (!sfObj) return;
|
case 12:
|
||||||
const maxLevel = sfObj?.n === 12 ? "∞" : "3";
|
maxLevel = "∞";
|
||||||
|
break;
|
||||||
|
case -1:
|
||||||
|
maxLevel = Object.keys(Exploit).length;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
maxLevel = "3";
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ListItemButton
|
<>
|
||||||
key={i + 1}
|
Level {selectedSf.lvl} / {maxLevel}
|
||||||
onClick={() => setSelectedSf(e)}
|
<br />
|
||||||
selected={selectedSf === e}
|
<br />
|
||||||
sx={{ py: 0 }}
|
{sfObj?.info}
|
||||||
>
|
</>
|
||||||
<ListItemText
|
);
|
||||||
disableTypography
|
})()}
|
||||||
primary={<Typography>{sfObj.name}</Typography>}
|
</Typography>
|
||||||
secondary={
|
</Box>
|
||||||
<Typography>
|
</Paper>
|
||||||
Level {e.lvl} / {maxLevel}
|
|
||||||
</Typography>
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
</ListItemButton>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</List>
|
|
||||||
</Box>
|
|
||||||
<Box sx={{ m: 1 }}>
|
|
||||||
<Typography variant="h6" sx={{ display: "flex", alignItems: "center", flexWrap: "wrap" }}>
|
|
||||||
{safeGetSf(selectedSf.n)?.name}
|
|
||||||
</Typography>
|
|
||||||
<Typography sx={{ maxHeight: 350, overflowY: "scroll" }}>
|
|
||||||
{(() => {
|
|
||||||
const sfObj = safeGetSf(selectedSf.n);
|
|
||||||
if (!sfObj) return;
|
|
||||||
|
|
||||||
let maxLevel;
|
|
||||||
switch (sfObj?.n) {
|
|
||||||
case 12:
|
|
||||||
maxLevel = "∞";
|
|
||||||
break;
|
|
||||||
case -1:
|
|
||||||
maxLevel = Object.keys(Exploit).length;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
maxLevel = "3";
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
Level {selectedSf.lvl} / {maxLevel}
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
{sfObj?.info}
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
})()}
|
|
||||||
</Typography>
|
|
||||||
</Box>
|
|
||||||
</Paper>
|
|
||||||
) : (
|
|
||||||
<></>
|
|
||||||
)}
|
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user