Files
club-launcher/electron/settings.ts
T
houseassassin b84a7bdf29 feat: v1.3.0 — Steam path override, game folder scanner
- electron/settings.ts: persist steamPath + gameFolders in settings.json
- electron/scanner.ts: scan folders 2 levels deep for .exe files,
  filter out known non-game binaries (uninstall/setup/redist/crash handlers)
- electron/steam.ts: detectSteamGames(customPath?) — uses user path when set
- electron/main.ts: new IPC handlers — dialog:pick-folder, settings:get/set-steam-path/
  add-folder/remove-folder, scanner:scan/import
- src/components/SettingsPanel.tsx: drawer UI — Steam path picker with auto-resolved
  path display, game folders list, per-folder scan with checkbox selection,
  one-click import of selected executables
- src/App.tsx: SlidersHorizontal button opens SettingsPanel, reload on import

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-02 13:05:29 +00:00

43 lines
1.1 KiB
TypeScript

import { app } from 'electron'
import { existsSync, readFileSync, writeFileSync } from 'fs'
import { join } from 'path'
export interface AppSettings {
steamPath: string | null
gameFolders: string[]
}
const DEFAULTS: AppSettings = {
steamPath: null,
gameFolders: [],
}
function settingsPath(): string {
return join(app.getPath('userData'), 'settings.json')
}
export function readSettings(): AppSettings {
const path = settingsPath()
if (!existsSync(path)) return { ...DEFAULTS }
try {
const raw = JSON.parse(readFileSync(path, 'utf-8'))
return {
steamPath: typeof raw.steamPath === 'string' ? raw.steamPath : null,
gameFolders: Array.isArray(raw.gameFolders) ? raw.gameFolders.filter((f: unknown) => typeof f === 'string') : [],
}
} catch {
return { ...DEFAULTS }
}
}
export function writeSettings(settings: AppSettings): void {
writeFileSync(settingsPath(), JSON.stringify(settings, null, 2), 'utf-8')
}
export function updateSettings(patch: Partial<AppSettings>): AppSettings {
const current = readSettings()
const updated = { ...current, ...patch }
writeSettings(updated)
return updated
}