aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXThe <101992755+SirXThe@users.noreply.github.com>2023-02-26 18:22:35 +0100
committerGitHub <noreply@github.com>2023-02-26 12:22:35 -0500
commit38af8a31a642fa3112ceb7651dd673e1de58851e (patch)
treedd4981f10d917b1409e4340f716f634d5ab805ab
parentccd2380da028e74b08e5c794c0721c325fec261f (diff)
downloadChatting-38af8a31a642fa3112ceb7651dd673e1de58851e.tar.gz
Chatting-38af8a31a642fa3112ceb7651dd673e1de58851e.tar.bz2
Chatting-38af8a31a642fa3112ceb7651dd673e1de58851e.zip
fix: fix: resolve duplicated lines are missing in chat screenshots (#21)
-rw-r--r--README.md8
-rw-r--r--src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin.java4
-rw-r--r--src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin_SmoothMessages.java2
-rw-r--r--src/main/kotlin/cc/woverflow/chatting/Chatting.kt16
4 files changed, 15 insertions, 15 deletions
diff --git a/README.md b/README.md
index a454cf0..7150e7d 100644
--- a/README.md
+++ b/README.md
@@ -2,7 +2,7 @@
# `Chatting`
A chat mod adding utilities such as extremely customizable chat tabs, chat shortcuts, chat screenshots, and message copying.\
-<img alt="downloads" src="https://img.shields.io/github/downloads/W-OVERFLOW/Chatting/total?color=F5C400&style=for-the-badge" /> <img alt="downloads latest" src="https://img.shields.io/github/downloads-pre/W-OVERFLOW/Chatting/latest/total?color=F5C400&style=for-the-badge" />\
+<img alt="downloads" src="https://img.shields.io/github/downloads/Polyfrost/Chatting/total?color=F5C400&style=for-the-badge" /> <img alt="downloads latest" src="https://img.shields.io/github/downloads-pre/Polyfrost/Chatting/latest/total?color=F5C400&style=for-the-badge" />\
[Report a Bug][bugreps]
ยท
[Request a Feature][featreqs]
@@ -11,6 +11,6 @@ A chat mod adding utilities such as extremely customizable chat tabs, chat short
</div>
-[bugreps]: https://github.com/W-OVERFLOW/Chatting/issues
-[featreqs]: https://woverflow.cc/discord
-[docs]: docs/docs.md
+[bugreps]: https://github.com/Polyfrost/Chatting/issues
+[featreqs]: https://polyfrost.cc/discord
+[docs]: docs/docs.md \ No newline at end of file
diff --git a/src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin.java b/src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin.java
index 6d4a60d..5503e35 100644
--- a/src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin.java
+++ b/src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin.java
@@ -28,7 +28,7 @@ import java.awt.datatransfer.Transferable;
import java.awt.image.BufferedImage;
import java.util.List;
-@Mixin(value = GuiNewChat.class, priority = Integer.MIN_VALUE)
+@Mixin(value = GuiNewChat.class, priority = 990)
public abstract class GuiNewChatMixin extends Gui implements GuiNewChatHook {
@Unique
private int chatting$right = 0;
@@ -243,7 +243,7 @@ public abstract class GuiNewChatMixin extends Gui implements GuiNewChatHook {
ChatLine fullLine = this.getFullMessage(subLine);
if (GuiScreen.isShiftKeyDown()) {
if (fullLine != null) {
- BufferedImage image = Chatting.INSTANCE.screenshotLine(fullLine);
+ BufferedImage image = Chatting.INSTANCE.screenshotLine(subLine);
if (image != null) RenderUtils.copyToClipboard(image);
}
return null;
diff --git a/src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin_SmoothMessages.java b/src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin_SmoothMessages.java
index 0ef7736..d2604de 100644
--- a/src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin_SmoothMessages.java
+++ b/src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin_SmoothMessages.java
@@ -69,7 +69,7 @@ public abstract class GuiNewChatMixin_SmoothMessages {
return line;
}
- @ModifyArg(method = "drawChat", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/FontRenderer;drawStringWithShadow(Ljava/lang/String;FFI)I"), index = 3)
+ @ModifyArg(method = "drawChat", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/FontRenderer;drawStringWithShadow(Ljava/lang/String;FFI)I"))
private int modifyTextOpacity(int original) {
if (ChattingConfig.INSTANCE.getSmoothChat() && chatting$lineBeingDrawn <= chatting$newLines) {
int opacity = (original >> 24) & 0xFF;
diff --git a/src/main/kotlin/cc/woverflow/chatting/Chatting.kt b/src/main/kotlin/cc/woverflow/chatting/Chatting.kt
index ae5f8a1..882be98 100644
--- a/src/main/kotlin/cc/woverflow/chatting/Chatting.kt
+++ b/src/main/kotlin/cc/woverflow/chatting/Chatting.kt
@@ -195,7 +195,7 @@ object Chatting {
val chat = hud.chatGUI
val i = MathHelper.floor_float(chat.chatWidth / chat.chatScale)
return screenshot(
- hashMapOf<String, ChatLine>().also {
+ hashMapOf<ChatLine, String>().also {
GuiUtilRenderComponents.splitText(
line.chatComponent,
i,
@@ -203,7 +203,7 @@ object Chatting {
false,
false
).map { it.formattedText }.reversed().forEach { string ->
- it[string] = line
+ it[line] = string
}
}
)
@@ -216,7 +216,7 @@ object Chatting {
fun screenshotChat(scrollPos: Int) {
val hud = Minecraft.getMinecraft().ingameGUI
val chat = hud.chatGUI
- val chatLines = LinkedHashMap<String, ChatLine>()
+ val chatLines = LinkedHashMap<ChatLine, String>()
ChatSearchingManager.filterMessages(
ChatSearchingManager.lastSearch,
(chat as GuiNewChatAccessor).drawnChatLines
@@ -226,14 +226,14 @@ object Chatting {
Minecraft.getMinecraft().gameSettings.chatHeightFocused / 9
)
for (i in scrollPos until drawnLines.size.coerceAtMost(scrollPos + chatHeight)) {
- chatLines[drawnLines[i].chatComponent.formattedText] = drawnLines[i]
+ chatLines[drawnLines[i]] = drawnLines[i].chatComponent.formattedText
}
screenshot(chatLines)?.copyToClipboard()
}
}
- private fun screenshot(messages: HashMap<String, ChatLine>): BufferedImage? {
+ private fun screenshot(messages: HashMap<ChatLine, String>): BufferedImage? {
if (messages.isEmpty()) {
Notifications.INSTANCE.send("Chatting", "Chat window is empty.")
return null
@@ -247,15 +247,15 @@ object Chatting {
}
val fr: FontRenderer = ModCompatHooks.fontRenderer
- val width = messages.maxOf { fr.getStringWidth(it.key) + (if (ChattingConfig.showChatHeads && ((it.value as ChatLineHook).hasDetected() || ChattingConfig.offsetNonPlayerMessages)) 10 else 0) } + 4
+ val width = messages.maxOf { fr.getStringWidth(it.value) + (if (ChattingConfig.showChatHeads && ((it.key as ChatLineHook).hasDetected() || ChattingConfig.offsetNonPlayerMessages)) 10 else 0) } + 4
val fb: Framebuffer = createBindFramebuffer(width * 2, (messages.size * 9) * 2)
val file = File(Minecraft.getMinecraft().mcDataDir, "screenshots/chat/" + fileFormatter.format(Date()))
GlStateManager.scale(2f, 2f, 1f)
val scale = Minecraft.getMinecraft().gameSettings.chatScale
GlStateManager.scale(scale, scale, 1f)
- messages.entries.forEachIndexed { i: Int, entry: MutableMap.MutableEntry<String, ChatLine> ->
- ModCompatHooks.redirectDrawString(entry.key, 0f, (messages.size - 1 - i) * 9f, 0xffffff, entry.value, true)
+ messages.entries.forEachIndexed { i: Int, entry: MutableMap.MutableEntry<ChatLine, String> ->
+ ModCompatHooks.redirectDrawString(entry.value, 0f, (messages.size - 1 - i) * 9f, 0xffffff, entry.key, true)
}
val image = fb.screenshot(file)