diff --git a/src/Faction/ui/CreateGangPopup.tsx b/src/Faction/ui/CreateGangPopup.tsx new file mode 100644 index 000000000..5423d6348 --- /dev/null +++ b/src/Faction/ui/CreateGangPopup.tsx @@ -0,0 +1,58 @@ +/** + * React Component for the popup used to create a new gang. + */ + import React from "react"; + import { removePopup } from "../../ui/React/createPopup"; + import { IPlayer } from "../../PersonObjects/IPlayer"; + import { StdButton } from "../../ui/React/StdButton"; + import { IEngine } from "../../IEngine"; + + interface ICreateGangPopupProps { + popupId: string; + facName: string; + p: IPlayer; + engine: IEngine; + } + + export function CreateGangPopup(props: ICreateGangPopupProps): React.ReactElement { + + const combatGangText = "This is a COMBAT gang. Members in this gang will have different tasks than HACKING gangs. " + + "Compared to hacking gangs, progression with combat gangs can be more difficult as territory management " + + "is more important. However, well-managed combat gangs can progress faster than hacking ones."; + + const hackingGangText = "This is a HACKING gang. Members in this gang will have different tasks than COMBAT gangs. " + + "Compared to combat gangs, progression with hacking gangs is more straightforward as territory warfare " + + "is not as important."; + + function isHacking(): boolean { + return ["NiteSec", "The Black Hand"].includes(props.facName); + } + + function createGang(): void { + props.p.startGang(props.facName, isHacking()); + removePopup(props.popupId); + props.engine.loadGangContent(); + } + + function onKeyUp(event: React.KeyboardEvent): void { + if (event.keyCode === 13) createGang(); + } + + return ( + <> + Would you like to create a new Gang with {props.facName}? +
+
+ Note that this will prevent you from creating a Gang with any other Faction until this BitNode is destroyed. It also resets your reputation with this faction. +
+
+ { (isHacking()) ? hackingGangText : combatGangText } +
+
+ Other than hacking vs combat, there are NO differences between the Factions you can create a Gang with, and each of these Factions have all Augmentations available. +
+ +
+ + ); + } \ No newline at end of file diff --git a/src/Faction/ui/Root.tsx b/src/Faction/ui/Root.tsx index ba9cbae46..755241842 100644 --- a/src/Faction/ui/Root.tsx +++ b/src/Faction/ui/Root.tsx @@ -19,7 +19,8 @@ import { IPlayer } from "../../PersonObjects/IPlayer"; import { createSleevePurchasesFromCovenantPopup } from "../../PersonObjects/Sleeve/SleeveCovenantPurchases"; import { SourceFileFlags } from "../../SourceFile/SourceFileFlags"; -import { yesNoBoxClose, yesNoBoxCreate, yesNoBoxGetNoButton, yesNoBoxGetYesButton } from "../../../utils/YesNoBox"; +import { createPopup } from "../../ui/React/createPopup"; +import { CreateGangPopup } from "./CreateGangPopup"; type IProps = { engine: IEngine; @@ -97,59 +98,13 @@ export class FactionRoot extends React.Component { return this.props.engine.loadGangContent(); } - // Otherwise, we have to create the gang - const facName = this.props.faction.name; - let isHacking = false; - if (facName === "NiteSec" || facName === "The Black Hand") { - isHacking = true; - } - - // A Yes/No popup box will allow the player to confirm gang creation - const yesBtn = yesNoBoxGetYesButton(); - const noBtn = yesNoBoxGetNoButton(); - if (yesBtn == null || noBtn == null) { - return; - } - - yesBtn.innerHTML = "Create Gang"; - yesBtn.addEventListener("click", () => { - this.props.p.startGang(facName, isHacking); - const worldMenuHeader = document.getElementById("world-menu-header"); - if (worldMenuHeader instanceof HTMLElement) { - worldMenuHeader.click(); - worldMenuHeader.click(); - } - - this.props.engine.loadGangContent(); - yesNoBoxClose(); + const popupId = "create-gang-popup"; + createPopup(popupId, CreateGangPopup, { + popupId: popupId, + facName: this.props.faction.name, + p: this.props.p, + engine: this.props.engine }); - - noBtn.innerHTML = "Cancel"; - noBtn.addEventListener("click", () => { - yesNoBoxClose(); - }); - - // Pop-up text - let gangTypeText = ""; - if (isHacking) { - gangTypeText = - "This is a HACKING gang. Members in this gang will have different tasks than COMBAT gangs. " + - "Compared to combat gangs, progression with hacking gangs is more straightforward as territory warfare " + - "is not as important.

"; - } else { - gangTypeText = - "This is a COMBAT gang. Members in this gang will have different tasks than HACKING gangs. " + - "Compared to hacking gangs, progression with combat gangs can be more difficult as territory management " + - "is more important. However, well-managed combat gangs can progress faster than hacking ones.

"; - } - yesNoBoxCreate( - `Would you like to create a new Gang with ${facName}?

` + - "Note that this will prevent you from creating a Gang with any other Faction until " + - "this BitNode is destroyed. It also resets your reputation with this faction.

" + - gangTypeText + - "Other than hacking vs combat, there are NO differences between the Factions you can " + - "create a Gang with, and each of these Factions have all Augmentations available.", - ); } rerender(): void { diff --git a/src/ui/React/StdButton.tsx b/src/ui/React/StdButton.tsx index dbfd74926..1c07e6e95 100644 --- a/src/ui/React/StdButton.tsx +++ b/src/ui/React/StdButton.tsx @@ -6,9 +6,11 @@ import * as React from "react"; interface IStdButtonProps { addClasses?: string; + autoFocus?: boolean; disabled?: boolean; id?: string; onClick?: (e: React.MouseEvent) => any; + onKeyUp?: (e: React.KeyboardEvent) => any; style?: any; text: string | JSX.Element; tooltip?: string | JSX.Element; @@ -43,7 +45,7 @@ export function StdButton(props: IStdButtonProps): React.ReactElement { } return ( -