diff options
author | Cephetir <silyichev@gmail.com> | 2022-05-06 12:57:50 +0300 |
---|---|---|
committer | Cephetir <silyichev@gmail.com> | 2022-05-06 12:57:50 +0300 |
commit | dae58987b89bc01fa2828b5f4840a594f416f592 (patch) | |
tree | 5769e04c97490d694b1ba855aaac0cb4289a457c | |
parent | b5002d403246d91b8276791c1d16847abbbadab9 (diff) | |
download | Chatting-dae58987b89bc01fa2828b5f4840a594f416f592.tar.gz Chatting-dae58987b89bc01fa2828b5f4840a594f416f592.tar.bz2 Chatting-dae58987b89bc01fa2828b5f4840a594f416f592.zip |
Clear button
4 files changed, 31 insertions, 2 deletions
diff --git a/src/main/java/cc/woverflow/chatting/mixin/GuiChatMixin.java b/src/main/java/cc/woverflow/chatting/mixin/GuiChatMixin.java index e3edf95..1774f82 100644 --- a/src/main/java/cc/woverflow/chatting/mixin/GuiChatMixin.java +++ b/src/main/java/cc/woverflow/chatting/mixin/GuiChatMixin.java @@ -5,6 +5,7 @@ import cc.woverflow.chatting.chat.ChatShortcuts; import cc.woverflow.chatting.chat.ChatTab; import cc.woverflow.chatting.chat.ChatTabs; import cc.woverflow.chatting.config.ChattingConfig; +import cc.woverflow.chatting.gui.components.ClearButton; import cc.woverflow.chatting.gui.components.ScreenshotButton; import cc.woverflow.chatting.gui.components.SearchButton; import cc.woverflow.chatting.hook.GuiNewChatHook; @@ -51,6 +52,7 @@ public abstract class GuiChatMixin extends GuiScreen { buttonList.add(searchButton); } buttonList.add(new ScreenshotButton()); + buttonList.add(new ClearButton()); if (ChattingConfig.INSTANCE.getChatTabs()) { for (ChatTab chatTab : ChatTabs.INSTANCE.getTabs()) { buttonList.add(chatTab.getButton()); 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<ChatLine, Long> = 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") |