aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/TextureManager.kt
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/kotlin/TextureManager.kt')
-rw-r--r--src/main/kotlin/TextureManager.kt7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/main/kotlin/TextureManager.kt b/src/main/kotlin/TextureManager.kt
index 58005e9..7c5ab10 100644
--- a/src/main/kotlin/TextureManager.kt
+++ b/src/main/kotlin/TextureManager.kt
@@ -10,14 +10,15 @@ class TextureManager {
private lateinit var textures: List<Texture>
fun getTexture(id: Int): Texture {
- return textures.first { it.id == id }
+ return textures.find { it.id == id } ?: textures.first()
}
- fun loadTextures() {
+ fun loadTextures(set: String) {
textures = document.getElementsByClassName("texture-definition").asList()
.map { it as HTMLImageElement }
+ .filter { it.getAttribute("data-set") == set }
.map {
- val id = it.id.toInt()
+ val id = it.getAttribute("data-texture-id")!!.toInt()
val width = it.getAttribute("data-width")?.toInt() ?: 64
val height = it.getAttribute("data-height")?.toInt() ?: 64
Texture(id, width, height, parseImage(it, width, height))