From dae58987b89bc01fa2828b5f4840a594f416f592 Mon Sep 17 00:00:00 2001 From: Cephetir Date: Fri, 6 May 2022 12:57:50 +0300 Subject: Clear button --- .../chatting/gui/components/ClearButton.kt | 27 ++++++++++++++++++++++ .../chatting/gui/components/ScreenshotButton.kt | 2 +- .../cc/woverflow/chatting/utils/renderutils.kt | 2 +- 3 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 src/main/kotlin/cc/woverflow/chatting/gui/components/ClearButton.kt (limited to 'src/main/kotlin') diff --git a/src/main/kotlin/cc/woverflow/chatting/gui/components/ClearButton.kt b/src/main/kotlin/cc/woverflow/chatting/gui/components/ClearButton.kt new file mode 100644 index 0000000..3035a98 --- /dev/null +++ b/src/main/kotlin/cc/woverflow/chatting/gui/components/ClearButton.kt @@ -0,0 +1,27 @@ +package cc.woverflow.chatting.gui.components + +import cc.woverflow.chatting.Chatting +import gg.essential.universal.UResolution +import net.minecraft.client.Minecraft +import net.minecraft.client.gui.Gui +import net.minecraft.client.renderer.GlStateManager +import net.minecraft.util.ResourceLocation + +class ClearButton : + CleanButton(13379014, { UResolution.scaledWidth - 28 }, { UResolution.scaledHeight - 27 }, 12, 12, "", + { RenderType.NONE }) { + + override fun onMousePress() { + Minecraft.getMinecraft().ingameGUI.chatGUI.clearChatMessages() + } + + override fun drawButton(mc: Minecraft, mouseX: Int, mouseY: Int) { + super.drawButton(mc, mouseX, mouseY) + if (visible) { + if (hovered) GlStateManager.color(1f, 1f, 160f / 255f) + else GlStateManager.color(1f, 1f, 1f) + mc.textureManager.bindTexture(ResourceLocation(Chatting.ID, "delete.png")) + Gui.drawModalRectWithCustomSizedTexture(xPosition + 1, yPosition + 1, 0f, 0f, 10, 10, 10f, 10f) + } + } +} \ No newline at end of file diff --git a/src/main/kotlin/cc/woverflow/chatting/gui/components/ScreenshotButton.kt b/src/main/kotlin/cc/woverflow/chatting/gui/components/ScreenshotButton.kt index ff51a1e..9fc5e8d 100644 --- a/src/main/kotlin/cc/woverflow/chatting/gui/components/ScreenshotButton.kt +++ b/src/main/kotlin/cc/woverflow/chatting/gui/components/ScreenshotButton.kt @@ -11,7 +11,7 @@ import net.minecraft.client.renderer.GlStateManager import net.minecraft.util.ResourceLocation class ScreenshotButton : - CleanButton(448318, { UResolution.scaledWidth - 28 }, { UResolution.scaledHeight - 27 }, 12, 12, "", + CleanButton(448318, { UResolution.scaledWidth - 42 }, { UResolution.scaledHeight - 27 }, 12, 12, "", { RenderType.NONE }) { override fun onMousePress() { diff --git a/src/main/kotlin/cc/woverflow/chatting/utils/renderutils.kt b/src/main/kotlin/cc/woverflow/chatting/utils/renderutils.kt index bf11c3b..dc6a1e6 100644 --- a/src/main/kotlin/cc/woverflow/chatting/utils/renderutils.kt +++ b/src/main/kotlin/cc/woverflow/chatting/utils/renderutils.kt @@ -226,7 +226,7 @@ val messages: Map = mutableMapOf() var lastMessage: ChatLine? = null fun showTimestamp() { if (!ChattingConfig.showTimestamp) return - val chatLine = getChatLineOverMouse(UMouse.Raw.x.roundToInt(), UMouse.Raw.y.roundToInt()) + val chatLine = getChatLineOverMouse(UMouse.getTrueX().roundToInt(), UMouse.getTrueY().roundToInt()) if (chatLine != null) { val long = messages[chatLine] if (long != null) chatLine.chatComponent.appendText(" §7[${sdf.format(Date(long))}]§r") -- cgit