From 510fcedf90d9aac5cfee608888530b870a9eb1f1 Mon Sep 17 00:00:00 2001
From: Olivier Gagnon
Date: Thu, 30 Sep 2021 13:51:55 -0400
Subject: [PATCH] convert some corp to mui
---
src/Corporation/Industry.ts | 3 -
src/Corporation/Warehouse.ts | 8 -
src/Corporation/ui/Industry.tsx | 13 +-
src/Corporation/ui/IndustryOffice.tsx | 2 +-
src/Corporation/ui/IndustryOverview.tsx | 502 ++++++++----------
src/Corporation/ui/IndustryWarehouse.tsx | 437 ++++++++-------
src/Corporation/ui/MainPanel.tsx | 4 +-
src/Corporation/ui/MakeProductModal.tsx | 193 +++++++
src/Corporation/ui/MakeProductPopup.tsx | 108 ----
src/Corporation/ui/ResearchPopup.tsx | 1 +
...rtSupplyPopup.tsx => SmartSupplyModal.tsx} | 60 +--
src/ui/React/StaticModal.tsx | 16 +
12 files changed, 691 insertions(+), 656 deletions(-)
create mode 100644 src/Corporation/ui/MakeProductModal.tsx
delete mode 100644 src/Corporation/ui/MakeProductPopup.tsx
rename src/Corporation/ui/{SmartSupplyPopup.tsx => SmartSupplyModal.tsx} (55%)
create mode 100644 src/ui/React/StaticModal.tsx
diff --git a/src/Corporation/Industry.ts b/src/Corporation/Industry.ts
index 5a895b083..1bcd03041 100644
--- a/src/Corporation/Industry.ts
+++ b/src/Corporation/Industry.ts
@@ -385,9 +385,6 @@ export class Industry implements IIndustry {
const prod = this.products[prodName];
if (prod === undefined) continue;
warehouse.sizeUsed += prod.data[warehouse.loc][0] * prod.siz;
- if (prod.data[warehouse.loc][0] > 0) {
- warehouse.breakdown += prodName + ": " + formatNumber(prod.data[warehouse.loc][0] * prod.siz, 0) + " ";
- }
}
}
}
diff --git a/src/Corporation/Warehouse.ts b/src/Corporation/Warehouse.ts
index 381ac9867..e0a83fa62 100644
--- a/src/Corporation/Warehouse.ts
+++ b/src/Corporation/Warehouse.ts
@@ -15,10 +15,6 @@ interface IConstructorParams {
}
export class Warehouse {
- // Text that describes how the space in this Warehouse is being used
- // Used to create a tooltip in the UI
- breakdown = "";
-
// Warehouse's level, which affects its maximum size
level = 1;
@@ -90,14 +86,10 @@ export class Warehouse {
// Re-calculate how much space is being used by this Warehouse
updateMaterialSizeUsed(): void {
this.sizeUsed = 0;
- this.breakdown = "";
for (const matName in this.materials) {
const mat = this.materials[matName];
if (MaterialSizes.hasOwnProperty(matName)) {
this.sizeUsed += mat.qty * MaterialSizes[matName];
- if (mat.qty > 0) {
- this.breakdown += matName + ": " + numeralWrapper.format(mat.qty * MaterialSizes[matName], "0,0.0") + " ";
- }
}
}
if (this.sizeUsed > this.size) {
diff --git a/src/Corporation/ui/Industry.tsx b/src/Corporation/ui/Industry.tsx
index 42e3a244c..9a5f65eb1 100644
--- a/src/Corporation/ui/Industry.tsx
+++ b/src/Corporation/ui/Industry.tsx
@@ -9,6 +9,7 @@ import { Warehouse } from "../Warehouse";
import { OfficeSpace } from "../OfficeSpace";
import { use } from "../../ui/Context";
import { useCorporation, useDivision } from "./Context";
+import Box from "@mui/material/Box";
interface IProps {
city: string;
@@ -22,12 +23,12 @@ export function Industry(props: IProps): React.ReactElement {
const corp = useCorporation();
const division = useDivision();
return (
-
-
+
+
-
-
+
+
-
-
+
+
);
}
diff --git a/src/Corporation/ui/IndustryOffice.tsx b/src/Corporation/ui/IndustryOffice.tsx
index 2ab9624f3..e4ced1c07 100644
--- a/src/Corporation/ui/IndustryOffice.tsx
+++ b/src/Corporation/ui/IndustryOffice.tsx
@@ -432,7 +432,7 @@ export function IndustryOffice(props: IProps): React.ReactElement {
Automatically hires an employee and gives him/her a random name}>
diff --git a/src/Corporation/ui/IndustryOverview.tsx b/src/Corporation/ui/IndustryOverview.tsx
index bd2526631..c9a512568 100644
--- a/src/Corporation/ui/IndustryOverview.tsx
+++ b/src/Corporation/ui/IndustryOverview.tsx
@@ -1,101 +1,74 @@
// React Component for displaying an Industry's overview information
// (top-left panel in the Industry UI)
-import React from "react";
+import React, { useState } from "react";
import { OfficeSpace } from "../OfficeSpace";
import { Industries } from "../IndustryData";
import { IndustryUpgrades } from "../IndustryUpgrades";
import { numeralWrapper } from "../../ui/numeralFormat";
-import { dialogBoxCreate } from "../../ui/React/DialogBox";
import { createProgressBarText } from "../../utils/helpers/createProgressBarText";
-import { MakeProductPopup } from "./MakeProductPopup";
+import { MakeProductModal } from "./MakeProductModal";
import { ResearchPopup } from "./ResearchPopup";
import { createPopup } from "../../ui/React/createPopup";
import { Money } from "../../ui/React/Money";
+import { MoneyRate } from "../../ui/React/MoneyRate";
+import { StatsTable } from "../../ui/React/StatsTable";
+import { StaticModal } from "../../ui/React/StaticModal";
import { MoneyCost } from "./MoneyCost";
import { useCorporation, useDivision } from "./Context";
import Typography from "@mui/material/Typography";
import Button from "@mui/material/Button";
import Tooltip from "@mui/material/Tooltip";
import Paper from "@mui/material/Paper";
+import IconButton from "@mui/material/IconButton";
+import HelpIcon from "@mui/icons-material/Help";
+import Box from "@mui/material/Box";
-interface IProps {
- currentCity: string;
- office: OfficeSpace;
- rerender: () => void;
-}
-
-export function IndustryOverview(props: IProps): React.ReactElement {
+function MakeProductButton(): React.ReactElement {
const corp = useCorporation();
const division = useDivision();
- function renderMakeProductButton(): React.ReactElement {
- let createProductButtonText = "";
- let createProductPopupText = "";
- switch (division.type) {
- case Industries.Food:
- createProductButtonText = "Build Restaurant";
- createProductPopupText = "Build and manage a new restaurant!";
- break;
- case Industries.Tobacco:
- createProductButtonText = "Create Product";
- createProductPopupText = "Create a new tobacco product!";
- break;
- case Industries.Pharmaceutical:
- createProductButtonText = "Create Drug";
- createProductPopupText = "Design and develop a new pharmaceutical drug!";
- break;
- case Industries.Computer:
- case "Computer":
- createProductButtonText = "Create Product";
- createProductPopupText = "Design and manufacture a new computer hardware product!";
- break;
- case Industries.Robotics:
- createProductButtonText = "Design Robot";
- createProductPopupText = "Design and create a new robot or robotic system!";
- break;
- case Industries.Software:
- createProductButtonText = "Develop Software";
- createProductPopupText = "Develop a new piece of software!";
- break;
- case Industries.Healthcare:
- createProductButtonText = "Build Hospital";
- createProductPopupText = "Build and manage a new hospital!";
- break;
- case Industries.RealEstate:
- createProductButtonText = "Develop Property";
- createProductPopupText = "Develop a new piece of real estate property!";
- break;
- default:
- createProductButtonText = "Create Product";
- createProductPopupText = "Create a new product!";
- return <>>;
- }
- createProductPopupText +=
- "
To begin developing a product, " +
- "first choose the city in which it will be designed. The stats of your employees " +
- "in the selected city affect the properties of the finished product, such as its " +
- "quality, performance, and durability.
" +
- "You can also choose to invest money in the design and marketing of " +
- "the product. Investing money in its design will result in a superior product. " +
- "Investing money in marketing the product will help the product's sales.";
+ const [makeOpen, setMakeOpen] = useState(false);
- const hasMaxProducts = division.hasMaximumNumberProducts();
+ const hasMaxProducts = division.hasMaximumNumberProducts();
- function openMakeProductPopup(): void {
- const popupId = "cmpy-mgmt-create-product-popup";
- createPopup(popupId, MakeProductPopup, {
- popupText: createProductPopupText,
- division: division,
- corp: corp,
- popupId: popupId,
- });
- }
+ function shouldFlash(): boolean {
+ return Object.keys(division.products).length === 0;
+ }
- function shouldFlash(): boolean {
- return Object.keys(division.products).length === 0;
- }
+ let createProductButtonText = "";
+ switch (division.type) {
+ case Industries.Food:
+ createProductButtonText = "Build Restaurant";
+ break;
+ case Industries.Tobacco:
+ createProductButtonText = "Create Product";
+ break;
+ case Industries.Pharmaceutical:
+ createProductButtonText = "Create Drug";
+ break;
+ case Industries.Computer:
+ case "Computer":
+ createProductButtonText = "Create Product";
+ break;
+ case Industries.Robotics:
+ createProductButtonText = "Design Robot";
+ break;
+ case Industries.Software:
+ createProductButtonText = "Develop Software";
+ break;
+ case Industries.Healthcare:
+ createProductButtonText = "Build Hospital";
+ break;
+ case Industries.RealEstate:
+ createProductButtonText = "Develop Property";
+ break;
+ default:
+ createProductButtonText = "Create Product";
+ return <>>;
+ }
- return (
+ return (
+ <>
-
- );
+ setMakeOpen(false)} />
+ >
+ );
+}
+function Text(): React.ReactElement {
+ const corp = useCorporation();
+ const division = useDivision();
+ const [helpOpen, setHelpOpen] = useState(false);
+ const vechain = corp.unlockUpgrades[4] === 1;
+ const profit = division.lastCycleRevenue.minus(division.lastCycleExpenses).toNumber();
+
+ let advertisingInfo = false;
+ const advertisingFactors = division.getAdvertisingFactors();
+ const awarenessFac = advertisingFactors[1];
+ const popularityFac = advertisingFactors[2];
+ const ratioFac = advertisingFactors[3];
+ const totalAdvertisingFac = advertisingFactors[0];
+ if (vechain) {
+ advertisingInfo = true;
}
- function renderText(): React.ReactElement {
- const vechain = corp.unlockUpgrades[4] === 1;
- const profit = division.lastCycleRevenue.minus(division.lastCycleExpenses).toNumber();
-
- let advertisingInfo = false;
- const advertisingFactors = division.getAdvertisingFactors();
- const awarenessFac = advertisingFactors[1];
- const popularityFac = advertisingFactors[2];
- const ratioFac = advertisingFactors[3];
- const totalAdvertisingFac = advertisingFactors[0];
- if (vechain) {
- advertisingInfo = true;
- }
-
- function productionMultHelpTipOnClick(): void {
- // Wrapper for createProgressBarText()
- // Converts the industry's "effectiveness factors"
- // into a graphic (string) depicting how high that effectiveness is
- function convertEffectFacToGraphic(fac: number): string {
- return createProgressBarText({
- progress: fac,
- totalTicks: 20,
- });
- }
-
- dialogBoxCreate(
- "Owning Hardware, Robots, AI Cores, and Real Estate " +
- "can boost your Industry's production. The effect these " +
- "materials have on your production varies between Industries. " +
- "For example, Real Estate may be very effective for some Industries, " +
- "but ineffective for others.
" +
- "This division's production multiplier is calculated by summing " +
- "the individual production multiplier of each of its office locations. " +
- "This production multiplier is applied to each office. Therefore, it is " +
- "beneficial to expand into new cities as this can greatly increase the " +
- "production multiplier of your entire Division.
" +
- "Below are approximations for how effective each material is at boosting " +
- "this industry's production multiplier (Bigger bars = more effective):
- Advertising Multiplier: x{numeralWrapper.format(totalAdvertisingFac, "0.000")}
-
- Total multiplier for this industrys sales due to its awareness and popularity
-
- Awareness Bonus: x{numeralWrapper.format(Math.pow(awarenessFac, 0.85), "0.000")}
-
- Popularity Bonus: x{numeralWrapper.format(Math.pow(popularityFac, 0.85), "0.000")}
-
- Ratio Multiplier: x{numeralWrapper.format(Math.pow(ratioFac, 0.85), "0.000")}
-
-
- )}
- {advertisingInfo}
-
-
-
-
-
-
-
-
Revenue:
-
-
-
- / s
-
-
-
-
-
-
Expenses:
-
-
-
- / s
-
-
-
-
-
-
Profit:
-
-
-
- / s
-
-
-
-
-
-
-
- Production Multiplier: {numeralWrapper.format(division.prodMult, "0.00")}
-
- Production gain from owning production-boosting materials such as hardware, Robots, AI Cores, and Real
- Estate
-
-
-
- ?
-
-
-
- Scientific Research: {numeralWrapper.format(division.sciResearch.qty, "0.000a")}
-
- Scientific Research increases the quality of the materials and products that you produce.
-
-
+
+ Industry: {division.type} (Corp Funds: )
+
+
+
+ {advertisingInfo !== false && (
+
- {upgrade[4]} -
+ Total multiplier for this industrys sales due to its awareness and popularity
+
>
- ),
- tooltip: upgrade[5],
- }),
- );
+ }
+ >
+ Advertising Multiplier: x{numeralWrapper.format(totalAdvertisingFac, "0.000")}
+
+ )}
+
+ ],
+ ["Expenses:", ],
+ ["Profit:", ],
+ ]}
+ />
+
+
+
+ Production gain from owning production-boosting materials such as hardware, Robots, AI Cores, and Real
+ Estate.
+
+ }
+ >
+ Production Multiplier: {numeralWrapper.format(division.prodMult, "0.00")}
+
+ setHelpOpen(true)}>
+
+
+ setHelpOpen(false)}>
+
+ Owning Hardware, Robots, AI Cores, and Real Estate can boost your Industry's production. The effect these
+ materials have on your production varies between Industries. For example, Real Estate may be very effective
+ for some Industries, but ineffective for others.
+
+
+ This division's production multiplier is calculated by summing the individual production multiplier of each
+ of its office locations. This production multiplier is applied to each office. Therefore, it is beneficial
+ to expand into new cities as this can greatly increase the production multiplier of your entire Division.
+
+
+ Below are approximations for how effective each material is at boosting this industry's production
+ multiplier (Bigger bars = more effective):
+
+
+ Hardware: {convertEffectFacToGraphic(division.hwFac)}
+
+ Robots: {convertEffectFacToGraphic(division.robFac)}
+
+ AI Cores: {convertEffectFacToGraphic(division.aiFac)}
+
+ Real Estate: {convertEffectFacToGraphic(division.reFac)}
+
+
+
+
+
+
+ Scientific Research increases the quality of the materials and products that you produce.
+
+ }
+ >
+ Scientific Research: {numeralWrapper.format(division.sciResearch.qty, "0.000a")}
+
+
+ Research
+
+
+