Replace duplicated code using the RenderingUtil.kt methods
This commit is contained in:
parent
e5f0cd0ab2
commit
dd2234be71
|
@ -1,6 +1,5 @@
|
|||
package fr.username404.snowygui.gui.elements
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem
|
||||
import com.mojang.blaze3d.vertex.DefaultVertexFormat
|
||||
import com.mojang.blaze3d.vertex.PoseStack
|
||||
import fr.username404.snowygui.Snowy.Companion.MissingComponent
|
||||
|
@ -10,6 +9,8 @@ import fr.username404.snowygui.gui.feature.ButtonImpl
|
|||
import fr.username404.snowygui.gui.feature.Category
|
||||
import fr.username404.snowygui.gui.feature.Colors
|
||||
import fr.username404.snowygui.utils.RenderingUtil.buffer
|
||||
import fr.username404.snowygui.utils.RenderingUtil.endDraw
|
||||
import fr.username404.snowygui.utils.RenderingUtil.prepareDraw
|
||||
import fr.username404.snowygui.utils.RenderingUtil.tessellator
|
||||
import io.github.config4k.extract
|
||||
import kotlinx.coroutines.CoroutineStart
|
||||
|
@ -46,12 +47,9 @@ class ClickBox(
|
|||
) {
|
||||
override val color: Int get() = this@ClickBox.color
|
||||
override fun render(poseStack: PoseStack?) {
|
||||
RenderSystem.disableTexture()
|
||||
RenderSystem.enableBlend()
|
||||
RenderSystem.defaultBlendFunc()
|
||||
prepareDraw()
|
||||
defaultRectFunc()
|
||||
RenderSystem.disableBlend()
|
||||
RenderSystem.enableTexture()
|
||||
endDraw()
|
||||
}
|
||||
init { height = 8 }
|
||||
}
|
||||
|
@ -82,9 +80,7 @@ class ClickBox(
|
|||
}
|
||||
override fun render(poseStack: PoseStack?) {
|
||||
runBlocking {
|
||||
RenderSystem.disableTexture()
|
||||
RenderSystem.enableBlend()
|
||||
RenderSystem.defaultBlendFunc()
|
||||
prepareDraw()
|
||||
with(buffer) {
|
||||
begin(GL20.GL_POLYGON, DefaultVertexFormat.POSITION_COLOR)
|
||||
// Render the header:
|
||||
|
@ -105,8 +101,7 @@ class ClickBox(
|
|||
vertex(x + width, y + height, 0.0).colorEnd(Colors.WHITE_LINES.hexValue)
|
||||
tessellator.end()
|
||||
}
|
||||
RenderSystem.enableTexture()
|
||||
RenderSystem.disableBlend()
|
||||
endDraw()
|
||||
|
||||
val renderButtons = if (buttons.isNotEmpty()) launch(start = CoroutineStart.UNDISPATCHED) {
|
||||
buttonsProgressBar.apply {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package fr.username404.snowygui.gui.feature
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem
|
||||
import com.mojang.blaze3d.vertex.PoseStack
|
||||
import fr.username404.snowygui.ClickGui
|
||||
import fr.username404.snowygui.Snowy
|
||||
|
@ -8,6 +7,8 @@ import fr.username404.snowygui.config.Configuration
|
|||
import fr.username404.snowygui.gui.ColoredElement
|
||||
import fr.username404.snowygui.utils.FontUtil
|
||||
import fr.username404.snowygui.gui.feature.ButtonInfo.Companion.Type
|
||||
import fr.username404.snowygui.utils.RenderingUtil.endDraw
|
||||
import fr.username404.snowygui.utils.RenderingUtil.prepareDraw
|
||||
import kotlin.reflect.full.findAnnotation
|
||||
|
||||
sealed class ButtonImpl: ColoredElement(0.0, 0.0, 73, 8, opacity = 0.60F) {
|
||||
|
@ -89,11 +90,9 @@ sealed class ButtonImpl: ColoredElement(0.0, 0.0, 73, 8, opacity = 0.60F) {
|
|||
}; return false
|
||||
}
|
||||
override fun render(poseStack: PoseStack?) {
|
||||
RenderSystem.disableTexture()
|
||||
RenderSystem.enableBlend()
|
||||
prepareDraw()
|
||||
defaultRectFunc()
|
||||
RenderSystem.enableTexture()
|
||||
RenderSystem.disableBlend()
|
||||
endDraw()
|
||||
if (poseStack != null) {
|
||||
FontUtil.drawScaled(poseStack, title, x + 1, y + 1, 0.75F)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue