Faster loading XP Widgets, file loading heleprs and XP widget resetting

This commit is contained in:
downthecrop 2025-08-19 23:56:25 -07:00
parent 7f09263209
commit 7cc56d0e53
5 changed files with 255 additions and 99 deletions

View file

@ -3,6 +3,8 @@ package KondoKit
import rt4.GameShell
import java.awt.*
import java.awt.event.MouseListener
import java.nio.charset.Charset
import java.nio.charset.StandardCharsets
import java.lang.reflect.Field
import java.lang.reflect.ParameterizedType
import java.lang.reflect.Type
@ -11,6 +13,16 @@ import java.util.Timer
import javax.swing.*
object Helpers {
// Convenience helper for loading resources relative to the KondoKit plugin class
fun openResource(path: String) = plugin::class.java.getResourceAsStream(path)
// Read a bundled resource as text using the given charset (UTF-8 by default)
fun readResourceText(path: String, charset: Charset = StandardCharsets.UTF_8): String? {
val stream = openResource(path) ?: return null
stream.use { s ->
return s.reader(charset).use { it.readText() }
}
}
fun convertValue(type: Class<*>, genericType: Type?, value: String): Any {
return when {
@ -233,4 +245,4 @@ object Helpers {
else -> Color(128, 128, 128) // Default grey for unhandled skill IDs
}
}
}
}