Sounds

object Sounds

Generates Gdx Sound objects from UncivSound ones on demand, only once per key (two UncivSound custom instances with the same filename are considered equal).

Gdx asks Sound usage to respect the Disposable contract, but since we're only caching a handful of them in memory we should be able to get away with keeping them alive for the app lifetime - and we do dispose them when the app is disposed.

Types

GetSoundResult
Link copied to clipboard
private data class GetSoundResult(resource: Sound, isFresh: Boolean)

Holds a Gdx Sound and a flag indicating the sound is freshly loaded and not from cache

SupportedExtensions
Link copied to clipboard
private enum SupportedExtensions : Enum<Sounds.SupportedExtensions>

Functions

checkCache
Link copied to clipboard
private fun checkCache()

Ensure cache is not outdated

clearCache
Link copied to clipboard
fun clearCache()

Release cached Sound resources

equals
Link copied to clipboard
open operator fun equals(other: Any?): Boolean
get
Link copied to clipboard
private fun get(sound: UncivSound): Sounds.GetSoundResult?

Retrieve (if not cached create from resources) a Gdx Sound from an UncivSound

getFolders
Link copied to clipboard
private fun getFolders(): Sequence<String>

Build list of folders to look for sounds

hashCode
Link copied to clipboard
open fun hashCode(): Int
play
Link copied to clipboard
fun play(sound: UncivSound)

Find, cache and play a Sound

toString
Link copied to clipboard
open fun toString(): String

Properties

debugMessages
Link copied to clipboard
private const val debugMessages: Boolean = false
modListHash
Link copied to clipboard
private var modListHash: Int
separator
Link copied to clipboard
private val separator: String
soundMap
Link copied to clipboard
private val soundMap: HashMap<UncivSound, Sound?>

Sources

jvm source
Link copied to clipboard