mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-20 05:16:01 +00:00
feat: suggest Steam libraries found on internal storage and cards (#2023)
* feat: suggest Steam libraries found on internal storage and cards * fix: add found card libraries by their readable path and drop superseded scan results
This commit is contained in:
1 parent
bc5edb81db
commit
5fe3021e5e
5 files changed
+153
-13
No files matched your search
@@ -496,19 +496,39 @@ class FrontEndActivity : ComponentActivity() {
|
||||
if (r.resultCode == RESULT_OK) InAppFilePicker.pickedPath(r.data)?.let { path -> setGameStorage(path, GameStorage.labelFor(this, path)) }
|
||||
}
|
||||
private var steamLibraries by mutableStateOf<List<SteamLibraries.Entry>>(emptyList())
|
||||
private var foundSteamLibraries by mutableStateOf<List<SteamLibraries.Found>>(emptyList())
|
||||
private var allFilesAccessMissing by mutableStateOf(false)
|
||||
private var steamLibraryScan = 0
|
||||
private val pickSteamLibrary = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { r ->
|
||||
val path = if (r.resultCode == RESULT_OK) InAppFilePicker.pickedPath(r.data) else null
|
||||
if (path != null) Thread({
|
||||
if (path != null) addSteamLibrary(path)
|
||||
}
|
||||
|
||||
private fun addSteamLibrary(path: String) {
|
||||
Thread({
|
||||
val result = SteamLibraries.add(this, path)
|
||||
ui.post {
|
||||
steamLibraries = SteamLibraries.list(this)
|
||||
refreshFoundSteamLibraries()
|
||||
refresh()
|
||||
if (result is SteamLibraries.AddResult.Refused) {
|
||||
android.widget.Toast.makeText(this, getString(R.string.main_storage_not_usable, result.reason), android.widget.Toast.LENGTH_LONG).show()
|
||||
when {
|
||||
result is SteamLibraries.AddResult.Refused ->
|
||||
android.widget.Toast.makeText(this, getString(R.string.main_storage_not_usable, result.reason), android.widget.Toast.LENGTH_LONG).show()
|
||||
result is SteamLibraries.AddResult.Added && result.entry.path != path ->
|
||||
android.widget.Toast.makeText(this, getString(R.string.libraries_used_inner, result.entry.label), android.widget.Toast.LENGTH_LONG).show()
|
||||
}
|
||||
}
|
||||
}, "steam-library-add").start()
|
||||
}
|
||||
|
||||
private fun refreshFoundSteamLibraries() {
|
||||
allFilesAccessMissing = com.droiddeck.launcher.files.AllFilesAccess.missing()
|
||||
val scan = ++steamLibraryScan
|
||||
Thread({
|
||||
val found = SteamLibraries.found(this)
|
||||
ui.post { if (scan == steamLibraryScan) foundSteamLibraries = found }
|
||||
}, "steam-library-scan").start()
|
||||
}
|
||||
private var romsDir by mutableStateOf<String?>(null)
|
||||
private var steamGames by mutableStateOf<List<Library.SteamGame>>(emptyList())
|
||||
private var steamGamesX64 by mutableStateOf(false)
|
||||
@@ -1681,6 +1701,7 @@ class FrontEndActivity : ComponentActivity() {
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
if (settingsMode == SessionService.MODE_STEAM) refreshFoundSteamLibraries()
|
||||
compatLaunchVisible = true
|
||||
com.droiddeck.launcher.ui.DualScreenPanel.yieldTo(taskId, false)
|
||||
com.droiddeck.launcher.ui.DualScreenPanel.ownerPaused(taskId, false)
|
||||
@@ -2141,6 +2162,8 @@ class FrontEndActivity : ComponentActivity() {
|
||||
gameStorage = if (mode == SessionService.MODE_STEAM) gameStorage else null,
|
||||
storageOptions = storageOptions,
|
||||
steamLibraries = steamLibraries,
|
||||
foundSteamLibraries = foundSteamLibraries,
|
||||
allFilesAccessMissing = allFilesAccessMissing,
|
||||
storageDiagnostics = mode == SessionService.MODE_STEAM && storageDiagnostics,
|
||||
fexPreset = if (mode == SessionService.MODE_STEAM) fexPreset else null,
|
||||
forceSsbs = forceSsbs,
|
||||
@@ -2208,6 +2231,8 @@ class FrontEndActivity : ComponentActivity() {
|
||||
onAddSteamLibrary = {
|
||||
pickSteamLibrary.launch(InAppFilePicker.buildDirIntent(this, getString(R.string.libraries_pick), null))
|
||||
},
|
||||
onAddFoundSteamLibrary = { path -> addSteamLibrary(path) },
|
||||
onAllowAllFilesAccess = { com.droiddeck.launcher.files.AllFilesAccess.open(this) },
|
||||
onRenameSteamLibrary = { id, label ->
|
||||
SteamLibraries.rename(this, id, label)
|
||||
steamLibraries = SteamLibraries.list(this)
|
||||
@@ -2217,6 +2242,7 @@ class FrontEndActivity : ComponentActivity() {
|
||||
SteamLibraries.remove(this, id)
|
||||
steamLibraries = SteamLibraries.list(this)
|
||||
refresh()
|
||||
refreshFoundSteamLibraries()
|
||||
},
|
||||
onStorageDiagnostics = { on ->
|
||||
SessionPrefs.setStorageDiagnosticsEnabled(this, on)
|
||||
@@ -2453,6 +2479,7 @@ class FrontEndActivity : ComponentActivity() {
|
||||
refreshWifiDiscovery()
|
||||
gameStorage = SessionPrefs.gameStorage(this)
|
||||
steamLibraries = SteamLibraries.list(this)
|
||||
if (mode == SessionService.MODE_STEAM) refreshFoundSteamLibraries()
|
||||
storageDiagnostics = SessionPrefs.storageDiagnosticsEnabled(this)
|
||||
settingsMode = mode
|
||||
Thread({
|
||||
@@ -2483,6 +2510,7 @@ class FrontEndActivity : ComponentActivity() {
|
||||
SessionPrefs.setGameStorage(this, path, label)
|
||||
gameStorage = path
|
||||
checkUsbLink()
|
||||
if (settingsMode == SessionService.MODE_STEAM) refreshFoundSteamLibraries()
|
||||
}
|
||||
|
||||
private fun checkUsbLink() {
|
||||
|
||||
Reference in new issue
Block a user