update sorry

This commit is contained in:
miles committed 2026-07-10 02:18:01 -05:00
1 parent 7cbde654ac
commit fa139ea580
20 files changed
+1036 -630

No files matched your search

+19 -2
View File
@@ -1,18 +1,32 @@
import React, { useState } from 'react';
import React, { useState, useEffect } from 'react';
import { Sidebar } from './components/Sidebar';
import { Dashboard } from './pages/Dashboard';
import { EmulatorsPage } from './pages/EmulatorsPage';
import { LibraryPage } from './pages/LibraryPage';
import { SettingsPage } from './pages/SettingsPage';
import { ControllerPage } from './pages/ControllerPage';
import { UtilitiesPage } from './pages/UtilitiesPage';
import { useGamepadNav } from './hooks/useGamepadNav';
type Page = 'dashboard' | 'emulators' | 'library' | 'settings' | 'controller';
type Page = 'dashboard' | 'emulators' | 'library' | 'settings' | 'controller' | 'utilities';
export function applyTheme(theme: string) {
if (theme === 'system') {
const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
document.documentElement.setAttribute('data-theme', prefersDark ? 'dark' : 'light');
} else {
document.documentElement.setAttribute('data-theme', theme);
}
}
export function App() {
useGamepadNav();
const [currentPage, setCurrentPage] = useState<Page>('dashboard');
useEffect(() => {
window.omni.settings.get().then((s) => applyTheme(s.theme));
}, []);
const renderPage = () => {
switch (currentPage) {
case 'dashboard':
@@ -25,6 +39,8 @@ export function App() {
return <SettingsPage />;
case 'controller':
return <ControllerPage />;
case 'utilities':
return <UtilitiesPage />;
}
};
@@ -34,6 +50,7 @@ export function App() {
library: 'Game Library',
settings: 'Settings',
controller: 'Controller',
utilities: 'Utilities',
};
return (
+2 -1
View File
@@ -1,6 +1,6 @@
import React from 'react';
type Page = 'dashboard' | 'emulators' | 'library' | 'settings' | 'controller';
type Page = 'dashboard' | 'emulators' | 'library' | 'settings' | 'controller' | 'utilities';
interface SidebarProps {
currentPage: Page;
@@ -12,6 +12,7 @@ const navItems: { page: Page; label: string; icon: string }[] = [
{ page: 'emulators', label: 'Emulators', icon: '🕹️' },
{ page: 'library', label: 'Game Library', icon: '📚' },
{ page: 'controller', label: 'Controller', icon: '🎮' },
{ page: 'utilities', label: 'Utilities', icon: '🔧' },
{ page: 'settings', label: 'Settings', icon: '⚙️' },
];
+9 -9
View File
@@ -29,12 +29,14 @@ export function useGamepadNav() {
const dpadLeft = gp.buttons[14]?.pressed || gp.axes[0] < -0.6;
const dpadRight = gp.buttons[15]?.pressed || gp.axes[0] > 0.6;
// --- Sidebar navigation with Left/Right ---
// --- Sidebar navigation with Left/Right (only when sidebar is focused) ---
if (dpadLeft && debounced('left')) {
cycleSidebar(-1);
const focused = document.activeElement;
if (focused?.closest('.sidebar')) cycleSidebar(-1);
}
if (dpadRight && debounced('right')) {
cycleSidebar(1);
const focused = document.activeElement;
if (focused?.closest('.sidebar')) cycleSidebar(1);
}
// --- Page content navigation with Up/Down (Tab/Shift+Tab) ---
@@ -44,7 +46,6 @@ export function useGamepadNav() {
if (sidebar) {
cycleSidebar(-1);
} else {
// Focus previous focusable element
const focusable = getFocusableElements();
const idx = focusable.indexOf(focused as HTMLElement);
if (idx > 0) focusable[idx - 1]?.focus();
@@ -63,17 +64,16 @@ export function useGamepadNav() {
}
}
// A button (0) → click
// A button (0) → confirm / click
if (gp.buttons[0]?.pressed && debounced('a')) {
const el = document.activeElement as HTMLElement;
if (el) el.click();
}
// B button (1) → focus sidebar (return to nav)
// B button (1) → back / blur (do not force sidebar)
if (gp.buttons[1]?.pressed && debounced('b')) {
const sideItems = document.querySelectorAll<HTMLElement>(SIDEBAR_SELECTOR);
const active = document.querySelector('.nav-item.active') as HTMLElement;
(active || sideItems[0])?.focus();
const focused = document.activeElement as HTMLElement;
if (focused) focused.blur();
}
// Start (9) → focus first interactive element on page
+202 -7
View File
@@ -1,13 +1,74 @@
import React, { useEffect, useState } from 'react';
import type { AppSettings } from '../../shared/types';
import type { AppSettings, EmulatorConfig } from '../../shared/types';
import { BiosCheckPanel } from '../components/BiosCheckPanel';
import { applyTheme } from '../App';
const systemLabels: Record<string, string> = {
nes: 'NES', snes: 'SNES', n64: 'N64',
gb: 'GB', gbc: 'GBC', gba: 'GBA',
nds: 'NDS', ps1: 'PlayStation', ps2: 'PS2',
ps3: 'PS3', psp: 'PSP', gc: 'GameCube',
wii: 'Wii', switch: 'Switch',
arcade: 'Arcade', pce: 'PC Engine',
'sega-md': 'Sega Mega Drive',
'sega-saturn': 'Sega Saturn',
'sega-dc': 'Sega Dreamcast',
dreamcast: 'Dreamcast',
};
export function SettingsPage() {
const [settings, setSettings] = useState<AppSettings | null>(null);
const [systemAssignments, setSystemAssignments] = useState<Record<string, string[]> | null>(null);
const [emuNameMap, setEmuNameMap] = useState<Record<string, string>>({});
const [saving, setSaving] = useState(false);
const [updateInfo, setUpdateInfo] = useState<{
status: string;
version?: string;
releaseNotes?: string;
message?: string;
} | null>(null);
const [checking, setChecking] = useState(false);
const [downloading, setDownloading] = useState(false);
const [downloadProgress, setDownloadProgress] = useState(0);
useEffect(() => {
window.omni.settings.get().then(setSettings);
const unsubStatus = window.omni.updates.onStatus((s) => {
setChecking(false);
if (s.status === 'available') {
setUpdateInfo({
status: 'available',
version: s.version as string,
releaseNotes: s.releaseNotes as string | undefined,
});
} else if (s.status === 'not-available') {
setUpdateInfo({ status: 'not-available', version: s.version as string });
} else if (s.status === 'downloaded') {
setDownloading(false);
setUpdateInfo((prev) => prev ? { ...prev, status: 'downloaded' } : null);
} else if (s.status === 'error') {
setChecking(false);
setDownloading(false);
setUpdateInfo({ status: 'error', message: s.message as string });
}
});
const unsubProgress = window.omni.updates.onDownloadProgress((p) => {
setDownloadProgress(p.percent as number);
});
return () => { unsubStatus(); unsubProgress(); };
}, []);
useEffect(() => {
Promise.all([
window.omni.settings.get(),
window.omni.emulators.systemAssignments(),
window.omni.emulators.list(),
]).then(([s, assignments, emulators]) => {
setSettings(s);
setSystemAssignments(assignments);
const nameMap: Record<string, string> = {};
for (const e of emulators) nameMap[e.id] = e.name;
setEmuNameMap(nameMap);
});
}, []);
const update = async (partial: Partial<AppSettings>) => {
@@ -18,10 +79,30 @@ export function SettingsPage() {
setSaving(false);
};
if (!settings) {
const handleCheckUpdates = async () => {
setChecking(true);
setUpdateInfo(null);
await window.omni.updates.check();
};
const handleDownloadUpdate = async () => {
setDownloading(true);
setDownloadProgress(0);
await window.omni.updates.download();
};
const handleQuitAndInstall = async () => {
await window.omni.updates.quitAndInstall();
};
if (!settings || !systemAssignments) {
return <div className="loading">Loading settings...</div>;
}
const multiSystems = Object.entries(systemAssignments)
.filter(([, emus]) => emus.length > 1)
.sort(([a], [b]) => a.localeCompare(b));
return (
<div>
<div className="settings-section">
@@ -72,6 +153,47 @@ export function SettingsPage() {
/>
</div>
<div className="settings-section">
<h3>Emulator Assignments</h3>
<p className="text-sm text-muted" style={{ marginBottom: 12 }}>
Choose which emulator handles each system when multiple options exist.
Re-scan your ROMs after changing these preferences.
</p>
{multiSystems.length === 0 ? (
<p className="text-sm text-muted">No systems with multiple emulator options available.</p>
) : (
multiSystems.map(([system, emus]) => (
<div className="setting-row" key={system}>
<div>
<div className="setting-label">
{systemLabels[system] || system}
</div>
<div className="setting-desc">
{emus.map((e) => emuNameMap[e] || e).join(', ')}
</div>
</div>
<select
value={settings.systemEmulators?.[system] ?? emus[0]}
onChange={(e) =>
update({
systemEmulators: {
...(settings.systemEmulators ?? {}),
[system]: e.target.value,
},
})
}
>
{emus.map((emu) => (
<option key={emu} value={emu}>
{emuNameMap[emu] || emu}
</option>
))}
</select>
</div>
))
)}
</div>
<div className="settings-section">
<h3>Appearance</h3>
@@ -82,9 +204,11 @@ export function SettingsPage() {
</div>
<select
value={settings.theme}
onChange={(e) =>
update({ theme: e.target.value as AppSettings['theme'] })
}
onChange={(e) => {
const t = e.target.value as AppSettings['theme'];
applyTheme(t);
update({ theme: t });
}}
>
<option value="dark">Dark</option>
<option value="light">Light</option>
@@ -165,10 +289,81 @@ export function SettingsPage() {
</div>
</div>
<div className="settings-section">
<h3>Updates</h3>
<div className="setting-row">
<div>
<div className="setting-label">Check for updates</div>
<div className="setting-desc">
{updateInfo?.status === 'available' && `v${updateInfo.version} available`}
{updateInfo?.status === 'not-available' && `v${updateInfo.version} — up to date`}
{updateInfo?.status === 'downloaded' && 'Ready to install — restart the app to apply'}
{updateInfo?.status === 'error' && `Error: ${updateInfo.message}`}
{!updateInfo && 'Check GitHub for new releases'}
</div>
</div>
{updateInfo?.status !== 'downloaded' ? (
<button
className="btn btn-secondary btn-sm"
disabled={checking || downloading}
onClick={handleCheckUpdates}
>
{checking ? 'Checking...' : updateInfo ? 'Check Again' : 'Check'}
</button>
) : (
<button
className="btn btn-primary btn-sm"
onClick={handleQuitAndInstall}
>
Restart & Install
</button>
)}
</div>
{updateInfo?.status === 'available' && (
<div className="setting-row">
<div>
<div className="setting-label">
{downloading ? `Downloading... ${downloadProgress}%` : 'Download update'}
</div>
<div className="setting-desc">
{downloading
? `Downloading v${updateInfo.version}`
: downloadProgress > 0
? `Downloaded ${downloadProgress}%`
: `v${updateInfo.version} will be downloaded and installed on restart`}
</div>
</div>
<button
className="btn btn-primary btn-sm"
disabled={downloading || downloadProgress > 0}
onClick={handleDownloadUpdate}
>
{downloading ? `${downloadProgress}%` : downloadProgress > 0 ? 'Downloading...' : 'Download'}
</button>
</div>
)}
{updateInfo?.releaseNotes && (
<details style={{ marginTop: 8 }}>
<summary className="text-sm text-muted" style={{ cursor: 'pointer' }}>
Release notes
</summary>
<pre style={{
marginTop: 8, padding: 8, fontSize: 12,
background: 'var(--surface)', borderRadius: 6,
maxHeight: 200, overflow: 'auto', whiteSpace: 'pre-wrap',
}}>
{typeof updateInfo.releaseNotes === 'string'
? updateInfo.releaseNotes
: JSON.stringify(updateInfo.releaseNotes, null, 2)}
</pre>
</details>
)}
</div>
<div className="settings-section">
<h3>About</h3>
<p className="text-sm text-muted">
OmniEmu v0.1.1 · Cross-platform emulator manager
OmniEmu v{updateInfo?.version || '0.1.1'} · Cross-platform emulator manager
<br />
Built with Electron + React + TypeScript
</p>
+36
View File
@@ -0,0 +1,36 @@
import React, { useState } from 'react';
export function UtilitiesPage() {
const [regenerating, setRegenerating] = useState(false);
const handleRecreate = async () => {
setRegenerating(true);
await window.omni.utilities.regenerateRomsStructure();
setTimeout(() => setRegenerating(false), 1500);
};
return (
<div>
<div className="settings-section">
<h3>ROM Folder Structure</h3>
<div className="setting-row">
<div>
<div className="setting-label">Regenerate ROM folders</div>
<div className="setting-desc">
Recreate the ~/Documents/roms/ folder and all system
subdirectories if any were deleted.
</div>
</div>
<button
className="btn btn-secondary btn-sm"
disabled={regenerating}
onClick={handleRecreate}
>
{regenerating ? 'Done!' : 'Recreate'}
</button>
</div>
</div>
</div>
);
}
+19
View File
@@ -41,6 +41,25 @@
--transition: 150ms ease;
}
[data-theme="light"] {
--bg-primary: #f5f5f8;
--bg-secondary: #ffffff;
--bg-tertiary: #eef0f5;
--bg-card: #ffffff;
--bg-hover: #e8e8f0;
--text-primary: #1a1a2e;
--text-secondary: #555577;
--text-muted: #9999bb;
--accent: #6c63ff;
--accent-hover: #5b52ee;
--accent-dim: rgba(108, 99, 255, 0.1);
--success: #22c55e;
--warning: #d97706;
--error: #dc2626;
--border: #d4d4e0;
--shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}
html, body, #root {
height: 100%;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;