Skip to content

Commit

Permalink
option for background extension
Browse files Browse the repository at this point in the history
  • Loading branch information
ImToggle committed Jul 9, 2024
1 parent 69e1fc6 commit f31f153
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/main/java/org/polyfrost/chatting/mixin/GuiChatMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/org/polyfrost/chatting/chat/ChatWindow.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
10 changes: 8 additions & 2 deletions src/main/kotlin/org/polyfrost/chatting/config/ChattingConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down

0 comments on commit f31f153

Please sign in to comment.