add importing from prefix
This commit is contained in:
parent
29a20324a6
commit
b83e530392
11 changed files with 287 additions and 22 deletions
|
|
@ -29,13 +29,23 @@ function writePlaySeconds(id, seconds) {
|
|||
fs.writeFileSync(file, String(Math.max(0, Math.round(seconds))))
|
||||
}
|
||||
|
||||
// Prefix imports keep exe/workdir paths relative to the PREFIX ROOT
|
||||
// ("drive_c/..." for plain wine, "pfx/drive_c/..." for Proton-managed
|
||||
// prefixes) so wine sees them under C:\... - everything else is
|
||||
// FILES-relative/absolute.
|
||||
const isPrefixRel = v => typeof v === 'string' && /^(pfx[/\\])?drive_c([/\\]|$)/i.test(v)
|
||||
|
||||
function loadGames() {
|
||||
const games = readJson(REGISTRY, [])
|
||||
for (const g of games) {
|
||||
// stored relative to FILES (portable) -> resolve to absolute for use
|
||||
g.path = resolvePortablePath(g.path)
|
||||
g.exePath = resolvePortablePath(g.exePath)
|
||||
if (g.workdir) g.workdir = resolvePortablePath(g.workdir)
|
||||
// stored relative to FILES (portable) -> resolve to absolute for use.
|
||||
// Prefix imports resolve against their own prefix instead (never the
|
||||
// launcher-wide default).
|
||||
const usePrefix = g.importSource === 'prefix' && g.prefix ? prefixPath(g.prefix) : null
|
||||
for (const k of ['path', 'exePath', 'workdir']) {
|
||||
if (!g[k]) continue
|
||||
g[k] = usePrefix && isPrefixRel(g[k]) ? path.join(usePrefix, g[k]) : resolvePortablePath(g[k])
|
||||
}
|
||||
if (g.iconSource) g.iconSource = resolvePortablePath(g.iconSource)
|
||||
const ps = readPlaySeconds(g.id)
|
||||
if (ps != null) g.playSeconds = ps
|
||||
|
|
@ -48,8 +58,18 @@ function loadGames() {
|
|||
// FILES (apps left in place) are kept as-is.
|
||||
function portableGame(g) {
|
||||
const out = { ...g }
|
||||
const pfx = out.importSource === 'prefix' && out.prefix ? prefixPath(out.prefix) : null
|
||||
for (const k of ['path', 'exePath', 'workdir', 'iconSource']) {
|
||||
if (out[k]) out[k] = toPortablePath(out[k])
|
||||
const v = out[k]
|
||||
if (!v) continue
|
||||
if (pfx && k !== 'iconSource' && !isPrefixRel(v)) {
|
||||
// prefix game: store relative to the PREFIX ROOT (keeps the drive_c
|
||||
// segment, e.g. "drive_c/Games/..." or "pfx/drive_c/Games/...")
|
||||
const rel = path.relative(pfx, resolvePortablePath(v))
|
||||
if (rel && !rel.startsWith('..') && !path.isAbsolute(rel)) out[k] = rel
|
||||
} else if (!(pfx && isPrefixRel(v))) {
|
||||
out[k] = toPortablePath(v)
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
|
@ -95,6 +115,9 @@ function removeGame(id) {
|
|||
require('fs').rmSync(g.path, { recursive: true, force: true })
|
||||
} catch {}
|
||||
}
|
||||
// prefix imports live inside the prefix: deleting launcher files would
|
||||
// nuke the user's prefix (installed DLLs, saves of every other app), so
|
||||
// only the registry entry is dropped
|
||||
games.splice(idx, 1)
|
||||
saveGames(games)
|
||||
return true
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue