Extend the launcher design specification and prototype reference with the "Call to Play" multiplayer coordination feature and clean up top-bar chrome. Key additions and changes: - Spec & Roadmap: Document Call to Play mechanics in SPEC.md, including Play Now / Scheduled call flavors, 15-minute check-in windows, top-bar button with active count badge, quick-bar ticker stack above grid, overlay modal, and per-call group chat. Update design/README.md. - Components & Logic: Add calltoplay.jsx and ctp-chat.jsx components for call creation, status progression, and chat. Extend data.jsx with a mock peer roster (PEERS) and helper functions for peer install count tracking. - Top-bar Cleanup: Move game-folder configuration from top bar into Settings -> Library, freeing top-bar space for the Call to Play action button. - Styling & Layout: Add CTP quick-bar, ticker, badge, card, and chat styles to styles.css, and integrate CTP components into launcher.jsx, components.jsx, and SoftLAN Launcher.html. Test Plan: - `git diff --cached --check` -- passed (no trailing whitespace or conflict markers) - `cargo check --workspace` -- passed cleanly - Manual review of staged diff across 9 design/launcher files -- confirmed clean staging
140 lines
6.0 KiB
React
140 lines
6.0 KiB
React
// launcher.jsx — composes top bar + grid into a complete launcher screen
|
|
// Comes in two chrome variants: 'single' (one-row) and 'two' (two-row).
|
|
|
|
function applyFilterAndSort(games, filter, sort, query) {
|
|
let g = filterGames(games, filter);
|
|
if (query.trim()) {
|
|
const q = query.toLowerCase();
|
|
g = g.filter(x => x.title.toLowerCase().includes(q) || x.tags.some(t => t.toLowerCase().includes(q)));
|
|
}
|
|
if (sort === 'az') g = [...g].sort((a, b) => a.title.localeCompare(b.title));
|
|
else if (sort === 'size') g = [...g].sort((a, b) => b.size - a.size);
|
|
else if (sort === 'state') {
|
|
const order = { installed: 0, local: 1, none: 2 };
|
|
g = [...g].sort((a, b) => order[a.state] - order[b.state] || a.title.localeCompare(b.title));
|
|
} else if (sort === 'recent') {
|
|
const order = { installed: 0, local: 1, none: 2 };
|
|
g = [...g].sort((a, b) => order[a.state] - order[b.state] || b.version.localeCompare(a.version));
|
|
} else if (sort === 'peers') {
|
|
g = [...g].sort((a, b) => installedPeersFor(b).length - installedPeersFor(a).length || a.title.localeCompare(b.title));
|
|
}
|
|
return g;
|
|
}
|
|
|
|
function Launcher({
|
|
variant,
|
|
tweaks, setTweak,
|
|
initialFilter = 'all', initialSort = 'recent', initialQuery = '',
|
|
initialOpenGame = null,
|
|
initialSettingsOpen = false,
|
|
seedCallToPlay = [],
|
|
initialCtpOpen = false,
|
|
}) {
|
|
const { density, aspect, accent, bg } = tweaks;
|
|
const [filter, setFilter] = useState(initialFilter);
|
|
const [sort, setSort] = useState(initialSort);
|
|
const [query, setQuery] = useState(initialQuery);
|
|
const [openGame, setOpenGame] = useState(initialOpenGame);
|
|
const [settingsOpen, setSettingsOpen] = useState(initialSettingsOpen);
|
|
const [ctpOpen, setCtpOpen] = useState(initialCtpOpen);
|
|
const [ctpFocusId, setCtpFocusId] = useState(null);
|
|
|
|
const nomUsername = tweaks.username && tweaks.username.trim() ? tweaks.username.trim() : 'you';
|
|
const ctp = useNominations({ username: nomUsername, seed: seedCallToPlay });
|
|
|
|
const counts = useMemo(() => countByFilter(GAMES), []);
|
|
const list = useMemo(() => applyFilterAndSort(GAMES, filter, sort, query), [filter, sort, query]);
|
|
|
|
const menuItems = [
|
|
{ label: 'Settings', onClick: () => setSettingsOpen(true) },
|
|
{ label: 'Refresh library', onClick: () => {} },
|
|
'-',
|
|
{ label: 'Unpack logs', onClick: () => {} },
|
|
{ label: 'About SoftLAN', onClick: () => {} },
|
|
];
|
|
|
|
return (
|
|
<div className={`launcher launcher-${variant} bg-${bg} density-${density}`}
|
|
style={{ '--accent': accent }}>
|
|
{variant === 'single' ? (
|
|
<header className="topbar topbar-single">
|
|
<div className="topbar-left">
|
|
<div className="brand">
|
|
<div className="brand-mark" style={{ background: accent }}>S</div>
|
|
<div className="brand-name">SoftLAN</div>
|
|
</div>
|
|
<div className="topbar-left-trail">
|
|
<SegmentedFilters value={filter} onChange={setFilter} counts={counts} accent={accent}/>
|
|
</div>
|
|
</div>
|
|
<div className="topbar-center">
|
|
<SearchField value={query} onChange={setQuery} accent={accent} wide/>
|
|
</div>
|
|
<div className="topbar-right">
|
|
<div className="topbar-right-lead">
|
|
<SortMenu value={sort} onChange={setSort} accent={accent}/>
|
|
</div>
|
|
<div className="topbar-right-trail">
|
|
<CallToPlayButton nominations={ctp.nominations} onClick={() => setCtpOpen(true)}/>
|
|
<KebabMenu items={menuItems}/>
|
|
</div>
|
|
</div>
|
|
</header>
|
|
) : (
|
|
<header className="topbar topbar-two">
|
|
<div className="topbar-row topbar-row1">
|
|
<div className="brand">
|
|
<div className="brand-mark" style={{ background: accent }}>S</div>
|
|
<div className="brand-name">SoftLAN <span className="brand-name-soft">Launcher</span></div>
|
|
</div>
|
|
<div className="topbar-row1-right">
|
|
<StorageMeter accent={accent}/>
|
|
<CallToPlayButton nominations={ctp.nominations} onClick={() => setCtpOpen(true)}/>
|
|
<KebabMenu items={menuItems}/>
|
|
</div>
|
|
</div>
|
|
<div className="topbar-row topbar-row2">
|
|
<UnderlineFilters value={filter} onChange={setFilter} counts={counts} accent={accent}/>
|
|
<div className="topbar-row2-right">
|
|
<SearchField value={query} onChange={setQuery} accent={accent} wide/>
|
|
<SortMenu value={sort} onChange={setSort} accent={accent}/>
|
|
</div>
|
|
</div>
|
|
</header>
|
|
)}
|
|
|
|
<main className="grid-wrap">
|
|
<CallToPlayTicker nominations={ctp.nominations} accent={accent}
|
|
onOpen={(id) => { setCtpFocusId(id); setCtpOpen(true); }}/>
|
|
{variant === 'single' && (
|
|
<div className="results-bar">
|
|
<div className="results-count">
|
|
Showing <strong>{list.length}</strong> of {counts.all} games
|
|
</div>
|
|
<StorageMeter accent={accent} compact/>
|
|
</div>
|
|
)}
|
|
<div className="grid">
|
|
{list.map(g => (
|
|
<GameCard key={g.id} game={g} accent={accent} aspect={aspect}
|
|
onOpen={(game) => setOpenGame(game)}/>
|
|
))}
|
|
</div>
|
|
</main>
|
|
|
|
{openGame && <GameDetailModal game={openGame} accent={accent} onClose={() => setOpenGame(null)}/>}
|
|
{settingsOpen && setTweak && (
|
|
<SettingsDialog settings={tweaks} onChange={setTweak} onClose={() => setSettingsOpen(false)}/>
|
|
)}
|
|
{ctpOpen && (
|
|
<CallToPlayOverlay nominations={ctp.nominations} username={nomUsername} accent={accent}
|
|
focusId={ctpFocusId}
|
|
onClose={() => { setCtpOpen(false); setCtpFocusId(null); }}
|
|
actions={{ createNomination: ctp.createNomination, respond: ctp.respond, rsvp: ctp.rsvp, sendMessage: ctp.sendMessage, leave: ctp.leave, cancel: ctp.cancel, startNow: ctp.startNow, addTime: ctp.addTime }}/>
|
|
)}
|
|
</div>
|
|
);
|
|
}
|
|
|
|
window.Launcher = Launcher;
|