diff options
author | Jacob <42344274+jacobk999@users.noreply.github.com> | 2022-02-03 11:07:10 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-03 23:07:10 +0700 |
commit | 1307b6c8f8f7a4aa4d1fd9781cddb5edd0c9f349 (patch) | |
tree | 71fa7f7a435a7ca3f460eddd8c057cccad3cd154 /src/main/kotlin/cc/woverflow/chatting/Chatting.kt | |
parent | 4e587bc97c3aee3c3458a6ac60a43122f7c7971e (diff) | |
download | Chatting-1307b6c8f8f7a4aa4d1fd9781cddb5edd0c9f349.tar.gz Chatting-1307b6c8f8f7a4aa4d1fd9781cddb5edd0c9f349.tar.bz2 Chatting-1307b6c8f8f7a4aa4d1fd9781cddb5edd0c9f349.zip |
Improved Screenshotting (#4)
* make copy button 9x9
* make font scale 2x and image width max text width in screenshots
Diffstat (limited to 'src/main/kotlin/cc/woverflow/chatting/Chatting.kt')
-rw-r--r-- | src/main/kotlin/cc/woverflow/chatting/Chatting.kt | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/main/kotlin/cc/woverflow/chatting/Chatting.kt b/src/main/kotlin/cc/woverflow/chatting/Chatting.kt index a72fcbb..d90ba34 100644 --- a/src/main/kotlin/cc/woverflow/chatting/Chatting.kt +++ b/src/main/kotlin/cc/woverflow/chatting/Chatting.kt @@ -198,7 +198,7 @@ object Chatting { val hud = Minecraft.getMinecraft().ingameGUI val chat = hud.chatGUI val i = MathHelper.floor_float(chat.chatWidth / chat.chatScale) - return screenshot(GuiUtilRenderComponents.splitText(line.chatComponent, i, Minecraft.getMinecraft().fontRendererObj, false, false).map { it.formattedText }.reversed(), chat.chatWidth) + return screenshot(GuiUtilRenderComponents.splitText(line.chatComponent, i, Minecraft.getMinecraft().fontRendererObj, false, false).map { it.formattedText }.reversed()) } private fun screenshotChat() { @@ -215,11 +215,11 @@ object Chatting { chatLines.add(drawnLines[i].chatComponent.formattedText) } - screenshot(chatLines, chat.chatWidth)?.copyToClipboard() + screenshot(chatLines)?.copyToClipboard() } } - private fun screenshot(messages: List<String>, width: Int): BufferedImage? { + private fun screenshot(messages: List<String>): BufferedImage? { if (messages.isEmpty()) { EssentialAPI.getNotifications().push("Chatting", "Chat window is empty.") return null @@ -230,10 +230,11 @@ object Chatting { } val fr: FontRenderer = ModCompatHooks.fontRenderer - val fb: Framebuffer = createBindFramebuffer(width * 3, (messages.size * 9) * 3) + val width = messages.maxOf { fr.getStringWidth(it) } + val fb: Framebuffer = createBindFramebuffer(width * 2, (messages.size * 9) * 2) val file = File(Minecraft.getMinecraft().mcDataDir, "screenshots/chat/" + fileFormatter.format(Date())) - GlStateManager.scale(3f, 3f, 1f) + GlStateManager.scale(2f, 2f, 1f) val scale = Minecraft.getMinecraft().gameSettings.chatScale GlStateManager.scale(scale, scale, 1f) for (i in messages.indices) { |