mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-27 22:06:05 -04:00
Fix city ambient sounds not working on Desktop (#7271)
This commit is contained in:
parent
88cb73f565
commit
b558d92a1e
@ -18,33 +18,32 @@ class CityAmbiencePlayer(
|
|||||||
play(city)
|
play(city)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getFile(path: String): FileHandle {
|
private fun getModsFolder(): FileHandle {
|
||||||
|
val path = "mods"
|
||||||
val internal = Gdx.files.internal(path)
|
val internal = Gdx.files.internal(path)
|
||||||
if (internal.exists()) return internal
|
if (internal.exists()) return internal
|
||||||
return Gdx.files.local(path)
|
return Gdx.files.local(path)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getSoundFolders() = sequence {
|
private fun getModSoundFolders(): Sequence<FileHandle> {
|
||||||
val visualMods = UncivGame.Current.settings.visualMods
|
val visualMods = UncivGame.Current.settings.visualMods
|
||||||
val mods = UncivGame.Current.gameInfo!!.gameParameters.getModsAndBaseRuleset()
|
val mods = UncivGame.Current.gameInfo!!.gameParameters.getModsAndBaseRuleset()
|
||||||
val modSoundFolders = (visualMods + mods).asSequence()
|
return (visualMods + mods).asSequence()
|
||||||
.map { modName ->
|
.map { modName ->
|
||||||
getFile("mods")
|
getModsFolder()
|
||||||
.child(modName)
|
.child(modName)
|
||||||
.child("sounds")
|
.child("sounds")
|
||||||
}
|
}
|
||||||
|
|
||||||
yieldAll(modSoundFolders)
|
|
||||||
yield(getFile("sounds"))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getSoundFile(fileName: String): FileHandle? {
|
private fun getSoundFile(fileName: String): FileHandle {
|
||||||
return getSoundFolders()
|
val fileFromMods = getModSoundFolders()
|
||||||
.filter { it.exists() && it.isDirectory }
|
.filter { it.isDirectory }
|
||||||
.flatMap { it.list().asSequence() }
|
.flatMap { it.list().asSequence() }
|
||||||
// ensure only normal files with common sound extension
|
|
||||||
.filter { !it.isDirectory && it.extension() in MusicController.gdxSupportedFileExtensions }
|
.filter { !it.isDirectory && it.extension() in MusicController.gdxSupportedFileExtensions }
|
||||||
.firstOrNull { it.nameWithoutExtension() == fileName }
|
.firstOrNull { it.nameWithoutExtension() == fileName }
|
||||||
|
|
||||||
|
return fileFromMods ?: Gdx.files.internal("sounds/$fileName.ogg")
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun play(city: CityInfo) {
|
private fun play(city: CityInfo) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user