Stores: Epic overlay off by default, switches saved on disk, registry writes checked

With the overlay pointer set Metalstorm exits while loading; without it
the game signs in and runs. The overlay now defaults to off: the
sidecar's epic block carries a version, and a block from before it (the
old default wrote overlay=true unasked) reads as off, in the app and in
droiddeck-store-launch alike. The overlay is fetched only for a game that
turns it on.

The card's switches read the sidecar fresh, write it and read it back,
and show what was read back. droiddeck-store-launch waits for a
wineserver still holding the prefix before appending to user.reg - one
that exits rewrites the file and drops the line - reads the value back
and logs what the file holds. Its docstring is raw. The game-PATH
xdg-open logs each call as scheme://host only and accepts
steam://openurl.
This commit is contained in:
The412Banner committed 2026-10-09 00:09:39 -04:00
1 parent 1d1de10b2d
commit a844483080
9 files changed
+165 -30

No files matched your search

@@ -60,7 +60,7 @@ class StoreGameSidecar(
put("title", title)
if (exe.isNotEmpty()) put("exe", exe)
if (state != STATE_INSTALLED) put("state", state)
if (store == Store.EPIC) put("epic", JSONObject().put("eos", epic.eos).put("offline", epic.offline).put("overlay", epic.overlay))
if (store == Store.EPIC) put("epic", JSONObject().put("v", EpicOptions.VERSION).put("eos", epic.eos).put("offline", epic.offline).put("overlay", epic.overlay))
if (!launcher.isNullOrEmpty()) put("launcher", launcher)
if (args.isNotEmpty()) put("args", JSONArray(args))
if (env.isNotEmpty()) put("env", JSONObject(env as Map<*, *>))
@@ -87,6 +87,18 @@ class StoreGameSidecar(
fun file(folder: File): File = File(folder, FILE_NAME)
/**
* Changes an Epic game's launch choices on disk: reads the sidecar fresh (never a copy held
* by a screen), applies [change], writes it, and reads it back. The written sidecar, or null
* when there is none or the write did not take. Blocking.
*/
fun updateEpic(folder: File, change: (EpicOptions) -> EpicOptions): StoreGameSidecar? {
val current = read(folder) ?: return null
val next = current.copy(epic = change(current.epic))
next.write(folder)
return read(folder)?.takeIf { it.epic == next.epic }
}
/** The sidecar in [folder], or null when there is none or it cannot be read. */
fun read(folder: File): StoreGameSidecar? {
val f = file(folder)
@@ -122,7 +134,10 @@ class StoreGameSidecar(
extra = extra,
state = state,
epic = o.optJSONObject("epic")?.let { e ->
EpicOptions(eos = e.optBoolean("eos", true), offline = e.optBoolean("offline", false), overlay = e.optBoolean("overlay", true))
// Before v2 the overlay was on by default and written so without anyone choosing
// it; the overlay crashed games, so those read as off. From v2 it is a choice.
val chosen = e.optInt("v", 1) >= EpicOptions.VERSION
EpicOptions(eos = e.optBoolean("eos", true), offline = e.optBoolean("offline", false), overlay = chosen && e.optBoolean("overlay", false))
} ?: EpicOptions(),
)
}
@@ -136,9 +151,15 @@ class StoreGameSidecar(
/**
* An Epic game's launch choices. [eos]: pass a fresh exchange code (Epic sign-in). [offline]: start
* with the Epic identity arguments only, no code - for a game that will not start when sign-in fails.
* [overlay]: point the game's prefix at Epic's EOS overlay.
* [overlay]: point the game's prefix at Epic's EOS overlay - off by default: with it on, a game can
* exit while loading on this stack (Metalstorm did, twice; off, it signs in and runs).
*/
data class EpicOptions(val eos: Boolean = true, val offline: Boolean = false, val overlay: Boolean = true) {
data class EpicOptions(val eos: Boolean = true, val offline: Boolean = false, val overlay: Boolean = false) {
/** Whether a launch asks for a code at all. */
val wantsCode: Boolean get() = eos && !offline
companion object {
/** v2: the overlay is off unless chosen (Metalstorm exits while loading with it on). */
const val VERSION = 2
}
}
@@ -62,8 +62,10 @@ object StoreLaunchRequests {
val code = StoreLaunch.epicCode(app, id)
// The overlay is placed once and shared; the launch writes the prefix's pointer.
val overlay = com.droiddeck.launcher.stores.epic.EpicOverlay.installedVersion(app)
Log.i(TAG, "epic overlay installed=${overlay ?: "no"} prefix=${request.optString("prefix").ifEmpty { "?" }}")
if (overlay == null) com.droiddeck.launcher.stores.epic.EpicOverlay.ensureAsync(app)
val wanted = StoreInstallRoot.gameFolders(app).firstNotNullOfOrNull { f -> StoreGameSidecar.read(f)?.takeIf { it.store == Store.EPIC && it.id == id } }?.epic?.overlay == true
Log.i(TAG, "epic overlay installed=${overlay ?: "no"} wanted=$wanted prefix=${request.optString("prefix").ifEmpty { "?" }}")
// Fetched only for a game that has the overlay on (656 MB; off by default).
if (overlay == null && wanted) com.droiddeck.launcher.stores.epic.EpicOverlay.ensureAsync(app)
JSONObject().put("ok", true).put("code", code.written).put("reason", code.reason).put("overlay", overlay ?: "")
}
}
@@ -51,8 +51,6 @@ object EpicBackend : StoreBackend, EpicLaunchSupport {
when (result) {
is EpicLibrary.SyncResult.Ok -> {
StoresState.library[store] = result.games.map { EpicLibrary.toCatalogItem(app, it) }; StoresState.problems.remove(store)
// The EOS overlay, once, so a game's first launch already has it.
EpicOverlay.ensureAsync(app)
}
is EpicLibrary.SyncResult.Failed -> StoresState.problems[store] = result.message
EpicLibrary.SyncResult.NotLoggedIn -> StoresState.problems[store] = "Epic session expired: sign in again."
@@ -508,6 +508,7 @@ internal fun LaunchSettings(s: FrontEndState, a: FrontEndActions, host: MenuHost
/** The Epic card: sign-in, offline and overlay switches, read from and written to the game's sidecar. */
@Composable
private fun EpicLaunchCard(host: MenuHost, folder: java.io.File) {
val appContext = androidx.compose.ui.platform.LocalContext.current.applicationContext
var sidecar by remember(folder) { mutableStateOf(com.droiddeck.launcher.stores.StoreGameSidecar.read(folder)) }
val options = sidecar?.epic ?: com.droiddeck.launcher.stores.EpicOptions()
val value = buildList {
@@ -515,19 +516,25 @@ private fun EpicLaunchCard(host: MenuHost, folder: java.io.File) {
else if (options.eos) add(stringResource(R.string.epic_card_eos))
if (options.overlay) add(stringResource(R.string.epic_card_overlay))
}.ifEmpty { listOf(stringResource(R.string.epic_card_none)) }.joinToString(" · ")
fun set(next: com.droiddeck.launcher.stores.EpicOptions) {
val current = sidecar ?: return
val updated = current.copy(epic = next)
sidecar = updated
Thread({ runCatching { updated.write(folder) } }, "epic-options").start()
// Each switch goes straight to the sidecar on disk - both launch paths read it there - and the
// card shows what was read back, so a write that did not take is never shown as done.
fun set(change: (com.droiddeck.launcher.stores.EpicOptions) -> com.droiddeck.launcher.stores.EpicOptions) {
Thread({
val written = runCatching { com.droiddeck.launcher.stores.StoreGameSidecar.updateEpic(folder, change) }
.onFailure { android.util.Log.w("EpicLaunchCard", "could not write ${folder.name}: ${it.message}") }.getOrNull()
if (written != null) android.util.Log.i("EpicLaunchCard", "epic options ${written.id} eos=${written.epic.eos} offline=${written.epic.offline} overlay=${written.epic.overlay}")
if (written?.epic?.overlay == true) com.droiddeck.launcher.stores.epic.EpicOverlay.ensureAsync(appContext)
else android.util.Log.w("EpicLaunchCard", "epic options not saved for ${folder.name}")
com.droiddeck.launcher.stores.StoresState.post { sidecar = written ?: com.droiddeck.launcher.stores.StoreGameSidecar.read(folder) }
}, "epic-options").start()
}
SettingCard(stringResource(R.string.epic_card_title), value, "card:epic", Modifier.fillMaxSize()) {
host.open = if (host.open == "epic") null else "epic"
}
AnchoredMenu(host.open == "epic", onDismiss = { if (host.open == "epic") host.open = null }, title = stringResource(R.string.epic_card_title)) { first ->
MenuItem(stringResource(R.string.epic_eos), checked = options.eos, focusRequester = first) { set(options.copy(eos = !options.eos)) }
MenuItem(stringResource(R.string.epic_offline), checked = options.offline) { set(options.copy(offline = !options.offline)) }
MenuItem(stringResource(R.string.epic_overlay), checked = options.overlay) { set(options.copy(overlay = !options.overlay)) }
MenuItem(stringResource(R.string.epic_eos), checked = options.eos, focusRequester = first) { set { it.copy(eos = !it.eos) } }
MenuItem(stringResource(R.string.epic_offline), checked = options.offline) { set { it.copy(offline = !it.offline) } }
MenuItem(stringResource(R.string.epic_overlay), checked = options.overlay) { set { it.copy(overlay = !it.overlay) } }
}
}
@@ -47,14 +47,34 @@ class StoreGameSidecarTest {
@Test fun epicLaunchChoicesRoundTripAndDefaultOn() {
val plain = StoreGameSidecar.parse(StoreGameSidecar(Store.EPIC, "m", "Metalstorm", "M.exe").toJson().toString())!!
assertEquals(EpicOptions(eos = true, offline = false, overlay = true), plain.epic)
assertEquals(EpicOptions(eos = true, offline = false, overlay = false), plain.epic)
assertTrue(plain.epic.wantsCode)
val set = StoreGameSidecar(Store.EPIC, "m", "Metalstorm", "M.exe", epic = EpicOptions(eos = true, offline = true, overlay = false))
val back = StoreGameSidecar.parse(set.toJson().toString())!!
assertEquals(EpicOptions(eos = true, offline = true, overlay = false), back.epic)
assertFalse(back.epic.wantsCode)
// A sidecar from before the choices existed reads as all on.
// A sidecar from before the choices existed reads as the defaults: sign-in on, overlay off.
assertEquals(EpicOptions(), StoreGameSidecar.parse("""{"store":"epic","id":"m","title":"M","exe":"M.exe"}""")!!.epic)
// The old default wrote overlay=true without a version: nobody chose it, so it reads as off.
assertFalse(StoreGameSidecar.parse("""{"store":"epic","id":"m","title":"M","exe":"M.exe","epic":{"eos":true,"offline":false,"overlay":true}}""")!!.epic.overlay)
// Chosen from v2 on, it stays.
val on = StoreGameSidecar.parse(StoreGameSidecar(Store.EPIC, "m", "M", "M.exe", epic = EpicOptions(overlay = true)).toJson().toString())!!
assertTrue(on.epic.overlay)
}
@Test fun aSwitchOnTheEpicCardChangesTheSidecarOnDisk() {
val folder = java.io.File(org.robolectric.RuntimeEnvironment.getApplication().filesDir, "Games/Stores/Epic/Metalstorm").apply { mkdirs() }
StoreGameSidecar(Store.EPIC, "m", "Metalstorm", "Metalstorm.exe", launcher = ".droiddeck-launch.bat").write(folder)
val written = StoreGameSidecar.updateEpic(folder) { it.copy(overlay = true) }!!
assertTrue(written.epic.overlay)
// What the Steam-launch helper reads: the file itself.
val onDisk = org.json.JSONObject(java.io.File(folder, StoreGameSidecar.FILE_NAME).readText())
assertTrue(onDisk.getJSONObject("epic").getBoolean("overlay"))
assertEquals(EpicOptions.VERSION, onDisk.getJSONObject("epic").getInt("v"))
assertTrue(onDisk.getJSONObject("epic").getBoolean("eos"))
// Everything else in it stays.
assertEquals(".droiddeck-launch.bat", StoreGameSidecar.read(folder)!!.launcher)
assertEquals(null, StoreGameSidecar.updateEpic(java.io.File(folder, "missing")) { it })
}
@Test fun anInstallUnderWayHasNoExeYetAndIsNotInstalled() {