Skip to content

Commit 47705b3

Browse files
authored
Merge pull request #1023 from MarechJ/ui/maps
UI: Map settings
2 parents 5c21bb4 + bc43bac commit 47705b3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+3176
-1926
lines changed

rcongui/package-lock.json

Lines changed: 8 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rcongui/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
"react-hook-form": "^7.53.0",
6363
"react-markdown": "^9.0.1",
6464
"react-router-dom": "^6.26.1",
65-
"react-toastify": "^10.0.5",
65+
"react-toastify": "^11.0.5",
6666
"react-window": "^1.8.10",
6767
"remark-gfm": "^4.0.0",
6868
"tiny-invariant": "^1.2.0",

rcongui/src/components/Header/server-status.jsx

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { useEffect } from "react";
21
import { Skeleton, Stack, Typography } from "@mui/material";
32
import { styled } from "@mui/material/styles";
43
import { useQuery } from "@tanstack/react-query";
54
import { gameQueryOptions } from "@/queries/game-query";
65
import dayjs from "dayjs";
6+
import { useGlobalStore } from "@/stores/global-state";
77

88
const Wrapper = styled("div")(({ theme }) => ({
99
color: theme.palette.text.primary,
@@ -20,23 +20,21 @@ const Wrapper = styled("div")(({ theme }) => ({
2020
}));
2121

2222
const ServerStatus = ({ compact }) => {
23-
const { data: status, isLoading } = useQuery({
24-
...gameQueryOptions.publicState(),
25-
});
26-
27-
const name = status?.name?.short_name ?? "<Server Name>";
28-
const numCurrentPlayers = status?.player_count ?? 0;
29-
const maxPlayers = status?.max_player_count ?? 100;
30-
const mapName = status?.current_map?.map?.pretty_name ?? "Unknown Map";
23+
const serverState = useGlobalStore((state) => state.status)
24+
const gameState = useGlobalStore((state) => state.gameState)
25+
const name = serverState?.short_name ?? "<Server Name>";
26+
const numCurrentPlayers = serverState?.current_players ?? 0;
27+
const maxPlayers = serverState?.max_players ?? 100;
28+
const mapName = gameState?.current_map?.pretty_name ?? "Unknown Map";
3129
const timeRemaining = dayjs
32-
.duration(status?.time_remaining ?? 0, "seconds")
30+
.duration(gameState?.time_remaining ?? 0, "seconds")
3331
.format("HH:mm:ss");
34-
const balance = `${status?.player_count_by_team?.allied ?? 0}vs${
35-
status?.player_count_by_team?.axis ?? 0
32+
const balance = `${gameState?.num_allied_players ?? 0}vs${
33+
gameState?.num_axis_players ?? 0
3634
}`;
37-
const score = `${status?.score?.allied ?? 0}:${status?.score?.axis ?? 0}`;
35+
const score = `${gameState?.allied_score ?? 0}:${gameState?.axis_score ?? 0}`;
3836

39-
if (isLoading) {
37+
if (!(serverState && gameState)) {
4038
return (
4139
<Wrapper>
4240
<Stack

rcongui/src/components/MapManager/map-autocomplete.jsx

Lines changed: 0 additions & 30 deletions
This file was deleted.

rcongui/src/components/MapManager/map-details.jsx

Lines changed: 0 additions & 57 deletions
This file was deleted.

rcongui/src/components/MapManager/map-list-item.jsx

Lines changed: 0 additions & 31 deletions
This file was deleted.

rcongui/src/components/MapManager/map-state.jsx

Lines changed: 0 additions & 55 deletions
This file was deleted.
Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
import { useQuery } from "@tanstack/react-query";
22
import { cmd } from "@/utils/fetchUtils";
3-
import {
4-
Box,
5-
Typography,
6-
} from "@mui/material";
7-
import { MapAvatar } from "@/components/MapManager/map-details";
3+
import { Divider, Stack } from "@mui/material";
84
import ScrollableCard from "@/components/shared/card/ScrollableCard";
5+
import { MapDetailsCardCompact } from "@/pages/settings/maps/MapDetailsCard";
96

107
const MapRotationCard = () => {
118
const { data: mapRotation = [] } = useQuery({
@@ -15,20 +12,13 @@ const MapRotationCard = () => {
1512

1613
return (
1714
<ScrollableCard sx={{ height: "100%" }} title="Map Rotation">
18-
<Box component="ol" sx={{ listStylePosition: "inside", pl: 0 }}>
15+
<Stack divider={<Divider sx={{ my: 0.2 }} />}>
1916
{mapRotation.map((map) => (
20-
<Box
21-
component="li"
22-
key={map.id}
23-
sx={{ display: "flex", alignItems: "center", gap: 1, mb: 0.25 }}
24-
>
25-
<MapAvatar mapLayer={map} sx={{ width: 24, height: 24 }} />
26-
<Typography variant="subtitle2">{map.pretty_name}</Typography>
27-
</Box>
17+
<MapDetailsCardCompact key={map.id} mapLayer={map} />
2818
))}
29-
</Box>
19+
</Stack>
3020
</ScrollableCard>
3121
);
3222
};
3323

34-
export default MapRotationCard;
24+
export default MapRotationCard;
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import { useClipboard } from "@/hooks/useClipboard";
2+
import {
3+
Button,
4+
Dialog,
5+
DialogContent,
6+
Typography,
7+
Tooltip,
8+
IconButton,
9+
} from "@mui/material";
10+
import ContentCopyIcon from "@mui/icons-material/ContentCopy";
11+
import DoneAllIcon from "@mui/icons-material/DoneAll";
12+
import { useState } from "react";
13+
14+
export default function CopyToClipboardButton({
15+
text,
16+
title,
17+
iconOnly = false,
18+
...props
19+
}) {
20+
const { isClipboardAvailable, isCopied, copyToClipboard } = useClipboard();
21+
const [dialogOpen, setDialogOpen] = useState(false);
22+
23+
const handleClick = () => {
24+
if (isClipboardAvailable) {
25+
copyToClipboard(text);
26+
} else {
27+
setDialogOpen(true);
28+
}
29+
};
30+
31+
return (
32+
<>
33+
<Tooltip title={isCopied ? "Copied!" : (title ?? null)}>
34+
{iconOnly ? (
35+
<IconButton
36+
variant="outlined"
37+
color="warning"
38+
onClick={handleClick}
39+
{...props}
40+
>
41+
{isCopied ? <DoneAllIcon /> : <ContentCopyIcon />}
42+
</IconButton>
43+
) : (
44+
<Button
45+
variant="outlined"
46+
color="warning"
47+
onClick={handleClick}
48+
startIcon={isCopied ? <DoneAllIcon /> : <ContentCopyIcon />}
49+
{...props}
50+
>
51+
{isCopied ? "Copied!" : "Copy"}
52+
</Button>
53+
)}
54+
</Tooltip>
55+
<Dialog open={dialogOpen} onClose={() => setDialogOpen(false)}>
56+
<DialogContent>
57+
<Typography>Copy to Clipboard only available with HTTPS</Typography>
58+
</DialogContent>
59+
<DialogContent>
60+
<Typography>{text}</Typography>
61+
</DialogContent>
62+
</Dialog>
63+
</>
64+
);
65+
}

0 commit comments

Comments
 (0)