aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob <42344274+jacobk999@users.noreply.github.com>2022-02-03 11:07:10 -0500
committerGitHub <noreply@github.com>2022-02-03 23:07:10 +0700
commit1307b6c8f8f7a4aa4d1fd9781cddb5edd0c9f349 (patch)
tree71fa7f7a435a7ca3f460eddd8c057cccad3cd154
parent4e587bc97c3aee3c3458a6ac60a43122f7c7971e (diff)
downloadChatting-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
-rw-r--r--src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin.java2
-rw-r--r--src/main/kotlin/cc/woverflow/chatting/Chatting.kt11
2 files changed, 7 insertions, 6 deletions
diff --git a/src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin.java b/src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin.java
index d6bc8f5..9c292c6 100644
--- a/src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin.java
+++ b/src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin.java
@@ -204,7 +204,7 @@ public abstract class GuiNewChatMixin extends Gui implements GuiNewChatHook {
GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f);
chatting$right = right;
Gui.drawModalRectWithCustomSizedTexture(right + 1, top, 0f, 0f, 9, 9, 9, 9);
- drawRect(right + 1, top, right + 11, top + 9, (((right + ModCompatHooks.getXOffset() + 3) <= (UMouse.getScaledX() / mc.ingameGUI.getChatGUI().getChatScale()) && (right + ModCompatHooks.getXOffset()) + 13 > (UMouse.getScaledX() / mc.ingameGUI.getChatGUI().getChatScale())) ? CleanButton.Companion.getHoveredColor() : CleanButton.Companion.getColor()));
+ drawRect(right + 1, top, right + 10, top + 9, (((right + ModCompatHooks.getXOffset() + 3) <= (UMouse.getScaledX() / mc.ingameGUI.getChatGUI().getChatScale()) && (right + ModCompatHooks.getXOffset()) + 13 > (UMouse.getScaledX() / mc.ingameGUI.getChatGUI().getChatScale())) ? CleanButton.Companion.getHoveredColor() : CleanButton.Companion.getColor()));
GlStateManager.disableAlpha();
GlStateManager.disableRescaleNormal();
GlStateManager.disableLighting();
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) {