From f31f1531596315e7bfd6b4f7907075e4cf8f4a52 Mon Sep 17 00:00:00 2001 From: ImToggle <98242902+ImToggle@users.noreply.github.com> Date: Tue, 9 Jul 2024 23:58:11 +0800 Subject: [PATCH] option for background extension --- .../org/polyfrost/chatting/mixin/GuiChatMixin.java | 4 ++-- .../org/polyfrost/chatting/mixin/GuiNewChatMixin.java | 6 ++++-- .../kotlin/org/polyfrost/chatting/chat/ChatWindow.kt | 2 +- .../org/polyfrost/chatting/config/ChattingConfig.kt | 10 ++++++++-- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/polyfrost/chatting/mixin/GuiChatMixin.java b/src/main/java/org/polyfrost/chatting/mixin/GuiChatMixin.java index c695962..97a07b3 100644 --- a/src/main/java/org/polyfrost/chatting/mixin/GuiChatMixin.java +++ b/src/main/java/org/polyfrost/chatting/mixin/GuiChatMixin.java @@ -108,7 +108,7 @@ private void onDrawScreen(int mouseX, int mouseY, float partialTicks, CallbackIn ChatWindow hud = ChattingConfig.INSTANCE.getChatWindow(); int scale = new ScaledResolution(mc).getScaleFactor(); int x = Mouse.getX(); - int right = (int) ((hook.chatting$getRight() + ModCompatHooks.getXOffset() + 1 + hud.getPaddingX() * 2) * hud.getScale() + (int) hud.position.getX()); + int right = (int) ((hook.chatting$getRight() + ModCompatHooks.getXOffset() + 1 + hud.getPaddingX() * (ChattingConfig.INSTANCE.getExtendBG() ? 1f : 2f)) * hud.getScale() + (int) hud.position.getX()); delete = delete && chatting$hovered(hook, x, right + (int) ((copy ? 10 : 0) * hud.getScale()), scale, hud); copy = copy && chatting$hovered(hook, x, right, scale, hud); @@ -139,7 +139,7 @@ private void mouseClicked(int mouseX, int mouseY, int mouseButton, CallbackInfo int x = Mouse.getX(); if (hook.chatting$isHovering()) { boolean copy = ChattingConfig.INSTANCE.getChatCopy(); - int right = (int) ((hook.chatting$getRight() + ModCompatHooks.getXOffset() + 1 + hud.getPaddingX() * 2) * hud.getScale() + (int) hud.position.getX()) * scale; + int right = (int) ((hook.chatting$getRight() + ModCompatHooks.getXOffset() + 1 + hud.getPaddingX() * (ChattingConfig.INSTANCE.getExtendBG() ? 1f : 2f)) * hud.getScale() + (int) hud.position.getX()) * scale; if (copy && x > right && x < right + 9 * hud.getScale() * scale || (mouseButton == 1 && ChattingConfig.INSTANCE.getRightClickCopy())) { Transferable message = hook.chatting$getChattingChatComponent(Mouse.getY()); if (message == null) return; diff --git a/src/main/java/org/polyfrost/chatting/mixin/GuiNewChatMixin.java b/src/main/java/org/polyfrost/chatting/mixin/GuiNewChatMixin.java index be628f5..1a2beb2 100644 --- a/src/main/java/org/polyfrost/chatting/mixin/GuiNewChatMixin.java +++ b/src/main/java/org/polyfrost/chatting/mixin/GuiNewChatMixin.java @@ -175,7 +175,7 @@ private void startScissor(int updateCounter, CallbackInfo ci) { int mcScale = new ScaledResolution(mc).getScaleFactor(); GL11.glEnable(GL11.GL_SCISSOR_TEST); int height = (int) hud.getAnimationHeight(); - GL11.glScissor((int) ((hud.position.getX() - 1) * mcScale), mc.displayHeight - (int) (hud.position.getBottomY() + hud.getScale()) * mcScale, (int) ((hud.getAnimationWidth() + 21) * mcScale), (int) ((height + hud.getScale()) * mcScale)); + GL11.glScissor((int) ((hud.position.getX() - 1) * mcScale), mc.displayHeight - (int) (hud.position.getBottomY() + hud.getScale()) * mcScale, (int) ((hud.getAnimationWidth() + 1 + (ChattingConfig.INSTANCE.getExtendBG() ? 0 : 20)) * mcScale), (int) ((height + hud.getScale()) * mcScale)); } @Inject(method = "drawChat", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/GlStateManager;popMatrix()V")) @@ -337,7 +337,9 @@ private void checkStuff(int j2, CallbackInfo ci) { GlStateManager.pushMatrix(); int posLeft = right + 1; int posRight = right + 10; - GlStateManager.translate(chatting$config().getChatWindow().getPaddingX() * chatting$config().getChatWindow().getScale(), 0f, 0f); + if (!ChattingConfig.INSTANCE.getExtendBG()) { + GlStateManager.translate(chatting$config().getChatWindow().getPaddingX() * chatting$config().getChatWindow().getScale(), 0f, 0f); + } if (chatting$config().getChatCopy()) { mc.getTextureManager().bindTexture(chatting$COPY); chatting$right = right; diff --git a/src/main/kotlin/org/polyfrost/chatting/chat/ChatWindow.kt b/src/main/kotlin/org/polyfrost/chatting/chat/ChatWindow.kt index 84df067..ea8a838 100644 --- a/src/main/kotlin/org/polyfrost/chatting/chat/ChatWindow.kt +++ b/src/main/kotlin/org/polyfrost/chatting/chat/ChatWindow.kt @@ -214,7 +214,7 @@ class ChatWindow : BasicHud(true, 2f, 1080 - 27f - 45f - 12f, fun drawBG() { animationWidth = widthAnimation.get() animationHeight = heightAnimation.get() - width = position.width // + (if (mc.ingameGUI.chatGUI.chatOpen && !Chatting.peeking) ModCompatHooks.chatButtonOffset else 0) * scale + width = position.width + (if (mc.ingameGUI.chatGUI.chatOpen && !Chatting.peeking && ChattingConfig.extendBG) ModCompatHooks.chatButtonOffset else 0) * scale val heightEnd = if (height == 0) 0f else (height + paddingY * 2f) * scale val duration = ChattingConfig.bgDuration GlStateManager.enableAlpha() diff --git a/src/main/kotlin/org/polyfrost/chatting/config/ChattingConfig.kt b/src/main/kotlin/org/polyfrost/chatting/config/ChattingConfig.kt index 7cc1f81..0c69a2a 100644 --- a/src/main/kotlin/org/polyfrost/chatting/config/ChattingConfig.kt +++ b/src/main/kotlin/org/polyfrost/chatting/config/ChattingConfig.kt @@ -167,11 +167,17 @@ object ChattingConfig : Config( @Switch( name = "Button Shadow", category = "Buttons", - description = "Enable button shadow.", - size = 2 + description = "Enable button shadow." ) var buttonShadow = true + @Switch( + name = "Extend Chat Background", + category = "Buttons", + description = "Extends the chat background if buttons are enabled." + ) + var extendBG = true + @Switch( name = "Chat Copying Button", category = "Buttons", description = "Enable copying chat messages via a button."