Use java reflection instead of kotlin-reflect in ButtonImpl.kt and reintroduce the alphabetical ordering of buttons
This commit is contained in:
parent
f4979bfa94
commit
7fd3e3f641
|
@ -10,10 +10,10 @@ import fr.username404.snowygui.misc.AddKeyMaps
|
||||||
import io.github.config4k.getValue
|
import io.github.config4k.getValue
|
||||||
import org.apache.logging.log4j.LogManager
|
import org.apache.logging.log4j.LogManager
|
||||||
import org.apache.logging.log4j.Logger
|
import org.apache.logging.log4j.Logger
|
||||||
import kotlin.reflect.full.hasAnnotation
|
import java.lang.reflect.Modifier
|
||||||
|
|
||||||
abstract class Snowy {
|
abstract class Snowy {
|
||||||
protected fun Class<*>.isValidForButtonCollection(): Boolean = (!(kotlin.isAbstract || kotlin.hasAnnotation<Ignored>()))
|
protected fun Class<*>.isValidForButtonCollection(): Boolean = (!((Modifier.isAbstract(javaClass.modifiers)) || javaClass.isAnnotationPresent(Ignored::class.java)))
|
||||||
private val displayInitMessage: Boolean by obtained
|
private val displayInitMessage: Boolean by obtained
|
||||||
companion object {
|
companion object {
|
||||||
val Gson: Gson = GsonBuilder().excludeFieldsWithoutExposeAnnotation().create()
|
val Gson: Gson = GsonBuilder().excludeFieldsWithoutExposeAnnotation().create()
|
||||||
|
|
|
@ -33,7 +33,9 @@ sealed class ButtonImpl: ColoredElement(0.0, 0.0, 73, 8, opacity = 0.60F) {
|
||||||
}
|
}
|
||||||
}.entries.forEach { entry ->
|
}.entries.forEach { entry ->
|
||||||
with(entry) {
|
with(entry) {
|
||||||
value.forEach {
|
value.sortedWith(
|
||||||
|
compareBy(String.CASE_INSENSITIVE_ORDER) { it.title }
|
||||||
|
).forEach {
|
||||||
key?.buttons!!.add(it)
|
key?.buttons!!.add(it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,9 +46,11 @@ sealed class ButtonImpl: ColoredElement(0.0, 0.0, 73, 8, opacity = 0.60F) {
|
||||||
((try {
|
((try {
|
||||||
it.getConstructor().newInstance()
|
it.getConstructor().newInstance()
|
||||||
} catch (e: NoSuchMethodException) {
|
} catch (e: NoSuchMethodException) {
|
||||||
it.getDeclaredField("INSTANCE").get(null)
|
try {
|
||||||
}) as ButtonImpl)
|
it.getDeclaredField("INSTANCE").get(null)
|
||||||
}.filterNot {
|
} catch (e: NoSuchFieldException) {}
|
||||||
|
}) as? ButtonImpl)
|
||||||
|
}.filterNotNull().filterNot {
|
||||||
(it.info.parent == Category.RISKY) && !riskyCheats
|
(it.info.parent == Category.RISKY) && !riskyCheats
|
||||||
}.plus(Configuration.macros)
|
}.plus(Configuration.macros)
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue