mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-20 05:16:01 +00:00
settings without a pop-up: pages in the pane with anchored menus under each value; frame generation, logs and offline open in place on the rail
The cog's settings window and the Performance dialog become pages in the front end's pane: one row per setting, its value in a chip, and a small faded menu that opens under the chip (SettingsWidgets: AnchoredMenu on a Popup with its own position provider, MenuItem, ValueChip, Choice/Toggle/Multi/Action rows). One menu at a time; the page dims while it is open; the back key, the rail and the page's Back all leave it. Steam and Desktop each get a Settings entry in the rail that lights while its page shows, as does Performance under Setup. Frame generation, Session logs and Start offline open their menu right on their rail row; the frame-generation dialog is gone.
This commit is contained in:
1 parent
39272cf0f2
commit
8dd36b794e
6 files changed
+661
-560
No files matched your search
@@ -12,6 +12,7 @@ import android.util.Log
|
||||
import androidx.activity.ComponentActivity
|
||||
import androidx.activity.compose.setContent
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableIntStateOf
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
@@ -35,14 +36,13 @@ import com.steamdeck.launcher.ui.ProtonDialog
|
||||
import com.steamdeck.launcher.ui.ProtonRow
|
||||
import com.steamdeck.launcher.core.CpuCores
|
||||
import com.steamdeck.launcher.ui.CoreRow
|
||||
import com.steamdeck.launcher.ui.PerformanceDialog
|
||||
import com.steamdeck.launcher.ui.ModeSettingsDialog
|
||||
import com.steamdeck.launcher.ui.PerformancePage
|
||||
import com.steamdeck.launcher.ui.ModeSettingsPage
|
||||
import com.steamdeck.launcher.ui.ModeSettings
|
||||
import com.steamdeck.launcher.ui.ModeSettingsActions
|
||||
import com.steamdeck.launcher.ui.DriverRow
|
||||
import com.steamdeck.launcher.ui.ConfirmDialog
|
||||
import com.steamdeck.launcher.ui.CreditsDialog
|
||||
import com.steamdeck.launcher.ui.FrameGenDialog
|
||||
import com.steamdeck.launcher.ui.FrontEndScreen
|
||||
import com.steamdeck.launcher.ui.FrontEndState
|
||||
import com.steamdeck.launcher.ui.FrontEndActions
|
||||
@@ -148,6 +148,12 @@ class MainActivity : ComponentActivity() {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContent {
|
||||
SteamDeckTheme {
|
||||
val sm = settingsMode
|
||||
val page: (@Composable () -> Unit)? = when {
|
||||
sm != null -> { { ModeSettingsHost(sm) } }
|
||||
showPerformance -> { { PerformanceHost() } }
|
||||
else -> null
|
||||
}
|
||||
FrontEndScreen(
|
||||
FrontEndState(
|
||||
installed = installed, ready = ready, available = available?.version,
|
||||
@@ -156,6 +162,9 @@ class MainActivity : ComponentActivity() {
|
||||
offlineAccount = offlineAccount, offline = offline,
|
||||
frameGenLabel = frameGenLabel, romsDir = romsDir, logsEnabled = logsEnabled,
|
||||
steamGames = steamGames, emulators = emulatorList, running = runningLabel,
|
||||
frameGenEngine = FrameGen.engine(this), frameGenMultiplier = FrameGen.multiplier(this),
|
||||
lsfgReady = LsfgNative.isInstalled(this),
|
||||
pageKey = sm?.let { "settings:$it" } ?: if (showPerformance) "performance" else null,
|
||||
),
|
||||
FrontEndActions(
|
||||
onPlay = { startActivity(Intent(this, SessionActivity::class.java)) },
|
||||
@@ -185,7 +194,10 @@ class MainActivity : ComponentActivity() {
|
||||
onDesktopSettings = { openModeSettings(SessionService.MODE_DESKTOP) },
|
||||
onApps = { openApps() },
|
||||
onRuntime = { onRuntimeButton() },
|
||||
onFrameGen = { showFrameGen = true },
|
||||
onFrameGenPick = { engine, multiplier ->
|
||||
FrameGen.set(this, engine, multiplier)
|
||||
frameGenLabel = FrameGen.label(this)
|
||||
},
|
||||
onProtons = { refreshProtons(); showProtons = true },
|
||||
onPerformance = { refreshCores(); showPerformance = true },
|
||||
onRoms = { showRoms = true },
|
||||
@@ -200,7 +212,9 @@ class MainActivity : ComponentActivity() {
|
||||
},
|
||||
onEmulatorHelp = { showEmulatorHelp = true },
|
||||
onCredits = { showCredits = true },
|
||||
onPageBack = { settingsMode = null; showPerformance = false },
|
||||
),
|
||||
page = page,
|
||||
)
|
||||
if (showRoms) RomsDialog(
|
||||
path = romsDir,
|
||||
@@ -225,73 +239,6 @@ class MainActivity : ComponentActivity() {
|
||||
onRemove = { id -> ProtonExtras.tools.first { it.id == id }.let { ProtonExtras.remove(this, it) }; refreshProtons() },
|
||||
onDismiss = { showProtons = false },
|
||||
)
|
||||
settingsMode?.let { mode ->
|
||||
ModeSettingsDialog(
|
||||
ModeSettings(
|
||||
mode = mode, resolutionCap = resolutionCap, shapeMode = shapeMode,
|
||||
hdr = hdrOn, hdrReason = hdrReason,
|
||||
linuxRows = linuxRows,
|
||||
linuxSelected = if (mode == SessionService.MODE_STEAM) linuxSteam else linuxDesktop,
|
||||
androidRows = androidRows, androidSelected = androidSelected,
|
||||
touchMode = touchMode,
|
||||
oscMode = if (mode == SessionService.MODE_STEAM) oscMode else null,
|
||||
directAudio = if (mode == SessionService.MODE_STEAM) directAudio else null,
|
||||
mic = if (mode == SessionService.MODE_STEAM) mic else null,
|
||||
renderer = if (mode == SessionService.MODE_DESKTOP) renderer else null,
|
||||
gameStorage = if (mode == SessionService.MODE_STEAM) gameStorage else null,
|
||||
storageOptions = storageOptions,
|
||||
),
|
||||
ModeSettingsActions(
|
||||
onResolution = { cap -> SessionPrefs.setResolutionCap(this, mode, cap); resolutionCap = cap },
|
||||
onShape = { shape -> SessionPrefs.setShapeMode(this, shape); shapeMode = shape },
|
||||
onHdr = { on -> SessionPrefs.setHdr(this, mode, on); hdrOn = on },
|
||||
onSelectLinux = { id -> SessionPrefs.setLinuxDriver(this, mode, id); refreshDrivers() },
|
||||
onImportLinux = { pickLinuxDriver.launch(InAppFilePicker.buildIntent(this, ZIP_EXT, "Choose a Linux runtime driver (-Linux zip)")) },
|
||||
onRemoveLinux = { id -> LinuxVulkanDriverManager(this).removeDriver(id); refreshDrivers() },
|
||||
onSelectAndroid = { id -> SessionPrefs.setAndroidDriver(this, id); refreshDrivers() },
|
||||
onImportAndroid = { pickAndroidDriver.launch(InAppFilePicker.buildIntent(this, ZIP_EXT, "Choose a display driver (AdrenoTools zip)")) },
|
||||
onRemoveAndroid = { id -> TurnipDriver(this).remove(id); refreshDrivers() },
|
||||
onTouch = { t -> SessionPrefs.setTouchMode(this, t); touchMode = t },
|
||||
onOsc = { o -> SessionPrefs.setOscMode(this, o); oscMode = o },
|
||||
onDirectAudio = { on -> SessionPrefs.setDirectAudio(this, on); directAudio = on },
|
||||
onMic = { on ->
|
||||
SessionPrefs.setMicEnabled(this, on)
|
||||
mic = on
|
||||
// The session checks the grant itself at start; asking here means the
|
||||
// answer is in before the first session that wants it.
|
||||
if (on && checkSelfPermission(Manifest.permission.RECORD_AUDIO) != PackageManager.PERMISSION_GRANTED) {
|
||||
requestPermissions(arrayOf(Manifest.permission.RECORD_AUDIO), 2)
|
||||
}
|
||||
},
|
||||
onRenderer = { r -> SessionPrefs.setDesktopRenderer(this, r); renderer = r },
|
||||
onGameStorage = { path, label -> setGameStorage(path, label) },
|
||||
onPickGameStorageFolder = {
|
||||
pickGameStorage.launch(InAppFilePicker.buildDirIntent(this, "Choose the game storage folder", gameStorage.ifEmpty { null }))
|
||||
},
|
||||
onDismiss = { settingsMode = null },
|
||||
),
|
||||
)
|
||||
}
|
||||
if (showPerformance) PerformanceDialog(
|
||||
cores = CpuCores.all.map { c -> CoreRow(c, "cpu$c" + (CpuCores.maxGhz(c)?.let { String.format(java.util.Locale.US, " · %.1f GHz", it) } ?: "")) },
|
||||
clientOverride = clientOverride, clientCores = clientCores, gameCores = gameCores,
|
||||
tuSysmem = tuSysmem, zinkLazy = zinkLazy, noXalia = noXalia,
|
||||
prootNoSeccomp = prootNoSeccomp, phantomWarning = phantomWarning,
|
||||
onClientOverride = { on -> SessionPrefs.setClientCpusOverride(this, on); clientOverride = on },
|
||||
onTuSysmem = { on -> SessionPrefs.setTuSysmem(this, on); tuSysmem = on },
|
||||
onZinkLazy = { on -> SessionPrefs.setZinkLazy(this, on); zinkLazy = on },
|
||||
onNoXalia = { on -> SessionPrefs.setNoXalia(this, on); noXalia = on },
|
||||
onProotNoSeccomp = { on -> SessionPrefs.setProotNoSeccomp(this, on); prootNoSeccomp = on },
|
||||
onClientCore = { core, on ->
|
||||
clientCores = if (on) clientCores + core else clientCores - core
|
||||
SessionPrefs.setClientCpus(this, CpuCores.format(clientCores))
|
||||
},
|
||||
onGameCore = { core, on ->
|
||||
gameCores = if (on) gameCores + core else gameCores - core
|
||||
SessionPrefs.setGameCpus(this, CpuCores.format(gameCores))
|
||||
},
|
||||
onDismiss = { showPerformance = false },
|
||||
)
|
||||
if (showRemove) ConfirmDialog(
|
||||
title = "Remove Linux runtime",
|
||||
text = "This deletes the runtime, the Steam client inside it, and every game installed there.",
|
||||
@@ -299,16 +246,6 @@ class MainActivity : ComponentActivity() {
|
||||
onConfirm = { Thread({ LinuxRuntimeInstaller.uninstall(this); ui.post { refresh() } }, "uninstall").start() },
|
||||
onDismiss = { showRemove = false },
|
||||
)
|
||||
if (showFrameGen) FrameGenDialog(
|
||||
engine = FrameGen.engine(this), multiplier = FrameGen.multiplier(this),
|
||||
lsfgReady = LsfgNative.isInstalled(this),
|
||||
onPick = { engine, multiplier ->
|
||||
FrameGen.set(this, engine, multiplier)
|
||||
frameGenLabel = FrameGen.label(this)
|
||||
showFrameGen = false
|
||||
},
|
||||
onDismiss = { showFrameGen = false },
|
||||
)
|
||||
if (showCredits) CreditsDialog { showCredits = false }
|
||||
if (showEmulatorHelp) com.steamdeck.launcher.ui.EmulatorHelpDialog { showEmulatorHelp = false }
|
||||
}
|
||||
@@ -396,6 +333,81 @@ class MainActivity : ComponentActivity() {
|
||||
|
||||
/** Both driver lists as the dialog shows them, re-read from disk so an import or removal shows at once. */
|
||||
/** Everything the mode's cog shows, read fresh, then the dialog. */
|
||||
/** The Steam or Desktop settings page, in the front end's pane. */
|
||||
@Composable
|
||||
private fun ModeSettingsHost(mode: String) {
|
||||
ModeSettingsPage(
|
||||
ModeSettings(
|
||||
mode = mode, resolutionCap = resolutionCap, shapeMode = shapeMode,
|
||||
hdr = hdrOn, hdrReason = hdrReason,
|
||||
linuxRows = linuxRows,
|
||||
linuxSelected = if (mode == SessionService.MODE_STEAM) linuxSteam else linuxDesktop,
|
||||
androidRows = androidRows, androidSelected = androidSelected,
|
||||
touchMode = touchMode,
|
||||
oscMode = if (mode == SessionService.MODE_STEAM) oscMode else null,
|
||||
directAudio = if (mode == SessionService.MODE_STEAM) directAudio else null,
|
||||
mic = if (mode == SessionService.MODE_STEAM) mic else null,
|
||||
renderer = if (mode == SessionService.MODE_DESKTOP) renderer else null,
|
||||
gameStorage = if (mode == SessionService.MODE_STEAM) gameStorage else null,
|
||||
storageOptions = storageOptions,
|
||||
),
|
||||
ModeSettingsActions(
|
||||
onResolution = { cap -> SessionPrefs.setResolutionCap(this, mode, cap); resolutionCap = cap },
|
||||
onShape = { shape -> SessionPrefs.setShapeMode(this, shape); shapeMode = shape },
|
||||
onHdr = { on -> SessionPrefs.setHdr(this, mode, on); hdrOn = on },
|
||||
onSelectLinux = { id -> SessionPrefs.setLinuxDriver(this, mode, id); refreshDrivers() },
|
||||
onImportLinux = { pickLinuxDriver.launch(InAppFilePicker.buildIntent(this, ZIP_EXT, "Choose a Linux runtime driver (-Linux zip)")) },
|
||||
onRemoveLinux = { id -> LinuxVulkanDriverManager(this).removeDriver(id); refreshDrivers() },
|
||||
onSelectAndroid = { id -> SessionPrefs.setAndroidDriver(this, id); refreshDrivers() },
|
||||
onImportAndroid = { pickAndroidDriver.launch(InAppFilePicker.buildIntent(this, ZIP_EXT, "Choose a display driver (AdrenoTools zip)")) },
|
||||
onRemoveAndroid = { id -> TurnipDriver(this).remove(id); refreshDrivers() },
|
||||
onTouch = { t -> SessionPrefs.setTouchMode(this, t); touchMode = t },
|
||||
onOsc = { o -> SessionPrefs.setOscMode(this, o); oscMode = o },
|
||||
onDirectAudio = { on -> SessionPrefs.setDirectAudio(this, on); directAudio = on },
|
||||
onMic = { on ->
|
||||
SessionPrefs.setMicEnabled(this, on)
|
||||
mic = on
|
||||
// The session checks the grant itself at start; asking here means the
|
||||
// answer is in before the first session that wants it.
|
||||
if (on && checkSelfPermission(Manifest.permission.RECORD_AUDIO) != PackageManager.PERMISSION_GRANTED) {
|
||||
requestPermissions(arrayOf(Manifest.permission.RECORD_AUDIO), 2)
|
||||
}
|
||||
},
|
||||
onRenderer = { r -> SessionPrefs.setDesktopRenderer(this, r); renderer = r },
|
||||
onGameStorage = { path, label -> setGameStorage(path, label) },
|
||||
onPickGameStorageFolder = {
|
||||
pickGameStorage.launch(InAppFilePicker.buildDirIntent(this, "Choose the game storage folder", gameStorage.ifEmpty { null }))
|
||||
},
|
||||
onDismiss = { settingsMode = null },
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
/** The Performance page, in the front end's pane. */
|
||||
@Composable
|
||||
private fun PerformanceHost() {
|
||||
PerformancePage(
|
||||
cores = CpuCores.all.map { c -> CoreRow(c, "cpu$c" + (CpuCores.maxGhz(c)?.let { String.format(java.util.Locale.US, " · %.1f GHz", it) } ?: "")) },
|
||||
clientOverride = clientOverride, clientCores = clientCores, gameCores = gameCores,
|
||||
tuSysmem = tuSysmem, zinkLazy = zinkLazy, noXalia = noXalia,
|
||||
prootNoSeccomp = prootNoSeccomp, phantomWarning = phantomWarning,
|
||||
onClientOverride = { on -> SessionPrefs.setClientCpusOverride(this, on); clientOverride = on },
|
||||
onTuSysmem = { on -> SessionPrefs.setTuSysmem(this, on); tuSysmem = on },
|
||||
onZinkLazy = { on -> SessionPrefs.setZinkLazy(this, on); zinkLazy = on },
|
||||
onNoXalia = { on -> SessionPrefs.setNoXalia(this, on); noXalia = on },
|
||||
onProotNoSeccomp = { on -> SessionPrefs.setProotNoSeccomp(this, on); prootNoSeccomp = on },
|
||||
onClientCore = { core, on ->
|
||||
clientCores = if (on) clientCores + core else clientCores - core
|
||||
SessionPrefs.setClientCpus(this, CpuCores.format(clientCores))
|
||||
},
|
||||
onGameCore = { core, on ->
|
||||
gameCores = if (on) gameCores + core else gameCores - core
|
||||
SessionPrefs.setGameCpus(this, CpuCores.format(gameCores))
|
||||
},
|
||||
onDismiss = { showPerformance = false },
|
||||
)
|
||||
}
|
||||
|
||||
private fun openModeSettings(mode: String) {
|
||||
refreshDrivers()
|
||||
resolutionCap = SessionPrefs.resolutionCap(this, mode)
|
||||
|
||||
Reference in new issue
Block a user