cleanup comments, update translations, bump to 0.4.1
This commit is contained in:
parent
9edcc9841b
commit
7d8ab87eee
28 changed files with 412 additions and 1114 deletions
38
src/paths.js
38
src/paths.js
|
|
@ -3,9 +3,7 @@
|
|||
const path = require('path')
|
||||
const fs = require('fs')
|
||||
|
||||
// Packaged builds run from <portable root>/olcxja.plwl/resources/app.asar:
|
||||
// the portable layout (<root>/files) is two levels above the resources dir
|
||||
// and files bundled with the release are unpacked next to the asar.
|
||||
// Packaged: resources/app.asar two levels below the portable root.
|
||||
function computeRoots() {
|
||||
const m = __dirname.match(/^(.*)[/\\]app\.asar([/\\]|$)/)
|
||||
if (m) {
|
||||
|
|
@ -16,8 +14,7 @@ function computeRoots() {
|
|||
APP_ROOT,
|
||||
// FILES = BUILD/files, so BUILD is the portable root itself.
|
||||
BUILD: process.env.PLWL_BUILD_DIR || APP_ROOT,
|
||||
// Bundled release files live inside the asar (Electron's patched fs
|
||||
// can read them directly from the archive).
|
||||
// bundled release files live inside the asar
|
||||
BUNDLED: fs.existsSync(path.join(RESOURCES, 'app.asar', 'files', 'translations'))
|
||||
? path.join(RESOURCES, 'app.asar', 'files')
|
||||
: path.join(APP_ROOT, 'files')
|
||||
|
|
@ -50,16 +47,11 @@ const DIRS = {
|
|||
FAKE_STEAM: path.join(DATA, 'fake-steam')
|
||||
}
|
||||
|
||||
// Bundled translation files are launcher-owned: on every start they are
|
||||
// refreshed in the portable files/translations folder WHENEVER THEIR CONTENT
|
||||
// CHANGED, so an update shipping new or changed keys reaches existing
|
||||
// installs too (the old copy-only-if-missing logic froze translations at the
|
||||
// version that happened to run first). Extra files in the target folder that
|
||||
// the bundle does not ship (user-added languages) are left untouched.
|
||||
// Bundled translations are refreshed on start whenever their content changed,
|
||||
// so updates reach existing installs; user-added languages are untouched.
|
||||
function filesDiffer(a, b) {
|
||||
try {
|
||||
// compare as text on purpose: Buffer.equals() throws on a string, and that
|
||||
// throw was read as "differs", so every boot recopied every translation
|
||||
// compare as text: Buffer.equals() throws on a string
|
||||
return fs.readFileSync(a, 'utf8') !== fs.readFileSync(b, 'utf8')
|
||||
} catch {
|
||||
return true // target missing/unreadable -> needs a (re)copy
|
||||
|
|
@ -100,10 +92,8 @@ function ensureDirs() {
|
|||
}
|
||||
}
|
||||
|
||||
// Portable paths: anything stored under FILES/ goes into the registry as a
|
||||
// path RELATIVE to FILES (e.g. apps/<id>/game.exe), so moving the whole
|
||||
// launcher folder keeps the library working. Absolute paths outside FILES
|
||||
// (games left in place) are stored as-is. Resolve on read, normalize on write.
|
||||
// Anything under FILES/ is stored FILES-relative; absolute paths outside are
|
||||
// kept as-is. Resolve on read, normalize on write.
|
||||
function toPortablePath(p) {
|
||||
if (typeof p !== 'string' || !p || !path.isAbsolute(p)) return p
|
||||
const rel = path.relative(FILES, p)
|
||||
|
|
@ -116,15 +106,8 @@ function resolvePortablePath(p) {
|
|||
return path.join(FILES, p)
|
||||
}
|
||||
|
||||
// The launcher's own icon (renderer/plwl.png), used by the tray, the app
|
||||
// icon and as the .desktop shortcut fallback.
|
||||
//
|
||||
// The module-relative copy comes FIRST: it is the only candidate that exists
|
||||
// in every layout, because a packaged build keeps renderer/ inside
|
||||
// app.asar and Electron's patched fs reads straight out of the archive (a
|
||||
// release only ships olcxja.plwl.png next to the portable root, so looking at
|
||||
// APP_ROOT alone made the tray icon vanish in installed builds). Cached: it
|
||||
// never moves at runtime.
|
||||
// The launcher's own icon (renderer/plwl.png) for tray, app icon, shortcut
|
||||
// fallback. The module-relative copy is the only candidate in every layout.
|
||||
function launcherIconCandidates() {
|
||||
const bundled = path.join(__dirname, '..', 'renderer')
|
||||
return [
|
||||
|
|
@ -151,8 +134,7 @@ function launcherIconPath() {
|
|||
return launcherIcon || null
|
||||
}
|
||||
|
||||
// The same icon, but only as a real file on disk: a .desktop entry's Icon= is
|
||||
// resolved by the desktop environment, which cannot look inside app.asar.
|
||||
// The icon as a real file: a .desktop Icon= cannot live inside app.asar.
|
||||
function launcherIconDiskPath() {
|
||||
const onDisk = launcherIconCandidates().filter(candidate => !candidate.includes(`.asar${path.sep}`))
|
||||
return firstExisting(onDisk)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue