import { Modal } from '../Modal'; import { Icon } from '../Icon'; import { GameCover } from '../grid/GameCover'; import { StateChip } from '../StateChip'; import { ActionButton } from '../ActionButton'; import { Game, InstallStatus } from '../../lib/types'; import { deriveState, isInProgress } from '../../lib/gameState'; import { formatBytes, formatEtiVersion, formatPlayers } from '../../lib/format'; interface Props { game: Game; thumbnailUrl: string | null; onClose: () => void; onPrimary: (game: Game) => void; onUninstall: (game: Game) => void; onRemoveDownload: (game: Game) => void; onCancelDownload: (game: Game) => void; onStartServer: (game: Game) => void; onViewFiles: (game: Game) => void; } const tagsFromGame = (game: Game): string[] => { const tags: string[] = []; if (game.genre) tags.push(game.genre); if (game.publisher) tags.push(game.publisher); if (game.release_year) tags.push(game.release_year); return tags; }; const statusLabelFor = (game: Game): string => { switch (deriveState(game)) { case 'installed': return 'Installed'; case 'local': return 'Downloaded'; case 'downloading': return 'Downloading'; case 'busy': return 'Working…'; case 'none': return 'Not downloaded'; } }; export const GameDetailModal = ({ game, thumbnailUrl, onClose, onPrimary, onUninstall, onRemoveDownload, onCancelDownload, onStartServer, onViewFiles, }: Props) => { const tags = tagsFromGame(game); // Some game metadata contains a literal ; keep sanitization exact. const description = game.description.split('').join(''); const canRemoveDownload = game.downloaded && !game.installed && !isInProgress(game.install_status); const canViewFiles = game.downloaded || game.installed || game.install_status === InstallStatus.Downloading || game.install_status === InstallStatus.Installing; return ( {tags.length > 0 && ( {tags.map(t => {t})} )} {game.name} Size {formatBytes(game.size)} Players {formatPlayers(game.max_players)} Version {formatEtiVersion(game.local_version ?? game.eti_game_version)} Status {statusLabelFor(game)} {description && ( {description} )} {game.status_message && ( {game.status_message} )} onPrimary(game)} onCancelDownload={onCancelDownload} /> {game.installed && game.can_host_server === true && ( onStartServer(game)} > Start Server )} {game.installed && ( onUninstall(game)} > Uninstall )} {canRemoveDownload && ( onRemoveDownload(game)} > Remove files )} {canViewFiles && ( <> onViewFiles(game)} > View Files > )} ); };
{description}
{game.status_message}