mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-27 18:13:52 +01:00
Hide irrelevant divisions in Export modal
This commit is contained in:
parent
a5f82e96ed
commit
f22f0ed50a
@ -6,6 +6,7 @@ import { IIndustry } from "../IIndustry";
|
|||||||
import { ExportMaterial } from "../Actions";
|
import { ExportMaterial } from "../Actions";
|
||||||
import { Modal } from "../../ui/React/Modal";
|
import { Modal } from "../../ui/React/Modal";
|
||||||
import { useCorporation } from "./Context";
|
import { useCorporation } from "./Context";
|
||||||
|
import { isRelevantMaterial } from "./Helpers";
|
||||||
import Typography from "@mui/material/Typography";
|
import Typography from "@mui/material/Typography";
|
||||||
import TextField from "@mui/material/TextField";
|
import TextField from "@mui/material/TextField";
|
||||||
import Button from "@mui/material/Button";
|
import Button from "@mui/material/Button";
|
||||||
@ -22,11 +23,13 @@ interface IProps {
|
|||||||
// Create a popup that lets the player manage exports
|
// Create a popup that lets the player manage exports
|
||||||
export function ExportModal(props: IProps): React.ReactElement {
|
export function ExportModal(props: IProps): React.ReactElement {
|
||||||
const corp = useCorporation();
|
const corp = useCorporation();
|
||||||
if (corp.divisions.length === 0) throw new Error("Export popup created with no divisions.");
|
const possibleDivisions = corp.divisions.filter((division: IIndustry) => isRelevantMaterial(props.mat.name, division));
|
||||||
if (Object.keys(corp.divisions[0].warehouses).length === 0)
|
if (possibleDivisions.length === 0) throw new Error("Export popup created with no divisions.");
|
||||||
|
const defaultDivision = possibleDivisions[0];
|
||||||
|
if (Object.keys(defaultDivision.warehouses).length === 0)
|
||||||
throw new Error("Export popup created in a division with no warehouses.");
|
throw new Error("Export popup created in a division with no warehouses.");
|
||||||
const [industry, setIndustry] = useState<string>(corp.divisions[0].name);
|
const [industry, setIndustry] = useState<string>(defaultDivision.name);
|
||||||
const [city, setCity] = useState<string>(Object.keys(corp.divisions[0].warehouses)[0]);
|
const [city, setCity] = useState<string>(Object.keys(defaultDivision.warehouses)[0]);
|
||||||
const [amt, setAmt] = useState("");
|
const [amt, setAmt] = useState("");
|
||||||
const setRerender = useState(false)[1];
|
const setRerender = useState(false)[1];
|
||||||
|
|
||||||
@ -84,10 +87,12 @@ export function ExportModal(props: IProps): React.ReactElement {
|
|||||||
second. You can set the export amount to 'MAX' to export all of the materials in this warehouse.
|
second. You can set the export amount to 'MAX' to export all of the materials in this warehouse.
|
||||||
</Typography>
|
</Typography>
|
||||||
<Select onChange={onIndustryChange} value={industry}>
|
<Select onChange={onIndustryChange} value={industry}>
|
||||||
{corp.divisions.map((division: IIndustry) => (
|
{corp.divisions
|
||||||
<MenuItem key={division.name} value={division.name}>
|
.filter((division: IIndustry) => isRelevantMaterial(props.mat.name, division))
|
||||||
{division.name}
|
.map((division: IIndustry) => (
|
||||||
</MenuItem>
|
<MenuItem key={division.name} value={division.name}>
|
||||||
|
{division.name}
|
||||||
|
</MenuItem>
|
||||||
))}
|
))}
|
||||||
</Select>
|
</Select>
|
||||||
<Select onChange={onCityChange} value={city}>
|
<Select onChange={onCityChange} value={city}>
|
||||||
|
@ -4,7 +4,7 @@ import { IIndustry } from "../IIndustry";
|
|||||||
// current industry.
|
// current industry.
|
||||||
export function isRelevantMaterial(matName: string, division: IIndustry): boolean {
|
export function isRelevantMaterial(matName: string, division: IIndustry): boolean {
|
||||||
// Materials that affect Production multiplier
|
// Materials that affect Production multiplier
|
||||||
const prodMultiplierMats = ["Hardware", "Robots", "AICores", "RealEstate"];
|
const prodMultiplierMats = ["Hardware", "Robots", "AICores", "RealEstate", "AI Cores", "Real Estate"];
|
||||||
|
|
||||||
if (Object.keys(division.reqMats).includes(matName)) {
|
if (Object.keys(division.reqMats).includes(matName)) {
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user