Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"loglevel": "^1.9.2",
"loglevel-plugin-prefix": "^0.8.4",
"microdiff": "^1.5.0",
"minidenticons": "^4.2.1",
"moize": "^6.1.7",
"pako": "^2.1.0",
"react": "^19.2.4",
Expand Down
2 changes: 1 addition & 1 deletion src/factories/list/FactoryGridCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import { ProgressChip } from '@/factories/components/ProgressChip';
import type { Factory } from '@/factories/Factory';
import { useIsFactoryVisible } from '@/factories/useIsFactoryVisible';
import { FactoryPeers } from '@/games/sync/FactoryPeers';
import { FactoryPeers } from '@/games/sync/ui/FactoryPeers';
import { FactoryItemImage } from '@/recipes/ui/FactoryItemImage';
import classes from './FactoryGridCard.module.css';

Expand Down Expand Up @@ -57,7 +57,7 @@
className={classes.outputsList}
>
{factory.outputs.map((output, outputIndex) => (
<Group gap={6} wrap={'nowrap'} key={outputIndex}>

Check warning on line 60 in src/factories/list/FactoryGridCard.tsx

View workflow job for this annotation

GitHub Actions / build

lint/suspicious/noArrayIndexKey

Avoid using the index of an array as key property in an element.
<FactoryItemImage id={output.resource} size={24} />
<Text size="xs">&times;</Text>
<Text size="xs">{output.amount}</Text>
Expand Down
2 changes: 1 addition & 1 deletion src/factories/list/FactoryRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import { FactoryOutputRow } from '@/factories/inputs/output-row/FactoryOutputRow';
import { useIsFactoryVisible } from '@/factories/useIsFactoryVisible';
import { useGameFactoryIsCollapsed } from '@/games/gamesSlice';
import { FactoryPeers } from '@/games/sync/FactoryPeers';
import { FactoryPeers } from '@/games/sync/ui/FactoryPeers';

export interface IFactoryRowProps {
id: string;
Expand Down Expand Up @@ -82,7 +82,7 @@
{(factory.outputs ?? [{ resource: null, amount: null }]).map(
(output, index) => (
<FactoryOutputRow
key={index}

Check warning on line 85 in src/factories/list/FactoryRow.tsx

View workflow job for this annotation

GitHub Actions / build

lint/suspicious/noArrayIndexKey

Avoid using the index of an array as key property in an element.
index={index}
output={output}
factoryId={factory.id}
Expand Down Expand Up @@ -145,7 +145,7 @@
<Stack gap="xs">
{factory.inputs?.map((input, index) => (
<FactoryInputRow
key={index}

Check warning on line 148 in src/factories/list/FactoryRow.tsx

View workflow job for this annotation

GitHub Actions / build

lint/suspicious/noArrayIndexKey

Avoid using the index of an array as key property in an element.
index={index}
input={input}
factoryId={factory.id}
Expand Down
210 changes: 99 additions & 111 deletions src/games/menu/GameMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Box, Button, Menu } from '@mantine/core';
import { Button, Menu } from '@mantine/core';
import { useDisclosure } from '@mantine/hooks';
import { notifications } from '@mantine/notifications';
import {
Expand Down Expand Up @@ -55,9 +55,6 @@ export function GameMenu(props: IGameMenuProps) {
state => !!state.games.games[selectedId ?? '']?.savedId,
);
const isSaving = useStore(state => state.gameSave.isSaving);
const isSyncConnected = useStore(
state => state.gameSave.isRealtimeSyncConnected,
);
const navigate = useNavigate();

const [opened, { toggle, open, close }] = useDisclosure();
Expand Down Expand Up @@ -96,122 +93,113 @@ export function GameMenu(props: IGameMenuProps) {

return (
<>
<Box pos="relative" style={{ display: 'inline-flex' }}>
<Button.Group data-tutorial-id="games-menu">
<Menu>
<Menu.Target>
<Button
data-tutorial-id="games-menu-trigger"
variant="light"
color="gray"
leftSection={<IconDeviceGamepad size={16} />}
rightSection={<IconChevronDown size={12} stroke={1.5} />}
>
{gameName ?? 'Select game'}
</Button>
</Menu.Target>
<Menu.Dropdown data-tutorial-id="games-menu-dropdown">
<Menu.Label>Change game</Menu.Label>
{gameOptions.map(option => (
<Menu.Item
key={option.value}
leftSection={<IconDeviceGamepad size={16} />}
onClick={() => {
useStore.getState().selectGame(option.value);
navigate(`/factories`);
}}
rightSection={
selectedId === option.value && (
<IconCircleFilled
size={8}
color="var(--mantine-color-green-7)"
/>
)
}
>
{option.label}
</Menu.Item>
))}

<Menu.Item
onClick={() => {
useStore.getState().createGame(v4(), {
name:
'New Game ' +
(Object.keys(useStore.getState().games.games).length + 1),
});
}}
leftSection={<IconPlus color="orange" size={16} />}
>
New game
</Menu.Item>
<Menu.Divider />
<Menu.Label>Game actions</Menu.Label>
<Button.Group data-tutorial-id="games-menu">
<Menu>
<Menu.Target>
<Button
data-tutorial-id="games-menu-trigger"
variant="light"
color="gray"
leftSection={<IconDeviceGamepad size={16} />}
rightSection={<IconChevronDown size={12} stroke={1.5} />}
>
{gameName ?? 'Select game'}
</Button>
</Menu.Target>
<Menu.Dropdown data-tutorial-id="games-menu-dropdown">
<Menu.Label>Change game</Menu.Label>
{gameOptions.map(option => (
<Menu.Item
leftSection={
<IconPencil color="var(--mantine-color-blue-3)" size={16} />
}
key={option.value}
leftSection={<IconDeviceGamepad size={16} />}
onClick={() => {
open();
useStore.getState().selectGame(option.value);
navigate(`/factories`);
}}
>
Rename game
</Menu.Item>
<Menu.Item
leftSection={
<IconSettings color="var(--mantine-color-gray-5)" size={16} />
rightSection={
selectedId === option.value && (
<IconCircleFilled
size={8}
color="var(--mantine-color-green-7)"
/>
)
}
onClick={openGameSettingsModal}
>
Game settings
</Menu.Item>
<Menu.Item
leftSection={<IconDeviceFloppy size={16} />}
onClick={() => handleSaveGame(selectedId)}
>
Save game
{option.label}
</Menu.Item>
{selectedId && isSelectedSavedOnRemote && (
<Menu.Item
leftSection={<IconDownload size={16} />}
onClick={() => handleLoadGame(selectedId)}
>
Load last save
</Menu.Item>
)}
<Menu.Divider />
))}

<Menu.Item
onClick={() => {
useStore.getState().createGame(v4(), {
name:
'New Game ' +
(Object.keys(useStore.getState().games.games).length + 1),
});
}}
leftSection={<IconPlus color="orange" size={16} />}
>
New game
</Menu.Item>
<Menu.Divider />
<Menu.Label>Game actions</Menu.Label>
<Menu.Item
leftSection={
<IconPencil color="var(--mantine-color-blue-3)" size={16} />
}
onClick={() => {
open();
}}
>
Rename game
</Menu.Item>
<Menu.Item
leftSection={
<IconSettings color="var(--mantine-color-gray-5)" size={16} />
}
onClick={openGameSettingsModal}
>
Game settings
</Menu.Item>
<Menu.Item
leftSection={<IconDeviceFloppy size={16} />}
onClick={() => handleSaveGame(selectedId)}
>
Save game
</Menu.Item>
{selectedId && isSelectedSavedOnRemote && (
<Menu.Item
data-tutorial-id="games-menu-list"
leftSection={<IconList size={16} />}
onClick={() => {
navigate(`/games`);
}}
leftSection={<IconDownload size={16} />}
onClick={() => handleLoadGame(selectedId)}
>
Games list
Load last save
</Menu.Item>
</Menu.Dropdown>
</Menu>
<Button
data-tutorial-id="game-save-button"
className={cx(classes.gameMenuSecondaryButton)}
variant="light"
color="gray"
loading={isSaving}
onClick={() => {
handleSaveGame(selectedId);
}}
>
<IconDeviceFloppy size={16} />
</Button>
</Button.Group>
{isSyncConnected && (
<IconCircleFilled
size={8}
color="var(--mantine-color-green-6)"
style={{ position: 'absolute', top: -2, right: -2 }}
/>
)}
</Box>
)}
<Menu.Divider />
<Menu.Item
data-tutorial-id="games-menu-list"
leftSection={<IconList size={16} />}
onClick={() => {
navigate(`/games`);
}}
>
Games list
</Menu.Item>
</Menu.Dropdown>
</Menu>
<Button
data-tutorial-id="game-save-button"
className={cx(classes.gameMenuSecondaryButton)}
variant="light"
color="gray"
loading={isSaving}
onClick={() => {
handleSaveGame(selectedId);
}}
>
<IconDeviceFloppy size={16} />
</Button>
</Button.Group>
{selectedId && (
<GameDetailModal opened={opened} close={close} gameId={selectedId} />
)}
Expand Down
23 changes: 0 additions & 23 deletions src/games/sync/FactoryPeers.tsx

This file was deleted.

19 changes: 0 additions & 19 deletions src/games/sync/OnlinePeers.tsx

This file was deleted.

Loading
Loading