From ccb1e895affa1e393a9c42efe22f28f7867434f2 Mon Sep 17 00:00:00 2001 From: Yang Seong Mo Date: Tue, 24 Dec 2024 02:46:43 +0900 Subject: [PATCH] Fix text include. --- .../toxicity/hud/manager/TextManagerImpl.kt | 39 +++++-------------- 1 file changed, 10 insertions(+), 29 deletions(-) diff --git a/dist/src/main/kotlin/kr/toxicity/hud/manager/TextManagerImpl.kt b/dist/src/main/kotlin/kr/toxicity/hud/manager/TextManagerImpl.kt index 9192fc22..a2142b4f 100644 --- a/dist/src/main/kotlin/kr/toxicity/hud/manager/TextManagerImpl.kt +++ b/dist/src/main/kotlin/kr/toxicity/hud/manager/TextManagerImpl.kt @@ -31,30 +31,11 @@ import kotlin.math.roundToInt object TextManagerImpl : BetterHudManager, TextManager { - private class TextCache( + private data class TextCache( val name: String, - val imagesName: Set - ) { - override fun equals(other: Any?): Boolean { - if (this === other) return true - if (javaClass != other?.javaClass) return false - - other as TextCache - - if (name != other.name) return false - if (!imagesName.containsAll(other.imagesName) || imagesName.size != other.imagesName.size) return false - - return true - } - - override fun hashCode(): Int { - var result = name.hashCode() - imagesName.forEach { - result = 31 * result + it.hashCode() - } - return result - } - } + val imagesName: Set, + val supportLanguage: Set? + ) private const val CHAR_LENGTH = 16 @@ -233,7 +214,7 @@ object TextManagerImpl : BetterHudManager, TextManager { ) val parseDefault = parseTTFFont("", "default_$configScale", configScale, defaultProvider, resource.textures, emptyMap(), fontConfig.get("include")?.asArray()?.map { it.asString() - } ?: emptyList(), fontConfig.getAsBoolean("merge-default-bitmap", true), fontConfig)() + }?.toSet(), fontConfig.getAsBoolean("merge-default-bitmap", true), fontConfig)() parseDefault.charWidth.forEach { textWidthMap[it.key] = (it.value.width * configHeight / it.value.height).roundToInt() } @@ -292,7 +273,7 @@ object TextManagerImpl : BetterHudManager, TextManager { }, section["include"]?.asArray()?.map { it.asString() - } ?: emptyList(), + }?.toSet(), section.getAsBoolean("merge-default-bitmap", false), section, ) @@ -445,7 +426,7 @@ object TextManagerImpl : BetterHudManager, TextManager { yamlObject: YamlObject, ): TextSupplier { return synchronized(textCacheMap) { - textCacheMap[TextCache(saveName, emptySet())]?.let { old -> + textCacheMap[TextCache(saveName, emptySet(), emptySet())]?.let { old -> TextSupplier { TextElement(saveName, null, old.array, old.charWidth, old.imageTextScale, yamlObject) } @@ -540,12 +521,12 @@ object TextManagerImpl : BetterHudManager, TextManager { fontProvider: FontBitmapProvider, imageSaveFolder: List, images: Map, - supportedLanguage: List?, + supportedLanguage: Set?, mergeDefaultBitmap: Boolean, yamlObject: YamlObject ): TextSupplier { return synchronized(textCacheMap) { - textCacheMap[TextCache(saveName, images.keys)]?.let { old -> + textCacheMap[TextCache(saveName, images.keys, supportedLanguage)]?.let { old -> TextSupplier { TextElement(internalName, scale, old.array, old.charWidth, old.imageTextScale, yamlObject) } @@ -651,7 +632,7 @@ object TextManagerImpl : BetterHudManager, TextManager { debug(ConfigManager.DebugLevel.ASSETS, "Finalizing font text $saveName...") val result = TextElement(internalName, scale, textList, charWidthMap, imageTextScaleMap, yamlObject) synchronized(textCacheMap) { - textCacheMap[TextCache(internalName, images.keys)] = result + textCacheMap[TextCache(internalName, images.keys, supportedLanguage)] = result } result }