Skip to content

Commit

Permalink
bugs fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ImToggle committed Jan 28, 2024
1 parent 02f1ea3 commit f81ad0e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ private void onDrawScreen(int mouseX, int mouseY, float partialTicks, CallbackIn
@ModifyArg(method = "drawScreen", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiChat;drawRect(IIIII)V"), index = 2)
private int modifyRight(int right) {
ChattingConfig config = ChattingConfig.INSTANCE;
return config.getCompactInputBox() ? (int) Math.max(config.getChatWindow().getAnimationWidth(), (fontRendererObj.getStringWidth(inputField.getText()) + 4 + (inputField.getText().length() < 100 ? 8 : 2)) * config.getChatWindow().getScale()) : right;
return config.getCompactInputBox() ? (int) Math.max(config.getChatWindow().getWidth(), (fontRendererObj.getStringWidth(inputField.getText()) + 2 + (inputField.getText().length() < 100 ? 8 : 2)) * config.getChatWindow().getScale()) + 2 : right;
}

@ModifyArg(method = "drawScreen", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiChat;drawRect(IIIII)V"), index = 4)
Expand Down
13 changes: 8 additions & 5 deletions src/main/kotlin/org/polyfrost/chatting/chat/ChatWindow.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import org.polyfrost.chatting.config.ChattingConfig
import org.polyfrost.chatting.utils.EaseOutQuart
import org.polyfrost.chatting.utils.ModCompatHooks

class ChatWindow : BasicHud(true, 0f, 1080 - 27f - 45f) {
class ChatWindow : BasicHud(true, 2f, 1080 - 27f - 45f) {

@Exclude
private val exampleList: List<ChatLine> = listOf(
Expand All @@ -31,6 +31,9 @@ class ChatWindow : BasicHud(true, 0f, 1080 - 27f - 45f) {
@Exclude
var heightAnimation: Animation = DummyAnimation(0f)

@Exclude
var width = 0f

@Exclude
var height = 0

Expand Down Expand Up @@ -58,16 +61,16 @@ class ChatWindow : BasicHud(true, 0f, 1080 - 27f - 45f) {
fun drawBG() {
animationWidth = widthAnimation.get()
animationHeight = heightAnimation.get()
val widthEnd = position.width + (if (mc.ingameGUI.chatGUI.chatOpen) 20 else 0) * scale
width = position.width + (if (mc.ingameGUI.chatGUI.chatOpen) ModCompatHooks.chatButtonOffset else 0) * scale
val heightEnd = if (height == 0) 0f else (height + paddingY * 2f) * scale
val duration = ChattingConfig.bgDuration
GlStateManager.enableAlpha()
GlStateManager.enableBlend()
if (widthEnd != widthAnimation.end) {
if (width != widthAnimation.end) {
if (ChattingConfig.smoothBG)
widthAnimation = EaseOutQuart(duration, animationWidth, widthEnd, false)
widthAnimation = EaseOutQuart(duration, animationWidth, width, false)
else
animationWidth = widthEnd
animationWidth = width
}
if (heightEnd != heightAnimation.end) {
if (ChattingConfig.smoothBG)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import net.minecraft.client.gui.ChatLine
import net.minecraft.client.gui.FontRenderer
import net.minecraft.client.gui.Gui
import net.minecraft.client.renderer.GlStateManager
import org.polyfrost.chatting.config.ChattingConfig
import org.polyfrost.chatting.hook.ChatLineHook
import org.polyfrost.chatting.hook.GuiNewChatHook
import org.polyfrost.chatting.mixin.GuiNewChatAccessor
Expand Down Expand Up @@ -57,6 +58,10 @@ object ModCompatHooks {
val chatHeadOffset
get() = if (showChatHeads) 10 else 0

@JvmStatic
val chatButtonOffset
get() = if (ChattingConfig.chatCopy) 10 else 0 + if (ChattingConfig.chatDelete) 10 else 0

@JvmStatic
fun redirectDrawString(text: String, x: Float, y: Float, color: Int, chatLine: ChatLine, screenshot: Boolean): Int {
var actualX = x
Expand Down

0 comments on commit f81ad0e

Please sign in to comment.