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

+8
View File
@@ -135,6 +135,14 @@ savestate_thumbnail_enable = true
notification_show_autoconfig = false
input_autodetect_enable = "true"
input_player1_joypad_index = "0"
# Default cores per system
nes_default_core = "nestopia_libretro"
snes_default_core = "snes9x_libretro"
n64_default_core = "mupen64plus_next_libretro"
gb_default_core = "gambatte_libretro"
gbc_default_core = "gambatte_libretro"
gba_default_core = "mgba_libretro"
nds_default_core = "melonds_libretro"
`,
},
},
+208 -46
View File
@@ -1,5 +1,5 @@
import { execSync, exec, ChildProcess } from 'child_process';
import { existsSync, mkdirSync, readdirSync } from 'fs';
import { existsSync, mkdirSync, readdirSync, renameSync } from 'fs';
import { join, dirname, basename, extname } from 'path';
import { app } from 'electron';
import {
@@ -29,7 +29,7 @@ export const knownEmulators: EmulatorConfig[] = [
downloads: {
win32: [
{
url: 'https://dl.dolphin-emu.org/releases/2412/dolphin-2412-x64.7z',
url: 'https://dl.dolphin-emu.org/releases/2606/dolphin-2606-x64.7z',
format: '7z',
executablePath: 'Dolphin.exe',
arch: 'x64',
@@ -37,14 +37,8 @@ export const knownEmulators: EmulatorConfig[] = [
],
darwin: [
{
url: 'https://dl.dolphin-emu.org/releases/2412/dolphin-2412-universal.dmg',
url: 'https://dl.dolphin-emu.org/releases/2606/dolphin-2606-universal.dmg',
format: 'dmg',
arch: 'arm64',
},
{
url: 'https://dl.dolphin-emu.org/releases/2412/dolphin-2412-x64.dmg',
format: 'dmg',
arch: 'x64',
},
],
linux: [
@@ -75,14 +69,14 @@ export const knownEmulators: EmulatorConfig[] = [
downloads: {
win32: [
{
url: 'https://github.com/RPCS3/rpcs3-binaries-win/releases/download/build-d2c3b344332efc6e545a09ad44b9f083c2a1a519/rpcs3-v0.0.34-17491-d2c3b344_win64.7z',
url: 'https://github.com/RPCS3/rpcs3-binaries-win/releases/download/build-4003b017f55f6ba3793469f35927cb5a2815cd22/rpcs3-v0.0.41-19563-4003b017_win64_msvc.7z',
format: '7z',
executablePath: 'rpcs3.exe',
},
],
linux: [
{
url: 'https://github.com/RPCS3/rpcs3-binaries-linux/releases/download/build-d2c3b344332efc6e545a09ad44b9f083c2a1a519/rpcs3-v0.0.34-17491-d2c3b344_linux64.AppImage',
url: 'https://github.com/RPCS3/rpcs3-binaries-linux/releases/download/build-4003b017f55f6ba3793469f35927cb5a2815cd22/rpcs3-v0.0.41-19563-4003b017_linux64.AppImage',
format: 'appimage',
},
],
@@ -145,25 +139,21 @@ export const knownEmulators: EmulatorConfig[] = [
downloads: {
win32: [
{
url: 'https://github.com/PCSX2/pcsx2/releases/download/v2.3.200/pcsx2-v2.3.200-windows-x64-installer.exe',
format: 'exe',
url: 'https://github.com/PCSX2/pcsx2/releases/download/v2.6.3/pcsx2-v2.6.3-windows-x64-Qt.7z',
format: '7z',
executablePath: 'pcsx2-qt.exe',
},
],
darwin: [
{
url: 'https://github.com/PCSX2/pcsx2/releases/download/v2.3.200/pcsx2-v2.3.200-macos-arm64.dmg',
format: 'dmg',
arch: 'arm64',
},
{
url: 'https://github.com/PCSX2/pcsx2/releases/download/v2.3.200/pcsx2-v2.3.200-macos-x64.dmg',
format: 'dmg',
arch: 'x64',
url: 'https://github.com/PCSX2/pcsx2/releases/download/v2.6.3/pcsx2-v2.6.3-macos-Qt.tar.xz',
format: 'tar.xz',
executablePath: 'PCSX2.app/Contents/MacOS/PCSX2',
},
],
linux: [
{
url: 'https://github.com/PCSX2/pcsx2/releases/download/v2.3.200/pcsx2-v2.3.200-linux-x86_64.AppImage',
url: 'https://github.com/PCSX2/pcsx2/releases/download/v2.6.3/pcsx2-v2.6.3-linux-appimage-x64-Qt.AppImage',
format: 'appimage',
},
],
@@ -189,19 +179,21 @@ export const knownEmulators: EmulatorConfig[] = [
downloads: {
win32: [
{
url: 'https://github.com/mamedev/mame/releases/download/mame0276/mame0276_64bit.7z',
format: '7z',
url: 'https://github.com/mamedev/mame/releases/download/mame0288/mame0288b_x64.exe',
format: 'exe',
installerType: 'nsis',
executablePath: 'mame64.exe',
},
],
linux: [
{
url: 'https://github.com/mamedev/mame/releases/download/mame0276/mame0276-x86_64.AppImage',
format: 'appimage',
url: 'https://github.com/mamedev/mame/releases/download/mame0288/mame0288lx.zip',
format: 'zip',
executablePath: 'mame',
},
],
},
packageNames: { linux: 'mame' },
packageNames: { linux: 'mame', darwin: 'mame' },
supported: true,
websiteUrl: {
win32: 'https://www.mamedev.org/release.html',
@@ -279,7 +271,7 @@ export const knownEmulators: EmulatorConfig[] = [
{
url: 'https://buildbot.libretro.com/stable/1.22.2/windows/x86_64/RetroArch.7z',
format: '7z',
executablePath: 'RetroArch.exe',
executablePath: 'retroarch.exe',
},
{
url: 'https://buildbot.libretro.com/stable/1.22.2/windows/x86_64/RetroArch_cores.7z',
@@ -325,6 +317,78 @@ export const knownEmulators: EmulatorConfig[] = [
linux: 'https://retroarch.com/?page=platforms',
},
},
{
id: 'ppsspp',
name: 'PPSSPP',
description: 'PlayStation Portable emulator',
platforms: ['psp'],
defaultPath: {
win32: 'C:\\Program Files\\PPSSPP\\PPSSPP.exe',
darwin: '/Applications/PPSSPP.app/Contents/MacOS/PPSSPP',
linux: '/usr/bin/ppsspp',
},
downloads: {
win32: [
{
url: 'https://github.com/hrydgard/ppsspp/releases/download/v1.20.4/ppsspp_win64_v1.20.4.7z',
format: '7z',
executablePath: 'PPSSPPWindows64.exe',
},
],
darwin: [
{
url: 'https://github.com/hrydgard/ppsspp/releases/download/v1.20.4/PPSSPPSDL-macOS-v1.20.4.zip',
format: 'zip',
executablePath: 'PPSSPPSDL.app/Contents/MacOS/PPSSPPSDL',
},
],
linux: [
{
url: 'https://github.com/hrydgard/ppsspp/releases/download/v1.20.4/PPSSPPSDL_Linux-x64_v1.20.4.AppImage',
format: 'appimage',
},
],
},
supported: true,
websiteUrl: {
win32: 'https://www.ppsspp.org/download/',
darwin: 'https://www.ppsspp.org/download/',
linux: 'https://www.ppsspp.org/download/',
},
},
{
id: 'melonds',
name: 'melonDS',
description: 'Nintendo DS emulator',
platforms: ['nds'],
defaultPath: {
win32: 'C:\\Program Files\\melonDS\\melonDS.exe',
darwin: '/Applications/melonDS.app/Contents/MacOS/melonDS',
linux: '/usr/bin/melonds',
},
downloads: {
win32: [
{
url: 'https://github.com/melonDS-emu/melonDS/releases/download/1.1/melonDS-1.1-win64.zip',
format: 'zip',
executablePath: 'melonDS.exe',
},
],
linux: [
{
url: 'https://github.com/melonDS-emu/melonDS/releases/download/1.1/melonDS-1.1-appimage-x86_64.zip',
format: 'zip',
executablePath: 'melonDS-x86_64.AppImage',
},
],
},
supported: true,
websiteUrl: {
win32: 'https://melonds.kuribo64.net/',
darwin: 'https://melonds.kuribo64.net/',
linux: 'https://melonds.kuribo64.net/',
},
},
];
export function findEmulator(id: string): EmulatorConfig | undefined {
@@ -460,11 +524,15 @@ export function checkEmulator(id: string): EmulatorState {
const path = detectEmulatorPath(config);
const version = path ? detectVersion(path) : undefined;
const hasDownload = config.downloads[platform] && config.downloads[platform]!.length > 0;
const hasPackage = !!config.packageNames?.[platform];
const configClone = { ...config, supported: hasDownload || hasPackage };
return {
installed: !!path,
version,
path,
config,
config: configClone,
configured: !!path && existsSync(join(app.getPath('userData'), 'configs', `${id}.configured`)),
};
}
@@ -573,16 +641,34 @@ function launchArgs(emulatorId: string, romPath: string): string {
}
}
const defaultRomsDir = () => join(require('os').homedir(), 'Documents', 'roms');
const romsSubdirs = [
'nes', 'snes', 'n64', 'gb', 'gbc', 'gba', 'nds',
'ps1', 'ps2', 'ps3', 'psp', 'gc', 'wii', 'switch',
'arcade', 'pce', 'sega-md', 'sega-saturn', 'sega-dc', 'dreamcast',
'other',
];
export function ensureRomsStructure(romsDir?: string): void {
const dir = romsDir || settings.get().romsDirectory || defaultRomsDir();
if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
for (const sub of romsSubdirs) {
const subDir = join(dir, sub);
if (!existsSync(subDir)) mkdirSync(subDir, { recursive: true });
}
}
export function getRomsDirectory(): string {
const s = settings.get();
if (s.romsDirectory && existsSync(s.romsDirectory)) return s.romsDirectory;
const home = require('os').homedir();
const defaultDir = join(home, 'OmniEmu', 'roms');
if (!existsSync(defaultDir)) {
mkdirSync(defaultDir, { recursive: true });
if (s.romsDirectory && existsSync(s.romsDirectory)) {
ensureRomsStructure(s.romsDirectory);
return s.romsDirectory;
}
return defaultDir;
const dir = defaultRomsDir();
ensureRomsStructure(dir);
return dir;
}
export function getEmulatorsDirectory(): string {
@@ -595,15 +681,17 @@ export function getEmulatorsDirectory(): string {
}
export function scanRoms(directory: string): GameEntry[] {
ensureRomsStructure(directory);
const romExtensions = [
'.nes', '.sfc', '.smc', '.n64', '.z64', '.v64',
'.gba', '.gb', '.gbc', '.nds', '.iso', '.bin', '.cue',
'.wbfs', '.wad', '.nsp', '.xci', '.pkg', '.chd',
'.gcm', '.gcz', '.rvz', '.m3u', '.ps2', '.cso',
'.rom', '.zip', '.7z',
'.rom', '.zip', '.7z', '.gdi', '.pbp',
];
const entries: GameEntry[] = [];
const emuPrefs = settings.get().systemEmulators ?? {};
function scanDir(dir: string) {
try {
@@ -616,12 +704,27 @@ export function scanRoms(directory: string): GameEntry[] {
} else {
const ext = extname(file).toLowerCase();
if (romExtensions.includes(ext)) {
const platform = guessPlatform(ext, dir);
const dirName = basename(dir).toLowerCase();
const inCorrectDir = romsSubdirs.includes(dirName) && (dirHints[dirName] === platform || dirName === platform);
let finalPath = fullPath;
if (!inCorrectDir) {
const targetDir = join(directory, platform);
if (!existsSync(targetDir)) mkdirSync(targetDir, { recursive: true });
const targetPath = join(targetDir, file);
try {
renameSync(fullPath, targetPath);
finalPath = targetPath;
} catch { /* skip if move fails */ }
}
entries.push({
id: fullPath,
romPath: fullPath,
id: finalPath,
romPath: finalPath,
title: basename(file, ext),
platform: guessPlatform(ext),
emulatorId: guessEmulator(ext),
platform,
emulatorId: emuPrefs[platform] ?? guessEmulator(ext, platform),
playCount: 0,
addedAt: new Date().toISOString(),
});
@@ -635,17 +738,47 @@ export function scanRoms(directory: string): GameEntry[] {
return applyCachedCovers(entries);
}
function guessPlatform(ext: string): string {
const dirHints: Record<string, string> = {
psp: 'psp', ppsspp: 'psp',
dreamcast: 'dreamcast', dc: 'dreamcast',
saturn: 'sega-saturn', 'sega-saturn': 'sega-saturn', 'sega saturn': 'sega-saturn',
ps1: 'ps1', psx: 'ps1', playstation: 'ps1', 'playstation 1': 'ps1',
ps2: 'ps2', 'playstation 2': 'ps2',
ps3: 'ps3', 'playstation 3': 'ps3',
gc: 'gc', gamecube: 'gc', 'game cube': 'gc',
wii: 'wii',
switch: 'switch', nsw: 'switch',
nes: 'nes', famicom: 'nes',
snes: 'snes', 'super nintendo': 'snes', superfamicom: 'snes', sfc: 'snes',
n64: 'n64', 'nintendo 64': 'n64',
gba: 'gba', 'game boy advance': 'gba',
gb: 'gb', 'game boy': 'gb',
gbc: 'gbc', 'game boy color': 'gbc',
nds: 'nds', ds: 'nds', 'nintendo ds': 'nds',
arcade: 'arcade', mame: 'arcade',
'sega-md': 'sega-md', 'sega genesis': 'sega-md', genesis: 'sega-md', megadrive: 'sega-md', 'mega drive': 'sega-md',
'sega-dc': 'dreamcast',
};
function guessPlatform(ext: string, dirPath?: string): string {
if (dirPath) {
const dirName = basename(dirPath).toLowerCase().replace(/[^a-z0-9\s-]/g, '');
const hint = dirHints[dirName];
if (hint) return hint;
}
const map: Record<string, string> = {
'.nes': 'nes', '.sfc': 'snes', '.smc': 'snes',
'.n64': 'n64', '.z64': 'n64', '.v64': 'n64',
'.gba': 'gba', '.gb': 'gb', '.gbc': 'gbc', '.nds': 'nds',
'.iso': 'ps1', '.bin': 'ps1', '.cue': 'ps1',
'.iso': 'ps1', '.bin': 'ps1', '.cue': 'ps1', '.chd': 'ps1',
'.wbfs': 'wii', '.wad': 'wii',
'.nsp': 'switch', '.xci': 'switch',
'.pkg': 'ps3', '.chd': 'ps1',
'.pkg': 'ps3',
'.gcm': 'gc', '.gcz': 'gc', '.rvz': 'gc',
'.ps2': 'ps2', '.cso': 'ps2',
'.gdi': 'dreamcast',
'.pbp': 'psp',
};
return map[ext] || 'other';
}
@@ -667,7 +800,23 @@ export function uninstallEmulator(id: string): boolean {
return removed;
}
function guessEmulator(ext: string): string {
function guessEmulator(ext: string, platform?: string): string {
if (platform) {
const platformMap: Record<string, string> = {
psp: 'ppsspp',
dreamcast: 'retroarch',
'sega-saturn': 'retroarch',
'sega-dc': 'retroarch',
'sega-md': 'retroarch',
pce: 'retroarch',
nes: 'retroarch', snes: 'retroarch', n64: 'retroarch',
gb: 'retroarch', gbc: 'retroarch', gba: 'retroarch',
nds: 'retroarch',
};
const mapped = platformMap[platform];
if (mapped) return mapped;
}
const map: Record<string, string> = {
'.nes': 'retroarch', '.sfc': 'retroarch', '.smc': 'retroarch',
'.n64': 'retroarch', '.z64': 'retroarch', '.v64': 'retroarch',
@@ -677,9 +826,22 @@ function guessEmulator(ext: string): string {
'.nsp': 'eden', '.xci': 'eden', '.nca': 'eden',
'.pkg': 'rpcs3',
'.bin': 'duckstation', '.cue': 'duckstation', '.iso': 'duckstation',
'.img': 'duckstation', '.m3u': 'duckstation', '.pbp': 'duckstation',
'.img': 'duckstation', '.m3u': 'duckstation',
'.chd': 'duckstation', '.ecm': 'duckstation', '.mds': 'duckstation',
'.ps2': 'pcsx2', '.cso': 'pcsx2',
'.gdi': 'retroarch',
'.pbp': 'ppsspp',
};
return map[ext] || 'retroarch';
}
export function getSystemEmulators(): Record<string, string[]> {
const map: Record<string, string[]> = {};
for (const emu of knownEmulators) {
for (const sys of emu.platforms) {
if (!map[sys]) map[sys] = [];
map[sys].push(emu.id);
}
}
return map;
}
+9
View File
@@ -4,6 +4,8 @@ import { existsSync } from 'fs';
import { registerIpcHandlers } from './ipc';
import { settings } from './settings';
import { isMacOS } from './platform';
import { ensureRomsStructure } from './emulators';
import { setupAutoUpdater } from './updater';
let mainWindow: BrowserWindow | null = null;
let tray: Tray | null = null;
@@ -35,6 +37,10 @@ function createAppIcon() {
function createWindow(): void {
const icon = createAppIcon();
if (isMacOS()) {
app.dock?.setIcon(icon);
}
mainWindow = new BrowserWindow({
width: 1200,
height: 800,
@@ -81,6 +87,7 @@ function createWindow(): void {
function createTray(): void {
const icon = createAppIcon();
const trayIcon = icon.resize({ width: 22, height: 22 });
if (isMacOS()) trayIcon.setTemplateImage(true);
tray = new Tray(trayIcon);
tray.setToolTip('OmniEmu');
@@ -110,6 +117,8 @@ if (!gotLock) {
}
app.whenReady().then(() => {
ensureRomsStructure();
setupAutoUpdater();
registerIpcHandlers();
createWindow();
createTray();
+127 -53
View File
@@ -1,8 +1,8 @@
import { createWriteStream, existsSync, mkdirSync, readdirSync, statSync } from 'fs';
import { join, basename, extname, dirname } from 'path';
import { createWriteStream, existsSync, mkdirSync, readdirSync, statSync, unlinkSync, writeFileSync } from 'fs';
import { join, basename, dirname } from 'path';
import { get as httpsGet, RequestOptions } from 'https';
import { get as httpGet } from 'http';
import { execSync } from 'child_process';
import { spawn, execSync } from 'child_process';
import { pipeline } from 'stream/promises';
import { randomBytes } from 'crypto';
import { app } from 'electron';
@@ -53,20 +53,36 @@ function downloadFile(url: string, dest: string, onProgress: (pct: number) => vo
});
}
function execOrThrow(cmd: string): string {
function execOrThrow(cmd: string, timeoutMs = 300000): string {
try {
return execSync(cmd, { stdio: 'pipe', timeout: 120000 }).toString();
return execSync(cmd, { stdio: 'pipe', timeout: timeoutMs }).toString();
} catch (e: any) {
throw new Error(`Command failed: ${cmd}\n${e.stderr?.toString() || e.message}`);
}
}
/** Run a command with args asynchronously with a timeout */
function runAsync(cmd: string, args: string[], timeoutMs = 300000): Promise<void> {
return new Promise((resolve, reject) => {
const child = spawn(cmd, args, {
stdio: 'pipe',
timeout: timeoutMs,
});
let stderr = '';
child.stderr?.on('data', (data: Buffer) => { stderr += data.toString(); });
child.on('close', (code) => {
if (code === 0) resolve();
else reject(new Error(`Exit code ${code}: ${stderr}`));
});
child.on('error', reject);
});
}
function findAppInDir(dir: string): string | undefined {
const entries = readdirSync(dir, { withFileTypes: true });
const dirs = entries.filter(e => e.isDirectory());
const files = entries.filter(e => e.isFile());
// Check .app bundles first (before cores or other dirs)
for (const e of dirs) {
if (e.name.endsWith('.app')) {
const macosBin = join(dir, e.name, 'Contents', 'MacOS', basename(e.name, '.app'));
@@ -74,7 +90,6 @@ function findAppInDir(dir: string): string | undefined {
}
}
// Then check known executable files in root
for (const e of files) {
const lowerName = e.name.toLowerCase();
const knownNames = ['retroarch', 'dolphin-emu', 'dolphin', 'rpcs3', 'ryujinx', 'eden', 'mame', 'mame64', 'pcsx2', 'duckstation'];
@@ -83,7 +98,6 @@ function findAppInDir(dir: string): string | undefined {
if (isExec) return join(dir, e.name);
}
// Recurse into non-.app directories (skip .app bundles)
for (const e of dirs) {
if (!e.name.endsWith('.app')) {
const found = findAppInDir(join(dir, e.name));
@@ -91,7 +105,6 @@ function findAppInDir(dir: string): string | undefined {
}
}
// Last resort: any executable file in root
for (const e of files) {
try {
if (statSync(join(dir, e.name)).mode & 0o111) return join(dir, e.name);
@@ -101,27 +114,40 @@ function findAppInDir(dir: string): string | undefined {
return undefined;
}
function extractArchive(archivePath: string, destDir: string, format: string, emulatorId: string, onProgress: (msg: string) => void): void {
function get7zaPath(): string {
try {
return require('7zip-bin').path7za;
} catch {
throw new Error('7z extraction requires 7zip-bin package — run: npm install 7zip-bin');
}
}
async function extractArchive(
archivePath: string,
destDir: string,
format: string,
emulatorId: string,
onProgress: (msg: string) => void
): Promise<void> {
if (!existsSync(destDir)) mkdirSync(destDir, { recursive: true });
onProgress(`Extracting ${basename(archivePath)}...`);
switch (format) {
case 'zip':
execOrThrow(`unzip -o "${archivePath}" -d "${destDir}"`);
await runAsync('unzip', ['-o', archivePath, '-d', destDir]);
break;
case 'tar.gz':
execOrThrow(`tar -xzf "${archivePath}" -C "${destDir}"`);
await runAsync('tar', ['-xzf', archivePath, '-C', destDir]);
break;
case 'tar.bz2':
execOrThrow(`tar -xjf "${archivePath}" -C "${destDir}"`);
await runAsync('tar', ['-xjf', archivePath, '-C', destDir]);
break;
case 'tar.xz':
await runAsync('tar', ['-xJf', archivePath, '-C', destDir]);
break;
case '7z': {
try {
execOrThrow(`7z x "${archivePath}" -o"${destDir}" -y`);
} catch {
// Try unzip as fallback (some 7z files are actually zip)
execOrThrow(`unzip -o "${archivePath}" -d "${destDir}"`);
}
const sevenZa = get7zaPath();
await runAsync(sevenZa, ['x', archivePath, `-o${destDir}`, '-y']);
break;
}
case 'dmg': {
@@ -129,7 +155,6 @@ function extractArchive(archivePath: string, destDir: string, format: string, em
const mountPoint = `/tmp/omniemu_${emulatorId}_${randomBytes(4).toString('hex')}`;
try {
execOrThrow(`hdiutil attach "${archivePath}" -mountpoint "${mountPoint}" -nobrowse -quiet`);
// Copy any .app bundles found in the mounted volume
const result = execSync(`ls "${mountPoint}" 2>/dev/null || true`).toString();
for (const item of result.split('\n').filter(Boolean)) {
const src = join(mountPoint, item);
@@ -146,7 +171,6 @@ function extractArchive(archivePath: string, destDir: string, format: string, em
case 'msi':
case 'appimage':
case 'pkg':
// These are installers, not archives
break;
default:
throw new Error(`Unknown archive format: ${format}`);
@@ -154,13 +178,24 @@ function extractArchive(archivePath: string, destDir: string, format: string, em
onProgress('Extraction complete');
}
function runInstaller(installerPath: string, format: string, emulatorId: string, installDir: string, onProgress: (msg: string) => void): void {
onProgress(`Running installer...`);
function runInstaller(
installerPath: string,
format: string,
emulatorId: string,
installDir: string,
installerType?: 'nsis' | 'inno',
onProgress?: (msg: string) => void
): void {
onProgress?.(`Running installer...`);
switch (format) {
case 'exe': {
if (isWindows()) {
execOrThrow(`"${installerPath}" /S /D="${installDir}"`);
if (installerType === 'inno') {
execOrThrow(`"${installerPath}" /VERYSILENT /SUPPRESSMSGBOXES /DIR="${installDir}"`);
} else {
execOrThrow(`"${installerPath}" /S /D="${installDir}"`);
}
} else {
execOrThrow(`chmod +x "${installerPath}" && "${installerPath}"`);
}
@@ -183,13 +218,13 @@ function runInstaller(installerPath: string, format: string, emulatorId: string,
case 'zip':
case 'tar.gz':
case 'tar.bz2':
case 'tar.xz':
case '7z':
// Already handled in extractArchive
break;
default:
throw new Error(`Cannot install format: ${format}`);
}
onProgress('Installer finished');
onProgress?.('Installer finished');
}
export type { ProgressCallback };
@@ -199,10 +234,16 @@ export async function installEmulator(
downloads: EmulatorDownload[],
platform: Platform,
arch: Arch,
onProgress: ProgressCallback
onProgress: ProgressCallback,
packageName?: string,
): Promise<string> {
const candidates = downloads.filter((d) => !d.arch || d.arch === arch);
if (candidates.length === 0) throw new Error(`No download available for ${emulatorId} on ${platform} (${arch})`);
if (candidates.length === 0) {
if (packageName) {
return installViaPackageManager(emulatorId, packageName, platform, onProgress);
}
throw new Error(`No download available for ${emulatorId} on ${platform} (${arch})`);
}
const report = (stage: InstallProgress['stage'], percent: number, message: string) => {
onProgress({ emulatorId, stage, percent, message });
@@ -211,7 +252,7 @@ export async function installEmulator(
const installDir = join(app.getPath('userData'), 'emulators', emulatorId);
if (!existsSync(installDir)) mkdirSync(installDir, { recursive: true });
const archiveFormats = ['zip', 'tar.gz', 'tar.bz2', '7z', 'dmg'];
const archiveFormats = ['zip', 'tar.gz', 'tar.bz2', 'tar.xz', '7z', 'dmg'];
const installerFormats = ['exe', 'msi', 'pkg', 'appimage'];
let totalSteps = candidates.length;
@@ -222,25 +263,27 @@ export async function installEmulator(
report('downloading', Math.round((completedSteps / totalSteps) * 100), `Downloading ${download.url.split('/').pop()}${stepLabel}...`);
const downloadPath = tempName(`.${download.format}`);
await downloadFile(download.url, downloadPath, (pct) => {
report('downloading', Math.round(((completedSteps + pct / 100) / totalSteps) * 100), `Downloading ${download.url.split('/').pop()}${stepLabel}... ${pct}%`);
});
if (archiveFormats.includes(download.format)) {
report('extracting', Math.round((completedSteps / totalSteps) * 100), `Extracting ${download.url.split('/').pop()}${stepLabel}...`);
extractArchive(downloadPath, installDir, download.format, emulatorId, (msg) => {
report('extracting', Math.round(((completedSteps + 0.5) / totalSteps) * 100), msg);
try {
await downloadFile(download.url, downloadPath, (pct) => {
report('downloading', Math.round(((completedSteps + pct / 100) / totalSteps) * 100), `Downloading ${download.url.split('/').pop()}${stepLabel}... ${pct}%`);
});
}
if (installerFormats.includes(download.format)) {
report('installing', Math.round((completedSteps / totalSteps) * 100), `Installing ${download.url.split('/').pop()}${stepLabel}...`);
runInstaller(downloadPath, download.format, emulatorId, installDir, (msg) => {
report('installing', Math.round(((completedSteps + 0.5) / totalSteps) * 100), msg);
});
}
if (archiveFormats.includes(download.format)) {
report('extracting', Math.round((completedSteps / totalSteps) * 100), `Extracting ${download.url.split('/').pop()}${stepLabel}...`);
await extractArchive(downloadPath, installDir, download.format, emulatorId, (msg) => {
report('extracting', Math.round(((completedSteps + 0.5) / totalSteps) * 100), msg);
});
}
try { execSync(`rm -f "${downloadPath}"`); } catch { /* ignore */ }
if (installerFormats.includes(download.format)) {
report('installing', Math.round((completedSteps / totalSteps) * 100), `Installing ${download.url.split('/').pop()}${stepLabel}...`);
runInstaller(downloadPath, download.format, emulatorId, installDir, download.installerType, (msg) => {
report('installing', Math.round(((completedSteps + 0.5) / totalSteps) * 100), msg);
});
}
} finally {
try { unlinkSync(downloadPath); } catch { /* ignore */ }
}
completedSteps++;
}
@@ -249,26 +292,57 @@ export async function installEmulator(
return installDir;
}
/** After install, find the executable in the install dir */
async function installViaPackageManager(
emulatorId: string,
packageName: string,
platform: Platform,
onProgress: ProgressCallback,
): Promise<string> {
const report = (stage: InstallProgress['stage'], percent: number, message: string) => {
onProgress({ emulatorId, stage, percent, message });
};
const installDir = join(app.getPath('userData'), 'emulators', emulatorId);
if (!existsSync(installDir)) mkdirSync(installDir, { recursive: true });
if (platform === 'darwin') {
report('installing', 10, `Installing ${packageName} via Homebrew...`);
execOrThrow(`brew install ${packageName}`, 600000);
try {
const binary = execSync(`which ${emulatorId} 2>/dev/null || which ${packageName} 2>/dev/null`).toString().trim();
if (binary) {
writeFileSync(join(installDir, '.installed'), binary);
}
} catch { /* binary not found via which, ok */ }
report('done', 100, `${emulatorId} installed via Homebrew`);
} else if (platform === 'linux') {
report('installing', 10, `Installing ${packageName} via package manager...`);
try {
execOrThrow(`snap install ${packageName} 2>/dev/null || apt-get install -y ${packageName} 2>/dev/null || echo "fallback"`, 600000);
} catch { /* package manager not available */ }
report('done', 100, `${emulatorId} installed`);
} else {
throw new Error(`Package manager install not supported on ${platform}`);
}
return installDir;
}
export function findInstalledBinary(emulatorId: string, installDir: string, executablePath?: string): string | undefined {
if (!existsSync(installDir)) return undefined;
// Try explicit executablePath first (from download config)
if (executablePath) {
const explicit = join(installDir, executablePath);
if (existsSync(explicit)) return explicit;
}
// macOS: check for .app bundle with several naming variants
if (isMacOS()) {
const appNames = [
`${capitalize(emulatorId)}.app`, // Retroarch.app
`${emulatorId}.app`, // retroarch.app
`${emulatorId.charAt(0).toUpperCase()}${emulatorId.slice(1).toLowerCase()}.app`, // Retroarch.app
`${capitalize(emulatorId)}.app`,
`${emulatorId}.app`,
`${emulatorId.charAt(0).toUpperCase()}${emulatorId.slice(1).toLowerCase()}.app`,
];
// Also check common overrides
if (emulatorId === 'retroarch') {
appNames.unshift('RetroArch.app'); // actual macOS app name
appNames.unshift('RetroArch.app');
}
for (const appName of appNames) {
+38 -4
View File
@@ -12,11 +12,14 @@ import {
findEmulator,
getRomsDirectory,
getEmulatorsDirectory,
getSystemEmulators,
ensureRomsStructure,
} from './emulators';
import { installEmulator, findInstalledBinary } from './installer';
import { applyRecommendedConfig, getPresets, checkConfigured, applyControllerConfig } from './configurator';
import { settings } from './settings';
import { getSystemInfo, platformName, getPlatform, getArch } from './platform';
import { checkForUpdates, downloadUpdate, quitAndInstall } from './updater';
import { InstallProgress, AppSettings, GameEntry } from '../shared/types';
import { addRecentGame, parseGameTitle, buildScrapeTitle, findValidThumbnail, cacheCovers } from './scraper';
import { scanBiosDirectory, getKnownBiosList, getDefaultBiosDir, updateRetroarchBiosPath } from './bios';
@@ -27,7 +30,15 @@ export function registerIpcHandlers(): void {
ipcMain.handle('system:platform-name', () => platformName());
// Emulators
ipcMain.handle('emulators:list', () => knownEmulators);
ipcMain.handle('emulators:list', () => {
const plat = getPlatform();
return knownEmulators.filter(e => {
const hasDownload = e.downloads?.[plat] && e.downloads[plat]!.length > 0;
const hasPackage = !!e.packageNames?.[plat];
return hasDownload || hasPackage;
});
});
ipcMain.handle('emulators:system-assignments', () => getSystemEmulators());
ipcMain.handle('emulators:states', () => getAllEmulatorStates());
ipcMain.handle('emulators:check', (_event, id: string) => checkEmulator(id));
@@ -42,7 +53,8 @@ export function registerIpcHandlers(): void {
const platform = getPlatform();
const arch = getArch();
const downloads = config.downloads[platform];
if (!downloads || downloads.length === 0)
const packageName = config.packageNames?.[platform];
if ((!downloads || downloads.length === 0) && !packageName)
throw new Error(`No downloads available for ${emulatorId} on ${platform}`);
const win = BrowserWindow.fromWebContents(event.sender);
@@ -50,10 +62,10 @@ export function registerIpcHandlers(): void {
win?.webContents.send('emulators:install-progress', p);
};
const installDir = await installEmulator(emulatorId, downloads, platform, arch, sendProgress);
const installDir = await installEmulator(emulatorId, downloads ?? [], platform, arch, sendProgress, config.packageNames?.[platform]);
// Try to find the binary and create a symlink or record it
const download = downloads.filter((d) => !d.arch || d.arch === arch)[0];
const download = (downloads ?? []).filter((d) => !d.arch || d.arch === arch)[0];
const binary = findInstalledBinary(emulatorId, installDir, download?.executablePath);
if (binary) {
const marker = join(installDir, '.installed');
@@ -217,4 +229,26 @@ export function registerIpcHandlers(): void {
// Paths
ipcMain.handle('paths:roms-directory', () => getRomsDirectory());
ipcMain.handle('paths:emulators-directory', () => getEmulatorsDirectory());
// Utilities
ipcMain.handle('utilities:regenerate-roms-structure', () => {
ensureRomsStructure();
return true;
});
// Updates
ipcMain.handle('updates:check', async () => {
await checkForUpdates();
return true;
});
ipcMain.handle('updates:download', async () => {
await downloadUpdate();
return true;
});
ipcMain.handle('updates:quit-and-install', async () => {
quitAndInstall();
return true;
});
}
+23
View File
@@ -17,6 +17,8 @@ const api = {
emulators: {
list: (): Promise<EmulatorConfig[]> => ipcRenderer.invoke('emulators:list'),
systemAssignments: (): Promise<Record<string, string[]>> =>
ipcRenderer.invoke('emulators:system-assignments'),
states: (): Promise<EmulatorState[]> => ipcRenderer.invoke('emulators:states'),
check: (id: string): Promise<EmulatorState> =>
ipcRenderer.invoke('emulators:check', id),
@@ -101,6 +103,27 @@ const api = {
emulatorsDirectory: (): Promise<string> =>
ipcRenderer.invoke('paths:emulators-directory'),
},
utilities: {
regenerateRomsStructure: (): Promise<boolean> =>
ipcRenderer.invoke('utilities:regenerate-roms-structure'),
},
updates: {
check: (): Promise<boolean> => ipcRenderer.invoke('updates:check'),
download: (): Promise<boolean> => ipcRenderer.invoke('updates:download'),
quitAndInstall: (): Promise<boolean> => ipcRenderer.invoke('updates:quit-and-install'),
onStatus: (cb: (status: Record<string, unknown>) => void) => {
const handler = (_event: Electron.IpcRendererEvent, s: Record<string, unknown>) => cb(s);
ipcRenderer.on('updates:status', handler);
return () => ipcRenderer.removeListener('updates:status', handler);
},
onDownloadProgress: (cb: (progress: Record<string, unknown>) => void) => {
const handler = (_event: Electron.IpcRendererEvent, p: Record<string, unknown>) => cb(p);
ipcRenderer.on('updates:download-progress', handler);
return () => ipcRenderer.removeListener('updates:download-progress', handler);
},
},
};
contextBridge.exposeInMainWorld('omni', api);
+62 -22
View File
@@ -46,50 +46,90 @@ const platformThumbDir: Record<string, string> = {
'gc': 'Nintendo_-_GameCube',
'wii': 'Nintendo_-_Wii',
'arcade': 'MAME',
'dreamcast': 'Sega_-_Dreamcast',
};
function safeTitle(title: string): string {
return title.replace(/[:]/g, '').replace(/[/\\?*]/g, '_').trim();
}
/** Build a properly URL-encoded thumbnail URL */
function buildEncodedUrl(dir: string, subdir: string, title: string): string {
const safe = safeTitle(title);
const raw = `${thumbBase}/${dir}/${subdir}/${safe}.png`;
return encodeURI(raw);
}
/** Try multiple URL patterns via GET and return the first valid URL */
function buildMobyGamesUrl(title: string): string {
const q = encodeURIComponent(title.trim());
return `https://www.mobygames.com/search/quick?q=${q}&search=Go`;
}
async function tryFetchImage(url: string): Promise<string | undefined> {
try {
const valid = await urlExists(url);
if (valid) return url;
} catch { /* skip */ }
return undefined;
}
async function tryMobyGames(title: string): Promise<string | undefined> {
const searchUrl = buildMobyGamesUrl(title);
try {
const html = await fetchText(searchUrl);
// Extract first game cover image from search results
const match = html.match(/<img[^>]*class="[^"]*cover[^"]*"[^>]*src="([^"]+)"/i)
|| html.match(/<img[^>]*src="([^"]+)"[^>]*alt="[^"]*Cover[^"]*"/i);
if (match) {
const imgUrl = match[1].startsWith('http') ? match[1] : `https://www.mobygames.com${match[1]}`;
const valid = await urlExists(imgUrl);
if (valid) return imgUrl;
}
} catch { /* skip */ }
return undefined;
}
/** Try multiple URL patterns and return the first valid URL */
export async function findValidThumbnail(title: string, platform: string): Promise<string | undefined> {
// Source 1: libretro-thumbnails
const dir = platformThumbDir[platform];
if (!dir) return undefined;
if (dir) {
const subdirs = ['Named_Boxarts', 'Named_Snaps', 'Named_Titles', 'Named_Logos'];
const titles = new Set<string>();
const urls: string[] = [];
const subdirs = ['Named_Boxarts', 'Named_Snaps'];
const titles = new Set<string>();
titles.add(safeTitle(title));
// Without region codes
const stripped = title.replace(/\([^)]*\)/g, '').trim();
const safeStripped = safeTitle(stripped);
if (safeStripped && safeStripped !== safeTitle(title)) titles.add(safeStripped);
// Try raw title (with region codes)
titles.add(safeTitle(title));
// Try title without region codes
const stripped = title.replace(/\([^)]*\)/g, '').trim();
const safeStripped = safeTitle(stripped);
if (safeStripped && safeStripped !== safeTitle(title)) titles.add(safeStripped);
for (const sub of subdirs) {
for (const t of titles) {
urls.push(buildEncodedUrl(dir, sub, t));
for (const sub of subdirs) {
for (const t of titles) {
const url = buildEncodedUrl(dir, sub, t);
const result = await tryFetchImage(url);
if (result) return result;
}
}
}
for (const url of urls) {
try {
const valid = await urlExists(url);
if (valid) return url;
} catch { /* try next */ }
}
// Source 2: MobyGames (generic)
const mbResult = await tryMobyGames(title);
if (mbResult) return mbResult;
return undefined;
}
function fetchText(url: string): Promise<string> {
return new Promise((resolve, reject) => {
const req = httpsGet(url, { headers: { 'User-Agent': 'OmniEmu/0.1.1' }, timeout: 10000 }, (res) => {
let data = '';
res.on('data', (chunk: string) => data += chunk);
res.on('end', () => resolve(data));
});
req.on('error', reject);
req.on('timeout', () => { req.destroy(); reject(new Error('timeout')); });
});
}
function urlExists(url: string): Promise<boolean> {
return new Promise((resolve) => {
const req = httpsGet(url, {
+10 -1
View File
@@ -9,8 +9,17 @@ function getSettingsPath(): string {
return join(app.getPath('userData'), SETTINGS_FILE);
}
function defaultRomsDir(): string {
try {
const { homedir } = require('os');
return join(homedir(), 'Documents', 'roms');
} catch {
return join(app.getPath('userData'), 'roms');
}
}
const defaultSettings: AppSettings = {
romsDirectory: '',
romsDirectory: defaultRomsDir(),
emulatorsDirectory: '',
theme: 'dark',
minimiseToTray: true,
+65
View File
@@ -0,0 +1,65 @@
import { autoUpdater } from 'electron-updater';
import { BrowserWindow } from 'electron';
autoUpdater.autoDownload = false;
autoUpdater.autoInstallOnAppQuit = false;
export function setupAutoUpdater() {
autoUpdater.on('checking-for-update', () => {
sendToWindows('updates:status', { status: 'checking' });
});
autoUpdater.on('update-available', (info) => {
sendToWindows('updates:status', {
status: 'available',
version: info.version,
releaseDate: info.releaseDate,
releaseNotes: info.releaseNotes,
});
});
autoUpdater.on('update-not-available', (info) => {
sendToWindows('updates:status', {
status: 'not-available',
version: info.version,
});
});
autoUpdater.on('error', (err) => {
sendToWindows('updates:status', { status: 'error', message: err.message });
});
autoUpdater.on('download-progress', (progress) => {
sendToWindows('updates:download-progress', {
percent: Math.round(progress.percent),
bytesPerSecond: progress.bytesPerSecond,
transferred: progress.transferred,
total: progress.total,
});
});
autoUpdater.on('update-downloaded', (info) => {
sendToWindows('updates:status', {
status: 'downloaded',
version: info.version,
});
});
}
function sendToWindows(channel: string, data: unknown) {
BrowserWindow.getAllWindows().forEach((w) => w.webContents.send(channel, data));
}
export function checkForUpdates() {
return autoUpdater.checkForUpdates();
}
export function downloadUpdate() {
return autoUpdater.downloadUpdate();
}
export function quitAndInstall() {
autoUpdater.quitAndInstall();
}
export { autoUpdater };
+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;
+16 -1
View File
@@ -5,7 +5,7 @@ export interface EmulatorDownload {
url: string;
/** Archive type: 'exe' = direct installer, 'msi' = windows msi,
* 'dmg' = macOS disk image, 'appimage' = linux appimage,
* 'tar.gz' | 'tar.bz2' | 'zip' = archive to extract,
* 'tar.gz' | 'tar.bz2' | 'tar.xz' | 'zip' = archive to extract,
* 'pkg' = macOS installer, '7z' = 7zip archive */
format: string;
/** Path inside archive to the executable (if archive format) */
@@ -14,6 +14,8 @@ export interface EmulatorDownload {
size?: number;
/** Only for this arch (omitted = all arches) */
arch?: Arch;
/** Installer type for exe format: 'nsis' (default), 'inno' */
installerType?: 'nsis' | 'inno';
}
export interface EmulatorConfig {
@@ -92,6 +94,8 @@ export interface AppSettings {
recentGames: GameEntry[];
/** Directory for BIOS files */
biosDirectory: string;
/** Per-system preferred emulator override: systemId -> emulatorId */
systemEmulators?: Record<string, string>;
}
export interface SystemInfo {
@@ -108,3 +112,14 @@ export interface EmulatorState {
config: EmulatorConfig;
configured: boolean;
}
export interface UpdateInfo {
available: boolean;
latestVersion: string;
currentVersion: string;
releaseUrl: string;
assetName?: string;
assetUrl?: string;
assetSize?: number;
releaseNotes?: string;
}