mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2025-04-15 06:41:42 +02:00
change modals so they close on mouse down outside the box
This commit is contained in:
dist
src
utils/uiHelpers
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 { CorporationUpgrade } from "./data/CorporationUpgrades";
|
||||||
import { Cities } from "../Locations/Cities";
|
import { Cities } from "../Locations/Cities";
|
||||||
import { EmployeePositions } from "./EmployeePositions";
|
import { EmployeePositions } from "./EmployeePositions";
|
||||||
|
import { Employee } from "./Employee";
|
||||||
|
import { IndustryUpgrades } from "./IndustryUpgrades";
|
||||||
|
|
||||||
export function NewIndustry(corporation: ICorporation, industry: string, name: string): void {
|
export function NewIndustry(corporation: ICorporation, industry: string, name: string): void {
|
||||||
for (let i = 0; i < corporation.divisions.length; ++i) {
|
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);
|
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 { Product } from "../Product";
|
||||||
import { ICorporation } from "../ICorporation";
|
import { ICorporation } from "../ICorporation";
|
||||||
import { IIndustry } from "../IIndustry";
|
import { IIndustry } from "../IIndustry";
|
||||||
|
import { MakeProduct } from "../Actions";
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
popupText: string;
|
popupText: string;
|
||||||
@ -36,37 +37,13 @@ export function MakeProductPopup(props: IProps): React.ReactElement {
|
|||||||
if (props.division.hasMaximumNumberProducts()) return <></>;
|
if (props.division.hasMaximumNumberProducts()) return <></>;
|
||||||
|
|
||||||
function makeProduct(): void {
|
function makeProduct(): void {
|
||||||
let designInvest = design;
|
if (design === null || marketing === null) return;
|
||||||
let marketingInvest = marketing;
|
try {
|
||||||
if (designInvest == null || designInvest < 0) {
|
MakeProduct(props.corp, props.division, city, name, design, marketing);
|
||||||
designInvest = 0;
|
} catch (err) {
|
||||||
}
|
dialogBoxCreate(err + "");
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
removePopup(props.popupId);
|
||||||
}
|
}
|
||||||
|
|
||||||
function onCityChange(event: React.ChangeEvent<HTMLSelectElement>): void {
|
function onCityChange(event: React.ChangeEvent<HTMLSelectElement>): void {
|
||||||
|
@ -30,6 +30,11 @@ import {
|
|||||||
AssignJob,
|
AssignJob,
|
||||||
UpgradeOfficeSize,
|
UpgradeOfficeSize,
|
||||||
ThrowParty,
|
ThrowParty,
|
||||||
|
PurchaseWarehouse,
|
||||||
|
UpgradeWarehouse,
|
||||||
|
BuyCoffee,
|
||||||
|
HireAdVert,
|
||||||
|
MakeProduct,
|
||||||
} from "./Corporation/Actions";
|
} from "./Corporation/Actions";
|
||||||
import { CorporationUnlockUpgrades } from "./Corporation/data/CorporationUnlockUpgrades";
|
import { CorporationUnlockUpgrades } from "./Corporation/data/CorporationUnlockUpgrades";
|
||||||
import { CorporationUpgrades } from "./Corporation/data/CorporationUpgrades";
|
import { CorporationUpgrades } from "./Corporation/data/CorporationUpgrades";
|
||||||
@ -4497,64 +4502,86 @@ function NetscriptFunctions(workerScript) {
|
|||||||
},
|
},
|
||||||
}, // End Bladeburner
|
}, // End Bladeburner
|
||||||
|
|
||||||
corporation: {
|
// corporation: {
|
||||||
expandIndustry: function (industryName, divisionName) {
|
// expandIndustry: function (industryName, divisionName) {
|
||||||
NewIndustry(Player.corporation, industryName, divisionName);
|
// NewIndustry(Player.corporation, industryName, divisionName);
|
||||||
},
|
// },
|
||||||
expandCity: function (divisionName, cityName) {
|
// expandCity: function (divisionName, cityName) {
|
||||||
const division = getDivision(divisionName);
|
// const division = getDivision(divisionName);
|
||||||
NewCity(Player.corporation, division, cityName);
|
// NewCity(Player.corporation, division, cityName);
|
||||||
},
|
// },
|
||||||
unlockUpgrade: function (upgradeName) {
|
// unlockUpgrade: function (upgradeName) {
|
||||||
const upgrade = Object.values(CorporationUnlockUpgrades).find((upgrade) => upgrade[2] === upgradeName);
|
// const upgrade = Object.values(CorporationUnlockUpgrades).find((upgrade) => upgrade[2] === upgradeName);
|
||||||
if (upgrade === undefined) throw new Error("No upgrade named '${upgradeName}'");
|
// if (upgrade === undefined) throw new Error("No upgrade named '${upgradeName}'");
|
||||||
UnlockUpgrade(Player.corporation, upgrade);
|
// UnlockUpgrade(Player.corporation, upgrade);
|
||||||
},
|
// },
|
||||||
levelUpgrade: function (upgradeName) {
|
// levelUpgrade: function (upgradeName) {
|
||||||
const upgrade = Object.values(CorporationUpgrades).find((upgrade) => upgrade[4] === upgradeName);
|
// const upgrade = Object.values(CorporationUpgrades).find((upgrade) => upgrade[4] === upgradeName);
|
||||||
if (upgrade === undefined) throw new Error("No upgrade named '${upgradeName}'");
|
// if (upgrade === undefined) throw new Error("No upgrade named '${upgradeName}'");
|
||||||
LevelUpgrade(Player.corporation, upgrade);
|
// LevelUpgrade(Player.corporation, upgrade);
|
||||||
},
|
// },
|
||||||
issueDividends: function (percent) {
|
// issueDividends: function (percent) {
|
||||||
IssueDividends(Player.corporation, percent);
|
// IssueDividends(Player.corporation, percent);
|
||||||
},
|
// },
|
||||||
sellMaterial: function (divisionName, cityName, materialName, amt, price) {
|
// sellMaterial: function (divisionName, cityName, materialName, amt, price) {
|
||||||
const material = getMaterial(divisionName, cityName, materialName);
|
// const material = getMaterial(divisionName, cityName, materialName);
|
||||||
SellMaterial(material, amt, price);
|
// SellMaterial(material, amt, price);
|
||||||
},
|
// },
|
||||||
sellProduct: function (divisionName, cityName, productName, amt, price, all) {
|
// sellProduct: function (divisionName, cityName, productName, amt, price, all) {
|
||||||
const product = getProduct(divisionName, productName);
|
// const product = getProduct(divisionName, productName);
|
||||||
SellProduct(product, cityName, amt, price, all);
|
// SellProduct(product, cityName, amt, price, all);
|
||||||
},
|
// },
|
||||||
setSmartSupply: function (divisionName, cityName, enabled) {
|
// setSmartSupply: function (divisionName, cityName, enabled) {
|
||||||
const warehouse = getWarehouse(divisionName, cityName);
|
// const warehouse = getWarehouse(divisionName, cityName);
|
||||||
SetSmartSupply(warehouse, enabled);
|
// SetSmartSupply(warehouse, enabled);
|
||||||
},
|
// },
|
||||||
buyMaterial: function (divisionName, cityName, materialName, amt) {
|
// buyMaterial: function (divisionName, cityName, materialName, amt) {
|
||||||
const material = getMaterial(divisionName, cityName, materialName);
|
// const material = getMaterial(divisionName, cityName, materialName);
|
||||||
BuyMaterial(material, amt);
|
// BuyMaterial(material, amt);
|
||||||
},
|
// },
|
||||||
employees: function (divisionName, cityName) {
|
// employees: function (divisionName, cityName) {
|
||||||
const office = getOffice(divisionName, cityName);
|
// const office = getOffice(divisionName, cityName);
|
||||||
return office.employees.map((e) => Object.assign({}, e));
|
// return office.employees.map((e) => Object.assign({}, e));
|
||||||
},
|
// },
|
||||||
assignJob: function (divisionName, cityName, employeeName, job) {
|
// assignJob: function (divisionName, cityName, employeeName, job) {
|
||||||
const employee = getEmployee(divisionName, cityName, employeeName);
|
// const employee = getEmployee(divisionName, cityName, employeeName);
|
||||||
AssignJob(employee, job);
|
// AssignJob(employee, job);
|
||||||
},
|
// },
|
||||||
hireEmployee: function (divisionName, cityName) {
|
// hireEmployee: function (divisionName, cityName) {
|
||||||
const office = getOffice(divisionName, cityName);
|
// const office = getOffice(divisionName, cityName);
|
||||||
office.hireRandomEmployee();
|
// office.hireRandomEmployee();
|
||||||
},
|
// },
|
||||||
upgradeOfficeSize: function (divisionName, cityName, size) {
|
// upgradeOfficeSize: function (divisionName, cityName, size) {
|
||||||
const office = getOffice(divisionName, cityName);
|
// const office = getOffice(divisionName, cityName);
|
||||||
UpgradeOfficeSize(Player.corporation, office, size);
|
// UpgradeOfficeSize(Player.corporation, office, size);
|
||||||
},
|
// },
|
||||||
throwParty: function (divisionName, cityName, costPerEmployee) {
|
// throwParty: function (divisionName, cityName, costPerEmployee) {
|
||||||
const office = getOffice(divisionName, cityName);
|
// const office = getOffice(divisionName, cityName);
|
||||||
ThrowParty(Player.corporation, office, costPerEmployee);
|
// ThrowParty(Player.corporation, office, costPerEmployee);
|
||||||
},
|
// },
|
||||||
}, // End Corporation API
|
// 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
|
// Coding Contract API
|
||||||
codingcontract: {
|
codingcontract: {
|
||||||
|
@ -57,7 +57,7 @@ export function createPopup<T>(
|
|||||||
display: "flex",
|
display: "flex",
|
||||||
id: id,
|
id: id,
|
||||||
backgroundColor: backgroundColor,
|
backgroundColor: backgroundColor,
|
||||||
clickListener: onClick,
|
mouseDown: onClick,
|
||||||
});
|
});
|
||||||
|
|
||||||
gameContainer.appendChild(container);
|
gameContainer.appendChild(container);
|
||||||
|
@ -36,6 +36,7 @@ interface ICreateElementLabelOptions {
|
|||||||
interface ICreateElementListenerOptions {
|
interface ICreateElementListenerOptions {
|
||||||
changeListener?(this: HTMLElement, ev: Event): any;
|
changeListener?(this: HTMLElement, ev: Event): any;
|
||||||
clickListener?(this: HTMLElement, ev: MouseEvent): any;
|
clickListener?(this: HTMLElement, ev: MouseEvent): any;
|
||||||
|
mouseDown?(this: HTMLElement, ev: MouseEvent): any;
|
||||||
inputListener?(this: HTMLElement, ev: Event): any;
|
inputListener?(this: HTMLElement, ev: Event): any;
|
||||||
onfocus?(this: HTMLElement, ev: FocusEvent): any;
|
onfocus?(this: HTMLElement, ev: FocusEvent): any;
|
||||||
onkeydown?(this: HTMLElement, ev: KeyboardEvent): any;
|
onkeydown?(this: HTMLElement, ev: KeyboardEvent): any;
|
||||||
@ -158,6 +159,9 @@ function setElementListeners(el: HTMLElement, params: ICreateElementListenerOpti
|
|||||||
if (params.clickListener !== undefined) {
|
if (params.clickListener !== undefined) {
|
||||||
el.addEventListener("click", params.clickListener);
|
el.addEventListener("click", params.clickListener);
|
||||||
}
|
}
|
||||||
|
if (params.mouseDown !== undefined) {
|
||||||
|
el.addEventListener("mousedown", params.mouseDown);
|
||||||
|
}
|
||||||
if (params.inputListener !== undefined) {
|
if (params.inputListener !== undefined) {
|
||||||
el.addEventListener("input", params.inputListener);
|
el.addEventListener("input", params.inputListener);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user