From 83b0b4cb19d7f0137cde962ee81a900baf2bd953 Mon Sep 17 00:00:00 2001 From: James Barnett Date: Wed, 30 Dec 2020 14:38:34 +0000 Subject: Add switchable texture sets. Fix minimap --- src/main/kotlin/TextureManager.kt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/main/kotlin/TextureManager.kt') 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 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)) -- cgit v1.2.3