diff --git a/common/src/main/kotlin/fr/username404/snowygui/gui/Box.kt b/common/src/main/kotlin/fr/username404/snowygui/gui/Box.kt index 34e3b2e..ac9ce27 100644 --- a/common/src/main/kotlin/fr/username404/snowygui/gui/Box.kt +++ b/common/src/main/kotlin/fr/username404/snowygui/gui/Box.kt @@ -1,9 +1,9 @@ package fr.username404.snowygui.gui -import fr.username404.snowygui.rendering.Util +import com.mojang.blaze3d.vertex.PoseStack class Box(x: Int, y: Int, scale: Int): Element(x, y, 20 * scale, 10 * scale) { - override fun render() { - Util.UIRect(x, y, this.width, this.height, opacity = 1F) + override fun render(poseStack: PoseStack?) { + } } \ No newline at end of file diff --git a/common/src/main/kotlin/fr/username404/snowygui/gui/Element.kt b/common/src/main/kotlin/fr/username404/snowygui/gui/Element.kt index bbf3dd4..f5d09e0 100644 --- a/common/src/main/kotlin/fr/username404/snowygui/gui/Element.kt +++ b/common/src/main/kotlin/fr/username404/snowygui/gui/Element.kt @@ -1,10 +1,12 @@ package fr.username404.snowygui.gui -fun interface Renderable { fun render() } +import com.mojang.blaze3d.vertex.PoseStack + +fun interface Renderable { fun render(poseStack: PoseStack?) } abstract class Element( var x: Int, var y: Int, val width: Int, val height: Int ): Renderable { - fun display() { if (!hidden) render() } + fun display(stack: PoseStack? = null) { if (!hidden) render(stack) } var hidden: Boolean = false } \ No newline at end of file diff --git a/common/src/main/kotlin/fr/username404/snowygui/gui/SnowyScreen.kt b/common/src/main/kotlin/fr/username404/snowygui/gui/SnowyScreen.kt index 639c743..7f0a26a 100644 --- a/common/src/main/kotlin/fr/username404/snowygui/gui/SnowyScreen.kt +++ b/common/src/main/kotlin/fr/username404/snowygui/gui/SnowyScreen.kt @@ -9,7 +9,7 @@ abstract class SnowyScreen(translatableString: String = "screen.snowy.gui", priv override fun render(poseStack: PoseStack?, i: Int, j: Int, f: Float) { if (poseStack != null) { components?.forEach { - it.display() + it.display(poseStack) } } } diff --git a/common/src/main/kotlin/fr/username404/snowygui/rendering/Util.kt b/common/src/main/kotlin/fr/username404/snowygui/rendering/Util.kt index 0764825..ef4b71a 100644 --- a/common/src/main/kotlin/fr/username404/snowygui/rendering/Util.kt +++ b/common/src/main/kotlin/fr/username404/snowygui/rendering/Util.kt @@ -1,40 +1,13 @@ package fr.username404.snowygui.rendering -import com.mojang.blaze3d.platform.GlStateManager -import com.mojang.blaze3d.systems.RenderSystem import com.mojang.blaze3d.vertex.BufferBuilder -import com.mojang.blaze3d.vertex.DefaultVertexFormat import com.mojang.blaze3d.vertex.PoseStack import com.mojang.blaze3d.vertex.Tesselator import net.minecraft.client.Minecraft -import org.lwjgl.opengl.GL11 internal object Util { private val tessellator: Tesselator = Tesselator.getInstance() private val buffer: BufferBuilder = tessellator.builder - fun UIRect(x: Int, y: Int, width: Int, height: Int, color: Int = -0x1, opacity: Float) { - val r = (color shr 16 and 255) / 255.0f - val g = (color shr 8 and 255) / 255.0f - val b = (color and 255) / 255.0f - RenderSystem.enableBlend() - RenderSystem.disableTexture() - RenderSystem.blendFuncSeparate( - GlStateManager.SourceFactor.SRC_ALPHA, - GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, - GlStateManager.SourceFactor.ONE, - GlStateManager.DestFactor.ZERO - ) - with(buffer) { - begin(GL11.GL_QUADS, DefaultVertexFormat.POSITION_COLOR) - vertex(x.toDouble(), y.toDouble() + height, 0.0).color(r, g, b, opacity).endVertex() - vertex(x.toDouble() + width, y.toDouble() + height, 0.0).color(r, g, b, opacity).endVertex() - vertex(x.toDouble() + width, y.toDouble(), 0.0).color(r, g, b, opacity).endVertex() - vertex(x.toDouble(), y.toDouble(), 0.0).color(r, g, b, opacity).endVertex() - tessellator.end() - RenderSystem.enableTexture() - RenderSystem.disableBlend() - } - } fun UIString(poseStack: PoseStack, string: String, i: Float, j: Float) { Minecraft.getInstance().font.draw(poseStack, string, i, j, 10) }