Skip to content

Commit

Permalink
fixed right click being able to screenshot, copy single line
Browse files Browse the repository at this point in the history
  • Loading branch information
ImToggle committed Aug 2, 2024
1 parent 7f6c041 commit 576adeb
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public interface GuiNewChatHook {

ChatLine chatting$getHoveredLine(int mouseY);

Transferable chatting$getChattingChatComponent(int mouseY);
Transferable chatting$getChattingChatComponent(int mouseY, int mouseButton);

int chatting$getTextOpacity();
}
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ private void mouseClicked(int mouseX, int mouseY, int mouseButton, CallbackInfo
boolean copy = ChattingConfig.INSTANCE.getChatCopy();
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() && (!ChattingConfig.INSTANCE.getRightClickCopyCtrl() || UKeyboard.isCtrlKeyDown()))) {
Transferable message = hook.chatting$getChattingChatComponent(Mouse.getY());
Transferable message = hook.chatting$getChattingChatComponent(Mouse.getY(), mouseButton);
if (message == null) return;
try {
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(message, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -393,18 +393,18 @@ private void chatScale(CallbackInfoReturnable<Float> cir) {
}

@Override
public Transferable chatting$getChattingChatComponent(int mouseY) {
public Transferable chatting$getChattingChatComponent(int mouseY, int mouseButton) {
ChatLine subLine = chatting$getHoveredLine(mouseY);
if (subLine != null) {
ChatLine fullLine = ((ChatLineHook) subLine).chatting$getFullMessage();
if (GuiScreen.isShiftKeyDown()) {
if (GuiScreen.isShiftKeyDown() && mouseButton == 0) {
if (fullLine != null) {
BufferedImage image = Chatting.INSTANCE.screenshotLine(subLine);
if (image != null) RenderUtils.copyToClipboard(image);
}
return null;
}
ChatLine line = GuiScreen.isCtrlKeyDown() ? subLine : fullLine;
ChatLine line = GuiScreen.isCtrlKeyDown() && mouseButton == 0 ? subLine : fullLine;
String message = line == null ? "Could not find chat message." : line.getChatComponent().getFormattedText();
String actualMessage = GuiScreen.isAltKeyDown() ? message : EnumChatFormatting.getTextWithoutFormattingCodes(message);
Notifications.INSTANCE.send("Chatting", line == null ? "Could not find chat message." : "Copied following text: " + actualMessage);
Expand Down

0 comments on commit 576adeb

Please sign in to comment.