Android: Support audio file names prefixed with track numbers

This commit is contained in:
kichikuou
2025-04-10 09:27:44 +09:00
parent a7e1c5c32e
commit f6bc689fcb
@@ -216,7 +216,7 @@ class Launcher private constructor(private val rootDir: File) {
// A helper class which generates playlist.txt in the game root directory.
private class GameConfigWriter {
private var hasAdisk = false
private val audioRegex = """.*?(\d+)\.(wav|mp3|ogg)""".toRegex(RegexOption.IGNORE_CASE)
private val audioRegex = """((\d+).*|.*?(\d+))\.(wav|mp3|ogg)""".toRegex(RegexOption.IGNORE_CASE)
private val audioFiles: Array<String?> = arrayOfNulls(100)
fun maybeAdd(path: String) {
@@ -226,7 +226,7 @@ class Launcher private constructor(private val rootDir: File) {
hasAdisk = true
}
audioRegex.matchEntire(name)?.let {
val track = it.groupValues[1].toInt()
val track = it.groupValues[2].toIntOrNull() ?: it.groupValues[3].toInt()
if (0 < track && track <= audioFiles.size)
audioFiles[track - 1] = path
}