diff options
Diffstat (limited to 'src/main/kotlin/gui')
-rw-r--r-- | src/main/kotlin/gui/BaseScreen.kt | 52 | ||||
-rw-r--r-- | src/main/kotlin/gui/MessageUi.kt | 27 | ||||
-rw-r--r-- | src/main/kotlin/gui/ScreenUtil.kt | 19 |
3 files changed, 44 insertions, 54 deletions
diff --git a/src/main/kotlin/gui/BaseScreen.kt b/src/main/kotlin/gui/BaseScreen.kt deleted file mode 100644 index 06aafb9..0000000 --- a/src/main/kotlin/gui/BaseScreen.kt +++ /dev/null @@ -1,52 +0,0 @@ -package moe.nea.ultranotifier.gui - -import net.minecraft.client.gui.DrawContext -import net.minecraft.client.gui.screen.Screen -import net.minecraft.text.Text -//#if MC < 1.20.4 -//$$import com.mojang.blaze3d.platform.GlStateManager -//#endif - -class DrawingContext( -//#if MC > 1.20.4 - val vanilla: DrawContext, -//#endif -) { - fun pushMatrix() { -//#if MC > 1.20.4 - vanilla.matrices.push() -//#else -//$$ GlStateManager.pushMatrix() -//#endif - } - fun popMatrix() { -//#if MC > 1.20.4 - vanilla.matrices.pop() -//#else -//$$ GlStateManager.popMatrix() -//#endif - } - fun translate(x: Double, y: Double, z: Double) { -//#if MC > 1.20.4 - vanilla.matrices.translate(x, y, z) -//#else -//$$ GlStateManager.translate(x, y, z) -//#endif - } - fun scale(x: Float, y: Float, z: Float) { -//#if MC > 1.20.4 - vanilla.matrices.scale(x, y, z) -//#else -//$$ GlStateManager.scale(x, y, z) -//#endif - } - -} - -abstract class BaseScreen(title: Text) : Screen( -//#if MC >= 11400 - title -//#endif -) { - -} diff --git a/src/main/kotlin/gui/MessageUi.kt b/src/main/kotlin/gui/MessageUi.kt index 78965b3..f4012da 100644 --- a/src/main/kotlin/gui/MessageUi.kt +++ b/src/main/kotlin/gui/MessageUi.kt @@ -1,6 +1,29 @@ package moe.nea.ultranotifier.gui -import moe.nea.ultranotifier.commands.literalText +import gg.essential.universal.UGraphics +import gg.essential.universal.UMatrixStack +import gg.essential.universal.UScreen +import java.awt.Color + +class MessageUi : UScreen() { + override fun onDrawScreen(matrixStack: UMatrixStack, mouseX: Int, mouseY: Int, partialTicks: Float) { + super.onDrawScreen(matrixStack, mouseX, mouseY, partialTicks) + fillRect(matrixStack, + 0.0, 0.0, width.toDouble(), height.toDouble(), Color.RED) + } + + fun fillRect( + matrixStack: UMatrixStack, + left: Double, top: Double, right: Double, bottom: Double, + color: Color, + ) { + val buffer = UGraphics.getFromTessellator() + buffer.beginWithDefaultShader(UGraphics.DrawMode.QUADS, UGraphics.CommonVertexFormats.POSITION_COLOR) + buffer.pos(matrixStack, left, top, 0.0).color(color).endVertex() + buffer.pos(matrixStack, left, bottom, 0.0).color(color).endVertex() + buffer.pos(matrixStack, right, bottom, 0.0).color(color).endVertex() + buffer.pos(matrixStack, right, top, 0.0).color(color).endVertex() + buffer.drawDirect() + } -class MessageUi : BaseScreen(literalText("Messages")) { } diff --git a/src/main/kotlin/gui/ScreenUtil.kt b/src/main/kotlin/gui/ScreenUtil.kt new file mode 100644 index 0000000..bb3dfc3 --- /dev/null +++ b/src/main/kotlin/gui/ScreenUtil.kt @@ -0,0 +1,19 @@ +package moe.nea.ultranotifier.gui + +import gg.essential.universal.UScreen +import moe.nea.ultranotifier.event.SubscriptionTarget +import moe.nea.ultranotifier.event.TickEvent +import moe.nea.ultranotifier.event.UltraSubscribe +import net.minecraft.client.gui.screen.Screen + +object ScreenUtil : SubscriptionTarget { + var openScreen: Screen? = null + + @UltraSubscribe + fun onTick(event: TickEvent) { + openScreen?.let { + UScreen.displayScreen(it) + openScreen = null + } + } +} |