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