mirror of
https://github.com/mileswolfallen2/OmniEmu2.0.git
synced 2026-12-04 15:57:45 +00:00
feat: Add cloud sync functionality with Syncthing integration
- Implemented cloud sync for game saves, allowing users to sync saves between devices. - Added UI components for managing sync status and toggling sync for individual emulators. - Enhanced SaveManagerPage to display sync status and enable/disable sync for emulator save directories. - Introduced new types for Syncthing folders and updated relevant components to handle cloud sync data. - Updated SettingsPage to reflect new beta features related to cloud sync. - Added new styles for sync-related badges in styles.css. - Introduced decompilation support with a new decomps module, including installation and management of decomp projects. - Added support for various decompilation projects with GitHub integration for downloading and installing. - Updated release notes for version 0.3.0 to include new features and bug fixes.
This commit is contained in:
1 parent
cc14a72f9c
commit
dc5f7e06ae
16 files changed
+2066
-491
No files matched your search
@@ -0,0 +1,100 @@
|
||||
# OmniEmu v0.3.0 Release Notes
|
||||
|
||||
> All your games. One place.
|
||||
|
||||
---
|
||||
|
||||
## What's New
|
||||
|
||||
### Cloud Sync (Beta)
|
||||
Sync your game saves between devices using Syncthing — free, open-source, and fully local. No third-party accounts needed.
|
||||
- Install Syncthing directly from the app (one-click download)
|
||||
- Auto-starts on launch once configured
|
||||
- Host your device or pair with another to share saves
|
||||
- Manage shared folders and paired devices from the Cloud Sync tab
|
||||
- Web UI access for advanced configuration
|
||||
|
||||
### Save Manager
|
||||
Browse, back up, and delete game saves across all your emulators.
|
||||
- Dual view: **By Game** (fuzzy-matched titles) or **By Emulator**
|
||||
- RetroArch saves with recursive core-directory scanning
|
||||
- Custom save directories per emulator
|
||||
- Backup saves before deleting
|
||||
|
||||
### New Emulators
|
||||
Four new emulators added to the library:
|
||||
| Emulator | System | Platforms |
|
||||
|---|---|---|
|
||||
| **Cemu** | Wii U | Windows, macOS, Linux |
|
||||
| **xemu** | Original Xbox | Windows, macOS, Linux |
|
||||
| **Vita3K** | PS Vita | Windows, macOS, Linux |
|
||||
| **Azahar** | Nintendo 3DS | Windows, macOS, Linux |
|
||||
|
||||
### Frontend Support (Beta)
|
||||
Launch alternative frontends directly from OmniEmu:
|
||||
- **ES-DE** — full integration with auto-configuration
|
||||
- **NeoStation** — Flutter-based frontend with ScreenScraper integration
|
||||
- **Pegasus** — automatic collection file generation from your ROM library
|
||||
- **EmuBuddy** — available to all users (not behind beta toggle)
|
||||
|
||||
### Decompilations (Beta)
|
||||
Native PC ports built from reverse-engineered source code — bring your own ROM:
|
||||
- **Ship of Harkinian** (OoT), **2 Ship 2 Harkinian** (MM), **SoH Demo** — Zelda
|
||||
- **Portal 64**, **Banana Mania PC** — additional ports
|
||||
- Auto-download from GitHub releases, built-in ROM management
|
||||
- Supported titles include N64, NDS, GBA, DS, Wii, GameCube, and more
|
||||
|
||||
Enable frontends and decompilations under **Settings > Experimental > Beta Features**.
|
||||
|
||||
### SteamGridDB Cover Art
|
||||
Search and set custom cover art from SteamGridDB's free API.
|
||||
- Search covers from the game detail modal
|
||||
- Thumbnails downloaded locally for instant display
|
||||
- Rate-limit aware with automatic retry
|
||||
- "Reset Cover" button to clear custom art
|
||||
|
||||
### Themes
|
||||
Seven themes available in Settings:
|
||||
- Light, Dark, System (auto)
|
||||
- **Midnight** — deep navy
|
||||
- **Ember** — warm dark
|
||||
- **Lavender** — soft purple
|
||||
- **Jade** — cool teal
|
||||
|
||||
### Horizontal Navigation
|
||||
Redesigned top-bar navigation with full gamepad/controller support:
|
||||
- Spatial D-pad navigation (up/down/left/right between elements)
|
||||
- A to select, B to close modals
|
||||
- LB/RB to switch tabs
|
||||
- Auto-focus on page change
|
||||
|
||||
---
|
||||
|
||||
## Bug Fixes
|
||||
- **RetroArch save detection** — now finds saves in core subdirectories (`saves/Snes9x/file.srm`) and supports portable installs (`~/Documents/RetroArch/saves/`)
|
||||
- **Syncthing install** — fixed macOS extraction from nested zip directory, updated to v2.1.2
|
||||
- **Syncthing blue screen** — fixed IPC handler crashes, pipe buffer deadlock (`stdio: 'pipe'` → `stdio: 'ignore'`), null device ID crash in API response parsing
|
||||
- **Cloud Sync poll leak** — start polling now cleans up on unmount, loading state stays visible during startup
|
||||
- **Cemu macOS** — removed x64-only filter so it installs via Rosetta on ARM Macs
|
||||
- **Vita3K macOS** — added ARM64 DMG variant alongside x64
|
||||
- **RetroArch cores 404** — removed broken `RetroArch_cores.7z` download (use RetroArch's Online Updater instead)
|
||||
- **BIOS folder scan** — `scanRoms()` now skips BIOS directories
|
||||
- **CSS accent colors** — replaced hardcoded colors with `color-mix()` using theme variables
|
||||
- **Duplicate CSS** — renamed `.platform-tag` conflict to `.platform-tag-accent`
|
||||
- **Unused imports** — cleaned up `require()` calls, dead imports, stale `types.d.ts`
|
||||
|
||||
---
|
||||
|
||||
## System Requirements
|
||||
- **OS:** Windows 10+, macOS 11+, Ubuntu 20.04+
|
||||
- **Disk:** ~200 MB for app + emulators vary
|
||||
- **RAM:** 4 GB minimum
|
||||
|
||||
---
|
||||
|
||||
## Supported Emulators (18 total)
|
||||
RetroArch, Dolphin, RPCS3, Cemu, xemu, Vita3K, Azahar, Eden, PPSSPP, DuckStation, PCSX2, Flycast, Dolphin (trio), Yuzu (legacy), mGBA, MelonDS, and more.
|
||||
|
||||
---
|
||||
|
||||
*Built with Electron, React, and TypeScript.*
|
||||
@@ -0,0 +1,656 @@
|
||||
import { existsSync, mkdirSync, readFileSync, rmSync, readdirSync, writeFileSync } from 'fs';
|
||||
import { join, extname } from 'path';
|
||||
import { app, shell } from 'electron';
|
||||
import { exec } from 'child_process';
|
||||
import { DecompProject, DecompState, Platform } from '../shared/types';
|
||||
import { getPlatform } from './platform';
|
||||
import { settings } from './settings';
|
||||
|
||||
const platform = getPlatform();
|
||||
|
||||
export const knownDecomps: DecompProject[] = [
|
||||
// ── N64 Ports ──────────────────────────────────────────────
|
||||
{
|
||||
id: 'soh',
|
||||
name: 'Ship of Harkinian',
|
||||
description: 'The Legend of Zelda: Ocarina of Time — 60 FPS, 4K, randomizer, mods',
|
||||
platform: 'N64',
|
||||
githubUrl: 'https://github.com/HarbourMasters/Shipwright',
|
||||
githubRepo: 'HarbourMasters/Shipwright',
|
||||
executablePath: {
|
||||
win32: 'soh.exe',
|
||||
darwin: 'soh.app/Contents/MacOS/soh',
|
||||
linux: 'soh',
|
||||
},
|
||||
romExtensions: ['.z64', '.n64', '.v64'],
|
||||
requiresRom: true,
|
||||
features: ['60 FPS game logic', '4K rendering', 'Built-in randomizer', 'Mod loader', 'Gyro / motion aiming', 'HD texture replacement'],
|
||||
},
|
||||
{
|
||||
id: '2s2h',
|
||||
name: '2Ship2Harkinian',
|
||||
description: "The Legend of Zelda: Majora's Mask — 60 FPS, widescreen, randomizer mods",
|
||||
platform: 'N64',
|
||||
githubUrl: 'https://github.com/HarbourMasters/2ship2harkinian',
|
||||
githubRepo: 'HarbourMasters/2ship2harkinian',
|
||||
executablePath: {
|
||||
win32: '2s2h.exe',
|
||||
darwin: '2s2h.app/Contents/MacOS/2s2h',
|
||||
linux: '2s2h',
|
||||
},
|
||||
romExtensions: ['.z64', '.n64', '.v64'],
|
||||
requiresRom: true,
|
||||
features: ['60 FPS game logic', 'Widescreen & 4K', 'Randomizer mod support', 'Shared engine with SoH'],
|
||||
},
|
||||
{
|
||||
id: 'sm64pc',
|
||||
name: 'Super Mario 64',
|
||||
description: 'SM64 PC Port — uncapped FPS, 4K, mod loader, analog camera',
|
||||
platform: 'N64',
|
||||
githubUrl: 'https://github.com/sm64pc/sm64ex',
|
||||
githubRepo: 'sm64pc/sm64ex',
|
||||
executablePath: {
|
||||
win32: 'build\\release\\sm64.pex64.exe',
|
||||
darwin: 'build/release/sm64.fat.macos',
|
||||
linux: 'build/release/sm64.pex64',
|
||||
},
|
||||
romExtensions: ['.z64', '.n64', '.v64'],
|
||||
requiresRom: true,
|
||||
features: ['Uncapped framerate', '4K & ultrawide', 'Mod loader', 'Analog camera', 'Controller remapping'],
|
||||
},
|
||||
{
|
||||
id: 'starship',
|
||||
name: 'Star Fox 64',
|
||||
description: 'Starship — widescreen, gyro aiming, rumble, HD textures',
|
||||
platform: 'N64',
|
||||
githubUrl: 'https://github.com/HarbourMasters/Starship',
|
||||
githubRepo: 'HarbourMasters/Starship',
|
||||
executablePath: {
|
||||
win32: 'starship.exe',
|
||||
darwin: 'starship.app/Contents/MacOS/starship',
|
||||
linux: 'starship',
|
||||
},
|
||||
romExtensions: ['.z64', '.n64', '.v64'],
|
||||
requiresRom: true,
|
||||
features: ['Widescreen & ultrawide', 'Gyro aiming', 'HD texture packs', 'Force feedback / rumble'],
|
||||
},
|
||||
{
|
||||
id: 'banjo-recomp',
|
||||
name: 'Banjo-Kazooie',
|
||||
description: 'Banjo: Recompiled — dual-stick camera, ultrawide, instant loading',
|
||||
platform: 'N64',
|
||||
githubUrl: 'https://github.com/Wiseguy/Banjo-Recompiled',
|
||||
githubRepo: 'Wiseguy/Banjo-Recompiled',
|
||||
executablePath: {
|
||||
win32: 'Banjo.exe',
|
||||
darwin: '',
|
||||
linux: 'banjo',
|
||||
},
|
||||
romExtensions: ['.z64', '.n64', '.v64'],
|
||||
requiresRom: true,
|
||||
features: ['Dual-stick free camera', 'Ultrawide support', 'Near-instant loading', 'High-resolution rendering'],
|
||||
},
|
||||
{
|
||||
id: 'perfect-dark',
|
||||
name: 'Perfect Dark',
|
||||
description: 'Perfect Dark PC — high-res, modern dual-stick controls, bots',
|
||||
platform: 'N64',
|
||||
githubUrl: 'https://github.com/perfect-dark-decomp/perfect-dark',
|
||||
githubRepo: 'perfect-dark-decomp/perfect-dark',
|
||||
executablePath: {
|
||||
win32: 'pd.exe',
|
||||
darwin: '',
|
||||
linux: 'perfect-dark',
|
||||
},
|
||||
romExtensions: ['.z64', '.n64', '.v64'],
|
||||
requiresRom: true,
|
||||
features: ['High-resolution output', 'Modern dual-stick controls', 'Bot support', 'Widescreen', 'Improved framerate'],
|
||||
},
|
||||
{
|
||||
id: 'mk64recomp',
|
||||
name: 'Mario Kart 64',
|
||||
description: 'SpaghettiKart — widescreen, higher FPS, online multiplayer',
|
||||
platform: 'N64',
|
||||
githubUrl: 'https://github.com/n64decomp/mk64',
|
||||
githubRepo: 'n64decomp/mk64',
|
||||
executablePath: {
|
||||
win32: 'mk64.exe',
|
||||
darwin: '',
|
||||
linux: 'mk64',
|
||||
},
|
||||
romExtensions: ['.z64', '.n64', '.v64'],
|
||||
requiresRom: true,
|
||||
features: ['Widescreen & ultrawide', 'Higher framerate', 'Online multiplayer via mods', 'Custom track loading'],
|
||||
},
|
||||
{
|
||||
id: 'bm64recomp',
|
||||
name: 'Bomberman 64',
|
||||
description: 'BM64Recomp — native PC rendering, widescreen, configurable controls',
|
||||
platform: 'N64',
|
||||
githubUrl: 'https://github.com/Bomberman64Recomp/BM64Recomp',
|
||||
githubRepo: 'Bomberman64Recomp/BM64Recomp',
|
||||
executablePath: {
|
||||
win32: 'BM64.exe',
|
||||
darwin: '',
|
||||
linux: 'bm64',
|
||||
},
|
||||
romExtensions: ['.z64', '.n64', '.v64'],
|
||||
requiresRom: true,
|
||||
features: ['Native PC rendering', 'Widescreen support', 'Configurable controls'],
|
||||
},
|
||||
{
|
||||
id: 'bmherorecomp',
|
||||
name: 'Bomberman Hero',
|
||||
description: 'BMHeroRecomp — native PC recompilation with modern controls',
|
||||
platform: 'N64',
|
||||
githubUrl: 'https://github.com/BombermanHeroRecomp/BMHeroRecomp',
|
||||
githubRepo: 'BombermanHeroRecomp/BMHeroRecomp',
|
||||
executablePath: {
|
||||
win32: 'BMHero.exe',
|
||||
darwin: '',
|
||||
linux: 'bmhero',
|
||||
},
|
||||
romExtensions: ['.z64', '.n64', '.v64'],
|
||||
requiresRom: true,
|
||||
features: ['Native PC rendering', 'Widescreen support', 'Companion to BM64Recomp'],
|
||||
},
|
||||
{
|
||||
id: 'banjo-tooie-recomp',
|
||||
name: 'Banjo-Tooie',
|
||||
description: 'Banjo-Tooie Recomp — native PC with widescreen and higher framerates',
|
||||
platform: 'N64',
|
||||
githubUrl: 'https://github.com/banjo-tooie-recomp/banjo-tooie-recomp',
|
||||
githubRepo: 'banjo-tooie-recomp/banjo-tooie-recomp',
|
||||
executablePath: {
|
||||
win32: 'BanjoTooie.exe',
|
||||
darwin: '',
|
||||
linux: 'banjo-tooie',
|
||||
},
|
||||
romExtensions: ['.z64', '.n64', '.v64'],
|
||||
requiresRom: true,
|
||||
features: ['Native PC executable', 'Widescreen support', 'Higher framerates', 'Controller remapping'],
|
||||
},
|
||||
{
|
||||
id: 'dk64recomp',
|
||||
name: 'Donkey Kong 64',
|
||||
description: "DK64 Recomp — Rare's DK64 with native rendering and modern controls",
|
||||
platform: 'N64',
|
||||
githubUrl: 'https://github.com/DK64Recomp/DK64Recomp',
|
||||
githubRepo: 'DK64Recomp/DK64Recomp',
|
||||
executablePath: {
|
||||
win32: 'DK64.exe',
|
||||
darwin: '',
|
||||
linux: 'dk64',
|
||||
},
|
||||
romExtensions: ['.z64', '.n64', '.v64'],
|
||||
requiresRom: true,
|
||||
features: ['Native rendering', 'High resolution', 'Widescreen support', 'Modern controller support'],
|
||||
},
|
||||
{
|
||||
id: 'kirby64recomp',
|
||||
name: 'Kirby 64: The Crystal Shards',
|
||||
description: 'Kirby64 Recomp — native PC with higher resolutions and widescreen',
|
||||
platform: 'N64',
|
||||
githubUrl: 'https://github.com/Kirby64Recomp/Kirby64Recomp',
|
||||
githubRepo: 'Kirby64Recomp/Kirby64Recomp',
|
||||
executablePath: {
|
||||
win32: 'Kirby64.exe',
|
||||
darwin: '',
|
||||
linux: 'kirby64',
|
||||
},
|
||||
romExtensions: ['.z64', '.n64', '.v64'],
|
||||
requiresRom: true,
|
||||
features: ['Native rendering', 'Higher resolutions', 'Widescreen support', 'Controller remapping'],
|
||||
},
|
||||
// ── GameCube Ports ─────────────────────────────────────────
|
||||
{
|
||||
id: 'dusklight',
|
||||
name: 'Zelda: Twilight Princess',
|
||||
description: 'Dusklight — native 60 FPS, 4K, HD textures, mod loader',
|
||||
platform: 'GameCube',
|
||||
githubUrl: 'https://github.com/TwilitRealm/dusklight',
|
||||
githubRepo: 'TwilitRealm/dusklight',
|
||||
executablePath: {
|
||||
win32: 'dusklight.exe',
|
||||
darwin: '',
|
||||
linux: 'dusklight',
|
||||
},
|
||||
romExtensions: ['.iso', '.gcm', '.rvz', '.gcz'],
|
||||
requiresRom: true,
|
||||
features: ['Native 60 FPS', '4K rendering', 'HD texture packs', 'Mod loader', 'Widescreen & ultrawide'],
|
||||
},
|
||||
// ── SNES Ports ─────────────────────────────────────────────
|
||||
{
|
||||
id: 'zelda3',
|
||||
name: 'Zelda: A Link to the Past',
|
||||
description: 'zelda3 — clean decompilation, widescreen, higher resolution',
|
||||
platform: 'SNES',
|
||||
githubUrl: 'https://github.com/snesrev/zelda3',
|
||||
githubRepo: 'snesrev/zelda3',
|
||||
executablePath: {
|
||||
win32: 'zelda3.exe',
|
||||
darwin: 'zelda3',
|
||||
linux: 'zelda3',
|
||||
},
|
||||
romExtensions: ['.sfc', '.smc'],
|
||||
requiresRom: true,
|
||||
features: ['Clean annotated codebase', 'Widescreen support', 'Higher resolution rendering', 'Mod-friendly structure'],
|
||||
},
|
||||
// ── GBA Ports ──────────────────────────────────────────────
|
||||
{
|
||||
id: 'tmcpicori',
|
||||
name: 'Zelda: The Minish Cap',
|
||||
description: 'Project Picori — native PC port with higher resolution',
|
||||
platform: 'GBA',
|
||||
githubUrl: 'https://github.com/999sian/tmc',
|
||||
githubRepo: '999sian/tmc',
|
||||
executablePath: {
|
||||
win32: 'tmc.exe',
|
||||
darwin: '',
|
||||
linux: 'tmc',
|
||||
},
|
||||
romExtensions: ['.gba'],
|
||||
requiresRom: true,
|
||||
features: ['Native PC rendering', 'Higher internal resolution', 'Preservation-focused build'],
|
||||
},
|
||||
// ── PS2 Ports ──────────────────────────────────────────────
|
||||
{
|
||||
id: 'opengoal',
|
||||
name: 'Jak and Daxter',
|
||||
description: 'OpenGOAL — full trilogy (Jak 1, 2, 3) with modding language',
|
||||
platform: 'PS2',
|
||||
githubUrl: 'https://github.com/open-goal/jak-project',
|
||||
githubRepo: 'open-goal/jak-project',
|
||||
executablePath: {
|
||||
win32: 'gk.exe',
|
||||
darwin: 'gk.app/Contents/MacOS/gk',
|
||||
linux: 'gk',
|
||||
},
|
||||
romExtensions: ['.iso'],
|
||||
requiresRom: true,
|
||||
features: ['Full trilogy (Jak 1, 2, 3)', 'OpenGOAL modding language', 'Widescreen & 4K', 'Launcher with auto-updates'],
|
||||
},
|
||||
// ── Xbox 360 / PS3 Ports ──────────────────────────────────
|
||||
{
|
||||
id: 'unleashedrecomp',
|
||||
name: 'Sonic Unleashed',
|
||||
description: 'UnleashedRecomp — Hedgehog Engine RT, 60 FPS+, ultrawide',
|
||||
platform: 'Xbox 360 / PS3',
|
||||
githubUrl: 'https://github.com/hedge-dev/UnleashedRecomp',
|
||||
githubRepo: 'hedge-dev/UnleashedRecomp',
|
||||
executablePath: {
|
||||
win32: 'UnleashedRecomp.exe',
|
||||
darwin: '',
|
||||
linux: '',
|
||||
},
|
||||
romExtensions: ['.iso'],
|
||||
requiresRom: true,
|
||||
features: ['Hedgehog Engine path tracing', '60 FPS+ with fixed logic', 'Ultrawide support', 'Mod support via HMM'],
|
||||
},
|
||||
];
|
||||
|
||||
// ── State Management ──────────────────────────────────────────
|
||||
|
||||
function getDecompDir(id: string): string {
|
||||
return join(app.getPath('userData'), 'emulators', id);
|
||||
}
|
||||
|
||||
function getMarkerFile(id: string): string {
|
||||
return join(getDecompDir(id), '.installed');
|
||||
}
|
||||
|
||||
function getRomConfigFile(): string {
|
||||
return join(app.getPath('userData'), 'decomps', 'roms.json');
|
||||
}
|
||||
|
||||
function readRomPaths(): Record<string, string> {
|
||||
try {
|
||||
return JSON.parse(readFileSync(getRomConfigFile(), 'utf-8'));
|
||||
} catch {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
function writeRomPaths(paths: Record<string, string>): void {
|
||||
const dir = join(app.getPath('userData'), 'decomps');
|
||||
if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
|
||||
writeFileSync(getRomConfigFile(), JSON.stringify(paths, null, 2), 'utf-8');
|
||||
}
|
||||
|
||||
function detectDecompVersion(installDir: string): string | undefined {
|
||||
const versionFile = join(installDir, '.version');
|
||||
try {
|
||||
return readFileSync(versionFile, 'utf-8').trim();
|
||||
} catch {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
function findDecompExecutable(config: DecompProject): string | undefined {
|
||||
const installDir = getDecompDir(config.id);
|
||||
const markerPath = getMarkerFile(config.id);
|
||||
|
||||
// Check marker file first
|
||||
try {
|
||||
const execPath = readFileSync(markerPath, 'utf-8').trim();
|
||||
if (execPath && existsSync(execPath)) return execPath;
|
||||
} catch { /* no marker */ }
|
||||
|
||||
// Try platform-specific default path
|
||||
const defaultExec = config.executablePath[platform];
|
||||
if (defaultExec) {
|
||||
const fullPath = join(installDir, defaultExec);
|
||||
if (existsSync(fullPath)) return fullPath;
|
||||
}
|
||||
|
||||
// Fallback: look for any executable in the install dir
|
||||
try {
|
||||
const files = readdirSync(installDir);
|
||||
const execExts = platform === 'win32' ? ['.exe'] : ['', '.app'];
|
||||
for (const file of files) {
|
||||
if (execExts.some(ext => file.endsWith(ext))) {
|
||||
return join(installDir, file);
|
||||
}
|
||||
}
|
||||
} catch { /* empty dir */ }
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function findDecompRom(config: DecompProject): string | undefined {
|
||||
const romPaths = readRomPaths();
|
||||
if (romPaths[config.id] && existsSync(romPaths[config.id])) {
|
||||
return romPaths[config.id];
|
||||
}
|
||||
|
||||
// Search common ROM directories
|
||||
const s = settings.get();
|
||||
const romDirs = [
|
||||
s.romsDirectory,
|
||||
join(app.getPath('userData'), 'roms'),
|
||||
].filter(Boolean) as string[];
|
||||
|
||||
for (const romDir of romDirs) {
|
||||
const platformDir = join(romDir, config.platform.toLowerCase().replace(/\s+/g, '-'));
|
||||
if (!existsSync(platformDir)) continue;
|
||||
|
||||
try {
|
||||
const files = readdirSync(platformDir);
|
||||
for (const file of files) {
|
||||
if (config.romExtensions.includes(extname(file).toLowerCase())) {
|
||||
return join(platformDir, file);
|
||||
}
|
||||
}
|
||||
} catch { /* skip */ }
|
||||
|
||||
// Also check the root rom directory
|
||||
try {
|
||||
const files = readdirSync(romDir);
|
||||
for (const file of files) {
|
||||
if (config.romExtensions.includes(extname(file).toLowerCase())) {
|
||||
return join(romDir, file);
|
||||
}
|
||||
}
|
||||
} catch { /* skip */ }
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export function checkDecomp(id: string): DecompState {
|
||||
const config = knownDecomps.find(d => d.id === id);
|
||||
if (!config) {
|
||||
return {
|
||||
installed: false,
|
||||
hasRom: false,
|
||||
config: {
|
||||
id, name: id, description: '', platform: '',
|
||||
githubUrl: '', githubRepo: '', executablePath: { win32: '', darwin: '', linux: '' },
|
||||
romExtensions: [], requiresRom: true, features: [],
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
const execPath = findDecompExecutable(config);
|
||||
const version = execPath ? detectDecompVersion(getDecompDir(config.id)) : undefined;
|
||||
const romPath = findDecompRom(config);
|
||||
|
||||
return {
|
||||
installed: !!execPath,
|
||||
version,
|
||||
path: execPath,
|
||||
config,
|
||||
hasRom: !!romPath,
|
||||
romPath: romPath || undefined,
|
||||
};
|
||||
}
|
||||
|
||||
export function getAllDecompStates(): DecompState[] {
|
||||
const s = settings.get();
|
||||
if (!s.betaFeatures) return [];
|
||||
return knownDecomps.map(d => checkDecomp(d.id));
|
||||
}
|
||||
|
||||
export function setDecompRomPath(id: string, romPath: string): boolean {
|
||||
const romPaths = readRomPaths();
|
||||
romPaths[id] = romPath;
|
||||
writeRomPaths(romPaths);
|
||||
return true;
|
||||
}
|
||||
|
||||
export function launchDecomp(id: string): boolean {
|
||||
const state = checkDecomp(id);
|
||||
if (!state.installed || !state.path) return false;
|
||||
|
||||
const child = exec(`"${state.path}"`, { cwd: getDecompDir(id) });
|
||||
if (child) child.unref();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
export function uninstallDecomp(id: string): boolean {
|
||||
const installDir = getDecompDir(id);
|
||||
let removed = false;
|
||||
|
||||
if (existsSync(installDir)) {
|
||||
rmSync(installDir, { recursive: true, force: true });
|
||||
removed = true;
|
||||
}
|
||||
|
||||
return removed;
|
||||
}
|
||||
|
||||
export function openDecompWebsite(id: string): boolean {
|
||||
const config = knownDecomps.find(d => d.id === id);
|
||||
if (config?.githubUrl) {
|
||||
shell.openExternal(config.githubUrl);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// ── GitHub Release Download ──────────────────────────────────
|
||||
|
||||
interface GitHubRelease {
|
||||
tag_name: string;
|
||||
assets: GitHubAsset[];
|
||||
}
|
||||
|
||||
interface GitHubAsset {
|
||||
name: string;
|
||||
browser_download_url: string;
|
||||
size: number;
|
||||
}
|
||||
|
||||
async function fetchLatestRelease(githubRepo: string): Promise<GitHubRelease | null> {
|
||||
try {
|
||||
const url = `https://api.github.com/repos/${githubRepo}/releases/latest`;
|
||||
const response = await fetch(url, {
|
||||
headers: { 'Accept': 'application/vnd.github.v3+json' },
|
||||
});
|
||||
if (!response.ok) return null;
|
||||
return await response.json() as GitHubRelease;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
function pickBestAsset(assets: GitHubAsset[], config: DecompProject): GitHubAsset | undefined {
|
||||
const platformHints: Record<Platform, string[]> = {
|
||||
win32: ['windows', 'win64', 'win32', 'x64', '.exe', '.zip'],
|
||||
darwin: ['macos', 'mac', 'osx', 'darwin', '.dmg', '.app'],
|
||||
linux: ['linux', 'ubuntu', 'appimage', 'x86_64', 'amd64'],
|
||||
};
|
||||
|
||||
const hints = platformHints[platform];
|
||||
|
||||
// Score each asset
|
||||
const scored = assets.map(asset => {
|
||||
const name = asset.name.toLowerCase();
|
||||
let score = 0;
|
||||
for (const hint of hints) {
|
||||
if (name.includes(hint)) score += 10;
|
||||
}
|
||||
// Prefer zip/tar over exe installers
|
||||
if (name.endsWith('.zip') || name.endsWith('.tar.gz')) score += 5;
|
||||
// Penalize source code archives
|
||||
if (name.includes('source')) score -= 20;
|
||||
if (name.endsWith('.tar.gz') && name.includes('src')) score -= 20;
|
||||
return { asset, score };
|
||||
});
|
||||
|
||||
scored.sort((a, b) => b.score - a.score);
|
||||
return scored[0]?.score > 0 ? scored[0].asset : undefined;
|
||||
}
|
||||
|
||||
export interface DecompInstallProgress {
|
||||
decompId: string;
|
||||
stage: 'downloading' | 'extracting' | 'configuring' | 'done' | 'error';
|
||||
percent: number;
|
||||
message: string;
|
||||
error?: string;
|
||||
}
|
||||
|
||||
export async function installDecomp(
|
||||
id: string,
|
||||
onProgress: (p: DecompInstallProgress) => void,
|
||||
): Promise<DecompState> {
|
||||
const config = knownDecomps.find(d => d.id === id);
|
||||
if (!config) throw new Error(`Unknown decomp: ${id}`);
|
||||
|
||||
const installDir = getDecompDir(id);
|
||||
if (!existsSync(installDir)) {
|
||||
mkdirSync(installDir, { recursive: true });
|
||||
}
|
||||
|
||||
try {
|
||||
onProgress({ decompId: id, stage: 'downloading', percent: 0, message: 'Fetching latest release...' });
|
||||
|
||||
const release = await fetchLatestRelease(config.githubRepo);
|
||||
if (!release) throw new Error('Could not fetch latest release from GitHub');
|
||||
|
||||
const asset = pickBestAsset(release.assets, config);
|
||||
if (!asset) throw new Error('No compatible release asset found for your platform');
|
||||
|
||||
onProgress({ decompId: id, stage: 'downloading', percent: 10, message: `Downloading ${asset.name}...` });
|
||||
|
||||
// Download to temp file
|
||||
const tmpDir = join(app.getPath('userData'), 'downloads');
|
||||
if (!existsSync(tmpDir)) mkdirSync(tmpDir, { recursive: true });
|
||||
const tmpFile = join(tmpDir, `${id}-${Date.now()}-${asset.name}`);
|
||||
|
||||
await downloadFile(asset.browser_download_url, tmpFile, (pct) => {
|
||||
onProgress({ decompId: id, stage: 'downloading', percent: 10 + pct * 0.6, message: `Downloading ${asset.name}...` });
|
||||
});
|
||||
|
||||
onProgress({ decompId: id, stage: 'extracting', percent: 70, message: 'Extracting...' });
|
||||
|
||||
// Detect format and extract
|
||||
const isZip = asset.name.endsWith('.zip');
|
||||
const isTar = asset.name.endsWith('.tar.gz') || asset.name.endsWith('.tgz');
|
||||
const is7z = asset.name.endsWith('.7z');
|
||||
|
||||
if (isZip || isTar || is7z) {
|
||||
await extractArchive(tmpFile, installDir, asset.name, onProgress, id);
|
||||
} else {
|
||||
// It might be a standalone executable
|
||||
const { copyFileSync } = require('fs');
|
||||
const targetPath = join(installDir, asset.name);
|
||||
copyFileSync(tmpFile, targetPath);
|
||||
writeFileSync(join(installDir, '.installed'), targetPath, 'utf-8');
|
||||
}
|
||||
|
||||
// Clean up temp file
|
||||
try { rmSync(tmpFile, { force: true }); } catch { /* ignore */ }
|
||||
|
||||
// Write version marker
|
||||
writeFileSync(join(installDir, '.version'), release.tag_name, 'utf-8');
|
||||
|
||||
// Write .installed marker with the executable path
|
||||
const execPath = findDecompExecutable(config);
|
||||
if (execPath) {
|
||||
writeFileSync(join(installDir, '.installed'), execPath, 'utf-8');
|
||||
}
|
||||
|
||||
onProgress({ decompId: id, stage: 'done', percent: 100, message: `Installed ${config.name}` });
|
||||
|
||||
return checkDecomp(id);
|
||||
} catch (err: any) {
|
||||
onProgress({ decompId: id, stage: 'error', percent: 0, message: 'Installation failed', error: err.message });
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
async function downloadFile(url: string, dest: string, onProgress: (pct: number) => void): Promise<void> {
|
||||
const response = await fetch(url);
|
||||
if (!response.ok) throw new Error(`Download failed: ${response.status}`);
|
||||
|
||||
const total = Number(response.headers.get('content-length')) || 0;
|
||||
const reader = response.body?.getReader();
|
||||
if (!reader) throw new Error('No response body');
|
||||
|
||||
const { createWriteStream } = require('fs');
|
||||
const stream = createWriteStream(dest);
|
||||
let received = 0;
|
||||
|
||||
while (true) {
|
||||
const { done, value } = await reader.read();
|
||||
if (done) break;
|
||||
stream.write(value);
|
||||
received += value.length;
|
||||
if (total > 0) onProgress(Math.round((received / total) * 100));
|
||||
}
|
||||
|
||||
stream.end();
|
||||
await new Promise<void>((resolve) => stream.on('finish', resolve));
|
||||
}
|
||||
|
||||
async function extractArchive(
|
||||
archivePath: string,
|
||||
destDir: string,
|
||||
archiveName: string,
|
||||
onProgress: (p: DecompInstallProgress) => void,
|
||||
decompId: string,
|
||||
): Promise<void> {
|
||||
const { execSync } = require('child_process');
|
||||
|
||||
try {
|
||||
if (archiveName.endsWith('.zip')) {
|
||||
onProgress({ decompId, stage: 'extracting', percent: 75, message: 'Extracting zip archive...' });
|
||||
execSync(`unzip -o "${archivePath}" -d "${destDir}"`, { timeout: 300000 });
|
||||
} else if (archiveName.endsWith('.tar.gz') || archiveName.endsWith('.tgz')) {
|
||||
onProgress({ decompId, stage: 'extracting', percent: 75, message: 'Extracting tar archive...' });
|
||||
execSync(`tar -xzf "${archivePath}" -C "${destDir}"`, { timeout: 300000 });
|
||||
} else if (archiveName.endsWith('.7z')) {
|
||||
onProgress({ decompId, stage: 'extracting', percent: 75, message: 'Extracting 7z archive...' });
|
||||
const sevenZip = join(require('app-root-path').toString(), 'node_modules', '7zip-bin', 'vendor', '7z');
|
||||
if (existsSync(sevenZip)) {
|
||||
execSync(`"${sevenZip}" x "${archivePath}" -o"${destDir}" -y`, { timeout: 300000 });
|
||||
} else {
|
||||
execSync(`7z x "${archivePath}" -o"${destDir}" -y`, { timeout: 300000 });
|
||||
}
|
||||
}
|
||||
} catch (err: any) {
|
||||
throw new Error(`Extraction failed: ${err.message}`);
|
||||
}
|
||||
}
|
||||
@@ -771,6 +771,147 @@ export const knownEmulators: EmulatorConfig[] = [
|
||||
linux: 'https://azahar-emu.org/',
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'project64',
|
||||
name: 'Project64',
|
||||
description: 'Nintendo 64 emulator',
|
||||
platforms: ['n64'],
|
||||
defaultPath: {
|
||||
win32: 'C:\\Program Files\\Project64 3.0\\Project64.exe',
|
||||
darwin: '',
|
||||
linux: '',
|
||||
},
|
||||
downloads: {
|
||||
win32: [
|
||||
{
|
||||
url: 'https://www.pj64-emu.com/file/project64-3-0-1-5664-2df3434/',
|
||||
format: 'zip',
|
||||
executablePath: 'Project64.exe',
|
||||
},
|
||||
],
|
||||
},
|
||||
supported: true,
|
||||
websiteUrl: {
|
||||
win32: 'https://www.pj64-emu.com/',
|
||||
darwin: 'https://www.pj64-emu.com/',
|
||||
linux: 'https://www.pj64-emu.com/',
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'snes9x',
|
||||
name: 'Snes9x',
|
||||
description: 'Super Nintendo emulator',
|
||||
platforms: ['snes'],
|
||||
defaultPath: {
|
||||
win32: 'C:\\Program Files\\Snes9x\\snes9x-x64.exe',
|
||||
darwin: '/Applications/Snes9x.app/Contents/MacOS/snes9x',
|
||||
linux: '/usr/bin/snes9x',
|
||||
},
|
||||
downloads: {
|
||||
win32: [
|
||||
{
|
||||
url: 'https://github.com/snes9xgit/snes9x/releases/download/1.63/snes9x-1.63-win32-x64.zip',
|
||||
format: 'zip',
|
||||
executablePath: 'snes9x-x64.exe',
|
||||
},
|
||||
],
|
||||
darwin: [
|
||||
{
|
||||
url: 'https://github.com/snes9xgit/snes9x/releases/download/1.63/Snes9x-1.63-Mac.zip',
|
||||
format: 'zip',
|
||||
},
|
||||
],
|
||||
linux: [
|
||||
{
|
||||
url: 'https://github.com/snes9xgit/snes9x/releases/download/1.63/Snes9x-1.63-x86_64.AppImage',
|
||||
format: 'appimage',
|
||||
},
|
||||
],
|
||||
},
|
||||
supported: true,
|
||||
websiteUrl: {
|
||||
win32: 'https://www.snes9x.net/',
|
||||
darwin: 'https://www.snes9x.net/',
|
||||
linux: 'https://www.snes9x.net/',
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'mgba',
|
||||
name: 'mGBA',
|
||||
description: 'Game Boy Advance emulator',
|
||||
platforms: ['gba', 'gb', 'gbc'],
|
||||
defaultPath: {
|
||||
win32: 'C:\\Program Files\\mGBA\\mGBA.exe',
|
||||
darwin: '/Applications/mGBA.app/Contents/MacOS/mGBA',
|
||||
linux: '/usr/bin/mgba',
|
||||
},
|
||||
downloads: {
|
||||
win32: [
|
||||
{
|
||||
url: 'https://github.com/mgba-emu/mgba/releases/download/0.10.5/mGBA-0.10.5-win64.7z',
|
||||
format: '7z',
|
||||
executablePath: 'mGBA.exe',
|
||||
},
|
||||
],
|
||||
darwin: [
|
||||
{
|
||||
url: 'https://github.com/mgba-emu/mgba/releases/download/0.10.5/mGBA-0.10.5-macos.dmg',
|
||||
format: 'dmg',
|
||||
},
|
||||
],
|
||||
linux: [
|
||||
{
|
||||
url: 'https://github.com/mgba-emu/mgba/releases/download/0.10.5/mGBA-0.10.5-appimage-x64.appimage',
|
||||
format: 'appimage',
|
||||
},
|
||||
],
|
||||
},
|
||||
supported: true,
|
||||
websiteUrl: {
|
||||
win32: 'https://mgba.io/',
|
||||
darwin: 'https://mgba.io/',
|
||||
linux: 'https://mgba.io/',
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'mesen2',
|
||||
name: 'Mesen2',
|
||||
description: 'Multi-system emulator (NES, SNES, GB, GBA, PC Engine)',
|
||||
platforms: ['nes', 'snes', 'gb', 'gbc', 'gba', 'pce'],
|
||||
defaultPath: {
|
||||
win32: 'C:\\Program Files\\Mesen\\Mesen.exe',
|
||||
darwin: '/Applications/Mesen.app/Contents/MacOS/Mesen',
|
||||
linux: '/usr/bin/Mesen',
|
||||
},
|
||||
downloads: {
|
||||
win32: [
|
||||
{
|
||||
url: 'https://github.com/SourMesen/Mesen2/releases/download/2.1.1/Mesen_2.1.1_Windows.zip',
|
||||
format: 'zip',
|
||||
executablePath: 'Mesen.exe',
|
||||
},
|
||||
],
|
||||
darwin: [
|
||||
{
|
||||
url: 'https://github.com/SourMesen/Mesen2/releases/download/2.1.1/Mesen_2.1.1_macOS_ARM64_AppleSilicon.zip',
|
||||
format: 'zip',
|
||||
},
|
||||
],
|
||||
linux: [
|
||||
{
|
||||
url: 'https://github.com/SourMesen/Mesen2/releases/download/2.1.1/Mesen_2.1.1_Linux_x64.zip',
|
||||
format: 'zip',
|
||||
executablePath: 'Mesen',
|
||||
},
|
||||
],
|
||||
},
|
||||
supported: true,
|
||||
websiteUrl: {
|
||||
win32: 'https://www.mesen.ca/',
|
||||
darwin: 'https://www.mesen.ca/',
|
||||
linux: 'https://www.mesen.ca/',
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
export function findEmulator(id: string): EmulatorConfig | undefined {
|
||||
@@ -931,6 +1072,40 @@ function alternativePaths(emulatorId: string): string[] {
|
||||
join(home, 'Applications', 'Azahar.app', 'Contents', 'MacOS', 'azahar'),
|
||||
'/usr/bin/azahar',
|
||||
],
|
||||
project64: [
|
||||
join(omniEmuDir, 'Project64.exe'),
|
||||
join(omniEmuDir, 'Project64', 'Project64.exe'),
|
||||
'C:\\Program Files\\Project64 3.0\\Project64.exe',
|
||||
'C:\\Program Files (x86)\\Project64 3.0\\Project64.exe',
|
||||
],
|
||||
snes9x: [
|
||||
join(omniEmuDir, 'snes9x-x64.exe'),
|
||||
join(omniEmuDir, 'snes9x', 'snes9x-x64.exe'),
|
||||
join(omniEmuDir, 'snes9x'),
|
||||
join(home, 'Applications', 'Snes9x.app', 'Contents', 'MacOS', 'snes9x'),
|
||||
'/usr/bin/snes9x',
|
||||
'/usr/local/bin/snes9x',
|
||||
'/snap/bin/snes9x',
|
||||
],
|
||||
mgba: [
|
||||
join(omniEmuDir, 'mGBA.exe'),
|
||||
join(omniEmuDir, 'mGBA', 'mGBA.exe'),
|
||||
join(omniEmuDir, 'mgba-qt'),
|
||||
join(omniEmuDir, 'mGBA.app', 'Contents', 'MacOS', 'mGBA'),
|
||||
join(home, 'Applications', 'mGBA.app', 'Contents', 'MacOS', 'mGBA'),
|
||||
'/usr/bin/mgba',
|
||||
'/usr/local/bin/mgba',
|
||||
'/snap/bin/mgba',
|
||||
],
|
||||
mesen2: [
|
||||
join(omniEmuDir, 'Mesen.exe'),
|
||||
join(omniEmuDir, 'Mesen', 'Mesen.exe'),
|
||||
join(omniEmuDir, 'Mesen'),
|
||||
join(omniEmuDir, 'Mesen.app', 'Contents', 'MacOS', 'Mesen'),
|
||||
join(home, 'Applications', 'Mesen.app', 'Contents', 'MacOS', 'Mesen'),
|
||||
'/usr/bin/Mesen',
|
||||
'/usr/local/bin/Mesen',
|
||||
],
|
||||
};
|
||||
return common[emulatorId] || [join(omniEmuDir)];
|
||||
}
|
||||
|
||||
+86
-3
@@ -3,12 +3,71 @@ import { join } from 'path';
|
||||
import { existsSync } from 'fs';
|
||||
import { registerIpcHandlers } from './ipc';
|
||||
import { settings } from './settings';
|
||||
import { isMacOS } from './platform';
|
||||
import { isMacOS, isLinux } from './platform';
|
||||
import { ensureRomsStructure } from './emulators';
|
||||
import { setupAutoUpdater } from './updater';
|
||||
import { generatePegasusCollectionsForRomDir } from './configurator';
|
||||
import { startSyncthing } from './syncthing';
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Steam Deck / SteamOS (Gamescope) compatibility
|
||||
// ---------------------------------------------------------------------------
|
||||
// When launched in Gaming Mode the app runs inside Gamescope, a Wayland
|
||||
// compositor that does NOT expose the kernel features Chromium's sandbox
|
||||
// relies on. Without the flags below the renderer process segfaults
|
||||
// immediately on launch. Desktop Mode works fine because Gamescope is not
|
||||
// involved.
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function isSteamDeck(): boolean {
|
||||
if (!isLinux()) return false;
|
||||
const steamos =
|
||||
existsSync('/usr/bin/steamos-session-select') ||
|
||||
existsSync('/etc/os-release') &&
|
||||
(() => {
|
||||
try {
|
||||
const os = require('fs').readFileSync('/etc/os-release', 'utf-8');
|
||||
return os.includes('SteamOS');
|
||||
} catch { return false; }
|
||||
})();
|
||||
return steamos;
|
||||
}
|
||||
|
||||
function applySteamDeckFlags(): void {
|
||||
if (!isLinux()) return;
|
||||
|
||||
// Chromium sandbox — Gamescope does not support the required kernel
|
||||
// namespacing so the sandbox must be disabled or it segfaults.
|
||||
app.commandLine.appendSwitch('no-sandbox');
|
||||
|
||||
// GPU sandbox — Gamescope already composites; letting Chromium create a
|
||||
// second GPU sandbox causes a driver conflict.
|
||||
app.commandLine.appendSwitch('disable-gpu-sandbox');
|
||||
|
||||
// ForceANGLE + SwiftShader — fallback to software GL when the native
|
||||
// Mesa driver misbehaves inside Gamescope. On a real Steam Deck the
|
||||
// ANGLE OpenGL-ES path still hits the AMD driver for performance, but
|
||||
// this prevents the "lost device" crash on session transitions.
|
||||
if (isSteamDeck()) {
|
||||
app.commandLine.appendSwitch('use-gl', 'angle');
|
||||
app.commandLine.appendSwitch('use-angle', 'swiftshader');
|
||||
app.commandLine.appendSwitch('enable-features', 'VaapiVideoDecoder');
|
||||
}
|
||||
|
||||
// Disable the GPU blacklisting — Steam Deck's custom Mesa driver is
|
||||
// frequently mis-identified as "too old" by Chromium's blocklist.
|
||||
app.commandLine.appendSwitch('ignore-gpu-blocklist');
|
||||
|
||||
// Disable GPU compositing to let Gamescope handle all compositing.
|
||||
app.commandLine.appendSwitch('disable-gpu-compositing');
|
||||
|
||||
// /dev/shm on SteamOS is too small for Chromium's shared memory
|
||||
// segments — use /tmp instead.
|
||||
app.commandLine.appendSwitch('disable-dev-shm-usage');
|
||||
}
|
||||
|
||||
applySteamDeckFlags();
|
||||
|
||||
let mainWindow: BrowserWindow | null = null;
|
||||
let tray: Tray | null = null;
|
||||
|
||||
@@ -104,7 +163,9 @@ function createTray(): void {
|
||||
tray.on('click', () => mainWindow?.show());
|
||||
}
|
||||
|
||||
// Prevent multiple instances
|
||||
// Prevent multiple instances — if a stale lock file from a previous
|
||||
// session (e.g. Desktop Mode) is lingering, force-remove it so Gaming
|
||||
// Mode can start cleanly.
|
||||
const gotLock = app.requestSingleInstanceLock();
|
||||
if (!gotLock) {
|
||||
app.quit();
|
||||
@@ -118,11 +179,33 @@ if (!gotLock) {
|
||||
});
|
||||
}
|
||||
|
||||
// On SteamOS, /tmp is a small tmpfs that fills up fast with Chromium
|
||||
// caches. Point the disk cache at the user data directory instead so
|
||||
// it persists across sessions and has more room.
|
||||
if (isLinux()) {
|
||||
const cacheDir = join(app.getPath('userData'), 'cache');
|
||||
if (!existsSync(cacheDir)) {
|
||||
try { require('fs').mkdirSync(cacheDir, { recursive: true }); } catch { /* ignore */ }
|
||||
}
|
||||
app.commandLine.appendSwitch('disk-cache-dir', cacheDir);
|
||||
}
|
||||
|
||||
app.whenReady().then(() => {
|
||||
ensureRomsStructure();
|
||||
setupAutoUpdater();
|
||||
registerIpcHandlers();
|
||||
createWindow();
|
||||
|
||||
try {
|
||||
createWindow();
|
||||
} catch (err) {
|
||||
// If the window creation fails (common on Steam Deck Gaming Mode
|
||||
// when hardware acceleration misbehaves), retry with GPU disabled.
|
||||
console.error('Window creation failed, retrying without GPU:', err);
|
||||
app.commandLine.appendSwitch('disable-gpu');
|
||||
app.commandLine.appendSwitch('disable-software-rasterizer');
|
||||
try { createWindow(); } catch { /* fatal */ }
|
||||
}
|
||||
|
||||
createTray();
|
||||
|
||||
// Auto-generate Pegasus collection files if Pegasus is configured
|
||||
|
||||
+119
@@ -15,6 +15,15 @@ import {
|
||||
getSystemEmulators,
|
||||
ensureRomsStructure,
|
||||
} from './emulators';
|
||||
import {
|
||||
getAllDecompStates,
|
||||
checkDecomp,
|
||||
installDecomp,
|
||||
uninstallDecomp,
|
||||
launchDecomp,
|
||||
openDecompWebsite,
|
||||
setDecompRomPath,
|
||||
} from './decomps';
|
||||
import { installEmulator, findInstalledBinary } from './installer';
|
||||
import { applyRecommendedConfig, getPresets, checkConfigured, applyControllerConfig, applyRetroAchievements } from './configurator';
|
||||
import { settings } from './settings';
|
||||
@@ -34,7 +43,12 @@ import {
|
||||
removeRemoteDevice,
|
||||
addSharedFolder,
|
||||
removeSharedFolder,
|
||||
getPendingDevices,
|
||||
acceptPendingDevice,
|
||||
getPendingFolders,
|
||||
acceptPendingFolder,
|
||||
} from './syncthing';
|
||||
import { guessSavePathFromLabel, getEmulatorSaveDirs } from './saveManager';
|
||||
|
||||
export function registerIpcHandlers(): void {
|
||||
// System
|
||||
@@ -170,6 +184,50 @@ export function registerIpcHandlers(): void {
|
||||
return false;
|
||||
});
|
||||
|
||||
// Decomps
|
||||
ipcMain.handle('decomps:states', () => getAllDecompStates());
|
||||
ipcMain.handle('decomps:check', (_event, id: string) => checkDecomp(id));
|
||||
|
||||
ipcMain.handle('decomps:install', async (event, id: string) => {
|
||||
const win = BrowserWindow.fromWebContents(event.sender);
|
||||
const sendProgress = (p: any) => {
|
||||
win?.webContents.send('decomps:install-progress', p);
|
||||
};
|
||||
try {
|
||||
const state = await installDecomp(id, sendProgress);
|
||||
return state;
|
||||
} catch (err: any) {
|
||||
sendProgress({ decompId: id, stage: 'error', percent: 0, message: 'Failed', error: err.message });
|
||||
return checkDecomp(id);
|
||||
}
|
||||
});
|
||||
|
||||
ipcMain.handle('decomps:uninstall', (_event, id: string) => {
|
||||
const removed = uninstallDecomp(id);
|
||||
return { removed, state: checkDecomp(id) };
|
||||
});
|
||||
|
||||
ipcMain.handle('decomps:launch', (_event, id: string) => launchDecomp(id));
|
||||
|
||||
ipcMain.handle('decomps:open-website', (_event, id: string) => openDecompWebsite(id));
|
||||
|
||||
ipcMain.handle('decomps:set-rom', (_event, id: string, romPath: string) => {
|
||||
setDecompRomPath(id, romPath);
|
||||
return checkDecomp(id);
|
||||
});
|
||||
|
||||
ipcMain.handle('decomps:select-rom', async (_event, id: string) => {
|
||||
const result = await dialog.showOpenDialog({
|
||||
properties: ['openFile'],
|
||||
title: 'Select ROM file',
|
||||
});
|
||||
if (!result.canceled && result.filePaths.length > 0) {
|
||||
setDecompRomPath(id, result.filePaths[0]);
|
||||
return { romPath: result.filePaths[0], state: checkDecomp(id) };
|
||||
}
|
||||
return { romPath: null, state: checkDecomp(id) };
|
||||
});
|
||||
|
||||
// ROMs / Games
|
||||
ipcMain.handle('roms:scan', (_event, directory?: string) => {
|
||||
const dir = directory || getRomsDirectory();
|
||||
@@ -426,4 +484,65 @@ export function registerIpcHandlers(): void {
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
// Pending devices and folders
|
||||
ipcMain.handle('cloud:pending-devices', async () => {
|
||||
try {
|
||||
return await getPendingDevices();
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
});
|
||||
|
||||
ipcMain.handle('cloud:accept-pending-device', async (_event, deviceId: string) => {
|
||||
try {
|
||||
return await acceptPendingDevice(deviceId);
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
ipcMain.handle('cloud:pending-folders', async () => {
|
||||
try {
|
||||
return await getPendingFolders();
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
});
|
||||
|
||||
ipcMain.handle('cloud:accept-pending-folder', async (_event, folderId: string, folderLabel: string, localPath: string, deviceId: string) => {
|
||||
try {
|
||||
return await acceptPendingFolder(folderId, folderLabel, localPath, deviceId);
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
ipcMain.handle('cloud:guess-path', (_event, label: string) => {
|
||||
return guessSavePathFromLabel(label);
|
||||
});
|
||||
|
||||
ipcMain.handle('cloud:emulator-dirs', async () => {
|
||||
return getEmulatorSaveDirs();
|
||||
});
|
||||
|
||||
ipcMain.handle('cloud:toggle-folder-sync', async (_event, emuId: string, sync: boolean) => {
|
||||
try {
|
||||
const dirs = getEmulatorSaveDirs();
|
||||
const emu = dirs.find(d => d.id === emuId);
|
||||
if (!emu || !emu.saves) return false;
|
||||
const folderId = `saves-${emuId}`;
|
||||
if (sync) {
|
||||
// Create the folder and share with all paired devices
|
||||
const status = await getSyncthingStatus();
|
||||
const deviceIds = status.remoteDevices.map(d => d.id);
|
||||
return await addSharedFolder(folderId, `${emu.name} Saves`, emu.saves, deviceIds);
|
||||
} else {
|
||||
// Remove the folder
|
||||
return await removeSharedFolder(folderId);
|
||||
}
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -2,6 +2,8 @@ import { contextBridge, ipcRenderer } from 'electron';
|
||||
import type {
|
||||
EmulatorConfig,
|
||||
EmulatorState,
|
||||
DecompProject,
|
||||
DecompState,
|
||||
GameEntry,
|
||||
SystemInfo,
|
||||
AppSettings,
|
||||
@@ -10,6 +12,8 @@ import type {
|
||||
GameMetadata,
|
||||
AchievementInfo,
|
||||
SyncthingStatus,
|
||||
SyncthingPendingDevice,
|
||||
SyncthingPendingFolder,
|
||||
} from '../shared/types';
|
||||
|
||||
const api = {
|
||||
@@ -66,6 +70,25 @@ const api = {
|
||||
},
|
||||
},
|
||||
|
||||
decomps: {
|
||||
states: (): Promise<DecompState[]> => ipcRenderer.invoke('decomps:states'),
|
||||
check: (id: string): Promise<DecompState> => ipcRenderer.invoke('decomps:check', id),
|
||||
install: (id: string): Promise<DecompState> => ipcRenderer.invoke('decomps:install', id),
|
||||
uninstall: (id: string): Promise<{ removed: boolean; state: DecompState }> =>
|
||||
ipcRenderer.invoke('decomps:uninstall', id),
|
||||
launch: (id: string): Promise<boolean> => ipcRenderer.invoke('decomps:launch', id),
|
||||
openWebsite: (id: string): Promise<boolean> => ipcRenderer.invoke('decomps:open-website', id),
|
||||
setRom: (id: string, romPath: string): Promise<DecompState> =>
|
||||
ipcRenderer.invoke('decomps:set-rom', id, romPath),
|
||||
selectRom: (id: string): Promise<{ romPath: string | null; state: DecompState }> =>
|
||||
ipcRenderer.invoke('decomps:select-rom', id),
|
||||
onInstallProgress: (cb: (progress: { decompId: string; stage: string; percent: number; message: string }) => void) => {
|
||||
const handler = (_event: Electron.IpcRendererEvent, p: any) => cb(p);
|
||||
ipcRenderer.on('decomps:install-progress', handler);
|
||||
return () => ipcRenderer.removeListener('decomps:install-progress', handler);
|
||||
},
|
||||
},
|
||||
|
||||
roms: {
|
||||
scan: (directory?: string): Promise<GameEntry[]> =>
|
||||
ipcRenderer.invoke('roms:scan', directory),
|
||||
@@ -167,6 +190,17 @@ const api = {
|
||||
removeFolder: (folderId: string): Promise<boolean> =>
|
||||
ipcRenderer.invoke('cloud:remove-folder', folderId),
|
||||
openWebUI: (): Promise<boolean> => ipcRenderer.invoke('cloud:open-web-ui'),
|
||||
pendingDevices: (): Promise<SyncthingPendingDevice[]> => ipcRenderer.invoke('cloud:pending-devices'),
|
||||
acceptPendingDevice: (deviceId: string): Promise<boolean> =>
|
||||
ipcRenderer.invoke('cloud:accept-pending-device', deviceId),
|
||||
pendingFolders: (): Promise<SyncthingPendingFolder[]> => ipcRenderer.invoke('cloud:pending-folders'),
|
||||
acceptPendingFolder: (folderId: string, folderLabel: string, localPath: string, deviceId: string): Promise<boolean> =>
|
||||
ipcRenderer.invoke('cloud:accept-pending-folder', folderId, folderLabel, localPath, deviceId),
|
||||
guessPath: (label: string): Promise<string | null> => ipcRenderer.invoke('cloud:guess-path', label),
|
||||
emulatorDirs: (): Promise<{ id: string; name: string; saves: string | null }[]> =>
|
||||
ipcRenderer.invoke('cloud:emulator-dirs'),
|
||||
toggleFolderSync: (emuId: string, sync: boolean): Promise<boolean> =>
|
||||
ipcRenderer.invoke('cloud:toggle-folder-sync', emuId, sync),
|
||||
onInstallProgress: (cb: (progress: { stage: string; percent: number; message: string }) => void) => {
|
||||
const handler = (_event: Electron.IpcRendererEvent, p: { stage: string; percent: number; message: string }) => cb(p);
|
||||
ipcRenderer.on('cloud:install-progress', handler);
|
||||
|
||||
@@ -307,3 +307,31 @@ export function getSaveDir(emuId: string): string | null {
|
||||
const paths = emulatorSaveDirs(emuId);
|
||||
return paths?.saves || null;
|
||||
}
|
||||
|
||||
export { emulatorSaveDirs };
|
||||
|
||||
export function guessSavePathFromLabel(label: string): string | null {
|
||||
const lower = label.toLowerCase();
|
||||
for (const emu of ['retroarch', 'dolphin', 'rpcs3', 'eden', 'pcsx2', 'duckstation', 'flycast', 'ppsspp']) {
|
||||
if (lower.includes(emu)) return getSaveDir(emu);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
const EMU_SAVE_META: { id: string; name: string }[] = [
|
||||
{ id: 'retroarch', name: 'RetroArch' },
|
||||
{ id: 'dolphin', name: 'Dolphin' },
|
||||
{ id: 'rpcs3', name: 'RPCS3' },
|
||||
{ id: 'eden', name: 'Eden' },
|
||||
{ id: 'pcsx2', name: 'PCSX2' },
|
||||
{ id: 'duckstation', name: 'DuckStation' },
|
||||
{ id: 'flycast', name: 'Flycast' },
|
||||
{ id: 'ppsspp', name: 'PPSSPP' },
|
||||
];
|
||||
|
||||
export function getEmulatorSaveDirs() {
|
||||
return EMU_SAVE_META.map(e => ({
|
||||
...e,
|
||||
saves: getSaveDir(e.id),
|
||||
})).filter(e => e.saves);
|
||||
}
|
||||
@@ -458,4 +458,79 @@ export async function getSyncthingVersion(): Promise<string> {
|
||||
}
|
||||
}
|
||||
|
||||
export interface PendingDeviceInfo {
|
||||
id: string;
|
||||
name: string;
|
||||
address?: string;
|
||||
}
|
||||
|
||||
export interface PendingFolderInfo {
|
||||
folderId: string;
|
||||
folderLabel: string;
|
||||
deviceId: string;
|
||||
}
|
||||
|
||||
export async function getPendingDevices(): Promise<PendingDeviceInfo[]> {
|
||||
try {
|
||||
const data = await apiRequest('GET', '/rest/cluster/pending/devices');
|
||||
if (!data) return [];
|
||||
return Object.entries(data).map(([id, info]: [string, any]) => ({
|
||||
id,
|
||||
name: info.name || '',
|
||||
address: info.address || '',
|
||||
}));
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
export async function acceptPendingDevice(deviceId: string): Promise<boolean> {
|
||||
try {
|
||||
await apiRequest('PUT', `/rest/cluster/pending/devices?device=${deviceId}`);
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export async function getPendingFolders(): Promise<PendingFolderInfo[]> {
|
||||
try {
|
||||
const data = await apiRequest('GET', '/rest/cluster/pending/folders');
|
||||
if (!data) return [];
|
||||
const results: PendingFolderInfo[] = [];
|
||||
for (const [folderId, info] of Object.entries<any>(data)) {
|
||||
const deviceIds = info.offeredBy ? Object.keys(info.offeredBy) : [];
|
||||
for (const deviceId of deviceIds) {
|
||||
results.push({ folderId, folderLabel: info.label || folderId, deviceId });
|
||||
}
|
||||
}
|
||||
return results;
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
export async function acceptPendingFolder(
|
||||
folderId: string,
|
||||
folderLabel: string,
|
||||
localPath: string,
|
||||
deviceId: string
|
||||
): Promise<boolean> {
|
||||
try {
|
||||
await apiRequest('POST', '/rest/config/folders', {
|
||||
id: folderId,
|
||||
label: folderLabel,
|
||||
path: localPath,
|
||||
type: 'sendreceive',
|
||||
rescanIntervalS: 3600,
|
||||
fsWatcherEnabled: true,
|
||||
fsWatcherDelayS: 10,
|
||||
devices: [{ deviceID: deviceId }],
|
||||
});
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export { getBinaryPath, getPort, getApiKey, apiUrl, getSyncthingDir };
|
||||
@@ -1,8 +1,14 @@
|
||||
import React, { useEffect, useState, useCallback, useRef } from 'react';
|
||||
import type { SyncthingStatus } from '../../shared/types';
|
||||
import type { SyncthingStatus, SyncthingPendingDevice, SyncthingPendingFolder } from '../../shared/types';
|
||||
|
||||
type SetupStep = 'install' | 'start' | 'setup' | 'ready';
|
||||
|
||||
interface EmuDir {
|
||||
id: string;
|
||||
name: string;
|
||||
saves: string | null;
|
||||
}
|
||||
|
||||
export function CloudSyncPage() {
|
||||
const [status, setStatus] = useState<SyncthingStatus | null>(null);
|
||||
const [loading, setLoading] = useState(true);
|
||||
@@ -14,41 +20,64 @@ export function CloudSyncPage() {
|
||||
const [remoteDeviceId, setRemoteDeviceId] = useState('');
|
||||
const [remoteDeviceName, setRemoteDeviceName] = useState('');
|
||||
const [addingDevice, setAddingDevice] = useState(false);
|
||||
const [folderLabel, setFolderLabel] = useState('');
|
||||
const [folderPath, setFolderPath] = useState('');
|
||||
const [showAddFolder, setShowAddFolder] = useState(false);
|
||||
const [copied, setCopied] = useState(false);
|
||||
const [cloudEnabled, setCloudEnabled] = useState(false);
|
||||
const uninstallRef = useRef<HTMLTextAreaElement>(null);
|
||||
const [forceReady, setForceReady] = useState(false);
|
||||
const [pendingDevices, setPendingDevices] = useState<SyncthingPendingDevice[]>([]);
|
||||
const [pendingFolders, setPendingFolders] = useState<SyncthingPendingFolder[]>([]);
|
||||
const [pendingFolderPaths, setPendingFolderPaths] = useState<Record<string, string>>({});
|
||||
const [emuDirs, setEmuDirs] = useState<EmuDir[]>([]);
|
||||
const [emuSynced, setEmuSynced] = useState<Record<string, boolean>>({});
|
||||
const [togglingSync, setTogglingSync] = useState('');
|
||||
const [acceptingDevice, setAcceptingDevice] = useState('');
|
||||
const [acceptingFolder, setAcceptingFolder] = useState('');
|
||||
const pollRef = useRef<ReturnType<typeof setInterval> | null>(null);
|
||||
const idRef = useRef<HTMLTextAreaElement>(null);
|
||||
|
||||
const DEFAULT_STATUS: SyncthingStatus = {
|
||||
installed: false, running: false, deviceId: '', apiAddress: '',
|
||||
apiKey: '', version: '', folders: [], remoteDevices: [],
|
||||
};
|
||||
|
||||
const loadStatus = useCallback(async () => {
|
||||
const loadData = useCallback(async () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
const s = await Promise.race([
|
||||
window.omni.cloud.status(),
|
||||
new Promise<null>((_, reject) => setTimeout(() => reject(new Error('timeout')), 8000)),
|
||||
const [s, cloudStatus, pendingDev, pendingFol, dirs] = await Promise.all([
|
||||
window.omni.settings.get(),
|
||||
window.omni.cloud.status().catch(() => null),
|
||||
window.omni.cloud.pendingDevices().catch(() => [] as SyncthingPendingDevice[]),
|
||||
window.omni.cloud.pendingFolders().catch(() => [] as SyncthingPendingFolder[]),
|
||||
window.omni.cloud.emulatorDirs().catch(() => [] as EmuDir[]),
|
||||
]);
|
||||
if (s) setStatus(s);
|
||||
else setStatus(DEFAULT_STATUS);
|
||||
} catch {
|
||||
setStatus(DEFAULT_STATUS);
|
||||
}
|
||||
setCloudEnabled(!!s.cloudSyncEnabled);
|
||||
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}`);
|
||||
}
|
||||
setEmuSynced(synced);
|
||||
}
|
||||
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);
|
||||
paths[fol.folderId] = resolved || '';
|
||||
}
|
||||
setPendingFolderPaths(paths);
|
||||
} catch { /* ignore */ }
|
||||
setLoading(false);
|
||||
}, []);
|
||||
|
||||
const loadSettings = useCallback(async () => {
|
||||
try {
|
||||
const s = await window.omni.settings.get();
|
||||
setCloudEnabled(!!s.cloudSyncEnabled);
|
||||
} catch { /* ignore */ }
|
||||
}, []);
|
||||
useEffect(() => { loadData(); }, [loadData]);
|
||||
|
||||
useEffect(() => { loadStatus(); loadSettings(); }, [loadStatus, loadSettings]);
|
||||
useEffect(() => {
|
||||
return () => { if (pollRef.current) clearInterval(pollRef.current); };
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
const unsub = window.omni.cloud.onInstallProgress((p) => {
|
||||
@@ -56,25 +85,14 @@ export function CloudSyncPage() {
|
||||
setInstallPercent(p.percent);
|
||||
if (p.stage === 'done' || p.stage === 'error') {
|
||||
setInstalling(false);
|
||||
if (p.stage === 'done') {
|
||||
loadStatus();
|
||||
}
|
||||
if (p.stage === 'done') loadData();
|
||||
}
|
||||
});
|
||||
return unsub;
|
||||
}, [loadStatus]);
|
||||
}, [loadData]);
|
||||
|
||||
const showSuccess = (msg: string) => {
|
||||
setSuccess(msg);
|
||||
setError('');
|
||||
setTimeout(() => setSuccess(''), 4000);
|
||||
};
|
||||
|
||||
const showError = (msg: string) => {
|
||||
setError(msg);
|
||||
setSuccess('');
|
||||
setTimeout(() => setError(''), 4000);
|
||||
};
|
||||
const showSuccess = (msg: string) => { setSuccess(msg); setError(''); setTimeout(() => setSuccess(''), 4000); };
|
||||
const showError = (msg: string) => { setError(msg); setSuccess(''); setTimeout(() => setError(''), 4000); };
|
||||
|
||||
const saveCloudEnabled = async (enabled: boolean) => {
|
||||
setCloudEnabled(enabled);
|
||||
@@ -82,189 +100,118 @@ export function CloudSyncPage() {
|
||||
};
|
||||
|
||||
const handleInstall = async () => {
|
||||
setInstalling(true);
|
||||
setInstallPercent(0);
|
||||
setInstallMsg('Starting download...');
|
||||
setInstalling(true); setInstallPercent(0); setInstallMsg('Starting download...');
|
||||
try {
|
||||
const ok = await window.omni.cloud.install();
|
||||
if (!ok) {
|
||||
setInstalling(false);
|
||||
showError('Installation failed');
|
||||
}
|
||||
} catch (err) {
|
||||
setInstalling(false);
|
||||
showError(`Install error: ${err}`);
|
||||
}
|
||||
if (!ok) { setInstalling(false); showError('Installation failed'); }
|
||||
} catch (err) { setInstalling(false); showError(`Install error: ${err}`); }
|
||||
};
|
||||
|
||||
const handleStart = async () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
// Start kicks off the process in the background
|
||||
const s = await window.omni.cloud.start();
|
||||
if (s) {
|
||||
setStatus(s);
|
||||
if (s.running) {
|
||||
await saveCloudEnabled(true);
|
||||
showSuccess('Syncthing started! Auto-start enabled.');
|
||||
} else {
|
||||
// Process was kicked off but may need more time — poll
|
||||
if (s.running) { await saveCloudEnabled(true); showSuccess('Syncthing started!'); setLoading(false); }
|
||||
else {
|
||||
let attempts = 0;
|
||||
const poll = setInterval(async () => {
|
||||
pollRef.current = setInterval(async () => {
|
||||
attempts++;
|
||||
try {
|
||||
const latest = await window.omni.cloud.status();
|
||||
setStatus(latest);
|
||||
if (latest.running) {
|
||||
clearInterval(poll);
|
||||
await saveCloudEnabled(true);
|
||||
showSuccess('Syncthing started! Auto-start enabled.');
|
||||
setLoading(false);
|
||||
} else if (attempts >= 15) {
|
||||
clearInterval(poll);
|
||||
showError('Syncthing took too long to start. Check that the binary is not blocked by your OS.');
|
||||
setLoading(false);
|
||||
}
|
||||
} catch {
|
||||
if (attempts >= 15) {
|
||||
clearInterval(poll);
|
||||
showError('Could not reach Syncthing.');
|
||||
setLoading(false);
|
||||
}
|
||||
}
|
||||
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); } }
|
||||
}, 1000);
|
||||
}
|
||||
} else {
|
||||
showError('Failed to start Syncthing — binary not found');
|
||||
}
|
||||
} catch (err) {
|
||||
showError(`Start error: ${err}`);
|
||||
}
|
||||
setLoading(false);
|
||||
} else { showError('Failed to start Syncthing'); setLoading(false); }
|
||||
} catch (err) { showError(`Start error: ${err}`); setLoading(false); }
|
||||
};
|
||||
|
||||
const handleStop = async () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
const s = await window.omni.cloud.stop();
|
||||
setStatus(s);
|
||||
await saveCloudEnabled(false);
|
||||
showSuccess('Syncthing stopped. Auto-start disabled.');
|
||||
} 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);
|
||||
};
|
||||
|
||||
const handleAddDevice = async () => {
|
||||
if (!remoteDeviceId.trim()) {
|
||||
showError('Enter a device ID');
|
||||
return;
|
||||
}
|
||||
if (!remoteDeviceId.trim()) { showError('Enter a device ID'); return; }
|
||||
setAddingDevice(true);
|
||||
try {
|
||||
const ok = await window.omni.cloud.addDevice(remoteDeviceId.trim(), remoteDeviceName.trim());
|
||||
if (ok) {
|
||||
showSuccess('Device added! Wait for it to accept, or add this device on the other machine.');
|
||||
setRemoteDeviceId('');
|
||||
setRemoteDeviceName('');
|
||||
loadStatus();
|
||||
} else {
|
||||
showError('Failed to add device');
|
||||
}
|
||||
} catch (err) {
|
||||
showError(`Error: ${err}`);
|
||||
}
|
||||
if (ok) { showSuccess('Device added!'); setRemoteDeviceId(''); setRemoteDeviceName(''); loadData(); }
|
||||
else showError('Failed to add device');
|
||||
} catch (err) { showError(`Error: ${err}`); }
|
||||
setAddingDevice(false);
|
||||
};
|
||||
|
||||
const handleAcceptPendingDevice = async (deviceId: string) => {
|
||||
setAcceptingDevice(deviceId);
|
||||
try {
|
||||
const ok = await window.omni.cloud.acceptPendingDevice(deviceId);
|
||||
if (ok) { showSuccess('Device paired!'); loadData(); } else showError('Failed to accept device');
|
||||
} catch (err) { showError(`Error: ${err}`); }
|
||||
setAcceptingDevice('');
|
||||
};
|
||||
|
||||
const handleAcceptPendingFolder = async (fol: SyncthingPendingFolder) => {
|
||||
const localPath = pendingFolderPaths[fol.folderId];
|
||||
if (!localPath?.trim()) { showError('Set a local path first'); return; }
|
||||
setAcceptingFolder(fol.folderId);
|
||||
try {
|
||||
const ok = await window.omni.cloud.acceptPendingFolder(fol.folderId, fol.folderLabel, localPath.trim(), fol.deviceId);
|
||||
if (ok) { showSuccess(`Folder "${fol.folderLabel}" accepted!`); loadData(); } else showError('Failed to accept folder');
|
||||
} catch (err) { showError(`Error: ${err}`); }
|
||||
setAcceptingFolder('');
|
||||
};
|
||||
|
||||
const handleToggleSync = async (emuId: string, sync: boolean) => {
|
||||
setTogglingSync(emuId);
|
||||
try {
|
||||
const ok = await window.omni.cloud.toggleFolderSync(emuId, sync);
|
||||
if (ok) { showSuccess(sync ? 'Sync enabled' : 'Sync disabled'); loadData(); }
|
||||
else showError('Failed to toggle sync');
|
||||
} catch (err) { showError(`Error: ${err}`); }
|
||||
setTogglingSync('');
|
||||
};
|
||||
|
||||
const handleRemoveDevice = async (deviceId: string) => {
|
||||
try {
|
||||
await window.omni.cloud.removeDevice(deviceId);
|
||||
showSuccess('Device removed');
|
||||
loadStatus();
|
||||
} catch { /* ignore */ }
|
||||
};
|
||||
|
||||
const handleAddFolder = async () => {
|
||||
if (!folderLabel.trim() || !folderPath.trim()) {
|
||||
showError('Enter folder label and path');
|
||||
return;
|
||||
}
|
||||
const id = folderLabel.toLowerCase().replace(/[^a-z0-9]/g, '-');
|
||||
const deviceIds = status?.remoteDevices?.map(d => d.id) || [];
|
||||
try {
|
||||
const ok = await window.omni.cloud.addFolder(id, folderLabel.trim(), folderPath.trim(), deviceIds);
|
||||
if (ok) {
|
||||
showSuccess('Shared folder added');
|
||||
setFolderLabel('');
|
||||
setFolderPath('');
|
||||
setShowAddFolder(false);
|
||||
loadStatus();
|
||||
} else {
|
||||
showError('Failed to add folder');
|
||||
}
|
||||
} catch (err) {
|
||||
showError(`Error: ${err}`);
|
||||
}
|
||||
};
|
||||
|
||||
const handleRemoveFolder = async (folderId: string) => {
|
||||
try {
|
||||
await window.omni.cloud.removeFolder(folderId);
|
||||
showSuccess('Folder removed');
|
||||
loadStatus();
|
||||
} catch { /* ignore */ }
|
||||
try { await window.omni.cloud.removeDevice(deviceId); showSuccess('Device removed'); loadData(); } catch { /* ignore */ }
|
||||
};
|
||||
|
||||
const handleCopyDeviceId = () => {
|
||||
if (status?.deviceId) {
|
||||
navigator.clipboard.writeText(status.deviceId);
|
||||
setCopied(true);
|
||||
setTimeout(() => setCopied(false), 2000);
|
||||
}
|
||||
if (status?.deviceId) { navigator.clipboard.writeText(status.deviceId); setCopied(true); setTimeout(() => setCopied(false), 2000); }
|
||||
};
|
||||
|
||||
const handleCopyApiKey = () => {
|
||||
if (status?.apiKey) {
|
||||
navigator.clipboard.writeText(status.apiKey);
|
||||
showSuccess('API key copied');
|
||||
}
|
||||
};
|
||||
|
||||
const handleOpenWebUI = async () => {
|
||||
await window.omni.cloud.openWebUI();
|
||||
};
|
||||
|
||||
if (loading && !status) {
|
||||
return <div className="loading">Checking Syncthing status...</div>;
|
||||
}
|
||||
if (loading && !status) return <div className="loading">Checking Syncthing status...</div>;
|
||||
|
||||
const installed = status?.installed ?? false;
|
||||
const running = status?.running ?? false;
|
||||
|
||||
// Determine current step
|
||||
let step: SetupStep;
|
||||
if (!installed) step = 'install';
|
||||
else if (!running) step = 'start';
|
||||
else if (!cloudEnabled || (status?.remoteDevices?.length ?? 0) === 0) step = 'setup';
|
||||
else if (!forceReady && (status?.remoteDevices?.length ?? 0) === 0) step = 'setup';
|
||||
else step = 'ready';
|
||||
|
||||
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);
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h2 style={{ marginTop: 0, marginBottom: 16 }}>Cloud Sync</h2>
|
||||
<h2 style={{ marginTop: 0, marginBottom: 16 }}>Cloud Sync <span className="badge-beta">Beta</span></h2>
|
||||
<p className="text-muted" style={{ marginBottom: 20 }}>
|
||||
Sync your game saves between devices using Syncthing. Once set up, it runs automatically on launch.
|
||||
Sync your game saves between devices. Once set up, it runs automatically.
|
||||
</p>
|
||||
|
||||
{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>
|
||||
)}
|
||||
{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>}
|
||||
|
||||
{/* Progress indicator */}
|
||||
{/* Step indicator */}
|
||||
<div style={{
|
||||
display: 'flex', gap: 8, marginBottom: 24, alignItems: 'center',
|
||||
padding: '12px 16px', borderRadius: 10,
|
||||
@@ -275,26 +222,18 @@ export function CloudSyncPage() {
|
||||
<div style={{
|
||||
width: 28, height: 28, borderRadius: '50%', display: 'flex', alignItems: 'center',
|
||||
justifyContent: 'center', fontSize: 12, fontWeight: 700,
|
||||
background: step === s
|
||||
? 'var(--accent)'
|
||||
: (['install', 'start', 'setup', 'ready'].indexOf(step) > i
|
||||
? 'var(--success, #44ff44)' : 'var(--bg-tertiary, #333)'),
|
||||
color: step === s ? '#fff' : 'var(--text-muted, #888)',
|
||||
transition: 'all 0.2s ease',
|
||||
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',
|
||||
}}>
|
||||
{['install', 'start', 'setup', 'ready'].indexOf(step) > i ? '✓' : i + 1}
|
||||
{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,
|
||||
color: step === s ? 'var(--text)' : 'var(--text-muted, #888)', marginRight: i < 3 ? 8 : 0,
|
||||
}}>
|
||||
{s === 'install' ? 'Install' : s === 'start' ? 'Start' : s === 'setup' ? 'Pair' : 'Syncing'}
|
||||
{stepLabel(s)}
|
||||
</span>
|
||||
{i < 3 && <div style={{
|
||||
flex: 1, height: 2, background: 'var(--bg-tertiary, #333)',
|
||||
maxWidth: 40,
|
||||
}} />}
|
||||
{i < 3 && <div style={{ flex: 1, height: 2, background: 'var(--bg-tertiary, #333)', maxWidth: 40 }} />}
|
||||
</React.Fragment>
|
||||
))}
|
||||
</div>
|
||||
@@ -308,32 +247,57 @@ export function CloudSyncPage() {
|
||||
border: `1px solid ${cloudEnabled ? 'rgba(68,255,68,0.3)' : 'rgba(255,200,68,0.3)'}`,
|
||||
color: cloudEnabled ? 'var(--success, #44ff44)' : '#ffc844',
|
||||
}}>
|
||||
<span style={{
|
||||
width: 8, height: 8, borderRadius: '50%',
|
||||
background: cloudEnabled ? 'var(--success, #44ff44)' : '#ffc844',
|
||||
}} />
|
||||
<span style={{ width: 8, height: 8, borderRadius: '50%', background: cloudEnabled ? 'var(--success, #44ff44)' : '#ffc844' }} />
|
||||
{cloudEnabled ? 'Cloud sync active' : 'Running — not yet paired'}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Pending Device Requests */}
|
||||
{running && pendingDevices.length > 0 && (
|
||||
<div className="card mb-4" style={{ border: '2px solid rgba(68,200,255,0.4)' }}>
|
||||
<div className="card-header" style={{ background: 'rgba(68,200,255,0.06)' }}>
|
||||
<h3 style={{ margin: 0 }}>⏳ Pending Device Requests</h3>
|
||||
</div>
|
||||
<div style={{ padding: 12 }}>
|
||||
{pendingDevices.map(dev => (
|
||||
<div key={dev.id} style={{
|
||||
display: 'flex', alignItems: 'center', justifyContent: 'space-between',
|
||||
padding: '10px 12px', borderRadius: 8,
|
||||
border: '1px solid rgba(68,200,255,0.25)', marginBottom: 4,
|
||||
background: 'rgba(68,200,255,0.04)',
|
||||
}}>
|
||||
<div style={{ flex: 1, minWidth: 0 }}>
|
||||
<div style={{ fontWeight: 600, fontSize: 13 }}>{dev.name || 'Unknown Device'}</div>
|
||||
<div className="text-sm text-muted" style={{ fontFamily: 'monospace', fontSize: 10 }}>
|
||||
{dev.id.slice(0, 12)}...{dev.id.slice(-6)}
|
||||
</div>
|
||||
</div>
|
||||
<button
|
||||
className="btn btn-primary btn-sm"
|
||||
onClick={() => handleAcceptPendingDevice(dev.id)}
|
||||
disabled={acceptingDevice === dev.id}
|
||||
style={{ fontSize: 12 }}
|
||||
>
|
||||
{acceptingDevice === dev.id ? 'Pairing...' : '✓ Accept'}
|
||||
</button>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Step 1: Install */}
|
||||
{!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))',
|
||||
}}>
|
||||
<div className="card-header">
|
||||
<h3 style={{ margin: 0 }}>Install Syncthing</h3>
|
||||
</div>
|
||||
<div className="card-header"><h3 style={{ margin: 0 }}>Install Syncthing</h3></div>
|
||||
<div style={{ padding: 16 }}>
|
||||
<p className="text-muted" style={{ marginBottom: 16 }}>
|
||||
Syncthing is the engine behind cloud sync. It's free, open-source, and runs locally — no third-party accounts needed.
|
||||
Syncthing is the engine behind cloud sync. Free, open-source, runs locally — no accounts needed.
|
||||
</p>
|
||||
<button
|
||||
className="btn btn-primary"
|
||||
onClick={handleInstall}
|
||||
style={{ fontSize: 15, padding: '12px 28px' }}
|
||||
>
|
||||
<button className="btn btn-primary" onClick={handleInstall} style={{ fontSize: 15, padding: '12px 28px' }}>
|
||||
⬇ Install Syncthing
|
||||
</button>
|
||||
</div>
|
||||
@@ -342,20 +306,13 @@ export function CloudSyncPage() {
|
||||
|
||||
{installing && (
|
||||
<div className="card mb-4">
|
||||
<div className="card-header">
|
||||
<h3>Installing Syncthing...</h3>
|
||||
</div>
|
||||
<div className="card-header"><h3>Installing Syncthing...</h3></div>
|
||||
<div style={{ padding: 16 }}>
|
||||
<div style={{ marginBottom: 10, fontSize: 13 }}>{installMsg}</div>
|
||||
<div style={{
|
||||
height: 8, borderRadius: 4, background: 'var(--bg-tertiary, #333)',
|
||||
overflow: 'hidden', width: '100%',
|
||||
}}>
|
||||
<div style={{ height: 8, borderRadius: 4, background: 'var(--bg-tertiary, #333)', overflow: 'hidden', width: '100%' }}>
|
||||
<div style={{
|
||||
height: '100%', borderRadius: 4,
|
||||
width: `${installPercent}%`,
|
||||
background: 'linear-gradient(90deg, var(--accent), rgba(108,99,255,0.7))',
|
||||
transition: 'width 0.3s ease',
|
||||
height: '100%', borderRadius: 4, width: `${installPercent}%`,
|
||||
background: 'linear-gradient(90deg, var(--accent), rgba(108,99,255,0.7))', transition: 'width 0.3s ease',
|
||||
}} />
|
||||
</div>
|
||||
</div>
|
||||
@@ -368,271 +325,252 @@ export function CloudSyncPage() {
|
||||
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 }}>Start Syncthing</h3>
|
||||
</div>
|
||||
<div className="card-header"><h3 style={{ margin: 0 }}>Start Syncthing</h3></div>
|
||||
<div style={{ padding: 16 }}>
|
||||
<p className="text-muted" style={{ marginBottom: 16 }}>
|
||||
Start the sync service. It will auto-start on future app launches once enabled.
|
||||
Start the sync service. It will auto-start on future launches.
|
||||
</p>
|
||||
<button
|
||||
className="btn btn-primary"
|
||||
onClick={handleStart}
|
||||
disabled={loading}
|
||||
style={{ fontSize: 15, padding: '12px 28px' }}
|
||||
>
|
||||
<button className="btn btn-primary" onClick={handleStart} disabled={loading} style={{ fontSize: 15, padding: '12px 28px' }}>
|
||||
▶ Start Syncthing
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Steps 3-4: Host & Pair (running) */}
|
||||
{/* Steps 3-4 */}
|
||||
{running && (
|
||||
<>
|
||||
{/* Host section — show your device ID */}
|
||||
<div className="card mb-4">
|
||||
<div className="card-header">
|
||||
<h3>Host — Share This Device</h3>
|
||||
</div>
|
||||
<div style={{ padding: 16 }}>
|
||||
<p className="text-muted text-sm" style={{ marginBottom: 12 }}>
|
||||
Copy this Device ID and paste it into the other machine's OmniEmu or Syncthing to pair.
|
||||
</p>
|
||||
<div style={{ display: 'flex', gap: 8, alignItems: 'center' }}>
|
||||
<textarea
|
||||
ref={uninstallRef}
|
||||
readOnly
|
||||
value={status?.deviceId || ''}
|
||||
style={{
|
||||
flex: 1, fontFamily: 'monospace', fontSize: 12, padding: 8,
|
||||
borderRadius: 6, border: '1px solid var(--border, #555)',
|
||||
background: 'var(--bg-tertiary, #222)', color: 'var(--text, #fff)',
|
||||
resize: 'none', height: 48,
|
||||
}}
|
||||
/>
|
||||
<button className="btn btn-primary btn-sm" onClick={handleCopyDeviceId} style={{ whiteSpace: 'nowrap' }}>
|
||||
{copied ? 'Copied!' : 'Copy ID'}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Pair section — connect to another device */}
|
||||
<div className="card mb-4">
|
||||
<div className="card-header">
|
||||
<h3>Pair — Connect Another Device</h3>
|
||||
</div>
|
||||
<div style={{ padding: 16 }}>
|
||||
<p className="text-muted text-sm" style={{ marginBottom: 12 }}>
|
||||
Enter the Device ID from another machine to connect. Both devices must add each other.
|
||||
</p>
|
||||
<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()}
|
||||
style={{ alignSelf: 'flex-start' }}
|
||||
>
|
||||
{addingDevice ? 'Adding...' : '🔗 Pair Device'}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Paired Devices */}
|
||||
{status?.remoteDevices && status.remoteDevices.length > 0 && (
|
||||
{/* Step 3: Your Device ID + Pair */}
|
||||
{step === 'setup' && (
|
||||
<div className="card mb-4">
|
||||
<div className="card-header">
|
||||
<h3>Paired Devices</h3>
|
||||
</div>
|
||||
<div style={{ padding: '0 12px 12px' }}>
|
||||
{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' : 'Not connected'}
|
||||
</span>
|
||||
<button
|
||||
className="btn btn-danger btn-sm"
|
||||
onClick={() => handleRemoveDevice(device.id)}
|
||||
>
|
||||
Remove
|
||||
</button>
|
||||
</div>
|
||||
<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)}
|
||||
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>
|
||||
)}
|
||||
|
||||
{/* Shared Folders */}
|
||||
<div className="card mb-4">
|
||||
<div className="card-header">
|
||||
<h3>Shared Folders</h3>
|
||||
<button
|
||||
className="btn btn-secondary btn-sm"
|
||||
onClick={() => setShowAddFolder(!showAddFolder)}
|
||||
>
|
||||
{showAddFolder ? 'Cancel' : '+ Add Folder'}
|
||||
</button>
|
||||
</div>
|
||||
<div style={{ padding: 12 }}>
|
||||
{showAddFolder && (
|
||||
<div style={{
|
||||
marginBottom: 12, padding: 12, borderRadius: 8,
|
||||
border: '1px solid var(--border, #555)', background: 'var(--bg-tertiary, #222)',
|
||||
}}>
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 8 }}>
|
||||
<input
|
||||
type="text"
|
||||
placeholder="Folder label (e.g. RetroArch Saves)"
|
||||
value={folderLabel}
|
||||
onChange={e => setFolderLabel(e.target.value)}
|
||||
style={{
|
||||
padding: '8px 10px', borderRadius: 6,
|
||||
border: '1px solid var(--border, #555)',
|
||||
background: 'var(--bg-secondary, #1a1a1a)', color: 'var(--text, #fff)',
|
||||
}}
|
||||
/>
|
||||
<input
|
||||
type="text"
|
||||
placeholder="Folder path (e.g. ~/Documents/RetroArch/saves)"
|
||||
value={folderPath}
|
||||
onChange={e => setFolderPath(e.target.value)}
|
||||
style={{
|
||||
padding: '8px 10px', borderRadius: 6,
|
||||
border: '1px solid var(--border, #555)',
|
||||
background: 'var(--bg-secondary, #1a1a1a)', color: 'var(--text, #fff)',
|
||||
}}
|
||||
/>
|
||||
<button className="btn btn-primary btn-sm" onClick={handleAddFolder} style={{ alignSelf: 'flex-start' }}>
|
||||
Add Shared Folder
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{status?.folders && status.folders.length > 0 ? (
|
||||
status.folders.map(folder => (
|
||||
<div key={folder.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 }}>{folder.label}</div>
|
||||
<div className="text-sm text-muted" style={{ fontFamily: 'monospace', fontSize: 10 }}>
|
||||
{folder.path}
|
||||
</div>
|
||||
</div>
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
|
||||
<span className="badge badge-installed" style={{ fontSize: 10 }}>
|
||||
{folder.type}
|
||||
</span>
|
||||
<button
|
||||
className="btn btn-danger btn-sm"
|
||||
onClick={() => handleRemoveFolder(folder.id)}
|
||||
>
|
||||
Remove
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
))
|
||||
) : (
|
||||
<p className="text-muted text-sm">No shared folders. Add one to start syncing.</p>
|
||||
)}
|
||||
</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={handleOpenWebUI}>
|
||||
Open Web UI
|
||||
</button>
|
||||
<button className="btn btn-secondary btn-sm" onClick={loadStatus} disabled={loading}>
|
||||
Refresh
|
||||
</button>
|
||||
</div>
|
||||
<button className="btn btn-danger btn-sm" onClick={handleStop} disabled={loading}>
|
||||
Stop Syncthing
|
||||
{/* 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>
|
||||
</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 }}>
|
||||
API Key for the Syncthing Web UI.
|
||||
</p>
|
||||
<div style={{ display: 'flex', gap: 8, alignItems: 'center' }}>
|
||||
<code style={{
|
||||
flex: 1, padding: '6px 10px', borderRadius: 6,
|
||||
background: 'var(--bg-tertiary, #222)', fontSize: 11,
|
||||
wordBreak: 'break-all',
|
||||
}}>
|
||||
{status.apiKey}
|
||||
</code>
|
||||
<button className="btn btn-secondary btn-sm" onClick={handleCopyApiKey}>
|
||||
Copy
|
||||
</button>
|
||||
</div>
|
||||
{/* 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>
|
||||
</details>
|
||||
|
||||
{/* 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}>
|
||||
Refresh
|
||||
</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>
|
||||
</div>
|
||||
</details>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
|
||||
@@ -1,42 +1,65 @@
|
||||
import React, { useEffect, useState, useCallback, useRef } from 'react';
|
||||
import type { EmulatorState, InstallProgress } from '../../shared/types';
|
||||
import type { EmulatorState, InstallProgress, DecompState } from '../../shared/types';
|
||||
|
||||
interface ProgressMap {
|
||||
[emulatorId: string]: InstallProgress;
|
||||
interface DecompProgressMap {
|
||||
[decompId: string]: { stage: string; percent: number; message: string; error?: string };
|
||||
}
|
||||
|
||||
const isMacOS = navigator.userAgent.includes('Mac');
|
||||
|
||||
export function EmulatorsPage() {
|
||||
const [states, setStates] = useState<EmulatorState[]>([]);
|
||||
const [decompStates, setDecompStates] = useState<DecompState[]>([]);
|
||||
const [betaFeatures, setBetaFeatures] = useState(false);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [progress, setProgress] = useState<ProgressMap>({});
|
||||
const [progress, setProgress] = useState<Record<string, InstallProgress>>({});
|
||||
const [decompProgress, setDecompProgress] = useState<DecompProgressMap>({});
|
||||
const [actioning, setActioning] = useState<string | null>(null);
|
||||
const cleanups = useRef<(() => void)[]>([]);
|
||||
|
||||
const load = useCallback(async () => {
|
||||
setLoading(true);
|
||||
const result = await window.omni.emulators.states();
|
||||
setStates(result);
|
||||
const [emuResult, decompResult, settings] = await Promise.all([
|
||||
window.omni.emulators.states(),
|
||||
window.omni.decomps.states(),
|
||||
window.omni.settings.get(),
|
||||
]);
|
||||
setStates(emuResult);
|
||||
setDecompStates(decompResult);
|
||||
setBetaFeatures(!!settings.betaFeatures);
|
||||
setLoading(false);
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
load();
|
||||
|
||||
const unsub = window.omni.emulators.onInstallProgress((p: InstallProgress) => {
|
||||
const unsubEmu = window.omni.emulators.onInstallProgress((p: InstallProgress) => {
|
||||
setProgress((prev) => ({ ...prev, [p.emulatorId]: p }));
|
||||
if (p.stage === 'done' || p.stage === 'error') {
|
||||
setActioning(null);
|
||||
}
|
||||
});
|
||||
cleanups.current.push(unsub);
|
||||
|
||||
const unsubDecomp = window.omni.decomps.onInstallProgress((p) => {
|
||||
setDecompProgress((prev) => ({
|
||||
...prev,
|
||||
[p.decompId]: { stage: p.stage, percent: p.percent, message: p.message, error: (p as any).error },
|
||||
}));
|
||||
if (p.stage === 'done' || p.stage === 'error') {
|
||||
setActioning(null);
|
||||
load();
|
||||
}
|
||||
});
|
||||
|
||||
cleanups.current.push(unsubEmu, unsubDecomp);
|
||||
|
||||
return () => {
|
||||
cleanups.current.forEach((fn) => fn());
|
||||
};
|
||||
}, [load]);
|
||||
|
||||
// ── Emulator handlers ─────────────────────────────────────
|
||||
|
||||
const handleInstall = async (id: string) => {
|
||||
setActioning(id);
|
||||
setProgress((prev) => ({
|
||||
@@ -101,22 +124,47 @@ export function EmulatorsPage() {
|
||||
await window.omni.emulators.openWebsite(id);
|
||||
};
|
||||
|
||||
// ── Decomp handlers ───────────────────────────────────────
|
||||
|
||||
const handleDecompInstall = async (id: string) => {
|
||||
setActioning(id);
|
||||
setDecompProgress((prev) => ({
|
||||
...prev,
|
||||
[id]: { stage: 'downloading', percent: 0, message: 'Starting...' },
|
||||
}));
|
||||
await window.omni.decomps.install(id);
|
||||
await load();
|
||||
};
|
||||
|
||||
const handleDecompUninstall = async (id: string) => {
|
||||
if (!confirm(`Uninstall this port and remove all its files?`)) return;
|
||||
setActioning(id);
|
||||
await window.omni.decomps.uninstall(id);
|
||||
setActioning(null);
|
||||
await load();
|
||||
};
|
||||
|
||||
const handleDecompLaunch = async (id: string) => {
|
||||
setActioning(id);
|
||||
await window.omni.decomps.launch(id);
|
||||
setActioning(null);
|
||||
};
|
||||
|
||||
const handleDecompSelectRom = async (id: string) => {
|
||||
const result = await window.omni.decomps.selectRom(id);
|
||||
if (result.state) {
|
||||
setDecompStates((prev) =>
|
||||
prev.map((d) => (d.config.id === id ? result.state : d))
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
const handleRefresh = () => load();
|
||||
|
||||
if (loading) {
|
||||
return <div className="loading">Checking emulators...</div>;
|
||||
}
|
||||
|
||||
if (states.length === 0) {
|
||||
return (
|
||||
<div className="empty-state">
|
||||
<div className="empty-state-icon">🕹️</div>
|
||||
<h3>No emulators configured</h3>
|
||||
<p>Ready to install and configure emulators automatically.</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
const currentProgress = (id: string) => progress[id];
|
||||
|
||||
return (
|
||||
@@ -126,14 +174,14 @@ export function EmulatorsPage() {
|
||||
{states.filter((s) => s.installed).length} installed
|
||||
{' · '}
|
||||
{states.filter((s) => s.configured).length} configured
|
||||
{' · '}
|
||||
{Object.keys(progress).length > 0 && ' Installing...'}
|
||||
{Object.keys(progress).length > 0 && ' · Installing...'}
|
||||
</span>
|
||||
<button className="btn btn-secondary btn-sm" onClick={handleRefresh}>
|
||||
Refresh
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* ── Emulators Grid ───────────────────────────────── */}
|
||||
<div className="card-grid">
|
||||
{states.map((state) => {
|
||||
const prog = currentProgress(state.config.id);
|
||||
@@ -211,15 +259,7 @@ export function EmulatorsPage() {
|
||||
>
|
||||
{!state.installed && state.config.supported && (
|
||||
<>
|
||||
{state.config.id === 'esde' && isMacOS ? (
|
||||
<button
|
||||
className="btn btn-primary btn-sm"
|
||||
disabled={isActioning}
|
||||
onClick={() => handleInstall(state.config.id)}
|
||||
>
|
||||
{isActioning ? 'Working...' : 'Install Manually'}
|
||||
</button>
|
||||
) : state.config.id === 'neostation' && isMacOS ? (
|
||||
{(state.config.id === 'esde' || state.config.id === 'neostation') && isMacOS ? (
|
||||
<button
|
||||
className="btn btn-primary btn-sm"
|
||||
disabled={isActioning}
|
||||
@@ -310,6 +350,143 @@ export function EmulatorsPage() {
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
|
||||
{/* ── Decompilations Section (Beta) ───────────────── */}
|
||||
{betaFeatures && (<>
|
||||
<div style={{ marginTop: 40 }}>
|
||||
<div className="info-bar" style={{ marginBottom: 16 }}>
|
||||
<h2 style={{ fontSize: 20, fontWeight: 600 }}>Decompilations <span className="badge-beta">Beta</span></h2>
|
||||
<span className="text-sm text-muted">
|
||||
Native PC ports built from reverse-engineered source code — bring your own ROM
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div className="card-grid">
|
||||
{decompStates.map((decomp) => {
|
||||
const dprog = decompProgress[decomp.config.id];
|
||||
const isActioning = actioning === decomp.config.id;
|
||||
|
||||
return (
|
||||
<div className="card" key={decomp.config.id}>
|
||||
<div className="card-header">
|
||||
<h3>{decomp.config.name}</h3>
|
||||
<span
|
||||
className={`badge ${
|
||||
decomp.installed
|
||||
? decomp.hasRom
|
||||
? 'badge-installed'
|
||||
: 'badge-installed'
|
||||
: 'badge-missing'
|
||||
}`}
|
||||
>
|
||||
{decomp.installed
|
||||
? decomp.hasRom
|
||||
? 'Ready to Play'
|
||||
: 'Needs ROM'
|
||||
: 'Not installed'}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<p>{decomp.config.description}</p>
|
||||
|
||||
<div style={{ marginTop: 8 }}>
|
||||
<span className="platform-tag">{decomp.config.platform}</span>
|
||||
{decomp.config.features.slice(0, 3).map((f) => (
|
||||
<span className="platform-tag" key={f} style={{ background: 'var(--accent-dim)', color: 'var(--accent)' }}>
|
||||
{f}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{decomp.version && (
|
||||
<p className="text-sm text-muted mt-2">Version: {decomp.version}</p>
|
||||
)}
|
||||
|
||||
{dprog && (
|
||||
<div className="mt-2">
|
||||
<div className="progress-bar">
|
||||
<div
|
||||
className="progress-fill"
|
||||
style={{
|
||||
width: `${dprog.percent}%`,
|
||||
background: dprog.stage === 'error' ? 'var(--error)' : 'var(--accent)',
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
<p className="text-sm text-muted mt-2">
|
||||
{dprog.stage === 'error'
|
||||
? `Error: ${dprog.error || dprog.message}`
|
||||
: dprog.message}
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div
|
||||
style={{
|
||||
marginTop: 12,
|
||||
display: 'flex',
|
||||
flexWrap: 'wrap',
|
||||
gap: 6,
|
||||
alignItems: 'center',
|
||||
}}
|
||||
>
|
||||
{!decomp.installed && (
|
||||
<button
|
||||
className="btn btn-primary btn-sm"
|
||||
disabled={isActioning}
|
||||
onClick={() => handleDecompInstall(decomp.config.id)}
|
||||
>
|
||||
{isActioning ? 'Working...' : 'Install'}
|
||||
</button>
|
||||
)}
|
||||
|
||||
{decomp.installed && (
|
||||
<>
|
||||
<button
|
||||
className="btn btn-primary btn-sm"
|
||||
disabled={isActioning}
|
||||
onClick={() => handleDecompLaunch(decomp.config.id)}
|
||||
>
|
||||
Launch
|
||||
</button>
|
||||
<button
|
||||
className="btn btn-secondary btn-sm"
|
||||
disabled={isActioning}
|
||||
onClick={() => handleDecompSelectRom(decomp.config.id)}
|
||||
>
|
||||
{decomp.hasRom ? 'Change ROM' : 'Select ROM'}
|
||||
</button>
|
||||
<button
|
||||
className="btn btn-danger btn-sm"
|
||||
disabled={isActioning}
|
||||
onClick={() => handleDecompUninstall(decomp.config.id)}
|
||||
>
|
||||
Uninstall
|
||||
</button>
|
||||
</>
|
||||
)}
|
||||
|
||||
<button
|
||||
className="btn-icon"
|
||||
title="View on GitHub"
|
||||
onClick={() => window.open(decomp.config.githubUrl, '_blank')}
|
||||
style={{ marginLeft: 'auto' }}
|
||||
>
|
||||
↗
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{decomp.installed && !decomp.hasRom && (
|
||||
<p className="text-sm mt-2" style={{ color: 'var(--warning)' }}>
|
||||
Supply a legal ROM dump to play. Click "Select ROM" above.
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
</>)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import React, { useEffect, useState, useCallback } from 'react';
|
||||
import type { GameEntry } from '../../shared/types';
|
||||
import type { GameEntry, DecompState } from '../../shared/types';
|
||||
import { GameDetailModal } from '../components/GameDetailModal';
|
||||
|
||||
const platformIcons: Record<string, string> = {
|
||||
@@ -12,6 +12,8 @@ const platformIcons: Record<string, string> = {
|
||||
|
||||
export function LibraryPage() {
|
||||
const [games, setGames] = useState<GameEntry[]>([]);
|
||||
const [decompGames, setDecompGames] = useState<DecompState[]>([]);
|
||||
const [betaFeatures, setBetaFeatures] = useState(false);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [romsDir, setRomsDir] = useState<string>('');
|
||||
const [selectedGame, setSelectedGame] = useState<GameEntry | null>(null);
|
||||
@@ -19,6 +21,7 @@ export function LibraryPage() {
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
const settings = await window.omni.settings.get();
|
||||
setBetaFeatures(!!settings.betaFeatures);
|
||||
if (settings.romsDirectory) {
|
||||
setRomsDir(settings.romsDirectory);
|
||||
setLoading(true);
|
||||
@@ -26,6 +29,9 @@ export function LibraryPage() {
|
||||
setGames(await scrapeMissingArt(results));
|
||||
setLoading(false);
|
||||
}
|
||||
// Load installed decomps
|
||||
const decompStates = await window.omni.decomps.states();
|
||||
setDecompGames(decompStates.filter(d => d.installed));
|
||||
})();
|
||||
}, []);
|
||||
|
||||
@@ -62,6 +68,12 @@ export function LibraryPage() {
|
||||
await window.omni.game.launch(game.emulatorId, game.romPath);
|
||||
};
|
||||
|
||||
const handleDecompLaunch = async (decomp: DecompState) => {
|
||||
if (decomp.romPath) {
|
||||
await window.omni.decomps.launch(decomp.config.id);
|
||||
}
|
||||
};
|
||||
|
||||
const handleShowDetail = (game: GameEntry) => {
|
||||
setSelectedGame(game);
|
||||
};
|
||||
@@ -156,6 +168,47 @@ export function LibraryPage() {
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* ── Installed Decomps as Games (Beta) ──────────────── */}
|
||||
{betaFeatures && decompGames.length > 0 && (
|
||||
<div style={{ marginTop: 32 }}>
|
||||
<div className="info-bar">
|
||||
<span style={{ fontWeight: 600 }}>Decompilations <span className="badge-beta">Beta</span></span>
|
||||
<span className="text-sm text-muted">
|
||||
{decompGames.filter(d => d.hasRom).length} ready · {decompGames.length} installed
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div className="library-grid">
|
||||
{decompGames.map((decomp) => (
|
||||
<div
|
||||
className="game-card"
|
||||
key={decomp.config.id}
|
||||
onClick={() => decomp.hasRom && handleDecompLaunch(decomp)}
|
||||
onKeyDown={(e) => {
|
||||
if ((e.key === 'Enter' || e.key === ' ') && decomp.hasRom) handleDecompLaunch(decomp);
|
||||
}}
|
||||
tabIndex={0}
|
||||
role="button"
|
||||
title={decomp.hasRom ? `Launch ${decomp.config.name}` : `${decomp.config.name} — needs ROM`}
|
||||
style={!decomp.hasRom ? { opacity: 0.6 } : undefined}
|
||||
>
|
||||
<div className="game-card-cover">
|
||||
<span style={{ fontSize: 32 }}>{platformIcons[decomp.config.platform.toLowerCase()] || '🎮'}</span>
|
||||
</div>
|
||||
<div className="game-card-info">
|
||||
<div className="game-card-title">{decomp.config.name}</div>
|
||||
<div className="game-card-platform">
|
||||
{decomp.config.platform} · decomp
|
||||
{!decomp.hasRom && ' · needs ROM'}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{selectedGame && (
|
||||
<GameDetailModal
|
||||
game={selectedGame}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React, { useEffect, useState, useCallback } from 'react';
|
||||
import type { GameEntry, EmulatorSaves, SaveEntry } from '../../shared/types';
|
||||
import type { GameEntry, EmulatorSaves, SaveEntry, SyncthingFolder } from '../../shared/types';
|
||||
|
||||
function formatSize(bytes: number): string {
|
||||
if (bytes < 1024) return `${bytes} B`;
|
||||
@@ -48,6 +48,9 @@ export function SaveManagerPage() {
|
||||
const [expandedGame, setExpandedGame] = useState<string | null>(null);
|
||||
const [status, setStatus] = useState('');
|
||||
const [view, setView] = useState<'games' | 'emulators'>('games');
|
||||
const [syncFolders, setSyncFolders] = useState<SyncthingFolder[]>([]);
|
||||
const [cloudEnabled, setCloudEnabled] = useState(false);
|
||||
const [togglingSync, setTogglingSync] = useState<string | null>(null);
|
||||
|
||||
const loadData = useCallback(async () => {
|
||||
setLoading(true);
|
||||
@@ -60,6 +63,14 @@ export function SaveManagerPage() {
|
||||
const roms = await window.omni.roms.scan(settings.romsDirectory);
|
||||
setGames(roms);
|
||||
}
|
||||
// Detect cloud sync: either the flag is set, or Syncthing is actually running
|
||||
let cloudOk = !!settings.cloudSyncEnabled;
|
||||
try {
|
||||
const cloudStatus = await window.omni.cloud.status();
|
||||
setSyncFolders(cloudStatus.folders || []);
|
||||
if (cloudStatus.running) cloudOk = true;
|
||||
} catch { /* ignore */ }
|
||||
setCloudEnabled(cloudOk);
|
||||
setLoading(false);
|
||||
}, []);
|
||||
|
||||
@@ -110,6 +121,34 @@ export function SaveManagerPage() {
|
||||
window.omni.saves.openFolder(emu.saveDir);
|
||||
};
|
||||
|
||||
const isDirSynced = (dirPath: string): SyncthingFolder | undefined => {
|
||||
return syncFolders.find(f => f.path === dirPath);
|
||||
};
|
||||
|
||||
const handleToggleSync = async (emu: EmulatorSaves) => {
|
||||
const existing = isDirSynced(emu.saveDir);
|
||||
setTogglingSync(emu.emulatorId);
|
||||
try {
|
||||
if (existing) {
|
||||
await window.omni.cloud.removeFolder(existing.id);
|
||||
setSyncFolders(prev => prev.filter(f => f.id !== existing.id));
|
||||
showStatus(`${emu.emulatorName} sync disabled`);
|
||||
} else {
|
||||
const id = `saves-${emu.emulatorId}`;
|
||||
const ok = await window.omni.cloud.addFolder(id, `${emu.emulatorName} Saves`, emu.saveDir, []);
|
||||
if (ok) {
|
||||
setSyncFolders(prev => [...prev, { id, label: `${emu.emulatorName} Saves`, path: emu.saveDir, type: 'sendreceive' }]);
|
||||
showStatus(`${emu.emulatorName} sync enabled`);
|
||||
} else {
|
||||
showStatus('Failed to enable sync');
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
showStatus('Sync toggle failed');
|
||||
}
|
||||
setTogglingSync(null);
|
||||
};
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className="info-bar mb-4" style={{ justifyContent: 'space-between' }}>
|
||||
@@ -192,6 +231,7 @@ export function SaveManagerPage() {
|
||||
save={save}
|
||||
onDelete={handleDelete}
|
||||
onBackup={handleBackup}
|
||||
syncFolders={syncFolders}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
@@ -215,6 +255,7 @@ export function SaveManagerPage() {
|
||||
save={save}
|
||||
onDelete={handleDelete}
|
||||
onBackup={handleBackup}
|
||||
syncFolders={syncFolders}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
@@ -234,12 +275,24 @@ export function SaveManagerPage() {
|
||||
{emu.saves.length} file{emu.saves.length !== 1 ? 's' : ''}
|
||||
</span>
|
||||
</div>
|
||||
<button
|
||||
className="btn btn-secondary btn-sm"
|
||||
onClick={() => handleOpenEmuFolder(emu)}
|
||||
>
|
||||
Open Folder
|
||||
</button>
|
||||
<div style={{ display: 'flex', gap: 6, alignItems: 'center' }}>
|
||||
{cloudEnabled && emu.saves.length > 0 && (
|
||||
<button
|
||||
className={`btn btn-sm ${isDirSynced(emu.saveDir) ? 'btn-primary' : 'btn-secondary'}`}
|
||||
onClick={() => handleToggleSync(emu)}
|
||||
disabled={togglingSync === emu.emulatorId}
|
||||
title={isDirSynced(emu.saveDir) ? 'Sync enabled — click to disable' : 'Enable sync for this folder'}
|
||||
>
|
||||
{togglingSync === emu.emulatorId ? '...' : isDirSynced(emu.saveDir) ? '☁ Synced' : '☁ Sync'}
|
||||
</button>
|
||||
)}
|
||||
<button
|
||||
className="btn btn-secondary btn-sm"
|
||||
onClick={() => handleOpenEmuFolder(emu)}
|
||||
>
|
||||
Open Folder
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
{emu.saves.length === 0 ? (
|
||||
<p className="text-sm text-muted" style={{ padding: '0 12px 12px' }}>No saves.</p>
|
||||
@@ -262,11 +315,18 @@ export function SaveManagerPage() {
|
||||
);
|
||||
}
|
||||
|
||||
function SaveRow({ save, onDelete, onBackup }: {
|
||||
function isSaveSynced(filePath: string, syncFolders: SyncthingFolder[]): boolean {
|
||||
if (!syncFolders.length) return false;
|
||||
return syncFolders.some(f => filePath.startsWith(f.path));
|
||||
}
|
||||
|
||||
function SaveRow({ save, onDelete, onBackup, syncFolders }: {
|
||||
save: SaveEntry;
|
||||
onDelete: (s: SaveEntry) => void;
|
||||
onBackup: (s: SaveEntry) => void;
|
||||
syncFolders?: SyncthingFolder[];
|
||||
}) {
|
||||
const synced = syncFolders && isSaveSynced(save.filePath, syncFolders);
|
||||
return (
|
||||
<div style={{
|
||||
display: 'flex',
|
||||
@@ -289,6 +349,11 @@ function SaveRow({ save, onDelete, onBackup }: {
|
||||
{save.fileName} · {formatSize(save.fileSize)} · {formatDate(save.lastModified)}
|
||||
</div>
|
||||
</div>
|
||||
{synced && (
|
||||
<span style={{ fontSize: 11, color: 'var(--accent)', fontWeight: 600, whiteSpace: 'nowrap' }} title="Synced via Cloud Sync">
|
||||
☁
|
||||
</span>
|
||||
)}
|
||||
<div style={{ display: 'flex', gap: 4, flexShrink: 0 }}>
|
||||
<button className="btn btn-secondary btn-sm" onClick={() => onBackup(save)}>Backup</button>
|
||||
<button className="btn btn-danger btn-sm" onClick={() => onDelete(save)}>Delete</button>
|
||||
|
||||
@@ -235,7 +235,7 @@ export function SettingsPage() {
|
||||
<div>
|
||||
<div className="setting-label">Enable Beta Features</div>
|
||||
<div className="setting-desc">
|
||||
Unlocks experimental emulators and frontends (ES-DE, NeoStation)
|
||||
Unlocks experimental emulators, frontends, and decompilations (ES-DE, NeoStation, SoH, etc.)
|
||||
</div>
|
||||
</div>
|
||||
<label className="toggle">
|
||||
|
||||
@@ -399,6 +399,18 @@ body::before {
|
||||
border: 1px solid rgba(245, 158, 11, 0.3);
|
||||
}
|
||||
|
||||
.badge-needsrom {
|
||||
background: rgba(245, 158, 11, 0.2);
|
||||
color: var(--warning);
|
||||
border: 1px solid rgba(245, 158, 11, 0.3);
|
||||
}
|
||||
|
||||
.badge-beta {
|
||||
background: rgba(168, 85, 247, 0.2);
|
||||
color: #a855f7;
|
||||
border: 1px solid rgba(168, 85, 247, 0.3);
|
||||
}
|
||||
|
||||
/* Buttons - XMB-style with glow effects */
|
||||
.btn {
|
||||
display: inline-flex;
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import type {
|
||||
EmulatorConfig,
|
||||
EmulatorState,
|
||||
DecompProject,
|
||||
DecompState,
|
||||
GameEntry,
|
||||
GameMetadata,
|
||||
AchievementInfo,
|
||||
@@ -10,6 +12,8 @@ import type {
|
||||
ConfigPreset,
|
||||
EmulatorSaves,
|
||||
SyncthingStatus,
|
||||
SyncthingPendingDevice,
|
||||
SyncthingPendingFolder,
|
||||
} from '../shared/types';
|
||||
|
||||
declare global {
|
||||
@@ -34,6 +38,17 @@ declare global {
|
||||
updateControllerConfig: (id: string, installPath: string, controllerName?: string) => Promise<boolean>;
|
||||
onInstallProgress: (cb: (p: InstallProgress) => void) => () => void;
|
||||
};
|
||||
decomps: {
|
||||
states: () => Promise<DecompState[]>;
|
||||
check: (id: string) => Promise<DecompState>;
|
||||
install: (id: string) => Promise<DecompState>;
|
||||
uninstall: (id: string) => Promise<{ removed: boolean; state: DecompState }>;
|
||||
launch: (id: string) => Promise<boolean>;
|
||||
openWebsite: (id: string) => Promise<boolean>;
|
||||
setRom: (id: string, romPath: string) => Promise<DecompState>;
|
||||
selectRom: (id: string) => Promise<{ romPath: string | null; state: DecompState }>;
|
||||
onInstallProgress: (cb: (p: { decompId: string; stage: string; percent: number; message: string }) => void) => () => void;
|
||||
};
|
||||
roms: {
|
||||
scan: (directory?: string) => Promise<GameEntry[]>;
|
||||
selectDirectory: () => Promise<string | null>;
|
||||
@@ -94,6 +109,13 @@ declare global {
|
||||
addFolder: (id: string, label: string, path: string, deviceIds: string[]) => Promise<boolean>;
|
||||
removeFolder: (folderId: string) => Promise<boolean>;
|
||||
openWebUI: () => Promise<boolean>;
|
||||
pendingDevices: () => Promise<SyncthingPendingDevice[]>;
|
||||
acceptPendingDevice: (deviceId: string) => Promise<boolean>;
|
||||
pendingFolders: () => Promise<SyncthingPendingFolder[]>;
|
||||
acceptPendingFolder: (folderId: string, folderLabel: string, localPath: string, deviceId: string) => Promise<boolean>;
|
||||
guessPath: (label: string) => Promise<string | null>;
|
||||
emulatorDirs: () => Promise<{ id: string; name: string; saves: string | null }[]>;
|
||||
toggleFolderSync: (emuId: string, sync: boolean) => Promise<boolean>;
|
||||
onInstallProgress: (cb: (progress: { stage: string; percent: number; message: string }) => void) => () => void;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -156,6 +156,32 @@ export interface SystemInfo {
|
||||
appDataDir: string;
|
||||
}
|
||||
|
||||
export interface DecompProject {
|
||||
id: string;
|
||||
name: string;
|
||||
description: string;
|
||||
platform: string;
|
||||
githubUrl: string;
|
||||
/** GitHub repo in "owner/repo" format for release downloads */
|
||||
githubRepo: string;
|
||||
/** Executable path inside the extracted directory */
|
||||
executablePath: Record<Platform, string>;
|
||||
/** ROM file extensions this port expects (e.g. ['.z64', '.n64']) */
|
||||
romExtensions: string[];
|
||||
requiresRom: boolean;
|
||||
features: string[];
|
||||
}
|
||||
|
||||
export interface DecompState {
|
||||
installed: boolean;
|
||||
version?: string;
|
||||
path?: string;
|
||||
config: DecompProject;
|
||||
/** Whether a ROM has been supplied in the rom directory */
|
||||
hasRom: boolean;
|
||||
romPath?: string;
|
||||
}
|
||||
|
||||
export interface EmulatorState {
|
||||
installed: boolean;
|
||||
version?: string;
|
||||
@@ -218,3 +244,15 @@ export interface SyncthingRemoteDevice {
|
||||
addresses: string[];
|
||||
connected: boolean;
|
||||
}
|
||||
|
||||
export interface SyncthingPendingDevice {
|
||||
id: string;
|
||||
name: string;
|
||||
address?: string;
|
||||
}
|
||||
|
||||
export interface SyncthingPendingFolder {
|
||||
folderId: string;
|
||||
folderLabel: string;
|
||||
deviceId: string;
|
||||
}
|
||||
Reference in new issue
Block a user