UI: Added new locale-aware and configurable number formatting (#354)

This commit is contained in:
Snarling
2023-02-11 13:18:50 -05:00
committed by GitHub
parent 1f5546b721
commit b4074328ec
1231 changed files with 4233 additions and 11958 deletions
+2 -2
View File
@@ -1,6 +1,6 @@
import React, { useState } from "react";
import { purchaseServer } from "../../Server/ServerPurchases";
import { numeralWrapper } from "../../ui/numeralFormat";
import { formatRam } from "../../ui/formatNumber";
import { Money } from "../../ui/React/Money";
import { Modal } from "../../ui/React/Modal";
import { Player } from "@player";
@@ -37,7 +37,7 @@ export function PurchaseServerModal(props: IProps): React.ReactElement {
return (
<Modal open={props.open} onClose={props.onClose}>
<Typography>
Would you like to purchase a new server with {numeralWrapper.formatRAM(props.ram)} of RAM for{" "}
Would you like to purchase a new server with {formatRam(props.ram)} of RAM for{" "}
<Money money={props.cost} forPurchase={true} />?
</Typography>
<br />
+3 -3
View File
@@ -8,7 +8,7 @@ import { Player } from "@player";
import { purchaseRamForHomeComputer } from "../../Server/ServerPurchases";
import { Money } from "../../ui/React/Money";
import { numeralWrapper } from "../../ui/numeralFormat";
import { formatRam } from "../../ui/formatNumber";
import { MathJax } from "better-react-mathjax";
import { BitNodeMultipliers } from "../../BitNode/BitNodeMultipliers";
@@ -45,8 +45,8 @@ export function RamButton(props: IProps): React.ReactElement {
</Typography>
<br />
<Button disabled={!Player.canAfford(cost)} onClick={buy}>
Upgrade 'home' RAM ({numeralWrapper.formatRAM(homeComputer.maxRam)} -&gt;&nbsp;
{numeralWrapper.formatRAM(homeComputer.maxRam * 2)}) -&nbsp;
Upgrade 'home' RAM ({formatRam(homeComputer.maxRam)} -&gt;&nbsp;
{formatRam(homeComputer.maxRam * 2)}) -&nbsp;
<Money money={cost} forPurchase={true} />
</Button>
</span>
+2 -2
View File
@@ -9,7 +9,7 @@ import Tooltip from "@mui/material/Tooltip";
import { Crimes } from "../../Crime/Crimes";
import { numeralWrapper } from "../../ui/numeralFormat";
import { formatPercent } from "../../ui/formatNumber";
import { Router } from "../../ui/GameRoot";
import { Page } from "../../ui/Router";
import { Player } from "@player";
@@ -37,7 +37,7 @@ export function SlumsLocation(): React.ReactElement {
{crimes.map((crime) => (
<Tooltip title={crime.tooltipText}>
<Button onClick={(e) => doCrime(e, crime)}>
{crime.type} ({numeralWrapper.formatPercentage(crime.successRate(Player))} chance of success)
{crime.type} ({formatPercent(crime.successRate(Player))} chance of success)
</Button>
</Tooltip>
))}
+2 -2
View File
@@ -17,7 +17,7 @@ import { getPurchaseServerCost } from "../../Server/ServerPurchases";
import { Money } from "../../ui/React/Money";
import { Player } from "@player";
import { PurchaseServerModal } from "./PurchaseServerModal";
import { numeralWrapper } from "../../ui/numeralFormat";
import { formatRam } from "../../ui/formatNumber";
import { Box } from "@mui/material";
interface IServerProps {
@@ -31,7 +31,7 @@ function ServerButton(props: IServerProps): React.ReactElement {
return (
<>
<Button onClick={() => setOpen(true)} disabled={!Player.canAfford(cost)}>
Purchase {numeralWrapper.formatRAM(props.ram)} Server&nbsp;-&nbsp;
Purchase {formatRam(props.ram)} Server&nbsp;-&nbsp;
<Money money={cost} forPurchase={true} />
</Button>
<PurchaseServerModal