mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-09 17:23:53 +01:00
tech vendor buttons update better
This commit is contained in:
parent
0d5a302580
commit
1c9542d102
@ -9,14 +9,10 @@ import { MathComponent } from "mathjax-react";
|
||||
|
||||
type IProps = {
|
||||
p: IPlayer;
|
||||
rerender: () => void;
|
||||
};
|
||||
|
||||
export function CoresButton(props: IProps): React.ReactElement {
|
||||
const setRerender = useState(false)[1];
|
||||
function rerender(): void {
|
||||
setRerender((old) => !old);
|
||||
}
|
||||
|
||||
const btnStyle = { display: "block" };
|
||||
|
||||
const homeComputer = props.p.getHomeComputer();
|
||||
@ -37,7 +33,7 @@ export function CoresButton(props: IProps): React.ReactElement {
|
||||
if (!props.p.canAfford(cost)) return;
|
||||
props.p.loseMoney(cost);
|
||||
homeComputer.cpuCores++;
|
||||
rerender();
|
||||
props.rerender();
|
||||
}
|
||||
|
||||
return (
|
||||
|
@ -11,14 +11,10 @@ import { MathComponent } from "mathjax-react";
|
||||
|
||||
type IProps = {
|
||||
p: IPlayer;
|
||||
rerender: () => void;
|
||||
};
|
||||
|
||||
export function RamButton(props: IProps): React.ReactElement {
|
||||
const setRerender = useState(false)[1];
|
||||
function rerender(): void {
|
||||
setRerender((old) => !old);
|
||||
}
|
||||
|
||||
const btnStyle = { display: "block" };
|
||||
|
||||
const homeComputer = props.p.getHomeComputer();
|
||||
@ -32,7 +28,7 @@ export function RamButton(props: IProps): React.ReactElement {
|
||||
|
||||
function buy(): void {
|
||||
purchaseRamForHomeComputer(props.p);
|
||||
rerender();
|
||||
props.rerender();
|
||||
}
|
||||
|
||||
return (
|
||||
|
@ -3,7 +3,7 @@
|
||||
*
|
||||
* This subcomponent renders all of the buttons for purchasing things from tech vendors
|
||||
*/
|
||||
import * as React from "react";
|
||||
import React, { useState } from "react";
|
||||
|
||||
import { Location } from "../Location";
|
||||
import { createPurchaseServerPopup } from "../LocationsHelpers";
|
||||
@ -23,6 +23,10 @@ type IProps = {
|
||||
};
|
||||
|
||||
export function TechVendorLocation(props: IProps): React.ReactElement {
|
||||
const setRerender = useState(false)[1];
|
||||
function rerender() {
|
||||
setRerender((old) => !old);
|
||||
}
|
||||
const btnStyle = { display: "block" };
|
||||
|
||||
const purchaseServerButtons: React.ReactNode[] = [];
|
||||
@ -58,9 +62,9 @@ export function TechVendorLocation(props: IProps): React.ReactElement {
|
||||
</i>
|
||||
</p>
|
||||
<br />
|
||||
<TorButton p={props.p} />
|
||||
<RamButton p={props.p} />
|
||||
<CoresButton p={props.p} />
|
||||
<TorButton p={props.p} rerender={rerender} />
|
||||
<RamButton p={props.p} rerender={rerender} />
|
||||
<CoresButton p={props.p} rerender={rerender} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
@ -11,19 +11,15 @@ import { Money } from "../../ui/React/Money";
|
||||
|
||||
type IProps = {
|
||||
p: IPlayer;
|
||||
rerender: () => void;
|
||||
};
|
||||
|
||||
export function TorButton(props: IProps): React.ReactElement {
|
||||
const setRerender = useState(false)[1];
|
||||
function rerender(): void {
|
||||
setRerender((old) => !old);
|
||||
}
|
||||
|
||||
const btnStyle = { display: "block" };
|
||||
|
||||
function buy(): void {
|
||||
purchaseTorRouter(props.p);
|
||||
rerender();
|
||||
props.rerender();
|
||||
}
|
||||
|
||||
if (props.p.hasTorRouter()) {
|
||||
|
Loading…
Reference in New Issue
Block a user