mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-19 21:06:09 +00:00
fix: keep the shader pre-caching choice until a session confirms it, and read it from its own VDF section
This commit is contained in:
1 parent
f88227ed74
commit
b76f13f7ac
6 files changed
+58
-13
No files matched your search
@@ -304,19 +304,29 @@ object SessionPrefs {
|
||||
prefs(context).edit().putBoolean("returnAfterGame", on).apply()
|
||||
}
|
||||
|
||||
private fun shaderPrecacheApplied(context: Context) =
|
||||
java.io.File(com.droiddeck.launcher.runtime.LinuxRuntime.rootDir(context), "root/.bl-shader-precache-applied")
|
||||
|
||||
/**
|
||||
* Shader pre-caching as the launcher last set it, until the next session writes it into the
|
||||
* Shader pre-caching as the launcher last set it, until a session reports it written into the
|
||||
* client's config.vdf; after that the client's own toggle is the user's again.
|
||||
*/
|
||||
fun pendingShaderPrecache(context: Context): Boolean? =
|
||||
prefs(context).takeIf { it.contains("shaderPrecache") }?.getBoolean("shaderPrecache", true)
|
||||
|
||||
fun setShaderPrecache(context: Context, on: Boolean) {
|
||||
prefs(context).edit().putBoolean("shaderPrecache", on).apply()
|
||||
fun pendingShaderPrecache(context: Context): Boolean? {
|
||||
val prefs = prefs(context)
|
||||
if (!prefs.contains("shaderPrecache")) return null
|
||||
val on = prefs.getBoolean("shaderPrecache", true)
|
||||
val applied = shaderPrecacheApplied(context)
|
||||
val written = runCatching { applied.readText().trim() }.getOrNull() ?: return on
|
||||
applied.delete()
|
||||
if (written != if (on) "1" else "0") return on
|
||||
prefs.edit().remove("shaderPrecache").apply()
|
||||
return null
|
||||
}
|
||||
|
||||
fun takeShaderPrecache(context: Context): Boolean? =
|
||||
pendingShaderPrecache(context)?.also { prefs(context).edit().remove("shaderPrecache").apply() }
|
||||
fun setShaderPrecache(context: Context, on: Boolean) {
|
||||
shaderPrecacheApplied(context).delete()
|
||||
prefs(context).edit().putBoolean("shaderPrecache", on).apply()
|
||||
}
|
||||
|
||||
fun shaderPrecache(context: Context): Boolean = pendingShaderPrecache(context)
|
||||
?: runCatching { com.droiddeck.launcher.storage.SteamStorage.shaderPrecache(
|
||||
|
||||
@@ -673,7 +673,7 @@ class SessionService : Service() {
|
||||
com.droiddeck.launcher.core.AppLanguage.system(this).country,
|
||||
))
|
||||
guest.add("TZ=" + java.util.TimeZone.getDefault().id)
|
||||
if (SessionState.mode == MODE_STEAM) SessionPrefs.takeShaderPrecache(this)?.let { guest.add("BL_SHADER_PRECACHE=" + if (it) "1" else "0") }
|
||||
if (SessionState.mode == MODE_STEAM) SessionPrefs.pendingShaderPrecache(this)?.let { guest.add("BL_SHADER_PRECACHE=" + if (it) "1" else "0") }
|
||||
guest.add("XDG_RUNTIME_DIR=" + LinuxRuntime.GUEST_RUNTIME_DIR)
|
||||
guest.add("XDG_SESSION_TYPE=wayland")
|
||||
guest.add("WAYLAND_DISPLAY=wayland-0")
|
||||
|
||||
Reference in new issue
Block a user