mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-13 20:14:05 +09:00
footsteps using dynamic track wip
This commit is contained in:
@@ -6,6 +6,7 @@ import com.badlogic.gdx.graphics.Pixmap
|
||||
import com.badlogic.gdx.utils.JsonValue
|
||||
import net.torvald.terrarum.App.*
|
||||
import net.torvald.terrarum.App.setToGameConfig
|
||||
import net.torvald.terrarum.audio.AudioCodex
|
||||
import net.torvald.terrarum.blockproperties.BlockCodex
|
||||
import net.torvald.terrarum.blockproperties.OreCodex
|
||||
import net.torvald.terrarum.blockproperties.WireCodex
|
||||
@@ -464,6 +465,16 @@ object ModMgr {
|
||||
return dir.listFiles()
|
||||
}
|
||||
}
|
||||
fun getGdxFiles(module: String, path: String): Array<FileHandle> {
|
||||
checkExistence(module)
|
||||
val dir = getGdxFile(module, path)
|
||||
if (!dir.isDirectory) {
|
||||
throw FileNotFoundException("The path is not a directory")
|
||||
}
|
||||
else {
|
||||
return dir.list()
|
||||
}
|
||||
}
|
||||
|
||||
/** Get a common file (literal file or directory) from all the installed mods. Files are guaranteed to exist. If a mod does not
|
||||
* contain the file, the mod will be skipped.
|
||||
@@ -668,6 +679,35 @@ object ModMgr {
|
||||
}
|
||||
}
|
||||
|
||||
object GameAudioLoader {
|
||||
val audioPath = listOf(
|
||||
"audio/music",
|
||||
"audio/effects",
|
||||
"audio/ambient",
|
||||
)
|
||||
|
||||
init {
|
||||
Terrarum.audioCodex = AudioCodex()
|
||||
}
|
||||
|
||||
private fun loadAudio(basename: String, file: FileHandle) {
|
||||
if (file.isDirectory)
|
||||
file.list().forEach { loadAudio("$basename.${it.nameWithoutExtension()}", it) }
|
||||
else {
|
||||
val id = basename
|
||||
val materialID = file.nameWithoutExtension().substringBefore('_')
|
||||
Terrarum.audioCodex.addToFootstepPool(materialID, file)
|
||||
printdbg(this, "Registering music $id")
|
||||
}
|
||||
}
|
||||
|
||||
@JvmStatic operator fun invoke(module: String) {
|
||||
audioPath.forEach {
|
||||
getGdxFiles(module, it).forEach { file -> loadAudio("audio.${file.name()}", file) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A sugar-library for easy texture pack creation
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user