mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-22 22:22:26 +01:00
change modals so they close on mouse down outside the box
This commit is contained in:
parent
c4617e4b9a
commit
e906a6331f
4
dist/engine.bundle.js
vendored
4
dist/engine.bundle.js
vendored
File diff suppressed because one or more lines are too long
26
dist/vendor.bundle.js
vendored
26
dist/vendor.bundle.js
vendored
File diff suppressed because one or more lines are too long
@ -11,6 +11,8 @@ import { CorporationUnlockUpgrade } from "./data/CorporationUnlockUpgrades";
|
||||
import { CorporationUpgrade } from "./data/CorporationUpgrades";
|
||||
import { Cities } from "../Locations/Cities";
|
||||
import { EmployeePositions } from "./EmployeePositions";
|
||||
import { Employee } from "./Employee";
|
||||
import { IndustryUpgrades } from "./IndustryUpgrades";
|
||||
|
||||
export function NewIndustry(corporation: ICorporation, industry: string, name: string): void {
|
||||
for (let i = 0; i < corporation.divisions.length; ++i) {
|
||||
@ -277,3 +279,71 @@ export function PurchaseWarehouse(corp: ICorporation, division: IIndustry, city:
|
||||
});
|
||||
corp.funds = corp.funds.minus(CorporationConstants.WarehouseInitialCost);
|
||||
}
|
||||
|
||||
export function UpgradeWarehouse(corp: ICorporation, division: IIndustry, warehouse: Warehouse): void {
|
||||
const sizeUpgradeCost = CorporationConstants.WarehouseUpgradeBaseCost * Math.pow(1.07, warehouse.level + 1);
|
||||
++warehouse.level;
|
||||
warehouse.updateSize(corp, division);
|
||||
corp.funds = corp.funds.minus(sizeUpgradeCost);
|
||||
}
|
||||
|
||||
export function BuyCoffee(corp: ICorporation, division: IIndustry, office: OfficeSpace): void {
|
||||
const upgrade = IndustryUpgrades[0];
|
||||
const cost = office.employees.length * upgrade[1];
|
||||
if (corp.funds.lt(cost)) return;
|
||||
corp.funds = corp.funds.minus(cost);
|
||||
division.upgrade(upgrade, {
|
||||
corporation: corp,
|
||||
office: office,
|
||||
});
|
||||
}
|
||||
|
||||
export function HireAdVert(corp: ICorporation, division: IIndustry, office: OfficeSpace): void {
|
||||
const upgrade = IndustryUpgrades[1];
|
||||
const cost = upgrade[1] * Math.pow(upgrade[2], division.upgrades[1]);
|
||||
if (corp.funds.lt(cost)) return;
|
||||
corp.funds = corp.funds.minus(cost);
|
||||
division.upgrade(upgrade, {
|
||||
corporation: corp,
|
||||
office: office,
|
||||
});
|
||||
}
|
||||
|
||||
export function MakeProduct(
|
||||
corp: ICorporation,
|
||||
division: IIndustry,
|
||||
city: string,
|
||||
productName: string,
|
||||
designInvest: number,
|
||||
marketingInvest: number,
|
||||
): void {
|
||||
if (designInvest < 0) {
|
||||
designInvest = 0;
|
||||
}
|
||||
if (marketingInvest < 0) {
|
||||
marketingInvest = 0;
|
||||
}
|
||||
if (productName == null || productName === "") {
|
||||
throw new Error("You must specify a name for your product!");
|
||||
}
|
||||
if (isNaN(designInvest)) {
|
||||
throw new Error("Invalid value for design investment");
|
||||
}
|
||||
if (isNaN(marketingInvest)) {
|
||||
throw new Error("Invalid value for marketing investment");
|
||||
}
|
||||
if (corp.funds.lt(designInvest + marketingInvest)) {
|
||||
throw new Error("You don't have enough company funds to make this large of an investment");
|
||||
}
|
||||
const product = new Product({
|
||||
name: productName.replace(/[<>]/g, ""), //Sanitize for HTMl elements
|
||||
createCity: city,
|
||||
designCost: designInvest,
|
||||
advCost: marketingInvest,
|
||||
});
|
||||
if (division.products[product.name] instanceof Product) {
|
||||
throw new Error(`You already have a product with this name!`);
|
||||
}
|
||||
corp.funds = corp.funds.minus(designInvest + marketingInvest);
|
||||
division.products[product.name] = product;
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import { Industries } from "../IndustryData";
|
||||
import { Product } from "../Product";
|
||||
import { ICorporation } from "../ICorporation";
|
||||
import { IIndustry } from "../IIndustry";
|
||||
import { MakeProduct } from "../Actions";
|
||||
|
||||
interface IProps {
|
||||
popupText: string;
|
||||
@ -36,37 +37,13 @@ export function MakeProductPopup(props: IProps): React.ReactElement {
|
||||
if (props.division.hasMaximumNumberProducts()) return <></>;
|
||||
|
||||
function makeProduct(): void {
|
||||
let designInvest = design;
|
||||
let marketingInvest = marketing;
|
||||
if (designInvest == null || designInvest < 0) {
|
||||
designInvest = 0;
|
||||
}
|
||||
if (marketingInvest == null || marketingInvest < 0) {
|
||||
marketingInvest = 0;
|
||||
}
|
||||
if (name == null || name === "") {
|
||||
dialogBoxCreate("You must specify a name for your product!");
|
||||
} else if (isNaN(designInvest)) {
|
||||
dialogBoxCreate("Invalid value for design investment");
|
||||
} else if (isNaN(marketingInvest)) {
|
||||
dialogBoxCreate("Invalid value for marketing investment");
|
||||
} else if (props.corp.funds.lt(designInvest + marketingInvest)) {
|
||||
dialogBoxCreate("You don't have enough company funds to make this large of an investment");
|
||||
} else {
|
||||
const product = new Product({
|
||||
name: name.replace(/[<>]/g, ""), //Sanitize for HTMl elements
|
||||
createCity: city,
|
||||
designCost: designInvest,
|
||||
advCost: marketingInvest,
|
||||
});
|
||||
if (props.division.products[product.name] instanceof Product) {
|
||||
dialogBoxCreate(`You already have a product with this name!`);
|
||||
return;
|
||||
}
|
||||
props.corp.funds = props.corp.funds.minus(designInvest + marketingInvest);
|
||||
props.division.products[product.name] = product;
|
||||
removePopup(props.popupId);
|
||||
if (design === null || marketing === null) return;
|
||||
try {
|
||||
MakeProduct(props.corp, props.division, city, name, design, marketing);
|
||||
} catch (err) {
|
||||
dialogBoxCreate(err + "");
|
||||
}
|
||||
removePopup(props.popupId);
|
||||
}
|
||||
|
||||
function onCityChange(event: React.ChangeEvent<HTMLSelectElement>): void {
|
||||
|
@ -30,6 +30,11 @@ import {
|
||||
AssignJob,
|
||||
UpgradeOfficeSize,
|
||||
ThrowParty,
|
||||
PurchaseWarehouse,
|
||||
UpgradeWarehouse,
|
||||
BuyCoffee,
|
||||
HireAdVert,
|
||||
MakeProduct,
|
||||
} from "./Corporation/Actions";
|
||||
import { CorporationUnlockUpgrades } from "./Corporation/data/CorporationUnlockUpgrades";
|
||||
import { CorporationUpgrades } from "./Corporation/data/CorporationUpgrades";
|
||||
@ -4497,64 +4502,86 @@ 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);
|
||||
},
|
||||
employees: function (divisionName, cityName) {
|
||||
const office = getOffice(divisionName, cityName);
|
||||
return office.employees.map((e) => Object.assign({}, e));
|
||||
},
|
||||
assignJob: function (divisionName, cityName, employeeName, job) {
|
||||
const employee = getEmployee(divisionName, cityName, employeeName);
|
||||
AssignJob(employee, job);
|
||||
},
|
||||
hireEmployee: function (divisionName, cityName) {
|
||||
const office = getOffice(divisionName, cityName);
|
||||
office.hireRandomEmployee();
|
||||
},
|
||||
upgradeOfficeSize: function (divisionName, cityName, size) {
|
||||
const office = getOffice(divisionName, cityName);
|
||||
UpgradeOfficeSize(Player.corporation, office, size);
|
||||
},
|
||||
throwParty: function (divisionName, cityName, costPerEmployee) {
|
||||
const office = getOffice(divisionName, cityName);
|
||||
ThrowParty(Player.corporation, office, costPerEmployee);
|
||||
},
|
||||
}, // 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);
|
||||
// },
|
||||
// employees: function (divisionName, cityName) {
|
||||
// const office = getOffice(divisionName, cityName);
|
||||
// return office.employees.map((e) => Object.assign({}, e));
|
||||
// },
|
||||
// assignJob: function (divisionName, cityName, employeeName, job) {
|
||||
// const employee = getEmployee(divisionName, cityName, employeeName);
|
||||
// AssignJob(employee, job);
|
||||
// },
|
||||
// hireEmployee: function (divisionName, cityName) {
|
||||
// const office = getOffice(divisionName, cityName);
|
||||
// office.hireRandomEmployee();
|
||||
// },
|
||||
// upgradeOfficeSize: function (divisionName, cityName, size) {
|
||||
// const office = getOffice(divisionName, cityName);
|
||||
// UpgradeOfficeSize(Player.corporation, office, size);
|
||||
// },
|
||||
// throwParty: function (divisionName, cityName, costPerEmployee) {
|
||||
// const office = getOffice(divisionName, cityName);
|
||||
// ThrowParty(Player.corporation, office, costPerEmployee);
|
||||
// },
|
||||
// purchaseWarehouse: function (divisionName, cityName) {
|
||||
// PurchaseWarehouse(Player.corporation, getDivision(divisionName), cityName);
|
||||
// },
|
||||
// upgradeWarehouse: function (divisionName, cityName) {
|
||||
// UpgradeWarehouse(Player.corporation, getDivision(divisionName), getWarehouse(divisionName, cityName));
|
||||
// },
|
||||
// buyCoffee: function (divisionName, cityName) {
|
||||
// BuyCoffee(Player.corporation, getDivision(divisionName), getOffice(divisionName, cityName));
|
||||
// },
|
||||
// hireAdVert: function (divisionName) {
|
||||
// HireAdVert(Player.corporation, getDivision(divisionName), getOffice(divisionName, "Sector-12"));
|
||||
// },
|
||||
// makeProduct: function (divisionName, cityName, productName, designInvest, marketingInvest) {
|
||||
// MakeProduct(
|
||||
// Player.corporation,
|
||||
// getDivision(divisionName),
|
||||
// cityName,
|
||||
// productName,
|
||||
// designInvest,
|
||||
// marketingInvest,
|
||||
// );
|
||||
// },
|
||||
// }, // End Corporation API
|
||||
|
||||
// Coding Contract API
|
||||
codingcontract: {
|
||||
|
@ -57,7 +57,7 @@ export function createPopup<T>(
|
||||
display: "flex",
|
||||
id: id,
|
||||
backgroundColor: backgroundColor,
|
||||
clickListener: onClick,
|
||||
mouseDown: onClick,
|
||||
});
|
||||
|
||||
gameContainer.appendChild(container);
|
||||
|
@ -36,6 +36,7 @@ interface ICreateElementLabelOptions {
|
||||
interface ICreateElementListenerOptions {
|
||||
changeListener?(this: HTMLElement, ev: Event): any;
|
||||
clickListener?(this: HTMLElement, ev: MouseEvent): any;
|
||||
mouseDown?(this: HTMLElement, ev: MouseEvent): any;
|
||||
inputListener?(this: HTMLElement, ev: Event): any;
|
||||
onfocus?(this: HTMLElement, ev: FocusEvent): any;
|
||||
onkeydown?(this: HTMLElement, ev: KeyboardEvent): any;
|
||||
@ -158,6 +159,9 @@ function setElementListeners(el: HTMLElement, params: ICreateElementListenerOpti
|
||||
if (params.clickListener !== undefined) {
|
||||
el.addEventListener("click", params.clickListener);
|
||||
}
|
||||
if (params.mouseDown !== undefined) {
|
||||
el.addEventListener("mousedown", params.mouseDown);
|
||||
}
|
||||
if (params.inputListener !== undefined) {
|
||||
el.addEventListener("input", params.inputListener);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user