fix sleeve memory bug

This commit is contained in:
Olivier Gagnon
2021-09-08 23:47:34 -04:00
parent bada8a5f39
commit 2a13db39c7
360 changed files with 5424 additions and 15764 deletions
+1 -3
View File
@@ -23,9 +23,7 @@ export class Accordion extends React.Component<IProps, IState> {
this.handleHeaderClick = this.handleHeaderClick.bind(this);
this.state = {
panelOpened: props.panelInitiallyOpened
? props.panelInitiallyOpened
: false,
panelOpened: props.panelInitiallyOpened ? props.panelInitiallyOpened : false,
};
}
+2 -12
View File
@@ -38,19 +38,9 @@ export function AccordionButton(props: IProps): React.ReactElement {
};
return (
<button
className={className}
id={props.id}
onClick={props.onClick}
style={props.style}
>
<button className={className} id={props.id} onClick={props.onClick} style={props.style}>
{props.text}
{hasTooltip && (
<span
className={"tooltiptext"}
dangerouslySetInnerHTML={tooltipMarkup}
></span>
)}
{hasTooltip && <span className={"tooltiptext"} dangerouslySetInnerHTML={tooltipMarkup}></span>}
</button>
);
}
+1 -3
View File
@@ -60,9 +60,7 @@ export class AutoupdatingParagraph extends React.Component<IProps, IState> {
return (
<div className="tooltip" style={this.props.style}>
<p>{this.props.getContent()}</p>
{this.hasTooltip() && (
<span className={"tooltiptext"}>{this.tooltip()}</span>
)}
{this.hasTooltip() && <span className={"tooltiptext"}>{this.tooltip()}</span>}
</div>
);
}
+2 -11
View File
@@ -65,18 +65,9 @@ export class AutoupdatingStdButton extends React.Component<IProps, IState> {
};
return (
<button
className={className}
onClick={this.props.onClick}
style={this.props.style}
>
<button className={className} onClick={this.props.onClick} style={this.props.style}>
{this.props.text}
{hasTooltip && (
<span
className={"tooltiptext"}
dangerouslySetInnerHTML={tooltipMarkup}
></span>
)}
{hasTooltip && <span className={"tooltiptext"} dangerouslySetInnerHTML={tooltipMarkup}></span>}
</button>
);
}
+10 -39
View File
@@ -12,10 +12,7 @@ export class CharacterOverviewComponent extends Component {
const intelligence = (
<tr id="character-int-wrapper">
<td className="character-int-cell">Int:&nbsp;</td>
<td
id="character-int-text"
className="character-int-cell character-stat-cell"
>
<td id="character-int-text" className="character-int-cell character-stat-cell">
{numeralWrapper.formatSkill(Player.intelligence)}
</td>
</tr>
@@ -56,75 +53,49 @@ export class CharacterOverviewComponent extends Component {
<tbody>
<tr id="character-hp-wrapper">
<td className="character-hp-cell">HP:</td>
<td
id="character-hp-text"
className="character-hp-cell character-stat-cell"
>
{numeralWrapper.formatHp(Player.hp) +
" / " +
numeralWrapper.formatHp(Player.max_hp)}
<td id="character-hp-text" className="character-hp-cell character-stat-cell">
{numeralWrapper.formatHp(Player.hp) + " / " + numeralWrapper.formatHp(Player.max_hp)}
</td>
</tr>
<tr id="character-money-wrapper">
<td className="character-money-cell">Money:&nbsp;</td>
<td
id="character-money-text"
className="character-money-cell character-stat-cell"
>
<td id="character-money-text" className="character-money-cell character-stat-cell">
{numeralWrapper.formatMoney(Player.money.toNumber())}
</td>
</tr>
<tr id="character-hack-wrapper">
<td className="character-hack-cell">Hack:&nbsp;</td>
<td
id="character-hack-text"
className="character-hack-cell character-stat-cell"
>
<td id="character-hack-text" className="character-hack-cell character-stat-cell">
{numeralWrapper.formatSkill(Player.hacking_skill)}
</td>
</tr>
<tr id="character-str-wrapper" className="character-divider">
<td className="character-combat-cell">Str:&nbsp;</td>
<td
id="character-str-text"
className="character-combat-cell character-stat-cell"
>
<td id="character-str-text" className="character-combat-cell character-stat-cell">
{numeralWrapper.formatSkill(Player.strength)}
</td>
</tr>
<tr id="character-def-wrapper">
<td className="character-combat-cell">Def:&nbsp;</td>
<td
id="character-def-text"
className="character-combat-cell character-stat-cell"
>
<td id="character-def-text" className="character-combat-cell character-stat-cell">
{numeralWrapper.formatSkill(Player.defense)}
</td>
</tr>
<tr id="character-dex-wrapper">
<td className="character-combat-cell">Dex:&nbsp;</td>
<td
id="character-dex-text"
className="character-combat-cell character-stat-cell"
>
<td id="character-dex-text" className="character-combat-cell character-stat-cell">
{numeralWrapper.formatSkill(Player.dexterity)}
</td>
</tr>
<tr id="character-agi-wrapper">
<td className="character-combat-cell">Agi:&nbsp;</td>
<td
id="character-agi-text"
className="character-combat-cell character-stat-cell"
>
<td id="character-agi-text" className="character-combat-cell character-stat-cell">
{numeralWrapper.formatSkill(Player.agility)}
</td>
</tr>
<tr id="character-cha-wrapper" className="character-divider">
<td className="character-cha-cell">Cha:&nbsp;</td>
<td
id="character-cha-text"
className="character-cha-cell character-stat-cell"
>
<td id="character-cha-text" className="character-cha-cell character-stat-cell">
{numeralWrapper.formatSkill(Player.charisma)}
</td>
</tr>
+7 -28
View File
@@ -1,11 +1,7 @@
import React, { useState } from "react";
import { KEY } from "../../../utils/helpers/keyCodes";
import {
CodingContract,
CodingContractType,
CodingContractTypes,
} from "../../CodingContracts";
import { CodingContract, CodingContractType, CodingContractTypes } from "../../CodingContracts";
import { ClickableTag, CopyableText } from "./CopyableText";
import { PopupCloseButton } from "./PopupCloseButton";
@@ -40,25 +36,16 @@ export function CodingContractPopup(props: IProps): React.ReactElement {
const contractType: CodingContractType = CodingContractTypes[props.c.type];
const description = [];
for (const [i, value] of contractType
.desc(props.c.data)
.split("\n")
.entries())
description.push(
<span
key={i}
dangerouslySetInnerHTML={{ __html: value + "<br />" }}
></span>,
);
for (const [i, value] of contractType.desc(props.c.data).split("\n").entries())
description.push(<span key={i} dangerouslySetInnerHTML={{ __html: value + "<br />" }}></span>);
return (
<div>
<CopyableText value={props.c.type} tag={ClickableTag.Tag_h1} />
<br />
<br />
<p>
You are attempting to solve a Coding Contract. You have{" "}
{props.c.getMaxNumTries() - props.c.tries} tries remaining, after which
the contract will self-destruct.
You are attempting to solve a Coding Contract. You have {props.c.getMaxNumTries() - props.c.tries} tries
remaining, after which the contract will self-destruct.
</p>
<br />
<p>{description}</p>
@@ -72,16 +59,8 @@ export function CodingContractPopup(props: IProps): React.ReactElement {
onChange={onChange}
onKeyDown={onKeyDown}
/>
<PopupCloseButton
popup={props.popupId}
onClose={() => props.onAttempt(answer)}
text={"Solve"}
/>
<PopupCloseButton
popup={props.popupId}
onClose={props.onClose}
text={"Close"}
/>
<PopupCloseButton popup={props.popupId} onClose={() => props.onAttempt(answer)} text={"Solve"} />
<PopupCloseButton popup={props.popupId} onClose={props.onClose} text={"Close"} />
</div>
);
}
+1 -7
View File
@@ -10,13 +10,7 @@ interface IProps {
function randomize(char: string): string {
const randFrom = (str: string): string => str[Math.floor(Math.random() * str.length)];
const classes = [
"abcdefghijklmnopqrstuvwxyz",
"ABCDEFGHIJKLMNOPQRSTUVWXYZ",
"1234567890",
" _",
"()[]{}<>",
];
const classes = ["abcdefghijklmnopqrstuvwxyz", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "1234567890", " _", "()[]{}<>"];
const other = `!@#$%^&*()_+|\\';"/.,?\`~`;
for (const c of classes) {
+2 -6
View File
@@ -59,9 +59,7 @@ export class ErrorBoundary extends React.Component<IProps, IState> {
componentWillUnmount(): void {
if (this.hasEventEmitter()) {
(this.props.eventEmitterForReset as EventEmitter).removeSubscriber(
this.props.id as string,
);
(this.props.eventEmitterForReset as EventEmitter).removeSubscriber(this.props.id as string);
}
}
@@ -78,9 +76,7 @@ export class ErrorBoundary extends React.Component<IProps, IState> {
if (this.state.hasError) {
return (
<div style={styleMarkup}>
<p>
{`Error rendering UI. This is (probably) a bug. Please report to game developer.`}
</p>
<p>{`Error rendering UI. This is (probably) a bug. Please report to game developer.`}</p>
<p>{`In the meantime, try refreshing the game WITHOUT saving.`}</p>
<p>{`Error info: ${this.state.errorInfo}`}</p>
</div>
+1 -3
View File
@@ -4,9 +4,7 @@ import { numeralWrapper } from "../../ui/numeralFormat";
export function Hashes(hashes: number | string): JSX.Element {
return (
<span className={"money-gold samefont"}>
{typeof hashes === "number"
? numeralWrapper.formatHashes(hashes)
: hashes}
{typeof hashes === "number" ? numeralWrapper.formatHashes(hashes) : hashes}
</span>
);
}
+3 -12
View File
@@ -8,22 +8,13 @@ interface IProps {
}
export function Money(props: IProps): JSX.Element {
if (props.player !== undefined) {
if (typeof props.money !== "number")
throw new Error(
"if player if provided, money should be number, contact dev",
);
if (typeof props.money !== "number") throw new Error("if player if provided, money should be number, contact dev");
if (!props.player.canAfford(props.money))
return (
<span className={"unbuyable samefont"}>
{numeralWrapper.formatMoney(props.money)}
</span>
);
return <span className={"unbuyable samefont"}>{numeralWrapper.formatMoney(props.money)}</span>;
}
return (
<span className={"money-gold samefont"}>
{typeof props.money === "number"
? numeralWrapper.formatMoney(props.money)
: props.money}
{typeof props.money === "number" ? numeralWrapper.formatMoney(props.money) : props.money}
</span>
);
}
+1 -3
View File
@@ -52,9 +52,7 @@ const useLabelStyles = makeStyles({
},
});
export const MuiTextField: React.FC<TextFieldProps> = (
props: TextFieldProps,
) => {
export const MuiTextField: React.FC<TextFieldProps> = (props: TextFieldProps) => {
return (
<TextField
{...props}
+1 -4
View File
@@ -9,10 +9,7 @@ export interface IParagraphWithTooltipProps {
tooltip: string | React.ReactElement | JSX.Element;
}
export class ParagraphWithTooltip extends React.Component<
IParagraphWithTooltipProps,
any
> {
export class ParagraphWithTooltip extends React.Component<IParagraphWithTooltipProps, any> {
render(): React.ReactNode {
return (
<div className={"tooltip"} style={this.props.style}>
+1 -5
View File
@@ -63,11 +63,7 @@ export class PopupButton extends React.Component<IPopupButtonProps, any> {
const className = this.props.class ? this.props.class : "std-button";
return (
<button
className={className}
onClick={this.handleClick}
style={this.props.style}
>
<button className={className} onClick={this.handleClick} style={this.props.style}>
{this.props.text}
</button>
);
+1 -5
View File
@@ -48,11 +48,7 @@ export class PopupCloseButton extends PopupButton {
const className = this.props.class ? this.props.class : "std-button";
return (
<button
className={className}
onClick={this.closePopup}
style={this.props.style}
>
<button className={className} onClick={this.closePopup} style={this.props.style}>
{this.props.text}
</button>
);
+1 -3
View File
@@ -4,9 +4,7 @@ import { numeralWrapper } from "../../ui/numeralFormat";
export function Reputation(reputation: number | string): JSX.Element {
return (
<span className={"reputation samefont"}>
{typeof reputation === "number"
? numeralWrapper.formatReputation(reputation)
: reputation}
{typeof reputation === "number" ? numeralWrapper.formatReputation(reputation) : reputation}
</span>
);
}
+3 -13
View File
@@ -29,17 +29,11 @@ export class ServerDropdown extends React.Component {
case ServerType.Foreign:
return s.hostname !== "home" && !s.purchasedByPlayer;
case ServerType.Owned:
return (
s.purchasedByPlayer ||
s instanceof HacknetServer ||
s.hostname === "home"
);
return s.purchasedByPlayer || s instanceof HacknetServer || s.hostname === "home";
case ServerType.Purchased:
return s.purchasedByPlayer || s instanceof HacknetServer;
default:
console.warn(
`Invalid ServerType specified for ServerDropdown component: ${type}`,
);
console.warn(`Invalid ServerType specified for ServerDropdown component: ${type}`);
return false;
}
}
@@ -65,11 +59,7 @@ export class ServerDropdown extends React.Component {
}
return (
<select
className={"dropdown"}
onChange={this.props.onChange}
style={this.props.style}
>
<select className={"dropdown"} onChange={this.props.onChange} style={this.props.style}>
{servers}
</select>
);
+1 -2
View File
@@ -22,8 +22,7 @@ export function StatsTable(rows: any[][], title?: string): React.ReactElement {
<tr key={row[0]}>
{row.map((elem: any, i: number) => {
let style = {};
if (i !== 0)
style = { textAlign: "right", paddingLeft: ".25em" };
if (i !== 0) style = { textAlign: "right", paddingLeft: ".25em" };
return (
<td key={i} style={style}>
{elem}
+2 -12
View File
@@ -36,24 +36,14 @@ export function StdButton(props: IStdButtonProps): React.ReactElement {
const tooltipMarkup: IInnerHTMLMarkup = {
__html: props.tooltip,
};
tooltip = (
<span
className={"tooltiptext"}
dangerouslySetInnerHTML={tooltipMarkup}
></span>
);
tooltip = <span className={"tooltiptext"} dangerouslySetInnerHTML={tooltipMarkup}></span>;
} else {
tooltip = <span className={"tooltiptext"}>{props.tooltip}</span>;
}
}
return (
<button
className={className}
id={props.id}
onClick={props.onClick}
style={props.style}
>
<button className={className} id={props.id} onClick={props.onClick} style={props.style}>
{props.text}
{hasTooltip && tooltip}
</button>
+3 -15
View File
@@ -14,10 +14,7 @@ type IInnerHTMLMarkup = {
__html: string;
};
export class StdButtonPurchased extends React.Component<
IStdButtonPurchasedProps,
any
> {
export class StdButtonPurchased extends React.Component<IStdButtonPurchasedProps, any> {
constructor(props: IStdButtonPurchasedProps) {
super(props);
this.hasTooltip = this.hasTooltip.bind(this);
@@ -50,18 +47,9 @@ export class StdButtonPurchased extends React.Component<
}
return (
<button
className={className}
onClick={this.props.onClick}
style={this.props.style}
>
<button className={className} onClick={this.props.onClick} style={this.props.style}>
{this.props.text}
{this.hasTooltip() && (
<span
className={"tooltiptext"}
dangerouslySetInnerHTML={tooltipMarkup}
></span>
)}
{this.hasTooltip() && <span className={"tooltiptext"} dangerouslySetInnerHTML={tooltipMarkup}></span>}
</button>
);
}
+2 -11
View File
@@ -49,8 +49,7 @@ export function createPopup<T>(
if (clickedId !== id) return;
removePopup(id);
}
const backgroundColor =
deepestPopupId === "" ? "rgba(0,0,0,0.5)" : "rgba(0,0,0,0)";
const backgroundColor = deepestPopupId === "" ? "rgba(0,0,0,0.5)" : "rgba(0,0,0,0)";
container = createElement("div", {
class: "popup-box-container",
display: "flex",
@@ -63,15 +62,7 @@ export function createPopup<T>(
}
if (deepestPopupId === "") deepestPopupId = id;
ReactDOM.render(
<Popup
content={rootComponent}
id={id}
props={props}
removePopup={removePopup}
/>,
container,
);
ReactDOM.render(<Popup content={rootComponent} id={id} props={props} removePopup={removePopup} />, container);
return container;
}