From ab8852065c8d510300f6dfdb1fb9f106fcdb9ddd Mon Sep 17 00:00:00 2001 From: ImToggle <98242902+ImToggle@users.noreply.github.com> Date: Sun, 21 Jul 2024 09:44:23 +0800 Subject: [PATCH] fixed chat head not being drawn when closing --- .../chatting/mixin/GuiNewChatMixin.java | 7 +++- .../org/polyfrost/chatting/chat/ChatWindow.kt | 37 ++++--------------- 2 files changed, 13 insertions(+), 31 deletions(-) diff --git a/src/main/java/org/polyfrost/chatting/mixin/GuiNewChatMixin.java b/src/main/java/org/polyfrost/chatting/mixin/GuiNewChatMixin.java index 093e702..121ddc4 100644 --- a/src/main/java/org/polyfrost/chatting/mixin/GuiNewChatMixin.java +++ b/src/main/java/org/polyfrost/chatting/mixin/GuiNewChatMixin.java @@ -107,7 +107,7 @@ private void drawClosing(int updateCounter, CallbackInfo ci) { int q = m * 9; String string = chatLine.getChatComponent().getFormattedText(); GlStateManager.enableBlend(); - ModCompatHooks.redirectDrawString(string, chatting$config().getFade() ? 0 : 3, -q - 8, 16777215 + (chatting$getOpacity(chatting$updateCounter, chatLine) << 24), chatLine, false); + ModCompatHooks.redirectDrawString(string, chatting$config().getFade() ? 0 : 3, -q - 8, 0xFFFFFFFF, chatLine, false); GlStateManager.disableAlpha(); GlStateManager.disableBlend(); } @@ -317,6 +317,11 @@ private void checkStuff(int j2, CallbackInfo ci) { } } + @Inject(method = "getChatScale", at = @At("HEAD"), cancellable = true) + private void chatScale(CallbackInfoReturnable cir) { + cir.setReturnValue(ChattingConfig.INSTANCE.getChatWindow().getScale()); + } + @Override public int chatting$getRight() { return chatting$right; diff --git a/src/main/kotlin/org/polyfrost/chatting/chat/ChatWindow.kt b/src/main/kotlin/org/polyfrost/chatting/chat/ChatWindow.kt index b6e9a54..1b8d93a 100644 --- a/src/main/kotlin/org/polyfrost/chatting/chat/ChatWindow.kt +++ b/src/main/kotlin/org/polyfrost/chatting/chat/ChatWindow.kt @@ -173,42 +173,19 @@ class ChatWindow : BasicHud(true, 2f, 1080 - 27f - 45f - 12f, override fun drawBackground(x: Float, y: Float, width: Float, height: Float, scale: Float) { if (Chatting.isPatcher && PatcherConfig.transparentChat) return - val nanoVGHelper = NanoVGHelper.INSTANCE val animatingOpacity = wasInChatGui && (ChattingConfig.smoothBG && (previousAnimationWidth != width || previousAnimationHeight != height)) wasInChatGui = mc.currentScreen is GuiChat || animatingOpacity previousAnimationWidth = width previousAnimationHeight = height val bgOpacity = openOpacity val borderOpacity = openBorderOpacity - val bgColor = bgColor.getRGB().setAlpha(if (differentOpacity && wasInChatGui) bgOpacity else bgColor.alpha) - val borderColor = borderColor.getRGB().setAlpha(if (differentOpacity && wasInChatGui) borderOpacity else borderColor.alpha) - nanoVGHelper.setupAndDraw(true) { vg: Long -> - if (rounded) { - nanoVGHelper.drawRoundedRect(vg, x, y, width, height, bgColor, cornerRadius * scale) - if (border) nanoVGHelper.drawHollowRoundRect( - vg, - x - borderSize * scale, - y - borderSize * scale, - width + borderSize * scale, - height + borderSize * scale, - borderColor, - cornerRadius * scale, - borderSize * scale - ) - } else { - nanoVGHelper.drawRect(vg, x, y, width, height, bgColor) - if (border) nanoVGHelper.drawHollowRoundRect( - vg, - x - borderSize * scale, - y - borderSize * scale, - width + borderSize * scale, - height + borderSize * scale, - borderColor, - 0f, - borderSize * scale - ) - } - } + val tempBgAlpha = bgColor.alpha + val tempBorderAlpha = borderColor.alpha + bgColor.alpha = if (differentOpacity && wasInChatGui) bgOpacity else bgColor.alpha + borderColor.alpha = if (differentOpacity && wasInChatGui) borderOpacity else borderColor.alpha + super.drawBackground(x, y, width, height, scale) + bgColor.alpha = tempBgAlpha + borderColor.alpha = tempBorderAlpha } fun drawBG() {