Grid-align buttons in location UIs (and options)

This commit is contained in:
nickofolas 2022-01-14 23:12:16 -06:00
parent 5479c7e135
commit 0359229af6
7 changed files with 130 additions and 137 deletions

@ -10,6 +10,7 @@ import { CoinFlip } from "../../Casino/CoinFlip";
import { Roulette } from "../../Casino/Roulette"; import { Roulette } from "../../Casino/Roulette";
import { SlotMachine } from "../../Casino/SlotMachine"; import { SlotMachine } from "../../Casino/SlotMachine";
import { IPlayer } from "../../PersonObjects/IPlayer"; import { IPlayer } from "../../PersonObjects/IPlayer";
import { Box } from "@mui/material";
enum GameType { enum GameType {
None = "none", None = "none",
@ -33,15 +34,12 @@ export function CasinoLocation(props: IProps): React.ReactElement {
return ( return (
<> <>
{game === GameType.None && ( {game === GameType.None && (
<> <Box sx={{ display: 'grid', width: 'fit-content' }}>
<Button onClick={() => updateGame(GameType.Coin)}>Play coin flip</Button> <Button onClick={() => updateGame(GameType.Coin)}>Play coin flip</Button>
<br />
<Button onClick={() => updateGame(GameType.Slots)}>Play slots</Button> <Button onClick={() => updateGame(GameType.Slots)}>Play slots</Button>
<br />
<Button onClick={() => updateGame(GameType.Roulette)}>Play roulette</Button> <Button onClick={() => updateGame(GameType.Roulette)}>Play roulette</Button>
<br />
<Button onClick={() => updateGame(GameType.Blackjack)}>Play blackjack</Button> <Button onClick={() => updateGame(GameType.Blackjack)}>Play blackjack</Button>
</> </Box>
)} )}
{game !== GameType.None && ( {game !== GameType.None && (
<> <>

@ -226,8 +226,12 @@ export function CompanyLocation(props: IProps): React.ReactElement {
</Box> </Box>
<Typography>-------------------------</Typography> <Typography>-------------------------</Typography>
<br /> <br />
</>
)}
<Box sx={{ display: 'grid', width: 'fit-content' }}>
{isEmployedHere && (
<Box sx={{ display: 'grid', gridTemplateColumns: '1fr 1fr' }}>
<Button onClick={work}>Work</Button> <Button onClick={work}>Work</Button>
&nbsp;&nbsp;&nbsp;&nbsp;
<Button onClick={() => setQuitOpen(true)}>Quit</Button> <Button onClick={() => setQuitOpen(true)}>Quit</Button>
<QuitJobModal <QuitJobModal
locName={props.locName} locName={props.locName}
@ -236,9 +240,10 @@ export function CompanyLocation(props: IProps): React.ReactElement {
open={quitOpen} open={quitOpen}
onClose={() => setQuitOpen(false)} onClose={() => setQuitOpen(false)}
/> />
</> </Box>
)} )
<br />
}
{company.hasAgentPositions() && ( {company.hasAgentPositions() && (
<ApplyToJobButton <ApplyToJobButton
company={company} company={company}
@ -328,6 +333,7 @@ export function CompanyLocation(props: IProps): React.ReactElement {
/> />
)} )}
{location.infiltrationData != null && <Button onClick={startInfiltration}>Infiltrate Company</Button>} {location.infiltrationData != null && <Button onClick={startInfiltration}>Infiltrate Company</Button>}
</Box>
</> </>
); );
} }

@ -16,6 +16,7 @@ import { Server } from "../../Server/Server";
import { Money } from "../../ui/React/Money"; import { Money } from "../../ui/React/Money";
import { IRouter } from "../../ui/Router"; import { IRouter } from "../../ui/Router";
import { serverMetadata } from "../../Server/data/servers"; import { serverMetadata } from "../../Server/data/servers";
import { Box } from "@mui/material";
type IProps = { type IProps = {
loc: Location; loc: Location;
@ -56,7 +57,7 @@ export function GymLocation(props: IProps): React.ReactElement {
const cost = CONSTANTS.ClassGymBaseCost * calculateCost(); const cost = CONSTANTS.ClassGymBaseCost * calculateCost();
return ( return (
<> <Box sx={{ display: 'grid', width: 'fit-content' }}>
<Button onClick={trainStrength}> <Button onClick={trainStrength}>
Train Strength (<Money money={cost} player={props.p} /> / sec) Train Strength (<Money money={cost} player={props.p} /> / sec)
</Button> </Button>
@ -72,6 +73,6 @@ export function GymLocation(props: IProps): React.ReactElement {
<Button onClick={trainAgility}> <Button onClick={trainAgility}>
Train Agility (<Money money={cost} player={props.p} /> / sec) Train Agility (<Money money={cost} player={props.p} /> / sec)
</Button> </Button>
</> </Box>
); );
} }

@ -11,6 +11,7 @@ import { Crimes } from "../../Crime/Crimes";
import { numeralWrapper } from "../../ui/numeralFormat"; import { numeralWrapper } from "../../ui/numeralFormat";
import { use } from "../../ui/Context"; import { use } from "../../ui/Context";
import { Box } from "@mui/material";
export function SlumsLocation(): React.ReactElement { export function SlumsLocation(): React.ReactElement {
const player = use.Player(); const player = use.Player();
@ -113,73 +114,61 @@ export function SlumsLocation(): React.ReactElement {
const heistChance = Crimes.Heist.successRate(player); const heistChance = Crimes.Heist.successRate(player);
return ( return (
<> <Box sx={{ display: 'grid', width: 'fit-content' }}>
<Tooltip title={<>Attempt to shoplift from a low-end retailer</>}> <Tooltip title={<>Attempt to shoplift from a low-end retailer</>}>
<Button onClick={shoplift}> <Button onClick={shoplift}>
Shoplift ({numeralWrapper.formatPercentage(shopliftChance)} chance of success) Shoplift ({numeralWrapper.formatPercentage(shopliftChance)} chance of success)
</Button> </Button>
</Tooltip> </Tooltip>
<br />
<Tooltip title={<>Attempt to commit armed robbery on a high-end store</>}> <Tooltip title={<>Attempt to commit armed robbery on a high-end store</>}>
<Button onClick={robStore}> <Button onClick={robStore}>
Rob store ({numeralWrapper.formatPercentage(robStoreChance)} chance of success) Rob store ({numeralWrapper.formatPercentage(robStoreChance)} chance of success)
</Button> </Button>
</Tooltip> </Tooltip>
<br />
<Tooltip title={<>Attempt to mug a random person on the street</>}> <Tooltip title={<>Attempt to mug a random person on the street</>}>
<Button onClick={mug}>Mug someone ({numeralWrapper.formatPercentage(mugChance)} chance of success)</Button> <Button onClick={mug}>Mug someone ({numeralWrapper.formatPercentage(mugChance)} chance of success)</Button>
</Tooltip> </Tooltip>
<br />
<Tooltip title={<>Attempt to rob property from someone's house</>}> <Tooltip title={<>Attempt to rob property from someone's house</>}>
<Button onClick={larceny}>Larceny ({numeralWrapper.formatPercentage(larcenyChance)} chance of success)</Button> <Button onClick={larceny}>Larceny ({numeralWrapper.formatPercentage(larcenyChance)} chance of success)</Button>
</Tooltip> </Tooltip>
<br />
<Tooltip title={<>Attempt to deal drugs</>}> <Tooltip title={<>Attempt to deal drugs</>}>
<Button onClick={dealDrugs}> <Button onClick={dealDrugs}>
Deal Drugs ({numeralWrapper.formatPercentage(drugsChance)} chance of success) Deal Drugs ({numeralWrapper.formatPercentage(drugsChance)} chance of success)
</Button> </Button>
</Tooltip> </Tooltip>
<br />
<Tooltip title={<>Attempt to forge corporate bonds</>}> <Tooltip title={<>Attempt to forge corporate bonds</>}>
<Button onClick={bondForgery}> <Button onClick={bondForgery}>
Bond Forgery ({numeralWrapper.formatPercentage(bondChance)} chance of success) Bond Forgery ({numeralWrapper.formatPercentage(bondChance)} chance of success)
</Button> </Button>
</Tooltip> </Tooltip>
<br />
<Tooltip title={<>Attempt to smuggle illegal arms into the city</>}> <Tooltip title={<>Attempt to smuggle illegal arms into the city</>}>
<Button onClick={traffickArms}> <Button onClick={traffickArms}>
Traffick illegal Arms ({numeralWrapper.formatPercentage(armsChance)} chance of success) Traffick illegal Arms ({numeralWrapper.formatPercentage(armsChance)} chance of success)
</Button> </Button>
</Tooltip> </Tooltip>
<br />
<Tooltip title={<>Attempt to murder a random person on the street</>}> <Tooltip title={<>Attempt to murder a random person on the street</>}>
<Button onClick={homicide}> <Button onClick={homicide}>
Homicide ({numeralWrapper.formatPercentage(homicideChance)} chance of success) Homicide ({numeralWrapper.formatPercentage(homicideChance)} chance of success)
</Button> </Button>
</Tooltip> </Tooltip>
<br />
<Tooltip title={<>Attempt to commit grand theft auto</>}> <Tooltip title={<>Attempt to commit grand theft auto</>}>
<Button onClick={grandTheftAuto}> <Button onClick={grandTheftAuto}>
Grand theft Auto ({numeralWrapper.formatPercentage(gtaChance)} chance of success) Grand theft Auto ({numeralWrapper.formatPercentage(gtaChance)} chance of success)
</Button> </Button>
</Tooltip> </Tooltip>
<br />
<Tooltip title={<>Attempt to kidnap and ransom a high-profile-target</>}> <Tooltip title={<>Attempt to kidnap and ransom a high-profile-target</>}>
<Button onClick={kidnap}> <Button onClick={kidnap}>
Kidnap and Ransom ({numeralWrapper.formatPercentage(kidnapChance)} chance of success) Kidnap and Ransom ({numeralWrapper.formatPercentage(kidnapChance)} chance of success)
</Button> </Button>
</Tooltip> </Tooltip>
<br />
<Tooltip title={<>Attempt to assassinate a high-profile target</>}> <Tooltip title={<>Attempt to assassinate a high-profile target</>}>
<Button onClick={assassinate}> <Button onClick={assassinate}>
Assassinate ({numeralWrapper.formatPercentage(assassinateChance)} chance of success) Assassinate ({numeralWrapper.formatPercentage(assassinateChance)} chance of success)
</Button> </Button>
</Tooltip> </Tooltip>
<br />
<Tooltip title={<>Attempt to pull off the ultimate heist</>}> <Tooltip title={<>Attempt to pull off the ultimate heist</>}>
<Button onClick={heist}>Heist ({numeralWrapper.formatPercentage(heistChance)} chance of success)</Button> <Button onClick={heist}>Heist ({numeralWrapper.formatPercentage(heistChance)} chance of success)</Button>
</Tooltip> </Tooltip>
<br /> </Box>
</>
); );
} }

@ -18,6 +18,7 @@ import { Money } from "../../ui/React/Money";
import { use } from "../../ui/Context"; import { use } from "../../ui/Context";
import { PurchaseServerModal } from "./PurchaseServerModal"; import { PurchaseServerModal } from "./PurchaseServerModal";
import { numeralWrapper } from "../../ui/numeralFormat"; import { numeralWrapper } from "../../ui/numeralFormat";
import { Box } from "@mui/material";
interface IServerProps { interface IServerProps {
ram: number; ram: number;
@ -70,7 +71,9 @@ export function TechVendorLocation(props: IProps): React.ReactElement {
return ( return (
<> <>
<br /> <br />
<Box sx={{ display: 'grid', width: 'fit-content' }}>
{purchaseServerButtons} {purchaseServerButtons}
</Box>
<br /> <br />
<Typography> <Typography>
<i>"You can order bigger servers via scripts. We don't take custom orders in person."</i> <i>"You can order bigger servers via scripts. We don't take custom orders in person."</i>

@ -15,6 +15,7 @@ import { Server } from "../../Server/Server";
import { Money } from "../../ui/React/Money"; import { Money } from "../../ui/React/Money";
import { use } from "../../ui/Context"; import { use } from "../../ui/Context";
import { Box } from "@mui/material";
type IProps = { type IProps = {
loc: Location; loc: Location;
@ -72,45 +73,40 @@ export function UniversityLocation(props: IProps): React.ReactElement {
const earnCharismaExpTooltip = `Gain charisma experience!`; const earnCharismaExpTooltip = `Gain charisma experience!`;
return ( return (
<> <Box sx={{ display: 'grid', width: 'fit-content' }}>
<Tooltip title={earnHackingExpTooltip}> <Tooltip title={earnHackingExpTooltip}>
<Button onClick={study}>Study Computer Science (free)</Button> <Button onClick={study}>Study Computer Science (free)</Button>
</Tooltip> </Tooltip>
<br />
<Tooltip title={earnHackingExpTooltip}> <Tooltip title={earnHackingExpTooltip}>
<Button onClick={dataStructures}> <Button onClick={dataStructures}>
Take Data Structures course ( Take Data Structures course (
<Money money={dataStructuresCost} player={player} /> / sec) <Money money={dataStructuresCost} player={player} /> / sec)
</Button> </Button>
</Tooltip> </Tooltip>
<br />
<Tooltip title={earnHackingExpTooltip}> <Tooltip title={earnHackingExpTooltip}>
<Button onClick={networks}> <Button onClick={networks}>
Take Networks course ( Take Networks course (
<Money money={networksCost} player={player} /> / sec) <Money money={networksCost} player={player} /> / sec)
</Button> </Button>
</Tooltip> </Tooltip>
<br />
<Tooltip title={earnHackingExpTooltip}> <Tooltip title={earnHackingExpTooltip}>
<Button onClick={algorithms}> <Button onClick={algorithms}>
Take Algorithms course ( Take Algorithms course (
<Money money={algorithmsCost} player={player} /> / sec) <Money money={algorithmsCost} player={player} /> / sec)
</Button> </Button>
</Tooltip> </Tooltip>
<br />
<Tooltip title={earnCharismaExpTooltip}> <Tooltip title={earnCharismaExpTooltip}>
<Button onClick={management}> <Button onClick={management}>
Take Management course ( Take Management course (
<Money money={managementCost} player={player} /> / sec) <Money money={managementCost} player={player} /> / sec)
</Button> </Button>
</Tooltip> </Tooltip>
<br />
<Tooltip title={earnCharismaExpTooltip}> <Tooltip title={earnCharismaExpTooltip}>
<Button onClick={leadership}> <Button onClick={leadership}>
Take Leadership course ( Take Leadership course (
<Money money={leadershipCost} player={player} /> / sec) <Money money={leadershipCost} player={player} /> / sec)
</Button> </Button>
</Tooltip> </Tooltip>
</> </Box>
); );
} }

@ -529,12 +529,12 @@ export function GameOptionsRoot(props: IProps): React.ReactElement {
</> </>
)} )}
</Grid> </Grid>
<Grid item xs={12} sm={6}> <Box sx={{ display: 'grid', width: 'fit-content', height: 'fit-content' }}>
<Box> <Box sx={{ display: 'grid', gridTemplateColumns: '1fr 1fr' }}>
<Button onClick={() => props.save()}>Save Game</Button> <Button onClick={() => props.save()}>Save Game</Button>
<Button onClick={() => setDeleteOpen(true)}>Delete Game</Button> <Button onClick={() => setDeleteOpen(true)}>Delete Game</Button>
</Box> </Box>
<Box> <Box sx={{ display: 'grid', gridTemplateColumns: '1fr 1fr' }}>
<Tooltip title={<Typography>Export your game to a text file.</Typography>}> <Tooltip title={<Typography>Export your game to a text file.</Typography>}>
<Button onClick={() => props.export()}> <Button onClick={() => props.export()}>
<DownloadIcon color="primary" /> <DownloadIcon color="primary" />
@ -571,7 +571,7 @@ export function GameOptionsRoot(props: IProps): React.ReactElement {
} }
/> />
</Box> </Box>
<Box> <Box sx={{ display: 'grid' }}>
<Tooltip <Tooltip
title={ title={
<Typography> <Typography>
@ -586,7 +586,7 @@ export function GameOptionsRoot(props: IProps): React.ReactElement {
<Button onClick={() => props.forceKill()}>Force kill all active scripts</Button> <Button onClick={() => props.forceKill()}>Force kill all active scripts</Button>
</Tooltip> </Tooltip>
</Box> </Box>
<Box> <Box sx={{ display: 'grid', gridTemplateColumns: '1fr 1fr' }}>
<Tooltip <Tooltip
title={ title={
<Typography> <Typography>
@ -613,7 +613,7 @@ export function GameOptionsRoot(props: IProps): React.ReactElement {
<Button onClick={() => setDiagnosticOpen(true)}>Diagnose files</Button> <Button onClick={() => setDiagnosticOpen(true)}>Diagnose files</Button>
</Tooltip> </Tooltip>
</Box> </Box>
<Box> <Box sx={{ display: 'grid', gridTemplateColumns: '1fr 1fr' }}>
<Button onClick={() => setThemeEditorOpen(true)}>Theme editor</Button> <Button onClick={() => setThemeEditorOpen(true)}>Theme editor</Button>
<Button onClick={() => setStyleEditorOpen(true)}>Style editor</Button> <Button onClick={() => setStyleEditorOpen(true)}>Style editor</Button>
</Box> </Box>
@ -637,7 +637,7 @@ export function GameOptionsRoot(props: IProps): React.ReactElement {
<Typography>Incremental game plaza</Typography> <Typography>Incremental game plaza</Typography>
</Link> </Link>
</Box> </Box>
</Grid> </Box>
</Grid> </Grid>
<FileDiagnosticModal open={diagnosticOpen} onClose={() => setDiagnosticOpen(false)} /> <FileDiagnosticModal open={diagnosticOpen} onClose={() => setDiagnosticOpen(false)} />
<ConfirmationModal <ConfirmationModal