mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-22 15:43:49 +01:00
Added file diagnostic.
This commit is contained in:
parent
c110c22efb
commit
9e92df47a5
68
src/Diagnostic/FileDiagnosticPopup.tsx
Normal file
68
src/Diagnostic/FileDiagnosticPopup.tsx
Normal file
@ -0,0 +1,68 @@
|
||||
import React from "react";
|
||||
import { AllServers } from "../Server/AllServers";
|
||||
import { Script } from "../Script/Script";
|
||||
import { TextFile } from "../TextFile";
|
||||
import { Accordion } from "../ui/React/Accordion";
|
||||
import { numeralWrapper } from "../ui/numeralFormat";
|
||||
|
||||
interface IServerProps {
|
||||
ip: string;
|
||||
}
|
||||
|
||||
export function ServerAccordion(props: IServerProps): React.ReactElement {
|
||||
const server = AllServers[props.ip];
|
||||
let totalSize = 0;
|
||||
for(const f of server.scripts) {
|
||||
totalSize += f.code.length;
|
||||
}
|
||||
|
||||
for(const f of server.textFiles) {
|
||||
totalSize += f.text.length;
|
||||
}
|
||||
|
||||
if(totalSize === 0) {
|
||||
return <></>
|
||||
}
|
||||
|
||||
interface File {
|
||||
name: string;
|
||||
size: number;
|
||||
}
|
||||
|
||||
const files: File[] = [];
|
||||
|
||||
for(const f of server.scripts) {
|
||||
files.push({name: f.filename, size: f.code.length});
|
||||
}
|
||||
|
||||
for(const f of server.textFiles) {
|
||||
files.push({name: f.fn, size: f.text.length});
|
||||
}
|
||||
|
||||
files.sort((a: File, b: File): number => b.size-a.size);
|
||||
|
||||
return <Accordion
|
||||
headerContent={<>{server.hostname} ({numeralWrapper.formatBigNumber(totalSize)}b)</>}
|
||||
panelContent={<ul>
|
||||
{files.map((file: File) => <li key={file.name}>{file.name}: {numeralWrapper.formatBigNumber(file.size)}b</li>) }
|
||||
</ul>}
|
||||
/>
|
||||
}
|
||||
|
||||
interface IProps {}
|
||||
|
||||
export function FileDiagnosticPopup(props: IProps): React.ReactElement {
|
||||
const ips: string[] = [];
|
||||
for(const ip of Object.keys(AllServers)) {
|
||||
ips.push(ip);
|
||||
}
|
||||
|
||||
return (<>
|
||||
<p>
|
||||
Welcome to the file diagnostic! If your save file is really big it's
|
||||
likely because you have too many text/scripts. This tool can help you
|
||||
narrow down where they are.
|
||||
</p>
|
||||
{ips.map((ip: string) => <ServerAccordion key={ip} ip={ip} />)}
|
||||
</>);
|
||||
}
|
@ -102,6 +102,9 @@ import { ActiveScriptsRoot } from "./ui/ActiveScripts/Root";
|
||||
import { initializeMainMenuHeaders } from "./ui/MainMenu/Headers";
|
||||
import { initializeMainMenuLinks, MainMenuLinks } from "./ui/MainMenu/Links";
|
||||
|
||||
import { FileDiagnosticPopup } from "./Diagnostic/FileDiagnosticPopup";
|
||||
import { createPopup } from "./ui/React/createPopup";
|
||||
|
||||
import { dialogBoxCreate } from "../utils/DialogBox";
|
||||
import { gameOptionsBoxClose, gameOptionsBoxOpen } from "../utils/GameOptions";
|
||||
import { exceptionAlert } from "../utils/helpers/exceptionAlert";
|
||||
@ -1523,6 +1526,12 @@ const Engine = {
|
||||
gameOptionsBoxClose();
|
||||
return false;
|
||||
});
|
||||
|
||||
// DEBUG File diagnostic
|
||||
document.getElementById("debug-files").addEventListener("click", function() {
|
||||
createPopup("debug-files-diagnostic-popup", FileDiagnosticPopup, {});
|
||||
return false;
|
||||
});
|
||||
},
|
||||
|
||||
start: function() {
|
||||
|
@ -608,6 +608,14 @@ if (htmlWebpackPlugin.options.googleAnalytics.trackingId) { %>
|
||||
Perform a soft reset. Resets everything as if you had just purchased an Augmentation.
|
||||
</span>
|
||||
</button>
|
||||
<button id="debug-files" class="a-link-button tooltip">
|
||||
Diagnose files
|
||||
<span class="tooltiptextleft">
|
||||
If your save file is extremely big you can use this button
|
||||
to view a map of all the files on every server. Be careful
|
||||
there might be spoilers.
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user