mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-25 18:50:56 +02:00
UI work on corps
This commit is contained in:
@@ -95,9 +95,13 @@ export function IndustryOverview(props: IProps): React.ReactElement {
|
||||
});
|
||||
}
|
||||
|
||||
function shouldFlash(): boolean {
|
||||
return Object.keys(props.division.products).length === 0;
|
||||
}
|
||||
|
||||
return (
|
||||
<button
|
||||
className={className}
|
||||
className={className + (shouldFlash() ? " flashing-button" : "")}
|
||||
onClick={openMakeProductPopup}
|
||||
style={buttonStyle}
|
||||
disabled={props.corp.funds.lt(0)}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
import React from "react";
|
||||
import { IIndustry } from "../IIndustry";
|
||||
import { MathComponent } from "mathjax-react";
|
||||
|
||||
interface IProps {
|
||||
division: IIndustry;
|
||||
}
|
||||
|
||||
export function IndustryProductEquation(props: IProps): React.ReactElement {
|
||||
const reqs = [];
|
||||
for (const reqMat of Object.keys(props.division.reqMats)) {
|
||||
const reqAmt = props.division.reqMats[reqMat];
|
||||
if (reqAmt === undefined) continue;
|
||||
reqs.push(String.raw`${reqAmt}\text{ }${reqMat}`);
|
||||
}
|
||||
const prod = props.division.prodMats.slice();
|
||||
if (props.division.makesProducts) {
|
||||
prod.push(props.division.type);
|
||||
}
|
||||
|
||||
return (
|
||||
<span className="text">
|
||||
<MathComponent
|
||||
display={false}
|
||||
tex={reqs.join("+") + String.raw`\Rightarrow` + prod.map((p) => String.raw`1\text{ }${p}`).join("+")}
|
||||
/>
|
||||
</span>
|
||||
);
|
||||
}
|
||||
@@ -28,6 +28,7 @@ import { IPlayer } from "../../PersonObjects/IPlayer";
|
||||
import { Money } from "../../ui/React/Money";
|
||||
import { MoneyCost } from "./MoneyCost";
|
||||
import { isRelevantMaterial } from "./Helpers";
|
||||
import { IndustryProductEquation } from "./IndustryProductEquation";
|
||||
|
||||
interface IProductProps {
|
||||
corp: ICorporation;
|
||||
@@ -369,6 +370,10 @@ function MaterialComponent(props: IMaterialProps): React.ReactElement {
|
||||
});
|
||||
}
|
||||
|
||||
function shouldFlash(): boolean {
|
||||
return props.division.prodMats.includes(props.mat.name) && !mat.sllman[0];
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={"cmpy-mgmt-warehouse-material-div"}>
|
||||
<div style={{ display: "inline-block" }}>
|
||||
@@ -401,7 +406,11 @@ function MaterialComponent(props: IMaterialProps): React.ReactElement {
|
||||
</div>
|
||||
|
||||
<div style={{ display: "inline-block" }}>
|
||||
<button className={purchaseButtonClass} onClick={openPurchaseMaterialPopup}>
|
||||
<button
|
||||
className={purchaseButtonClass}
|
||||
onClick={openPurchaseMaterialPopup}
|
||||
disabled={props.warehouse.smartSupplyEnabled && Object.keys(props.division.reqMats).includes(props.mat.name)}
|
||||
>
|
||||
{purchaseButtonText}
|
||||
{tutorial && (
|
||||
<span className={"tooltiptext"}>Purchase your required materials to get production started!</span>
|
||||
@@ -415,7 +424,8 @@ function MaterialComponent(props: IMaterialProps): React.ReactElement {
|
||||
)}
|
||||
<br />
|
||||
|
||||
<button className={"std-button"} onClick={openSellMaterialPopup}>
|
||||
{/* TODO: add flashing here */}
|
||||
<button className={`std-button${shouldFlash() ? " flashing-button" : ""}`} onClick={openSellMaterialPopup}>
|
||||
{sellButtonText}
|
||||
</button>
|
||||
|
||||
@@ -579,11 +589,12 @@ export function IndustryWarehouse(props: IProps): React.ReactElement {
|
||||
Upgrade Warehouse Size - <MoneyCost money={sizeUpgradeCost} corp={props.corp} />
|
||||
</button>
|
||||
|
||||
<p>{generalReqsText}. The exact requirements for production are:</p>
|
||||
<p>This industry uses the following equation for it's production: </p>
|
||||
<br />
|
||||
<br />
|
||||
<IndustryProductEquation division={props.division} />
|
||||
<br />
|
||||
{ratioLines}
|
||||
<br />
|
||||
<p>{createdItemsText}</p>
|
||||
<p>
|
||||
To get started with production, purchase your required materials or import them from another of your company's
|
||||
divisions.
|
||||
|
||||
@@ -57,7 +57,7 @@ export function SmartSupplyPopup(props: IProps): React.ReactElement {
|
||||
const mats = [];
|
||||
for (const matName in props.warehouse.materials) {
|
||||
if (!(props.warehouse.materials[matName] instanceof Material)) continue;
|
||||
if (!isRelevantMaterial(matName, props.division)) continue;
|
||||
if (!Object.keys(props.division.reqMats).includes(matName)) continue;
|
||||
mats.push(<Leftover key={matName} warehouse={props.warehouse} matName={matName} />);
|
||||
}
|
||||
|
||||
|
||||
+38
-38
@@ -4479,44 +4479,44 @@ function NetscriptFunctions(workerScript) {
|
||||
},
|
||||
}, // End Bladeburner
|
||||
|
||||
corporation: {
|
||||
expandIndustry: function (industryName, divisionName) {
|
||||
NewIndustry(Player.corporation, industryName, divisionName);
|
||||
},
|
||||
expandCity: function (divisionName, cityName) {
|
||||
const division = getDivision(divisionName);
|
||||
NewCity(Player.corporation, division, cityName);
|
||||
},
|
||||
unlockUpgrade: function (upgradeName) {
|
||||
const upgrade = Object.values(CorporationUnlockUpgrades).find((upgrade) => upgrade[2] === upgradeName);
|
||||
if (upgrade === undefined) throw new Error("No upgrade named '${upgradeName}'");
|
||||
UnlockUpgrade(Player.corporation, upgrade);
|
||||
},
|
||||
levelUpgrade: function (upgradeName) {
|
||||
const upgrade = Object.values(CorporationUpgrades).find((upgrade) => upgrade[4] === upgradeName);
|
||||
if (upgrade === undefined) throw new Error("No upgrade named '${upgradeName}'");
|
||||
LevelUpgrade(Player.corporation, upgrade);
|
||||
},
|
||||
issueDividends: function (percent) {
|
||||
IssueDividends(Player.corporation, percent);
|
||||
},
|
||||
sellMaterial: function (divisionName, cityName, materialName, amt, price) {
|
||||
const material = getMaterial(divisionName, cityName, materialName);
|
||||
SellMaterial(material, amt, price);
|
||||
},
|
||||
sellProduct: function (divisionName, cityName, productName, amt, price, all) {
|
||||
const product = getProduct(divisionName, productName);
|
||||
SellProduct(product, cityName, amt, price, all);
|
||||
},
|
||||
setSmartSupply: function (divisionName, cityName, enabled) {
|
||||
const warehouse = getWarehouse(divisionName, cityName);
|
||||
SetSmartSupply(warehouse, enabled);
|
||||
},
|
||||
buyMaterial: function (divisionName, cityName, materialName, amt) {
|
||||
const material = getMaterial(divisionName, cityName, materialName);
|
||||
BuyMaterial(material, amt);
|
||||
},
|
||||
}, // End Corporation API
|
||||
// corporation: {
|
||||
// expandIndustry: function (industryName, divisionName) {
|
||||
// NewIndustry(Player.corporation, industryName, divisionName);
|
||||
// },
|
||||
// expandCity: function (divisionName, cityName) {
|
||||
// const division = getDivision(divisionName);
|
||||
// NewCity(Player.corporation, division, cityName);
|
||||
// },
|
||||
// unlockUpgrade: function (upgradeName) {
|
||||
// const upgrade = Object.values(CorporationUnlockUpgrades).find((upgrade) => upgrade[2] === upgradeName);
|
||||
// if (upgrade === undefined) throw new Error("No upgrade named '${upgradeName}'");
|
||||
// UnlockUpgrade(Player.corporation, upgrade);
|
||||
// },
|
||||
// levelUpgrade: function (upgradeName) {
|
||||
// const upgrade = Object.values(CorporationUpgrades).find((upgrade) => upgrade[4] === upgradeName);
|
||||
// if (upgrade === undefined) throw new Error("No upgrade named '${upgradeName}'");
|
||||
// LevelUpgrade(Player.corporation, upgrade);
|
||||
// },
|
||||
// issueDividends: function (percent) {
|
||||
// IssueDividends(Player.corporation, percent);
|
||||
// },
|
||||
// sellMaterial: function (divisionName, cityName, materialName, amt, price) {
|
||||
// const material = getMaterial(divisionName, cityName, materialName);
|
||||
// SellMaterial(material, amt, price);
|
||||
// },
|
||||
// sellProduct: function (divisionName, cityName, productName, amt, price, all) {
|
||||
// const product = getProduct(divisionName, productName);
|
||||
// SellProduct(product, cityName, amt, price, all);
|
||||
// },
|
||||
// setSmartSupply: function (divisionName, cityName, enabled) {
|
||||
// const warehouse = getWarehouse(divisionName, cityName);
|
||||
// SetSmartSupply(warehouse, enabled);
|
||||
// },
|
||||
// buyMaterial: function (divisionName, cityName, materialName, amt) {
|
||||
// const material = getMaterial(divisionName, cityName, materialName);
|
||||
// BuyMaterial(material, amt);
|
||||
// },
|
||||
// }, // End Corporation API
|
||||
|
||||
// Coding Contract API
|
||||
codingcontract: {
|
||||
|
||||
Reference in New Issue
Block a user