Shorten SnowyConfigScreen in ConfigScreen.kt

This commit is contained in:
Username404-59 2021-06-24 13:59:26 +02:00
parent cd4d25951c
commit 34de53beee
Signed by: Username404-59
GPG Key ID: 7AB361FBB257A5D1
1 changed files with 72 additions and 75 deletions

View File

@ -24,8 +24,17 @@ private fun supplyComponent(string: String?): Optional<Component> = string?.run
Optional.of(TranslatableComponent(string))
} ?: Optional.empty()
val SnowyConfigScreen: Screen get() {
return try {
val SnowyConfigScreen: Screen = object: Screen(translationComponent) {
override fun isPauseScreen(): Boolean = false
override fun render(poseStack: PoseStack, i: Int, j: Int, f: Float) {
super.renderBackground(poseStack)
FontUtil.drawScaled(poseStack,
text = "An appropriate version of the Cloth Config mod is required for the configuration of snowygui.", 16.0, 16.0,
color = Colors.WHITE, scaleFactor = 0.85F
)
}
override fun onClose() { minecraft?.screen = configScreenParent }
}; get() = try {
Class.forName("me.shedaniel.clothconfig2.api.ConfigBuilder")
val macrosBox: ClickBox = ClickGui.components.find {
(it is ClickBox) && it.isCategory(Category.MACROS)
@ -88,22 +97,10 @@ val SnowyConfigScreen: Screen get() {
macrosButtons.add(newMacro)
}
}
}
if (it.isEmpty().also { empty -> macrosBox.hidden = empty }) macrosButtons.clear()
}.build())
}
}; if (it.isEmpty().also { empty -> macrosBox.hidden = empty })
macrosButtons.clear()
}.build()
} catch (e: ClassNotFoundException) {
object: Screen(translationComponent) {
override fun isPauseScreen(): Boolean = false
override fun render(poseStack: PoseStack, i: Int, j: Int, f: Float) {
super.renderBackground(poseStack)
FontUtil.drawScaled(poseStack,
text = "An appropriate version of the Cloth Config mod is required for the configuration of snowygui.", 16.0, 16.0,
color = Colors.WHITE, scaleFactor = 0.85F
)
}
override fun onClose() { minecraft?.screen = configScreenParent }
}
}
}
}.build()
} catch (e: ClassNotFoundException) { field }