feat: enhance controller polling and settings management

- Improved controller state comparison in ControllerPage to include button and axis states.
- Added a "Danger Zone" section in SettingsPage for wiping all app data with confirmation prompts.
- Introduced new utilities in UtilitiesPage for auto applying covers and managing filter presets.
- Implemented filter management in a new filters module, allowing for applying and downloading shaders.
- Created an InstallerPage for streamlined emulator installation with quick and custom options.
- Updated types to support new functionalities related to filters and emulator settings.
This commit is contained in:
miles committed 2026-07-16 03:43:37 -05:00
1 parent 9150318662
commit b317bfec4d
22 files changed
+2271 -536

No files matched your search

+32 -8
View File
@@ -9,6 +9,7 @@ import { ControllerPage } from './pages/ControllerPage';
import { UtilitiesPage } from './pages/UtilitiesPage';
import { SaveManagerPage } from './pages/SaveManagerPage';
import { CloudSyncPage } from './pages/CloudSyncPage';
import { InstallerPage } from './pages/InstallerPage';
import { useGamepadNav } from './hooks/useGamepadNav';
type Page = 'dashboard' | 'emulators' | 'library' | 'saves' | 'cloud' | 'settings' | 'controller' | 'utilities';
@@ -24,31 +25,36 @@ export function applyTheme(theme: string) {
export function App() {
const [currentPage, setCurrentPage] = useState<Page>('dashboard');
const [showInstaller, setShowInstaller] = useState(false);
const { connected, showLegend, dismissLegend } = useGamepadNav(setCurrentPage, currentPage);
useEffect(() => {
window.omni.settings.get().then((s) => applyTheme(s.theme));
(async () => {
const s = await window.omni.settings.get();
applyTheme(s.theme);
if (!s.firstSetupComplete) setShowInstaller(true);
})();
}, []);
const renderPage = () => {
switch (currentPage) {
case 'dashboard':
return <Dashboard onNavigate={setCurrentPage} />;
return <ErrorBoundary><Dashboard onNavigate={setCurrentPage} /></ErrorBoundary>;
case 'emulators':
return <EmulatorsPage />;
return <ErrorBoundary><EmulatorsPage /></ErrorBoundary>;
case 'library':
return <LibraryPage />;
return <ErrorBoundary><LibraryPage /></ErrorBoundary>;
case 'saves':
return <SaveManagerPage />;
return <ErrorBoundary><SaveManagerPage /></ErrorBoundary>;
case 'cloud':
return <ErrorBoundary><CloudSyncPage /></ErrorBoundary>;
case 'settings':
return <SettingsPage />;
return <ErrorBoundary><SettingsPage /></ErrorBoundary>;
case 'controller':
return <ControllerPage />;
return <ErrorBoundary><ControllerPage /></ErrorBoundary>;
case 'utilities':
return <UtilitiesPage />;
return <ErrorBoundary><UtilitiesPage /></ErrorBoundary>;
}
};
@@ -61,6 +67,24 @@ export function App() {
</div>
</div>
{showInstaller && (
<div style={{
position: 'fixed', inset: 0, zIndex: 1000,
display: 'flex', alignItems: 'center', justifyContent: 'center',
background: 'rgba(0,0,0,0.7)', backdropFilter: 'blur(6px)',
}}>
<div style={{
width: '90vw', maxWidth: 820, maxHeight: '85vh',
overflowY: 'auto', borderRadius: 16,
background: 'var(--bg-primary, #0f0f1a)',
border: '1px solid var(--border, #333)',
padding: 32,
}}>
<InstallerPage onClose={() => setShowInstaller(false)} />
</div>
</div>
)}
{connected && showLegend && (
<div className="controller-legend" onClick={dismissLegend}>
<span>D-Pad: Navigate</span>
+40 -26
View File
@@ -16,6 +16,7 @@ const platformLabels: Record<string, string> = {
psp: 'PSP', pce: 'PC Engine',
'sega-md': 'Sega Genesis', 'sega-saturn': 'Sega Saturn', 'sega-dc': 'Sega Dreamcast',
dreamcast: 'Dreamcast', arcade: 'Arcade',
lynx: 'Atari Lynx', ngp: 'Neo Geo Pocket', wswan: 'WonderSwan',
};
const badgeBase = 'https://retroachievements.org/Badge/';
@@ -27,6 +28,7 @@ export function GameDetailModal({ game, onClose, onLaunch }: Props) {
const [loadingAchievements, setLoadingAchievements] = useState(false);
const [currentScreenshot, setCurrentScreenshot] = useState(0);
const [showCoverPicker, setShowCoverPicker] = useState(false);
const [coverUrl, setCoverUrl] = useState<string | undefined>(game.coverUrl);
useEffect(() => {
setLoadingMeta(true);
@@ -37,6 +39,12 @@ export function GameDetailModal({ game, onClose, onLaunch }: Props) {
useEffect(() => {
setLoadingAchievements(true);
const supported = ['nes','snes','n64','gb','gbc','gba','nds','gc','wii','ps1','ps2','ps3','psp','pce','sega-md','sega-saturn','sega-dc','dreamcast','arcade'];
if (!supported.includes(game.platform)) {
setAchievements(null);
setLoadingAchievements(false);
return;
}
window.omni.game.achievements(game.romPath, game.title, game.platform)
.then((a) => { setAchievements(a); setLoadingAchievements(false); })
.catch(() => setLoadingAchievements(false));
@@ -44,7 +52,7 @@ export function GameDetailModal({ game, onClose, onLaunch }: Props) {
const screenshots = metadata?.screenshots || [];
const hasScreenshots = screenshots.length > 0;
const displayScreenshot = hasScreenshots ? screenshots[currentScreenshot] : game.coverUrl;
const displayScreenshot = hasScreenshots ? screenshots[currentScreenshot] : coverUrl;
const handleKeyDown = useCallback((e: KeyboardEvent) => {
if (e.key === 'Escape') onClose();
@@ -113,11 +121,11 @@ export function GameDetailModal({ game, onClose, onLaunch }: Props) {
>
Change Cover
</button>
{game.coverUrl && (
{coverUrl && (
<button
className="btn btn-secondary btn-sm"
onClick={async () => {
game.coverUrl = undefined;
setCoverUrl(undefined);
await window.omni.game.cacheCovers([{ romPath: game.romPath, coverUrl: '' }]);
}}
>
@@ -173,30 +181,36 @@ export function GameDetailModal({ game, onClose, onLaunch }: Props) {
</>
)}
<div className="game-detail-achievements">
<h4>
Achievements
{achievements && (
<span className="text-sm text-muted" style={{ fontWeight: 400, marginLeft: 8 }}>
{achievements.userProgress}/{achievements.totalAchievements} · {achievements.totalPoints} pts
</span>
)}
</h4>
{(() => {
const raPlatforms = ['nes','snes','n64','gb','gbc','gba','nds','gc','wii','ps1','ps2','ps3','psp','pce','sega-md','sega-saturn','sega-dc','dreamcast','arcade'];
if (!raPlatforms.includes(game.platform)) return null;
return (
<div className="game-detail-achievements">
<h4>
Achievements
{achievements && (
<span className="text-sm text-muted" style={{ fontWeight: 400, marginLeft: 8 }}>
{achievements.userProgress}/{achievements.totalAchievements} · {achievements.totalPoints} pts
</span>
)}
</h4>
{loadingAchievements ? (
<p className="text-sm text-muted">Loading achievements...</p>
) : achievements ? (
<div className="achievement-list">
{achievements.achievements.map((a) => (
<AchievementRow key={a.id} achievement={a} />
))}
{loadingAchievements ? (
<p className="text-sm text-muted">Loading achievements...</p>
) : achievements ? (
<div className="achievement-list">
{achievements.achievements.map((a) => (
<AchievementRow key={a.id} achievement={a} />
))}
</div>
) : (
<p className="text-sm text-muted">
Add your RetroAchievements Web API Key in Settings &gt; Utilities to see achievements here.
</p>
)}
</div>
) : (
<p className="text-sm text-muted">
Add your RetroAchievements Web API Key in Settings &gt; Utilities to see achievements here.
</p>
)}
</div>
);
})()}
</div>
<button
@@ -215,7 +229,7 @@ export function GameDetailModal({ game, onClose, onLaunch }: Props) {
gameTitle={game.title}
platform={game.platform}
onSelect={async (url) => {
game.coverUrl = url;
setCoverUrl(url);
await window.omni.game.cacheCovers([{ romPath: game.romPath, coverUrl: url }]);
setShowCoverPicker(false);
}}
+405 -264
View File
@@ -31,6 +31,8 @@ export function CloudSyncPage() {
const [togglingSync, setTogglingSync] = useState('');
const [acceptingDevice, setAcceptingDevice] = useState('');
const [acceptingFolder, setAcceptingFolder] = useState('');
const [setupComplete, setSetupComplete] = useState(false);
const [showAddDevice, setShowAddDevice] = useState(false);
const pollRef = useRef<ReturnType<typeof setInterval> | null>(null);
const idRef = useRef<HTMLTextAreaElement>(null);
@@ -50,9 +52,9 @@ export function CloudSyncPage() {
window.omni.cloud.emulatorDirs().catch(() => [] as EmuDir[]),
]);
setCloudEnabled(!!s.cloudSyncEnabled);
setSetupComplete(!!s.cloudSyncSetupComplete);
if (cloudStatus) {
setStatus(cloudStatus);
// Determine which emus are synced
const synced: Record<string, boolean> = {};
for (const d of dirs) {
synced[d.id] = cloudStatus.folders.some(f => f.id === `saves-${d.id}`);
@@ -62,7 +64,6 @@ export function CloudSyncPage() {
setPendingDevices(pendingDev);
setPendingFolders(pendingFol);
setEmuDirs(dirs);
// Auto-resolve folder paths
const paths: Record<string, string> = {};
for (const fol of pendingFol) {
const resolved = await window.omni.cloud.guessPath(fol.folderLabel).catch(() => null);
@@ -99,6 +100,11 @@ export function CloudSyncPage() {
try { await window.omni.settings.save({ cloudSyncEnabled: enabled }); } catch { /* ignore */ }
};
const markSetupComplete = async () => {
setSetupComplete(true);
try { await window.omni.settings.save({ cloudSyncSetupComplete: true }); } catch { /* ignore */ }
};
const handleInstall = async () => {
setInstalling(true); setInstallPercent(0); setInstallMsg('Starting download...');
try {
@@ -113,17 +119,36 @@ export function CloudSyncPage() {
const s = await window.omni.cloud.start();
if (s) {
setStatus(s);
if (s.running) { await saveCloudEnabled(true); showSuccess('Syncthing started!'); setLoading(false); }
else {
if (s.running) {
await saveCloudEnabled(true);
if (!setupComplete) await markSetupComplete();
showSuccess('Syncthing started!');
setLoading(false);
} else {
let attempts = 0;
pollRef.current = setInterval(async () => {
attempts++;
try {
const latest = await window.omni.cloud.status();
setStatus(latest);
if (latest.running) { clearInterval(pollRef.current!); pollRef.current = null; await saveCloudEnabled(true); showSuccess('Syncthing started!'); setLoading(false); }
else if (attempts >= 15) { clearInterval(pollRef.current!); pollRef.current = null; showError('Syncthing took too long to start.'); setLoading(false); }
} catch { if (attempts >= 15) { clearInterval(pollRef.current!); pollRef.current = null; showError('Could not reach Syncthing.'); setLoading(false); } }
if (latest.running) {
clearInterval(pollRef.current!); pollRef.current = null;
await saveCloudEnabled(true);
if (!setupComplete) await markSetupComplete();
showSuccess('Syncthing started!');
setLoading(false);
} else if (attempts >= 15) {
clearInterval(pollRef.current!); pollRef.current = null;
showError('Syncthing took too long to start.');
setLoading(false);
}
} catch {
if (attempts >= 15) {
clearInterval(pollRef.current!); pollRef.current = null;
showError('Could not reach Syncthing.');
setLoading(false);
}
}
}, 1000);
}
} else { showError('Failed to start Syncthing'); setLoading(false); }
@@ -132,8 +157,12 @@ export function CloudSyncPage() {
const handleStop = async () => {
setLoading(true);
try { const s = await window.omni.cloud.stop(); setStatus(s); await saveCloudEnabled(false); showSuccess('Syncthing stopped.'); }
catch (err) { showError(`Stop error: ${err}`); }
try {
const s = await window.omni.cloud.stop();
setStatus(s);
await saveCloudEnabled(false);
showSuccess('Syncthing stopped.');
} catch (err) { showError(`Stop error: ${err}`); }
setLoading(false);
};
@@ -142,7 +171,7 @@ export function CloudSyncPage() {
setAddingDevice(true);
try {
const ok = await window.omni.cloud.addDevice(remoteDeviceId.trim(), remoteDeviceName.trim());
if (ok) { showSuccess('Device added!'); setRemoteDeviceId(''); setRemoteDeviceName(''); loadData(); }
if (ok) { showSuccess('Device added!'); setRemoteDeviceId(''); setRemoteDeviceName(''); setShowAddDevice(false); loadData(); }
else showError('Failed to add device');
} catch (err) { showError(`Error: ${err}`); }
setAddingDevice(false);
@@ -194,9 +223,11 @@ export function CloudSyncPage() {
let step: SetupStep;
if (!installed) step = 'install';
else if (!running) step = 'start';
else if (!forceReady && (status?.remoteDevices?.length ?? 0) === 0) step = 'setup';
else if (!forceReady && !setupComplete && (status?.remoteDevices?.length ?? 0) === 0) step = 'setup';
else step = 'ready';
const showStepCounter = !setupComplete;
const stepLabel = (s: SetupStep) => s === 'install' ? 'Install' : s === 'start' ? 'Start' : s === 'setup' ? 'Pair' : 'Sync';
const stepIdx = (s: SetupStep) => (['install', 'start', 'setup', 'ready'] as SetupStep[]).indexOf(s);
const currentIdx = stepIdx(step);
@@ -211,44 +242,49 @@ export function CloudSyncPage() {
{error && <div className="info-bar mb-4" style={{ color: 'var(--danger, #ff4444)' }}>{error}</div>}
{success && <div className="info-bar mb-4" style={{ color: 'var(--success, #44ff44)' }}>{success}</div>}
{/* Step indicator */}
<div style={{
display: 'flex', gap: 8, marginBottom: 24, alignItems: 'center',
padding: '12px 16px', borderRadius: 10,
background: 'var(--bg-secondary, #1a1a2e)', border: '1px solid var(--border, #333)',
}}>
{(['install', 'start', 'setup', 'ready'] as SetupStep[]).map((s, i) => (
<React.Fragment key={s}>
<div style={{
width: 28, height: 28, borderRadius: '50%', display: 'flex', alignItems: 'center',
justifyContent: 'center', fontSize: 12, fontWeight: 700,
background: step === s ? 'var(--accent)' : currentIdx > i ? 'var(--success, #44ff44)' : 'var(--bg-tertiary, #333)',
color: step === s ? '#fff' : 'var(--text-muted, #888)', transition: 'all 0.2s ease',
}}>
{currentIdx > i ? '✓' : i + 1}
</div>
<span style={{
fontSize: 12, fontWeight: step === s ? 600 : 400,
color: step === s ? 'var(--text)' : 'var(--text-muted, #888)', marginRight: i < 3 ? 8 : 0,
}}>
{stepLabel(s)}
</span>
{i < 3 && <div style={{ flex: 1, height: 2, background: 'var(--bg-tertiary, #333)', maxWidth: 40 }} />}
</React.Fragment>
))}
</div>
{/* Step indicator — only during initial setup */}
{showStepCounter && (
<div style={{
display: 'flex', gap: 8, marginBottom: 24, alignItems: 'center',
padding: '12px 16px', borderRadius: 10,
background: 'var(--bg-secondary, #1a1a2e)', border: '1px solid var(--border, #333)',
}}>
{(['install', 'start', 'setup', 'ready'] as SetupStep[]).map((s, i) => (
<React.Fragment key={s}>
<div style={{
width: 28, height: 28, borderRadius: '50%', display: 'flex', alignItems: 'center',
justifyContent: 'center', fontSize: 12, fontWeight: 700,
background: step === s ? 'var(--accent)' : currentIdx > i ? 'var(--success, #44ff44)' : 'var(--bg-tertiary, #333)',
color: step === s ? '#fff' : 'var(--text-muted, #888)', transition: 'all 0.2s ease',
}}>
{currentIdx > i ? '✓' : i + 1}
</div>
<span style={{
fontSize: 12, fontWeight: step === s ? 600 : 400,
color: step === s ? 'var(--text)' : 'var(--text-muted, #888)', marginRight: i < 3 ? 8 : 0,
}}>
{stepLabel(s)}
</span>
{i < 3 && <div style={{ flex: 1, height: 2, background: 'var(--bg-tertiary, #333)', maxWidth: 40 }} />}
</React.Fragment>
))}
</div>
)}
{/* Status badge */}
{running && (
{(running || setupComplete) && (
<div style={{
display: 'inline-flex', alignItems: 'center', gap: 8, padding: '6px 14px',
borderRadius: 20, marginBottom: 20, fontSize: 13, fontWeight: 600,
background: cloudEnabled ? 'rgba(68,255,68,0.1)' : 'rgba(255,200,68,0.1)',
border: `1px solid ${cloudEnabled ? 'rgba(68,255,68,0.3)' : 'rgba(255,200,68,0.3)'}`,
color: cloudEnabled ? 'var(--success, #44ff44)' : '#ffc844',
background: running && cloudEnabled ? 'rgba(68,255,68,0.1)' : running ? 'rgba(255,200,68,0.1)' : 'rgba(255,100,100,0.1)',
border: `1px solid ${running && cloudEnabled ? 'rgba(68,255,68,0.3)' : running ? 'rgba(255,200,68,0.3)' : 'rgba(255,100,100,0.3)'}`,
color: running && cloudEnabled ? 'var(--success, #44ff44)' : running ? '#ffc844' : 'var(--danger, #ff4444)',
}}>
<span style={{ width: 8, height: 8, borderRadius: '50%', background: cloudEnabled ? 'var(--success, #44ff44)' : '#ffc844' }} />
{cloudEnabled ? 'Cloud sync active' : 'Running — not yet paired'}
<span style={{
width: 8, height: 8, borderRadius: '50%',
background: running && cloudEnabled ? 'var(--success, #44ff44)' : running ? '#ffc844' : 'var(--danger, #ff4444)',
}} />
{running ? (cloudEnabled ? 'Cloud sync active' : 'Running — not yet paired') : 'Syncthing stopped'}
</div>
)}
@@ -286,8 +322,8 @@ export function CloudSyncPage() {
</div>
)}
{/* Step 1: Install */}
{!installed && !installing && (
{/* ── Initial Setup: Step 1 — Install ──────────────── */}
{!setupComplete && !installed && !installing && (
<div className="card mb-4" style={{
border: '2px solid var(--accent)',
background: 'linear-gradient(135deg, rgba(108,99,255,0.08), rgba(108,99,255,0.02))',
@@ -304,7 +340,7 @@ export function CloudSyncPage() {
</div>
)}
{installing && (
{!setupComplete && installing && (
<div className="card mb-4">
<div className="card-header"><h3>Installing Syncthing...</h3></div>
<div style={{ padding: 16 }}>
@@ -319,8 +355,8 @@ export function CloudSyncPage() {
</div>
)}
{/* Step 2: Start */}
{installed && !running && (
{/* ── Initial Setup: Step 2 — Start ────────────────── */}
{!setupComplete && installed && !running && (
<div className="card mb-4" style={{
border: '2px solid var(--accent)',
background: 'linear-gradient(135deg, rgba(108,99,255,0.08), rgba(108,99,255,0.02))',
@@ -337,240 +373,345 @@ export function CloudSyncPage() {
</div>
)}
{/* Steps 3-4 */}
{running && (
{/* ── Initial Setup: Step 3 — Pair ─────────────────── */}
{!setupComplete && step === 'setup' && (
<>
{/* Step 3: Your Device ID + Pair */}
{step === 'setup' && (
<div className="card mb-4">
<div className="card-header"><h3>Step 3 — Pair a Device</h3></div>
<div style={{ padding: 16 }}>
<p className="text-muted text-sm" style={{ marginBottom: 12 }}>
Copy this ID and paste it into the other device. Then enter their ID below.
</p>
<div style={{ marginBottom: 16 }}>
<label className="text-sm text-muted" style={{ display: 'block', marginBottom: 4 }}>Your Device ID</label>
<div style={{ display: 'flex', gap: 8, alignItems: 'center' }}>
<textarea
ref={idRef}
readOnly
value={status?.deviceId || ''}
style={{
flex: 1, fontFamily: 'monospace', fontSize: 11, padding: 8,
borderRadius: 6, border: '1px solid var(--border, #555)',
background: 'var(--bg-tertiary, #222)', color: 'var(--text, #fff)',
resize: 'none', height: 40,
}}
/>
<button className="btn btn-primary btn-sm" onClick={handleCopyDeviceId} style={{ whiteSpace: 'nowrap' }}>
{copied ? 'Copied!' : 'Copy ID'}
</button>
</div>
</div>
<label className="text-sm text-muted" style={{ display: 'block', marginBottom: 4 }}>Add Remote Device</label>
<div style={{ display: 'flex', flexDirection: 'column', gap: 8 }}>
<input
type="text" placeholder="Remote Device ID"
value={remoteDeviceId} onChange={e => setRemoteDeviceId(e.target.value)}
<div className="card mb-4">
<div className="card-header"><h3>Step 3 — Pair a Device</h3></div>
<div style={{ padding: 16 }}>
<p className="text-muted text-sm" style={{ marginBottom: 12 }}>
Copy this ID and paste it into the other device. Then enter their ID below.
</p>
<div style={{ marginBottom: 16 }}>
<label className="text-sm text-muted" style={{ display: 'block', marginBottom: 4 }}>Your Device ID</label>
<div style={{ display: 'flex', gap: 8, alignItems: 'center' }}>
<textarea
ref={idRef}
readOnly
value={status?.deviceId || ''}
style={{
fontFamily: 'monospace', fontSize: 12, padding: '8px 10px',
flex: 1, fontFamily: 'monospace', fontSize: 11, padding: 8,
borderRadius: 6, border: '1px solid var(--border, #555)',
background: 'var(--bg-tertiary, #222)', color: 'var(--text, #fff)',
resize: 'none', height: 40,
}}
/>
<input
type="text" placeholder="Device name (optional)"
value={remoteDeviceName} onChange={e => setRemoteDeviceName(e.target.value)}
style={{
padding: '8px 10px', borderRadius: 6,
border: '1px solid var(--border, #555)',
background: 'var(--bg-tertiary, #222)', color: 'var(--text, #fff)',
}}
/>
<button className="btn btn-primary" onClick={handleAddDevice} disabled={addingDevice || !remoteDeviceId.trim()}>
{addingDevice ? 'Adding...' : '🔗 Pair Device'}
<button className="btn btn-primary btn-sm" onClick={handleCopyDeviceId} style={{ whiteSpace: 'nowrap' }}>
{copied ? 'Copied!' : 'Copy ID'}
</button>
</div>
</div>
<label className="text-sm text-muted" style={{ display: 'block', marginBottom: 4 }}>Add Remote Device</label>
<div style={{ display: 'flex', flexDirection: 'column', gap: 8 }}>
<input
type="text" placeholder="Remote Device ID"
value={remoteDeviceId} onChange={e => setRemoteDeviceId(e.target.value)}
style={{
fontFamily: 'monospace', fontSize: 12, padding: '8px 10px',
borderRadius: 6, border: '1px solid var(--border, #555)',
background: 'var(--bg-tertiary, #222)', color: 'var(--text, #fff)',
}}
/>
<input
type="text" placeholder="Device name (optional)"
value={remoteDeviceName} onChange={e => setRemoteDeviceName(e.target.value)}
style={{
padding: '8px 10px', borderRadius: 6,
border: '1px solid var(--border, #555)',
background: 'var(--bg-tertiary, #222)', color: 'var(--text, #fff)',
}}
/>
<button className="btn btn-primary" onClick={handleAddDevice} disabled={addingDevice || !remoteDeviceId.trim()}>
{addingDevice ? 'Adding...' : '🔗 Pair Device'}
</button>
</div>
</div>
</div>
<button
className="btn btn-primary"
onClick={() => { setForceReady(true); markSetupComplete(); saveCloudEnabled(true); }}
style={{ fontSize: 15, padding: '12px 28px', width: '100%', marginBottom: 16 }}
>
Next →
</button>
</>
)}
{/* ═══════════════════════════════════════════════════════
POST-SETUP MANAGEMENT VIEW
═══════════════════════════════════════════════════════ */}
{setupComplete && (
<>
{/* ── Start Syncthing (if stopped) ─────────────── */}
{installed && !running && (
<div className="card mb-4" style={{
border: '2px solid var(--accent)',
background: 'linear-gradient(135deg, rgba(108,99,255,0.08), rgba(108,99,255,0.02))',
}}>
<div className="card-header"><h3 style={{ margin: 0 }}>Syncthing is stopped</h3></div>
<div style={{ padding: 16 }}>
<p className="text-muted" style={{ marginBottom: 16 }}>
Start the sync service to manage devices and share saves.
</p>
<button className="btn btn-primary" onClick={handleStart} disabled={loading} style={{ fontSize: 15, padding: '12px 28px' }}>
▶ Start Syncthing
</button>
</div>
</div>
)}
{/* Next button — step 3 only */}
{step === 'setup' && (
<button
className="btn btn-primary"
onClick={() => { setForceReady(true); saveCloudEnabled(true); }}
style={{ fontSize: 15, padding: '12px 28px', width: '100%', marginBottom: 16 }}
>
Next →
</button>
)}
{/* Step 4: Sync Dashboard */}
{step === 'ready' && (
<>
{/* Paired Devices */}
<div className="card mb-4">
<div className="card-header"><h3>Paired Devices</h3></div>
<div style={{ padding: '0 12px 12px' }}>
{status?.remoteDevices && status.remoteDevices.filter(d => d.id).length > 0 ? (
status.remoteDevices.filter(d => d.id).map(device => (
<div key={device.id} style={{
display: 'flex', alignItems: 'center', justifyContent: 'space-between',
padding: '8px 10px', borderRadius: 8,
border: '1px solid var(--border, #555)', marginBottom: 4,
background: 'var(--bg-tertiary, #222)',
}}>
<div style={{ flex: 1, minWidth: 0 }}>
<div style={{ fontWeight: 600, fontSize: 13 }}>{device.name || 'Unknown Device'}</div>
<div className="text-sm text-muted" style={{ fontFamily: 'monospace', fontSize: 10 }}>
{device.id.slice(0, 12)}...{device.id.slice(-6)}
</div>
</div>
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
<span style={{ fontSize: 11, color: device.connected ? 'var(--success, #44ff44)' : 'var(--text-muted, #888)' }}>
{device.connected ? 'Connected' : 'Offline'}
</span>
<button className="btn btn-danger btn-sm" onClick={() => handleRemoveDevice(device.id)}>
Remove
</button>
</div>
</div>
))
) : (
<p className="text-muted text-sm" style={{ padding: 8 }}>No devices paired yet.</p>
)}
</div>
</div>
{/* Pending Folder Requests */}
{pendingFolders.length > 0 && (
<div className="card mb-4" style={{ border: '2px solid rgba(255,200,68,0.4)' }}>
<div className="card-header" style={{ background: 'rgba(255,200,68,0.06)' }}>
<h3 style={{ margin: 0 }}>Incoming Folders</h3>
</div>
<div style={{ padding: 12 }}>
{pendingFolders.map(fol => (
<div key={fol.folderId} style={{
padding: '10px 12px', borderRadius: 8,
border: '1px solid rgba(255,200,68,0.25)', marginBottom: 8,
background: 'rgba(255,200,68,0.04)',
}}>
<div style={{ fontWeight: 600, fontSize: 13, marginBottom: 6 }}>{fol.folderLabel}</div>
<div style={{ display: 'flex', gap: 8, alignItems: 'center' }}>
<input
type="text"
value={pendingFolderPaths[fol.folderId] || ''}
onChange={e => setPendingFolderPaths(prev => ({ ...prev, [fol.folderId]: e.target.value }))}
placeholder="Save location (auto-detected)"
style={{
flex: 1, padding: '6px 10px', borderRadius: 6,
border: '1px solid var(--border, #555)',
background: 'var(--bg-secondary, #1a1a1a)', color: 'var(--text, #fff)',
fontFamily: 'monospace', fontSize: 11,
}}
/>
<button
className="btn btn-primary btn-sm"
onClick={() => handleAcceptPendingFolder(fol)}
disabled={acceptingFolder === fol.folderId || !(pendingFolderPaths[fol.folderId] || '').trim()}
style={{ fontSize: 12, whiteSpace: 'nowrap' }}
>
{acceptingFolder === fol.folderId ? '...' : '✓ Accept'}
</button>
</div>
</div>
))}
</div>
</div>
)}
{/* Save Directories — Sync Toggles */}
<div className="card mb-4">
<div className="card-header">
<h3>Save Directories</h3>
</div>
<div style={{ padding: '0 12px 12px' }}>
<p className="text-muted text-sm" style={{ padding: '4px 0 8px' }}>
Toggle sync on for each emulator to start sharing its saves with paired devices.
</p>
{emuDirs.map(emu => {
const synced = !!emuSynced[emu.id];
const busy = togglingSync === emu.id;
return (
<div key={emu.id} style={{
display: 'flex', alignItems: 'center', justifyContent: 'space-between',
padding: '10px 12px', borderRadius: 8,
border: `1px solid ${synced ? 'rgba(68,255,68,0.3)' : 'var(--border, #555)'}`,
marginBottom: 4,
background: synced ? 'rgba(68,255,68,0.04)' : 'var(--bg-tertiary, #222)',
transition: 'all 0.2s ease',
}}>
<div style={{ flex: 1, minWidth: 0 }}>
<div style={{ fontWeight: 600, fontSize: 13 }}>{emu.name}</div>
<div className="text-sm text-muted" style={{ fontFamily: 'monospace', fontSize: 10 }}>
{emu.saves}
</div>
</div>
<button
className="btn btn-sm"
onClick={() => handleToggleSync(emu.id, !synced)}
disabled={busy}
style={{
padding: '6px 14px', borderRadius: 20, fontSize: 12, fontWeight: 600,
background: synced ? 'var(--success, #44ff44)' : 'var(--bg-secondary, #1a1a2e)',
color: synced ? '#000' : 'var(--text-muted, #888)',
border: `1px solid ${synced ? 'var(--success, #44ff44)' : 'var(--border, #555)'}`,
transition: 'all 0.2s ease',
}}
>
{busy ? '...' : synced ? 'Syncing' : 'Off'}
</button>
</div>
);
})}
</div>
</div>
{/* Control bar */}
<div style={{
display: 'flex', alignItems: 'center', justifyContent: 'space-between',
padding: '12px 16px', borderRadius: 10,
background: 'var(--bg-secondary, #1a1a2e)', border: '1px solid var(--border, #333)',
marginBottom: 16,
}}>
<div style={{ display: 'flex', gap: 8 }}>
<button className="btn btn-secondary btn-sm" onClick={loadData} disabled={loading}>
{/* ── Paired Devices ──────────────────────────── */}
{running && (
<div className="card mb-4">
<div className="card-header" style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}>
<h3 style={{ margin: 0 }}>Paired Devices</h3>
<div style={{ display: 'flex', gap: 8, alignItems: 'center' }}>
<button className="btn btn-secondary btn-sm" onClick={loadData} disabled={loading} style={{ fontSize: 12 }}>
Refresh
</button>
<button className="btn btn-primary btn-sm" onClick={() => setShowAddDevice(!showAddDevice)} style={{ fontSize: 12 }}>
{showAddDevice ? 'Cancel' : '+ Add Device'}
</button>
</div>
<button className="btn btn-danger btn-sm" onClick={handleStop} disabled={loading}>
Stop Syncthing
</button>
</div>
{/* Advanced */}
{status?.apiKey && (
<details style={{ marginBottom: 16 }}>
<summary style={{ cursor: 'pointer', fontSize: 13, color: 'var(--text-muted, #888)', padding: '8px 0' }}>
Advanced Settings
</summary>
<div className="card" style={{ marginTop: 8 }}>
<div className="card-header"><h3>Advanced</h3></div>
<div style={{ padding: 12 }}>
<p className="text-muted text-sm" style={{ marginBottom: 8 }}>Syncthing API Key</p>
<code style={{
display: 'block', padding: '6px 10px', borderRadius: 6,
background: 'var(--bg-tertiary, #222)', fontSize: 11, wordBreak: 'break-all',
}}>
{status.apiKey}
</code>
<div style={{ padding: '0 12px 12px' }}>
{/* Add Device form — inline */}
{showAddDevice && (
<div style={{
padding: 12, borderRadius: 8, marginBottom: 8,
border: '1px solid rgba(108,99,255,0.3)', background: 'rgba(108,99,255,0.04)',
}}>
<div style={{ fontWeight: 600, fontSize: 13, marginBottom: 8 }}>Add New Device</div>
<div style={{ marginBottom: 8 }}>
<label className="text-sm text-muted" style={{ display: 'block', marginBottom: 4 }}>Your Device ID</label>
<div style={{ display: 'flex', gap: 8, alignItems: 'center' }}>
<textarea
ref={idRef}
readOnly
value={status?.deviceId || ''}
style={{
flex: 1, fontFamily: 'monospace', fontSize: 11, padding: 8,
borderRadius: 6, border: '1px solid var(--border, #555)',
background: 'var(--bg-tertiary, #222)', color: 'var(--text, #fff)',
resize: 'none', height: 40,
}}
/>
<button className="btn btn-primary btn-sm" onClick={handleCopyDeviceId} style={{ whiteSpace: 'nowrap' }}>
{copied ? 'Copied!' : 'Copy ID'}
</button>
</div>
</div>
<div style={{ display: 'flex', flexDirection: 'column', gap: 8 }}>
<input
type="text" placeholder="Remote Device ID"
value={remoteDeviceId} onChange={e => setRemoteDeviceId(e.target.value)}
style={{
fontFamily: 'monospace', fontSize: 12, padding: '8px 10px',
borderRadius: 6, border: '1px solid var(--border, #555)',
background: 'var(--bg-tertiary, #222)', color: 'var(--text, #fff)',
}}
/>
<input
type="text" placeholder="Device name (optional)"
value={remoteDeviceName} onChange={e => setRemoteDeviceName(e.target.value)}
style={{
padding: '8px 10px', borderRadius: 6,
border: '1px solid var(--border, #555)',
background: 'var(--bg-tertiary, #222)', color: 'var(--text, #fff)',
}}
/>
<button className="btn btn-primary" onClick={handleAddDevice} disabled={addingDevice || !remoteDeviceId.trim()}>
{addingDevice ? 'Adding...' : '🔗 Pair Device'}
</button>
</div>
</div>
</details>
)}
</>
)}
{/* Device list */}
{status?.remoteDevices && status.remoteDevices.filter(d => d.id).length > 0 ? (
status.remoteDevices.filter(d => d.id).map(device => (
<div key={device.id} style={{
display: 'flex', alignItems: 'center', justifyContent: 'space-between',
padding: '8px 10px', borderRadius: 8,
border: '1px solid var(--border, #555)', marginBottom: 4,
background: 'var(--bg-tertiary, #222)',
}}>
<div style={{ flex: 1, minWidth: 0 }}>
<div style={{ fontWeight: 600, fontSize: 13 }}>{device.name || 'Unknown Device'}</div>
<div className="text-sm text-muted" style={{ fontFamily: 'monospace', fontSize: 10 }}>
{device.id.slice(0, 12)}...{device.id.slice(-6)}
</div>
</div>
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
<span style={{ fontSize: 11, color: device.connected ? 'var(--success, #44ff44)' : 'var(--text-muted, #888)' }}>
{device.connected ? 'Connected' : 'Offline'}
</span>
<button className="btn btn-danger btn-sm" onClick={() => handleRemoveDevice(device.id)}>
Remove
</button>
</div>
</div>
))
) : (
<p className="text-muted text-sm" style={{ padding: 8 }}>No devices paired yet. Click "Add Device" to get started.</p>
)}
</div>
</div>
)}
{/* ── Pending Folder Requests ──────────────────── */}
{running && pendingFolders.length > 0 && (
<div className="card mb-4" style={{ border: '2px solid rgba(255,200,68,0.4)' }}>
<div className="card-header" style={{ background: 'rgba(255,200,68,0.06)' }}>
<h3 style={{ margin: 0 }}>Incoming Folders</h3>
</div>
<div style={{ padding: 12 }}>
{pendingFolders.map(fol => (
<div key={fol.folderId} style={{
padding: '10px 12px', borderRadius: 8,
border: '1px solid rgba(255,200,68,0.25)', marginBottom: 8,
background: 'rgba(255,200,68,0.04)',
}}>
<div style={{ fontWeight: 600, fontSize: 13, marginBottom: 6 }}>{fol.folderLabel}</div>
<div style={{ display: 'flex', gap: 8, alignItems: 'center' }}>
<input
type="text"
value={pendingFolderPaths[fol.folderId] || ''}
onChange={e => setPendingFolderPaths(prev => ({ ...prev, [fol.folderId]: e.target.value }))}
placeholder="Save location (auto-detected)"
style={{
flex: 1, padding: '6px 10px', borderRadius: 6,
border: '1px solid var(--border, #555)',
background: 'var(--bg-secondary, #1a1a1a)', color: 'var(--text, #fff)',
fontFamily: 'monospace', fontSize: 11,
}}
/>
<button
className="btn btn-primary btn-sm"
onClick={() => handleAcceptPendingFolder(fol)}
disabled={acceptingFolder === fol.folderId || !(pendingFolderPaths[fol.folderId] || '').trim()}
style={{ fontSize: 12, whiteSpace: 'nowrap' }}
>
{acceptingFolder === fol.folderId ? '...' : '✓ Accept'}
</button>
</div>
</div>
))}
</div>
</div>
)}
{/* ── Save Directories — Sync Toggles ──────────── */}
{running && (
<div className="card mb-4">
<div className="card-header">
<h3>Save Directories</h3>
</div>
<div style={{ padding: '0 12px 12px' }}>
<p className="text-muted text-sm" style={{ padding: '4px 0 8px' }}>
Toggle sync on for each emulator to start sharing its saves with paired devices.
</p>
{emuDirs.map(emu => {
const synced = !!emuSynced[emu.id];
const busy = togglingSync === emu.id;
return (
<div key={emu.id} style={{
display: 'flex', alignItems: 'center', justifyContent: 'space-between',
padding: '10px 12px', borderRadius: 8,
border: `1px solid ${synced ? 'rgba(68,255,68,0.3)' : 'var(--border, #555)'}`,
marginBottom: 4,
background: synced ? 'rgba(68,255,68,0.04)' : 'var(--bg-tertiary, #222)',
transition: 'all 0.2s ease',
}}>
<div style={{ flex: 1, minWidth: 0 }}>
<div style={{ fontWeight: 600, fontSize: 13 }}>{emu.name}</div>
<div className="text-sm text-muted" style={{ fontFamily: 'monospace', fontSize: 10 }}>
{emu.saves}
</div>
</div>
<button
className="btn btn-sm"
onClick={() => handleToggleSync(emu.id, !synced)}
disabled={busy}
style={{
padding: '6px 14px', borderRadius: 20, fontSize: 12, fontWeight: 600,
background: synced ? 'var(--success, #44ff44)' : 'var(--bg-secondary, #1a1a2e)',
color: synced ? '#000' : 'var(--text-muted, #888)',
border: `1px solid ${synced ? 'var(--success, #44ff44)' : 'var(--border, #555)'}`,
transition: 'all 0.2s ease',
}}
>
{busy ? '...' : synced ? 'Syncing' : 'Off'}
</button>
</div>
);
})}
</div>
</div>
)}
{/* ── Stop Syncthing ──────────────────────────── */}
{running && (
<div style={{
display: 'flex', alignItems: 'center', justifyContent: 'space-between',
marginBottom: 16,
}}>
<button className="btn btn-secondary btn-sm" onClick={() => window.omni.cloud.openWebUI()}>
Open Web UI
</button>
<button className="btn btn-danger btn-sm" onClick={handleStop} disabled={loading}>
Stop Syncthing
</button>
</div>
)}
{/* ── Advanced Settings ────────────────────────── */}
{running && status?.apiKey && (
<details style={{ marginBottom: 16 }}>
<summary style={{ cursor: 'pointer', fontSize: 13, color: 'var(--text-muted, #888)', padding: '8px 0' }}>
Advanced Settings
</summary>
<div className="card" style={{ marginTop: 8 }}>
<div className="card-header"><h3>Advanced</h3></div>
<div style={{ padding: 12 }}>
<p className="text-muted text-sm" style={{ marginBottom: 8 }}>Syncthing API Key</p>
<code style={{
display: 'block', padding: '6px 10px', borderRadius: 6,
background: 'var(--bg-tertiary, #222)', fontSize: 11, wordBreak: 'break-all',
}}>
{status.apiKey}
</code>
<div style={{ marginTop: 16, paddingTop: 12, borderTop: '1px solid var(--border, #333)' }}>
<p className="text-muted text-sm" style={{ marginBottom: 8 }}>
Uninstall Syncthing and remove all its data. You can reinstall it anytime.
</p>
<button
className="btn btn-danger btn-sm"
onClick={async () => {
if (!confirm('Uninstall Syncthing? This removes the binary and all sync data.')) return;
setLoading(true);
try {
const ok = await window.omni.cloud.uninstall();
if (ok) {
await window.omni.settings.save({ cloudSyncEnabled: false, cloudSyncSetupComplete: false });
setCloudEnabled(false);
setSetupComplete(false);
setStatus(null);
showSuccess('Syncthing uninstalled.');
loadData();
} else showError('Failed to uninstall');
} catch (err) { showError(`Error: ${err}`); }
setLoading(false);
}}
>
Uninstall Syncthing
</button>
</div>
</div>
</div>
</details>
)}
</>
)}
+9 -2
View File
@@ -67,8 +67,15 @@ export function ControllerPage() {
}
}
setControllers(prev => {
const same = prev.length === connected.length &&
prev.every((c, i) => c.id === connected[i]?.id && c.index === connected[i]?.index);
if (prev.length !== connected.length) return connected;
const same = prev.every((c, i) => {
const n = connected[i];
return c.id === n?.id && c.index === n?.index &&
c.buttons.length === n.buttons.length &&
c.buttons.every((b, j) => b.pressed === n.buttons[j]?.pressed && b.value === n.buttons[j]?.value) &&
c.axes.length === n.axes.length &&
c.axes.every((a, j) => a === n.axes[j]);
});
return same ? prev : connected;
});
rafRef.current = requestAnimationFrame(poll);
+398
View File
@@ -0,0 +1,398 @@
import React, { useEffect, useState, useCallback } from 'react';
import type { EmulatorState, InstallProgress } from '../../shared/types';
type View = 'pick' | 'installing';
const QUICK_PICK_IDS = [
'retroarch', 'dolphin', 'duckstation', 'pcsx2',
'ppsspp', 'flycast', 'mgba', 'melonds',
];
const QUICK_PICK_INFO: Record<string, { systems: string; icon: string }> = {
retroarch: { systems: 'NES, SNES, N64, GBA, GB, Genesis, PS1 & more', icon: '🕹️' },
dolphin: { systems: 'GameCube, Wii', icon: '🎮' },
duckstation: { systems: 'PlayStation 1', icon: '💿' },
pcsx2: { systems: 'PlayStation 2', icon: '💿' },
ppsspp: { systems: 'PSP', icon: '🎮' },
flycast: { systems: 'Dreamcast, Naomi', icon: '🎮' },
mgba: { systems: 'GBA, GB, GBC', icon: '🎮' },
melonds: { systems: 'Nintendo DS', icon: '🎮' },
};
interface InstallJob {
id: string;
name: string;
status: 'queued' | 'installing' | 'done' | 'error';
progress: number;
message: string;
}
interface Props {
onClose: () => void;
}
export function InstallerPage({ onClose }: Props) {
const [view, setView] = useState<View>('pick');
const [mode, setMode] = useState<'quick' | 'custom'>('quick');
const [allStates, setAllStates] = useState<EmulatorState[]>([]);
const [selected, setSelected] = useState<Set<string>>(new Set(QUICK_PICK_IDS));
const [jobs, setJobs] = useState<InstallJob[]>([]);
const [currentIdx, setCurrentIdx] = useState(0);
const [loading, setLoading] = useState(true);
const handleClose = async () => {
await window.omni.settings.save({ firstSetupComplete: true });
onClose();
};
const load = useCallback(async () => {
setLoading(true);
const states = await window.omni.emulators.states();
setAllStates(states);
setLoading(false);
}, []);
useEffect(() => { load(); }, [load]);
useEffect(() => {
const unsub = window.omni.emulators.onInstallProgress((p: InstallProgress) => {
setJobs(prev => prev.map(j => {
if (j.id === p.emulatorId && j.status === 'installing') {
return { ...j, progress: p.percent, message: p.message };
}
return j;
}));
});
return unsub;
}, []);
const toggleQuickPick = (id: string) => {
setSelected(prev => {
const next = new Set(prev);
if (next.has(id)) next.delete(id);
else next.add(id);
return next;
});
};
const toggleAll = () => {
const installable = allStates
.filter(s => !s.installed && s.config.downloads && Object.keys(s.config.downloads).length > 0)
.map(s => s.config.id);
if (selected.size === installable.length) {
setSelected(new Set());
} else {
setSelected(new Set(installable));
}
};
const startInstall = async () => {
const toInstall = allStates
.filter(s => selected.has(s.config.id) && !s.installed)
.map(s => ({ id: s.config.id, name: s.config.name }));
if (toInstall.length === 0) return;
const initial: InstallJob[] = toInstall.map(t => ({
id: t.id, name: t.name, status: 'queued', progress: 0, message: '',
}));
setJobs(initial);
setView('installing');
setCurrentIdx(0);
for (let i = 0; i < toInstall.length; i++) {
setCurrentIdx(i);
setJobs(prev => prev.map((j, idx) =>
idx === i ? { ...j, status: 'installing' as const, message: 'Starting...' } : j
));
try {
await window.omni.emulators.install(toInstall[i].id);
setJobs(prev => prev.map((j, idx) =>
idx === i ? { ...j, status: 'done' as const, progress: 100, message: 'Installed' } : j
));
} catch {
setJobs(prev => prev.map((j, idx) =>
idx === i ? { ...j, status: 'error' as const, message: 'Failed' } : j
));
}
}
await load();
};
const installable = allStates.filter(s => !s.installed && s.config.downloads && Object.keys(s.config.downloads).length > 0);
const alreadyInstalled = allStates.filter(s => s.installed);
const notAvailable = allStates.filter(s => !s.installed && (!s.config.downloads || Object.keys(s.config.downloads).length === 0));
if (loading) return <div className="loading">Loading emulators...</div>;
const allDone = view === 'installing' && jobs.every(j => j.status === 'done' || j.status === 'error');
return (
<div>
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', marginBottom: 8 }}>
<h2 style={{ margin: 0 }}>Welcome to OmniEmu</h2>
<button className="btn btn-secondary btn-sm" onClick={handleClose}>Skip for now</button>
</div>
<p className="text-muted" style={{ marginBottom: 24 }}>
Get started by installing the emulators you need. You can always add more later from the Emulators page.
</p>
{alreadyInstalled.length > 0 && (
<div className="info-bar" style={{ marginBottom: 16 }}>
{alreadyInstalled.length} emulator{alreadyInstalled.length !== 1 ? 's' : ''} already installed
</div>
)}
{view === 'pick' && (
<>
{/* Mode selector */}
<div style={{ display: 'flex', gap: 12, marginBottom: 24 }}>
<button
className="btn"
onClick={() => { setMode('quick'); setSelected(new Set(QUICK_PICK_IDS)); }}
style={{
flex: 1, padding: '16px 20px', borderRadius: 12, textAlign: 'left',
border: `2px solid ${mode === 'quick' ? 'var(--accent)' : 'var(--border)'}`,
background: mode === 'quick' ? 'var(--accent-dim)' : 'var(--bg-secondary)',
transition: 'all 0.2s ease',
}}
>
<div style={{ fontSize: 18, fontWeight: 700, marginBottom: 4, color: 'var(--text-primary)' }}>
⚡ Quick Install
</div>
<div style={{ fontSize: 13, color: 'var(--text-muted)' }}>
{QUICK_PICK_IDS.length} essential emulators covering the most popular systems
</div>
</button>
<button
className="btn"
onClick={() => {
setMode('custom');
setSelected(new Set(installable.map(s => s.config.id)));
}}
style={{
flex: 1, padding: '16px 20px', borderRadius: 12, textAlign: 'left',
border: `2px solid ${mode === 'custom' ? 'var(--accent)' : 'var(--border)'}`,
background: mode === 'custom' ? 'var(--accent-dim)' : 'var(--bg-secondary)',
transition: 'all 0.2s ease',
}}
>
<div style={{ fontSize: 18, fontWeight: 700, marginBottom: 4, color: 'var(--text-primary)' }}>
🎛️ Custom Install
</div>
<div style={{ fontSize: 13, color: 'var(--text-muted)' }}>
Pick exactly which emulators to install
</div>
</button>
</div>
{/* Quick Install — curated grid */}
{mode === 'quick' && (
<div style={{ marginBottom: 24 }}>
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(auto-fill, minmax(280px, 1fr))', gap: 10 }}>
{QUICK_PICK_IDS.map(id => {
const state = allStates.find(s => s.config.id === id);
if (!state) return null;
const info = QUICK_PICK_INFO[id];
const checked = selected.has(id);
const alreadyDone = state.installed;
return (
<div
key={id}
onClick={() => !alreadyDone && toggleQuickPick(id)}
style={{
display: 'flex', alignItems: 'center', gap: 12,
padding: '12px 14px', borderRadius: 10, cursor: alreadyDone ? 'default' : 'pointer',
border: `1px solid ${alreadyDone ? 'var(--success)' : checked ? 'var(--accent)' : 'var(--border)'}`,
background: alreadyDone ? 'var(--bg-tertiary)' : checked ? 'var(--accent-dim)' : 'var(--bg-secondary)',
opacity: alreadyDone ? 0.6 : 1,
transition: 'all 0.15s ease',
}}
>
<div style={{
width: 22, height: 22, borderRadius: 6, display: 'flex', alignItems: 'center',
justifyContent: 'center', fontSize: 13, fontWeight: 700, flexShrink: 0,
border: `2px solid ${alreadyDone ? 'var(--success)' : checked ? 'var(--accent)' : 'var(--border)'}`,
background: alreadyDone ? 'var(--success)' : checked ? 'var(--accent)' : 'transparent',
color: alreadyDone || checked ? '#fff' : 'transparent',
transition: 'all 0.15s ease',
}}>
{alreadyDone ? '✓' : checked ? '✓' : ''}
</div>
<span style={{ fontSize: 20 }}>{info?.icon || '🎮'}</span>
<div style={{ flex: 1, minWidth: 0 }}>
<div style={{ fontWeight: 600, fontSize: 13, color: 'var(--text-primary)' }}>
{state.config.name}
{alreadyDone && <span style={{ color: 'var(--success)', marginLeft: 6, fontSize: 11 }}>Installed</span>}
</div>
<div style={{ fontSize: 11, color: 'var(--text-muted)' }}>
{info?.systems || state.config.platforms.join(', ')}
</div>
</div>
</div>
);
})}
</div>
</div>
)}
{/* Custom Install — full list */}
{mode === 'custom' && (
<div style={{ marginBottom: 24 }}>
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', marginBottom: 10 }}>
<span style={{ fontSize: 13, color: 'var(--text-muted)' }}>
{selected.size} of {installable.length} selected
</span>
<button className="btn btn-secondary btn-sm" onClick={toggleAll}>
{selected.size === installable.length ? 'Deselect All' : 'Select All'}
</button>
</div>
<div style={{ display: 'flex', flexDirection: 'column', gap: 4 }}>
{installable.map(state => {
const checked = selected.has(state.config.id);
return (
<div
key={state.config.id}
onClick={() => toggleQuickPick(state.config.id)}
style={{
display: 'flex', alignItems: 'center', gap: 12,
padding: '10px 14px', borderRadius: 8, cursor: 'pointer',
border: `1px solid ${checked ? 'var(--accent)' : 'var(--border)'}`,
background: checked ? 'var(--accent-dim)' : 'var(--bg-secondary)',
transition: 'all 0.15s ease',
}}
>
<div style={{
width: 20, height: 20, borderRadius: 5, display: 'flex', alignItems: 'center',
justifyContent: 'center', fontSize: 12, fontWeight: 700, flexShrink: 0,
border: `2px solid ${checked ? 'var(--accent)' : 'var(--border)'}`,
background: checked ? 'var(--accent)' : 'transparent',
color: checked ? '#fff' : 'transparent',
transition: 'all 0.15s ease',
}}>
✓
</div>
<div style={{ flex: 1, minWidth: 0 }}>
<div style={{ fontWeight: 600, fontSize: 13, color: 'var(--text-primary)' }}>{state.config.name}</div>
<div style={{ fontSize: 11, color: 'var(--text-muted)' }}>
{state.config.platforms.join(', ')}
</div>
</div>
</div>
);
})}
</div>
{notAvailable.length > 0 && (
<div style={{ marginTop: 16 }}>
<div style={{ fontSize: 13, color: 'var(--text-muted)', marginBottom: 6, fontWeight: 600 }}>
Not available on this platform
</div>
<div style={{ display: 'flex', flexWrap: 'wrap', gap: 6 }}>
{notAvailable.map(s => (
<span key={s.config.id} style={{
padding: '4px 10px', borderRadius: 6, fontSize: 11,
background: 'var(--bg-tertiary)', color: 'var(--text-muted)',
}}>
{s.config.name}
</span>
))}
</div>
</div>
)}
</div>
)}
{/* Install button */}
{selected.size > 0 && (
<button
className="btn btn-primary"
onClick={startInstall}
style={{ fontSize: 16, padding: '14px 32px', width: '100%' }}
>
Install {selected.size} Emulator{selected.size !== 1 ? 's' : ''}
</button>
)}
</>
)}
{/* Installing view */}
{view === 'installing' && (
<div>
<div style={{ display: 'flex', flexDirection: 'column', gap: 4, marginBottom: 24 }}>
{jobs.map((job, i) => (
<div key={job.id} style={{
padding: '10px 14px', borderRadius: 8,
border: `1px solid ${
job.status === 'done' ? 'var(--success)'
: job.status === 'error' ? 'var(--error)'
: job.status === 'installing' ? 'var(--accent)'
: 'var(--border)'
}`,
background: job.status === 'done'
? 'var(--bg-tertiary)'
: job.status === 'error'
? 'var(--bg-tertiary)'
: job.status === 'installing'
? 'var(--accent-dim)'
: 'var(--bg-secondary)',
transition: 'all 0.2s ease',
}}>
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', marginBottom: job.status === 'installing' ? 8 : 0 }}>
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
<span style={{
width: 22, height: 22, borderRadius: '50%', display: 'flex', alignItems: 'center',
justifyContent: 'center', fontSize: 11, fontWeight: 700, flexShrink: 0,
background: job.status === 'done' ? 'var(--success)'
: job.status === 'error' ? 'var(--error)'
: job.status === 'installing' ? 'var(--accent)'
: 'var(--bg-tertiary)',
color: job.status === 'queued' ? 'var(--text-muted)' : '#fff',
}}>
{job.status === 'done' ? '✓' : job.status === 'error' ? '✗' : i + 1}
</span>
<span style={{ fontWeight: 600, fontSize: 13, color: 'var(--text-primary)' }}>{job.name}</span>
</div>
<span style={{ fontSize: 11, color: 'var(--text-muted)' }}>
{job.status === 'done' ? 'Done' : job.status === 'error' ? 'Failed' : job.status === 'installing' ? `${job.progress}%` : 'Waiting...'}
</span>
</div>
{job.status === 'installing' && (
<div style={{ height: 4, borderRadius: 2, background: 'var(--bg-tertiary)', overflow: 'hidden' }}>
<div style={{
height: '100%', borderRadius: 2, width: `${job.progress}%`,
background: 'var(--accent-gradient)',
transition: 'width 0.3s ease',
}} />
</div>
)}
{job.status === 'installing' && job.message && (
<div style={{ fontSize: 11, color: 'var(--text-muted)', marginTop: 4 }}>{job.message}</div>
)}
</div>
))}
</div>
{allDone && (
<div style={{ display: 'flex', flexDirection: 'column', gap: 10 }}>
<div className="info-bar" style={{ textAlign: 'center' }}>
{jobs.filter(j => j.status === 'done').length} installed
{jobs.filter(j => j.status === 'error').length > 0 && ` · ${jobs.filter(j => j.status === 'error').length} failed`}
</div>
<button
className="btn btn-primary"
onClick={handleClose}
style={{ width: '100%' }}
>
Done
</button>
</div>
)}
</div>
)}
</div>
);
}
+18
View File
@@ -420,6 +420,24 @@ export function SettingsPage() {
Built with Electron + React + TypeScript
</p>
</div>
<div className="settings-section" style={{ borderColor: 'var(--error)' }}>
<h3 style={{ color: 'var(--error)' }}>Danger Zone</h3>
<p className="text-sm text-muted" style={{ marginBottom: 12 }}>
Delete all installed emulators, downloaded data, Syncthing config, and reset settings to defaults. Your ROMs will not be affected.
</p>
<button
className="btn btn-danger"
onClick={async () => {
if (!confirm('This will delete all emulators, settings, and app data. Your ROMs are safe. Continue?')) return;
if (!confirm('Are you really sure? This cannot be undone.')) return;
await window.omni.app.nukeData();
window.location.reload();
}}
>
Wipe All Data
</button>
</div>
</div>
);
}
+186
View File
@@ -1,5 +1,11 @@
import React, { useState, useEffect } from 'react';
interface FilterPreset {
id: string;
name: string;
description: string;
}
export function UtilitiesPage() {
const [regenerating, setRegenerating] = useState(false);
const [raUsername, setRaUsername] = useState('');
@@ -9,6 +15,15 @@ export function UtilitiesPage() {
const [saving, setSaving] = useState(false);
const [sgdbKey, setSgdbKey] = useState('');
const [sgdbSaved, setSgdbSaved] = useState(false);
const [autoApplying, setAutoApplying] = useState(false);
const [autoApplyProgress, setAutoApplyProgress] = useState<{ current: number; total: number; title: string } | null>(null);
const [autoApplyResult, setAutoApplyResult] = useState<{ total: number; alreadyHadCover: number; applied: number; failed: number; skippedNoKey?: boolean } | null>(null);
const [clearingCovers, setClearingCovers] = useState(false);
const [filterPresets, setFilterPresets] = useState<FilterPreset[]>([]);
const [applyingFilter, setApplyingFilter] = useState<string | null>(null);
const [filterResult, setFilterResult] = useState<{ message: string; ok: boolean } | null>(null);
const [applyingAll, setApplyingAll] = useState(false);
const [applyAllResult, setApplyAllResult] = useState<string | null>(null);
useEffect(() => {
window.omni.settings.get().then((s) => {
@@ -17,6 +32,7 @@ export function UtilitiesPage() {
setRaApiKey(s.retroAchievementsApiKey || '');
setSgdbKey(s.steamGridDbApiKey || '');
});
window.omni.filters.list().then(setFilterPresets);
}, []);
const handleRecreate = async () => {
@@ -25,6 +41,50 @@ export function UtilitiesPage() {
setTimeout(() => setRegenerating(false), 1500);
};
const handleAutoApply = async () => {
setAutoApplying(true);
setAutoApplyResult(null);
setAutoApplyProgress(null);
const unsub = window.omni.game.onAutoApplyCoversProgress((p) => {
setAutoApplyProgress(p);
});
try {
const result = await window.omni.game.autoApplyCovers();
setAutoApplyResult(result);
} catch {
setAutoApplyResult(null);
}
unsub();
setAutoApplying(false);
setAutoApplyProgress(null);
};
const handleApplyFilter = async (presetId: string) => {
setApplyingFilter(presetId);
setFilterResult(null);
try {
const result = await window.omni.filters.apply(presetId);
setFilterResult({ message: result.message, ok: result.success });
} catch {
setFilterResult({ message: 'Failed to apply filter', ok: false });
}
setTimeout(() => { setApplyingFilter(null); setFilterResult(null); }, 2500);
};
const handleApplyAll = async () => {
setApplyingAll(true);
setApplyAllResult(null);
try {
const results = await window.omni.emulators.applyRecommendedAll(true);
const ok = results.filter(r => r.ok).length;
const fail = results.length - ok;
setApplyAllResult(fail === 0 ? `Applied to ${ok} emulator${ok !== 1 ? 's' : ''} (fullscreen enabled)` : `Applied to ${ok}, failed on ${fail}`);
} catch {
setApplyAllResult('Failed to apply settings');
}
setTimeout(() => { setApplyingAll(false); setApplyAllResult(null); }, 3000);
};
const handleRaSave = async () => {
setSaving(true);
setRaResults(null);
@@ -197,6 +257,132 @@ export function UtilitiesPage() {
</button>
</div>
</div>
<div className="settings-section">
<h3>Auto Apply Covers</h3>
<p className="text-sm text-muted" style={{ marginBottom: 12 }}>
Automatically search SteamGridDB for every ROM in your library that
doesn't have cover art and download the first match. Requires a
SteamGridDB API key above.
</p>
<div className="setting-row">
<div>
{autoApplyProgress && (
<div className="setting-desc">
{autoApplyProgress.title} ({autoApplyProgress.current}/{autoApplyProgress.total})
</div>
)}
</div>
<button
className="btn btn-secondary btn-sm"
disabled={autoApplying || !sgdbKey}
onClick={handleAutoApply}
>
{autoApplying ? 'Running...' : 'Auto Apply Covers'}
</button>
</div>
{autoApplyResult && (
<div style={{ fontSize: 13, marginTop: 8 }}>
{autoApplyResult.skippedNoKey ? (
<span style={{ color: 'var(--error)' }}>No SteamGridDB API key set</span>
) : (
<>
<span style={{ color: 'var(--muted)', marginRight: 10 }}>{autoApplyResult.total} ROMs scanned</span>
<span style={{ color: 'var(--muted)', marginRight: 10 }}>{autoApplyResult.alreadyHadCover} already had covers</span>
<span style={{ color: 'var(--success)', marginRight: 10 }}>{autoApplyResult.applied} applied</span>
{autoApplyResult.failed > 0 && (
<span style={{ color: 'var(--error)' }}>{autoApplyResult.failed} failed</span>
)}
</>
)}
</div>
)}
</div>
<div className="settings-section">
<h3>Recommended Filters</h3>
<p className="text-sm text-muted" style={{ marginBottom: 12 }}>
Apply video filters and shaders to RetroArch. CRT shaders are
downloaded from the libretro shader repository on first use.
</p>
{filterPresets.map((preset) => (
<div className="setting-row" key={preset.id}>
<div>
<div className="setting-label">{preset.name}</div>
<div className="setting-desc">{preset.description}</div>
</div>
<button
className="btn btn-secondary btn-sm"
disabled={applyingFilter !== null}
onClick={() => handleApplyFilter(preset.id)}
>
{applyingFilter === preset.id ? 'Applied!' : 'Apply'}
</button>
</div>
))}
{filterResult && (
<div style={{ fontSize: 13, marginTop: 8, color: filterResult.ok ? 'var(--success)' : 'var(--error)' }}>
{filterResult.message}
</div>
)}
</div>
<div className="settings-section">
<h3>Apply Recommended Settings</h3>
<p className="text-sm text-muted" style={{ marginBottom: 12 }}>
Apply the recommended configuration preset to every installed emulator
at once with fullscreen enabled. This writes optimal defaults for
video, audio, and input.
</p>
<div className="setting-row">
<div />
<button
className="btn btn-primary btn-sm"
disabled={applyingAll}
onClick={handleApplyAll}
>
{applyingAll ? 'Applying...' : 'Apply to All Emulators'}
</button>
</div>
{applyAllResult && (
<div style={{ fontSize: 13, marginTop: 8, color: 'var(--success)' }}>
{applyAllResult}
</div>
)}
</div>
<div className="settings-section">
<h3 style={{ color: 'var(--error)' }}>Danger Zone</h3>
<div className="setting-row">
<div>
<div className="setting-label">Clear game covers</div>
<div className="setting-desc">
Remove all downloaded cover art. Covers will be re-fetched from
SteamGridDB or libretro-thumbnails when you re-scrape.
</div>
</div>
<button
className="btn btn-sm"
style={{ background: 'var(--error)', color: '#fff' }}
disabled={clearingCovers}
onClick={async () => {
if (!window.confirm('Are you sure you want to clear all game covers? This cannot be undone.')) return;
setClearingCovers(true);
await window.omni.game.clearCoverCache();
setTimeout(() => setClearingCovers(false), 1500);
}}
>
{clearingCovers ? 'Cleared!' : 'Clear Covers'}
</button>
</div>
</div>
</div>
);
}
+11
View File
@@ -36,6 +36,7 @@ declare global {
configured: (id: string, installPath?: string) => Promise<boolean>;
openWebsite: (id: string) => Promise<boolean>;
updateControllerConfig: (id: string, installPath: string, controllerName?: string) => Promise<boolean>;
applyRecommendedAll: (fullscreen: boolean) => Promise<{ id: string; ok: boolean }[]>;
onInstallProgress: (cb: (p: InstallProgress) => void) => () => void;
};
decomps: {
@@ -59,9 +60,12 @@ declare global {
clearRecent: () => Promise<boolean>;
scrapeArt: (title: string, platform: string) => Promise<string | undefined>;
cacheCovers: (entries: { romPath: string; coverUrl: string }[]) => Promise<boolean>;
clearCoverCache: () => Promise<boolean>;
searchCoverSGDB: (title: string, platform: string) => Promise<any[]>;
scrapeMetadata: (romPath: string, title: string, platform: string) => Promise<GameMetadata>;
achievements: (romPath: string, title: string, platform: string) => Promise<AchievementInfo | null>;
autoApplyCovers: () => Promise<{ total: number; alreadyHadCover: number; applied: number; failed: number; skippedNoKey?: boolean }>;
onAutoApplyCoversProgress: (cb: (progress: { current: number; total: number; title: string }) => void) => () => void;
};
bios: {
listKnown: () => Promise<any[]>;
@@ -92,6 +96,10 @@ declare global {
retroachievements: {
save: (username: string, password: string) => Promise<Record<string, boolean>>;
};
filters: {
list: () => Promise<{ id: string; name: string; description: string }[]>;
apply: (presetId: string) => Promise<{ success: boolean; message: string; appliedPreset: string }>;
};
updates: {
check: () => Promise<boolean>;
download: () => Promise<boolean>;
@@ -118,6 +126,9 @@ declare global {
toggleFolderSync: (emuId: string, sync: boolean) => Promise<boolean>;
onInstallProgress: (cb: (progress: { stage: string; percent: number; message: string }) => void) => () => void;
};
app: {
nukeData: () => Promise<boolean>;
};
};
}
}