From bf3762fab95034d88908c99da3610b30227b87bf Mon Sep 17 00:00:00 2001 From: urFate Date: Sun, 5 Feb 2023 23:13:30 +0300 Subject: [PATCH 01/14] Implement notifications HUD --- .../hudgui/elements/client/Notifications.kt | 103 ++++++++++++++++++ .../manager/managers/NotificationManager.kt | 15 ++- .../lambda/client/module/AbstractModule.kt | 4 + 3 files changed, 118 insertions(+), 4 deletions(-) create mode 100644 src/main/kotlin/com/lambda/client/gui/hudgui/elements/client/Notifications.kt diff --git a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/client/Notifications.kt b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/client/Notifications.kt new file mode 100644 index 000000000..a77785f80 --- /dev/null +++ b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/client/Notifications.kt @@ -0,0 +1,103 @@ +package com.lambda.client.gui.hudgui.elements.client + +import com.lambda.client.gui.hudgui.HudElement +import com.lambda.client.util.color.ColorHolder +import com.lambda.client.util.graphics.RenderUtils2D +import com.lambda.client.util.graphics.VertexHelper +import com.lambda.client.util.graphics.font.FontRenderAdapter +import com.lambda.client.util.math.Vec2d +import com.lambda.client.util.threads.runSafe +import com.lambda.client.util.threads.safeAsyncListener +import net.minecraft.client.renderer.GlStateManager +import net.minecraftforge.fml.common.gameevent.TickEvent + +internal object Notifications : HudElement( + name = "Notifications", + category = Category.CLIENT, + description = "Shows notifications" +) { + + private var cacheWidth = 90.0 + private var cacheHeight = 23.0 + + override val hudWidth: Float + get() = cacheWidth.toFloat() + override val hudHeight: Float + get() = cacheHeight.toFloat() + + private val notifications = mutableListOf() + + init { + safeAsyncListener { event -> + if (event.phase != TickEvent.Phase.END) return@safeAsyncListener + + val removalList = notifications.filter { notification -> + notification.startTime + notification.duration < System.currentTimeMillis() + } + notifications.removeAll(removalList) + + cacheHeight = if (notifications.isEmpty()) 23.0 else notifications.size * 26.0 + } + } + + override fun renderHud(vertexHelper: VertexHelper) { + super.renderHud(vertexHelper) + + runSafe { + notifications.forEachIndexed { index, notification -> + GlStateManager.pushMatrix() + + GlStateManager.translate(0.0, index * 28.0, 0.0) + drawNotification(vertexHelper, notification) + + GlStateManager.popMatrix() + } + } + } + + private fun drawNotification(vertexHelper: VertexHelper, notification: Notification) { + + val color = when (notification.type) { + NotificationType.INFO -> ColorHolder(3, 169, 244) + NotificationType.WARNING -> ColorHolder(255, 255, 0) + NotificationType.ERROR -> ColorHolder(255, 0, 0) + } + + val startTime = notification.startTime + val duration = notification.duration + + val currentTime = System.currentTimeMillis() + val elapsedTime = currentTime - startTime + val timeout = (88 * elapsedTime) / duration + val timeoutBarWidth = if (timeout > 88) 88 else if (timeout < 0) 0 else timeout + + // Draw background + RenderUtils2D.drawRectFilled(vertexHelper, Vec2d.ZERO, Vec2d(90.0, 23.0), ColorHolder(0, 0, 0, 127)) + + // Draw timeout bar + RenderUtils2D.drawRectFilled(vertexHelper, Vec2d(timeoutBarWidth.toDouble(), 23.0), Vec2d(88.0, 22.0), color) + + // Draw right border + RenderUtils2D.drawRectFilled(vertexHelper, Vec2d(90.0, 0.0), Vec2d(88.0, 23.0), color) + + // Draw text + FontRenderAdapter.drawString(notification.text, 10.0f, 9.0f, true, ColorHolder(), 0.6f, true) + } + + fun addNotification(notification: Notification) { + notifications.add(notification) + } +} + +data class Notification( + val text: String, + val type: NotificationType, + val duration: Int, + val startTime: Long = System.currentTimeMillis(), +) + +enum class NotificationType { + INFO, + WARNING, + ERROR +} diff --git a/src/main/kotlin/com/lambda/client/manager/managers/NotificationManager.kt b/src/main/kotlin/com/lambda/client/manager/managers/NotificationManager.kt index 027acfcf3..eca3f22e2 100644 --- a/src/main/kotlin/com/lambda/client/manager/managers/NotificationManager.kt +++ b/src/main/kotlin/com/lambda/client/manager/managers/NotificationManager.kt @@ -1,23 +1,30 @@ package com.lambda.client.manager.managers +import com.lambda.client.gui.hudgui.elements.client.Notification +import com.lambda.client.gui.hudgui.elements.client.NotificationType +import com.lambda.client.gui.hudgui.elements.client.Notifications import com.lambda.client.manager.Manager -import com.lambda.client.util.text.MessageSendHelper import com.lambda.client.util.threads.safeListener import net.minecraftforge.fml.common.gameevent.TickEvent import java.util.* object NotificationManager : Manager { - private val pendingNotifications: Queue = LinkedList() + private val pendingNotifications: Queue = LinkedList() init { safeListener { while (pendingNotifications.isNotEmpty()) { - MessageSendHelper.sendErrorMessage(pendingNotifications.poll()) + val notification = pendingNotifications.poll() + Notifications.addNotification(notification) } } } fun registerNotification(message: String) { - pendingNotifications.add(message) + pendingNotifications.add(Notification(message, NotificationType.INFO, 3000)) + } + + fun registerNotification(message: String, type: NotificationType) { + pendingNotifications.add(Notification(message, type, 3000)) } } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/client/module/AbstractModule.kt b/src/main/kotlin/com/lambda/client/module/AbstractModule.kt index 98801b158..6dba4ca8c 100644 --- a/src/main/kotlin/com/lambda/client/module/AbstractModule.kt +++ b/src/main/kotlin/com/lambda/client/module/AbstractModule.kt @@ -5,6 +5,8 @@ import com.lambda.client.commons.interfaces.Nameable import com.lambda.client.event.LambdaEventBus import com.lambda.client.event.events.ModuleToggleEvent import com.lambda.client.gui.clickgui.LambdaClickGui +import com.lambda.client.gui.hudgui.elements.client.NotificationType +import com.lambda.client.manager.managers.NotificationManager import com.lambda.client.module.modules.client.ClickGUI import com.lambda.client.setting.configs.NameableConfig import com.lambda.client.setting.settings.AbstractSetting @@ -59,6 +61,8 @@ abstract class AbstractModule( enabled.value = !enabled.value isPaused = false if (enabled.value) clicks.value++ + + NotificationManager.registerNotification("$chatName ${if (enabled.value) "Enabled" else "Disabled"}", NotificationType.INFO) } fun enable() { From 729deb6b2575253f2dba431f6010fcde10978f00 Mon Sep 17 00:00:00 2001 From: urFate Date: Tue, 7 Feb 2023 00:18:55 +0300 Subject: [PATCH 02/14] Respect color scheme and text width --- .../hudgui/elements/client/Notifications.kt | 29 ++++++++++++++----- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/client/Notifications.kt b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/client/Notifications.kt index a77785f80..31eb4c476 100644 --- a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/client/Notifications.kt +++ b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/client/Notifications.kt @@ -1,10 +1,12 @@ package com.lambda.client.gui.hudgui.elements.client import com.lambda.client.gui.hudgui.HudElement +import com.lambda.client.module.modules.client.GuiColors import com.lambda.client.util.color.ColorHolder import com.lambda.client.util.graphics.RenderUtils2D import com.lambda.client.util.graphics.VertexHelper import com.lambda.client.util.graphics.font.FontRenderAdapter +import com.lambda.client.util.graphics.font.HAlign import com.lambda.client.util.math.Vec2d import com.lambda.client.util.threads.runSafe import com.lambda.client.util.threads.safeAsyncListener @@ -68,20 +70,33 @@ internal object Notifications : HudElement( val currentTime = System.currentTimeMillis() val elapsedTime = currentTime - startTime - val timeout = (88 * elapsedTime) / duration - val timeoutBarWidth = if (timeout > 88) 88 else if (timeout < 0) 0 else timeout + + val textWidth = FontRenderAdapter.getStringWidth(notification.text, 0.7f, true) + val width: Double = if(textWidth > 88) textWidth + 25.0 else 90.0 + val clearWidth = width - 2 + + val timeout = (clearWidth * elapsedTime) / duration + val timeoutBarWidth = if (timeout > clearWidth) clearWidth else if (timeout < 0) 0 else timeout + + val borderPosBegin = if(dockingH == HAlign.RIGHT) Vec2d(width, 0.0) else Vec2d(0.0, 0.0) + val borderPosEnd = if(dockingH == HAlign.RIGHT) Vec2d(clearWidth, 23.0) else Vec2d(2.0, 23.0) + + val timeoutBarPosBegin = if(dockingH == HAlign.RIGHT) Vec2d(timeoutBarWidth.toDouble(), 23.0) + else Vec2d(2.0, 23.0) + val timeoutBarPosEnd = if(dockingH == HAlign.RIGHT) Vec2d(clearWidth, 22.0) + else Vec2d(clearWidth - timeoutBarWidth.toDouble(), 22.0) // Draw background - RenderUtils2D.drawRectFilled(vertexHelper, Vec2d.ZERO, Vec2d(90.0, 23.0), ColorHolder(0, 0, 0, 127)) + RenderUtils2D.drawRectFilled(vertexHelper, Vec2d.ZERO, Vec2d(width, 23.0), GuiColors.backGround) // Draw timeout bar - RenderUtils2D.drawRectFilled(vertexHelper, Vec2d(timeoutBarWidth.toDouble(), 23.0), Vec2d(88.0, 22.0), color) + RenderUtils2D.drawRectFilled(vertexHelper, timeoutBarPosBegin, timeoutBarPosEnd, color) - // Draw right border - RenderUtils2D.drawRectFilled(vertexHelper, Vec2d(90.0, 0.0), Vec2d(88.0, 23.0), color) + // Draw border + RenderUtils2D.drawRectFilled(vertexHelper, borderPosBegin, borderPosEnd, color) // Draw text - FontRenderAdapter.drawString(notification.text, 10.0f, 9.0f, true, ColorHolder(), 0.6f, true) + FontRenderAdapter.drawString(notification.text, 10.0f, 10.5f, true, ColorHolder(), 0.7f, true) } fun addNotification(notification: Notification) { From 61af962b32248fde3081fc54de75fb1f0dae1f51 Mon Sep 17 00:00:00 2001 From: rfresh2 <89827146+rfresh2@users.noreply.github.com> Date: Thu, 9 Feb 2023 21:25:55 -0800 Subject: [PATCH 03/14] Notifications: Modes, scaling, and various additions I think a more opinionated set of rendering options works best for notifications, rather than letting users drag this around to random locations I've also added a few configuration options to the rendering, updated the rendering to handle different scales, and removed most hardcoded numbers. This lets us handle different window sizes better while still allowing some configuration by users within boundaries. --- .../hudgui/elements/client/Notifications.kt | 118 ----------------- .../manager/managers/NotificationManager.kt | 6 +- .../lambda/client/module/AbstractModule.kt | 6 +- .../module/modules/client/Notifications.kt | 123 ++++++++++++++++++ .../client/util/notifications/Notification.kt | 8 ++ .../util/notifications/NotificationType.kt | 7 + 6 files changed, 145 insertions(+), 123 deletions(-) delete mode 100644 src/main/kotlin/com/lambda/client/gui/hudgui/elements/client/Notifications.kt create mode 100644 src/main/kotlin/com/lambda/client/module/modules/client/Notifications.kt create mode 100644 src/main/kotlin/com/lambda/client/util/notifications/Notification.kt create mode 100644 src/main/kotlin/com/lambda/client/util/notifications/NotificationType.kt diff --git a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/client/Notifications.kt b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/client/Notifications.kt deleted file mode 100644 index 31eb4c476..000000000 --- a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/client/Notifications.kt +++ /dev/null @@ -1,118 +0,0 @@ -package com.lambda.client.gui.hudgui.elements.client - -import com.lambda.client.gui.hudgui.HudElement -import com.lambda.client.module.modules.client.GuiColors -import com.lambda.client.util.color.ColorHolder -import com.lambda.client.util.graphics.RenderUtils2D -import com.lambda.client.util.graphics.VertexHelper -import com.lambda.client.util.graphics.font.FontRenderAdapter -import com.lambda.client.util.graphics.font.HAlign -import com.lambda.client.util.math.Vec2d -import com.lambda.client.util.threads.runSafe -import com.lambda.client.util.threads.safeAsyncListener -import net.minecraft.client.renderer.GlStateManager -import net.minecraftforge.fml.common.gameevent.TickEvent - -internal object Notifications : HudElement( - name = "Notifications", - category = Category.CLIENT, - description = "Shows notifications" -) { - - private var cacheWidth = 90.0 - private var cacheHeight = 23.0 - - override val hudWidth: Float - get() = cacheWidth.toFloat() - override val hudHeight: Float - get() = cacheHeight.toFloat() - - private val notifications = mutableListOf() - - init { - safeAsyncListener { event -> - if (event.phase != TickEvent.Phase.END) return@safeAsyncListener - - val removalList = notifications.filter { notification -> - notification.startTime + notification.duration < System.currentTimeMillis() - } - notifications.removeAll(removalList) - - cacheHeight = if (notifications.isEmpty()) 23.0 else notifications.size * 26.0 - } - } - - override fun renderHud(vertexHelper: VertexHelper) { - super.renderHud(vertexHelper) - - runSafe { - notifications.forEachIndexed { index, notification -> - GlStateManager.pushMatrix() - - GlStateManager.translate(0.0, index * 28.0, 0.0) - drawNotification(vertexHelper, notification) - - GlStateManager.popMatrix() - } - } - } - - private fun drawNotification(vertexHelper: VertexHelper, notification: Notification) { - - val color = when (notification.type) { - NotificationType.INFO -> ColorHolder(3, 169, 244) - NotificationType.WARNING -> ColorHolder(255, 255, 0) - NotificationType.ERROR -> ColorHolder(255, 0, 0) - } - - val startTime = notification.startTime - val duration = notification.duration - - val currentTime = System.currentTimeMillis() - val elapsedTime = currentTime - startTime - - val textWidth = FontRenderAdapter.getStringWidth(notification.text, 0.7f, true) - val width: Double = if(textWidth > 88) textWidth + 25.0 else 90.0 - val clearWidth = width - 2 - - val timeout = (clearWidth * elapsedTime) / duration - val timeoutBarWidth = if (timeout > clearWidth) clearWidth else if (timeout < 0) 0 else timeout - - val borderPosBegin = if(dockingH == HAlign.RIGHT) Vec2d(width, 0.0) else Vec2d(0.0, 0.0) - val borderPosEnd = if(dockingH == HAlign.RIGHT) Vec2d(clearWidth, 23.0) else Vec2d(2.0, 23.0) - - val timeoutBarPosBegin = if(dockingH == HAlign.RIGHT) Vec2d(timeoutBarWidth.toDouble(), 23.0) - else Vec2d(2.0, 23.0) - val timeoutBarPosEnd = if(dockingH == HAlign.RIGHT) Vec2d(clearWidth, 22.0) - else Vec2d(clearWidth - timeoutBarWidth.toDouble(), 22.0) - - // Draw background - RenderUtils2D.drawRectFilled(vertexHelper, Vec2d.ZERO, Vec2d(width, 23.0), GuiColors.backGround) - - // Draw timeout bar - RenderUtils2D.drawRectFilled(vertexHelper, timeoutBarPosBegin, timeoutBarPosEnd, color) - - // Draw border - RenderUtils2D.drawRectFilled(vertexHelper, borderPosBegin, borderPosEnd, color) - - // Draw text - FontRenderAdapter.drawString(notification.text, 10.0f, 10.5f, true, ColorHolder(), 0.7f, true) - } - - fun addNotification(notification: Notification) { - notifications.add(notification) - } -} - -data class Notification( - val text: String, - val type: NotificationType, - val duration: Int, - val startTime: Long = System.currentTimeMillis(), -) - -enum class NotificationType { - INFO, - WARNING, - ERROR -} diff --git a/src/main/kotlin/com/lambda/client/manager/managers/NotificationManager.kt b/src/main/kotlin/com/lambda/client/manager/managers/NotificationManager.kt index eca3f22e2..f6d0ee601 100644 --- a/src/main/kotlin/com/lambda/client/manager/managers/NotificationManager.kt +++ b/src/main/kotlin/com/lambda/client/manager/managers/NotificationManager.kt @@ -1,9 +1,9 @@ package com.lambda.client.manager.managers -import com.lambda.client.gui.hudgui.elements.client.Notification -import com.lambda.client.gui.hudgui.elements.client.NotificationType -import com.lambda.client.gui.hudgui.elements.client.Notifications import com.lambda.client.manager.Manager +import com.lambda.client.module.modules.client.Notifications +import com.lambda.client.util.notifications.Notification +import com.lambda.client.util.notifications.NotificationType import com.lambda.client.util.threads.safeListener import net.minecraftforge.fml.common.gameevent.TickEvent import java.util.* diff --git a/src/main/kotlin/com/lambda/client/module/AbstractModule.kt b/src/main/kotlin/com/lambda/client/module/AbstractModule.kt index 6dba4ca8c..8f1f90040 100644 --- a/src/main/kotlin/com/lambda/client/module/AbstractModule.kt +++ b/src/main/kotlin/com/lambda/client/module/AbstractModule.kt @@ -5,7 +5,6 @@ import com.lambda.client.commons.interfaces.Nameable import com.lambda.client.event.LambdaEventBus import com.lambda.client.event.events.ModuleToggleEvent import com.lambda.client.gui.clickgui.LambdaClickGui -import com.lambda.client.gui.hudgui.elements.client.NotificationType import com.lambda.client.manager.managers.NotificationManager import com.lambda.client.module.modules.client.ClickGUI import com.lambda.client.setting.configs.NameableConfig @@ -15,6 +14,7 @@ import com.lambda.client.setting.settings.impl.number.IntegerSetting import com.lambda.client.setting.settings.impl.other.BindSetting import com.lambda.client.setting.settings.impl.primitive.BooleanSetting import com.lambda.client.util.Bind +import com.lambda.client.util.notifications.NotificationType import com.lambda.client.util.text.MessageSendHelper import net.minecraft.client.Minecraft @@ -62,7 +62,9 @@ abstract class AbstractModule( isPaused = false if (enabled.value) clicks.value++ - NotificationManager.registerNotification("$chatName ${if (enabled.value) "Enabled" else "Disabled"}", NotificationType.INFO) + if (this.category != Category.CLIENT) { + NotificationManager.registerNotification("$chatName ${if (enabled.value) "Enabled" else "Disabled"}", NotificationType.INFO) + } } fun enable() { diff --git a/src/main/kotlin/com/lambda/client/module/modules/client/Notifications.kt b/src/main/kotlin/com/lambda/client/module/modules/client/Notifications.kt new file mode 100644 index 000000000..321994aa7 --- /dev/null +++ b/src/main/kotlin/com/lambda/client/module/modules/client/Notifications.kt @@ -0,0 +1,123 @@ +package com.lambda.client.module.modules.client + +import com.lambda.client.event.events.RenderOverlayEvent +import com.lambda.client.module.Category +import com.lambda.client.module.Module +import com.lambda.client.util.color.ColorHolder +import com.lambda.client.util.graphics.GlStateUtils +import com.lambda.client.util.graphics.RenderUtils2D +import com.lambda.client.util.graphics.VertexHelper +import com.lambda.client.util.graphics.font.FontRenderAdapter +import com.lambda.client.util.math.Vec2d +import com.lambda.client.util.notifications.Notification +import com.lambda.client.util.notifications.NotificationType +import com.lambda.client.util.text.MessageSendHelper +import com.lambda.client.util.threads.safeListener +import net.minecraft.client.gui.ScaledResolution +import net.minecraft.client.renderer.GlStateManager +import net.minecraftforge.fml.common.gameevent.TickEvent +import org.lwjgl.opengl.GL11 + +object Notifications : Module( + name = "Notifications", + category = Category.CLIENT, + description = "Shows notifications", + alwaysListening = true, + enabledByDefault = true +) { + private val mode by setting("Mode", NotificationMode.RENDER) + private val notificationHeight by setting("Notification Height", 15.0, 13.0..25.0, 1.0) + private val renderLocation by setting("Render Location", RenderLocation.BOTTOM_RIGHT) + private val horizontalPadding by setting("W Padding", 6f, 0f..40f, 1f) + private val verticalPadding by setting("H Padding", 15f, 0f..40f, 1f) + + enum class RenderLocation(val renderDirection: Int) { + BOTTOM_RIGHT(-1), TOP_RIGHT(1), TOP_LEFT(1) + } + + enum class NotificationMode { + RENDER, CHAT, RENDER_AND_CHAT + } + + private val notifications = mutableListOf() + + init { + safeListener { event -> + if (event.phase != TickEvent.Phase.END) return@safeListener + + val removalList = notifications.filter { notification -> + notification.startTime + notification.duration < System.currentTimeMillis() + } + notifications.removeAll(removalList) + } + + safeListener { + val scaledResolution = ScaledResolution(mc) + val vertexHelper = VertexHelper(GlStateUtils.useVbo()) + + notifications.forEachIndexed { index, notification -> + GlStateManager.pushMatrix() + when (renderLocation) { + RenderLocation.BOTTOM_RIGHT -> GL11.glTranslatef((scaledResolution.scaledWidth_double - horizontalPadding - 90).toFloat(), (scaledResolution.scaledHeight_double - verticalPadding - notificationHeight).toFloat(), 0f) + RenderLocation.TOP_RIGHT -> GL11.glTranslatef((scaledResolution.scaledWidth_double - horizontalPadding - 90).toFloat(), verticalPadding, 0f) + RenderLocation.TOP_LEFT -> GL11.glTranslatef(horizontalPadding, verticalPadding, 0f) + } + GlStateManager.translate(0.0, index * (notificationHeight + 3.0) * renderLocation.renderDirection, 0.0) + drawNotification(vertexHelper, notification) + GlStateManager.popMatrix() + } + } + } + + private fun drawNotification(vertexHelper: VertexHelper, notification: Notification) { + + val color = when (notification.type) { + NotificationType.INFO -> ColorHolder(3, 169, 244) + NotificationType.WARNING -> ColorHolder(255, 255, 0) + NotificationType.ERROR -> ColorHolder(255, 0, 0) + } + + val startTime = notification.startTime + val duration = notification.duration + + val currentTime = System.currentTimeMillis() + val elapsedTime = currentTime - startTime + + val textScale = (notificationHeight / 16f).toFloat().coerceAtMost(1.0f) + val textWidth = FontRenderAdapter.getStringWidth(notification.text, textScale, CustomFont.isEnabled) + val textHeight = FontRenderAdapter.getFontHeight(textScale, CustomFont.isEnabled) + val width: Double = if(textWidth > 88) textWidth + 25.0 else 90.0 + val clearWidth = width - 2 + + val timeout = (clearWidth * elapsedTime) / duration + val timeoutBarWidth = if (timeout > clearWidth) clearWidth else if (timeout < 0) 0 else timeout + + val borderPosBegin = if(renderLocation == RenderLocation.BOTTOM_RIGHT) Vec2d(width, 0.0) else Vec2d(0.0, 0.0) + val borderPosEnd = if(renderLocation == RenderLocation.BOTTOM_RIGHT) Vec2d(clearWidth, notificationHeight) else Vec2d(2.0, notificationHeight) + + val timeoutBarPosBegin = if(renderLocation == RenderLocation.BOTTOM_RIGHT) Vec2d(timeoutBarWidth.toDouble(), notificationHeight) + else Vec2d(2.0, notificationHeight) + val timeoutBarPosEnd = if(renderLocation == RenderLocation.BOTTOM_RIGHT) Vec2d(clearWidth, notificationHeight - 1) + else Vec2d(clearWidth - timeoutBarWidth.toDouble(), notificationHeight - 1) + + // Draw background + RenderUtils2D.drawRectFilled(vertexHelper, Vec2d.ZERO, Vec2d(width, notificationHeight), GuiColors.backGround) + + // Draw timeout bar + RenderUtils2D.drawRectFilled(vertexHelper, timeoutBarPosBegin, timeoutBarPosEnd, color) + + // Draw border + RenderUtils2D.drawRectFilled(vertexHelper, borderPosBegin, borderPosEnd, color) + + // Draw text + FontRenderAdapter.drawString(notification.text, 4.0f, ((notificationHeight / 2.5) - (textHeight / 2)).toFloat(), true, ColorHolder(), textScale, CustomFont.isEnabled) + } + fun addNotification(notification: Notification) { + if (mode == NotificationMode.CHAT || mode == NotificationMode.RENDER_AND_CHAT) { + MessageSendHelper.sendChatMessage(notification.text) + } + if (mode == NotificationMode.RENDER || mode == NotificationMode.RENDER_AND_CHAT) { + notifications.add(notification) + } + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/client/util/notifications/Notification.kt b/src/main/kotlin/com/lambda/client/util/notifications/Notification.kt new file mode 100644 index 000000000..a10a51517 --- /dev/null +++ b/src/main/kotlin/com/lambda/client/util/notifications/Notification.kt @@ -0,0 +1,8 @@ +package com.lambda.client.util.notifications + +data class Notification( + val text: String, + val type: NotificationType, + val duration: Int, + val startTime: Long = System.currentTimeMillis(), +) \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/client/util/notifications/NotificationType.kt b/src/main/kotlin/com/lambda/client/util/notifications/NotificationType.kt new file mode 100644 index 000000000..4a4cb8d04 --- /dev/null +++ b/src/main/kotlin/com/lambda/client/util/notifications/NotificationType.kt @@ -0,0 +1,7 @@ +package com.lambda.client.util.notifications + +enum class NotificationType { + INFO, + WARNING, + ERROR +} \ No newline at end of file From a9b5b8ecee3f723bf2e62db2346efb5b48e63b70 Mon Sep 17 00:00:00 2001 From: urFate Date: Sat, 11 Feb 2023 14:43:43 +0300 Subject: [PATCH 04/14] Code refactor --- .../module/modules/client/Notifications.kt | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/client/Notifications.kt b/src/main/kotlin/com/lambda/client/module/modules/client/Notifications.kt index 321994aa7..a7ec25fc9 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/client/Notifications.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/client/Notifications.kt @@ -71,11 +71,7 @@ object Notifications : Module( private fun drawNotification(vertexHelper: VertexHelper, notification: Notification) { - val color = when (notification.type) { - NotificationType.INFO -> ColorHolder(3, 169, 244) - NotificationType.WARNING -> ColorHolder(255, 255, 0) - NotificationType.ERROR -> ColorHolder(255, 0, 0) - } + val color = colorFromType(notification.type) val startTime = notification.startTime val duration = notification.duration @@ -86,6 +82,8 @@ object Notifications : Module( val textScale = (notificationHeight / 16f).toFloat().coerceAtMost(1.0f) val textWidth = FontRenderAdapter.getStringWidth(notification.text, textScale, CustomFont.isEnabled) val textHeight = FontRenderAdapter.getFontHeight(textScale, CustomFont.isEnabled) + val textPosY = ((notificationHeight / 2.5) - (textHeight / 2)).toFloat() + val width: Double = if(textWidth > 88) textWidth + 25.0 else 90.0 val clearWidth = width - 2 @@ -110,7 +108,7 @@ object Notifications : Module( RenderUtils2D.drawRectFilled(vertexHelper, borderPosBegin, borderPosEnd, color) // Draw text - FontRenderAdapter.drawString(notification.text, 4.0f, ((notificationHeight / 2.5) - (textHeight / 2)).toFloat(), true, ColorHolder(), textScale, CustomFont.isEnabled) + FontRenderAdapter.drawString(notification.text, 4.0f, textPosY, true, ColorHolder(), textScale, CustomFont.isEnabled) } fun addNotification(notification: Notification) { if (mode == NotificationMode.CHAT || mode == NotificationMode.RENDER_AND_CHAT) { @@ -120,4 +118,10 @@ object Notifications : Module( notifications.add(notification) } } + + private fun colorFromType(notificationType: NotificationType): ColorHolder = when (notificationType) { + NotificationType.INFO -> ColorHolder(3, 169, 244) + NotificationType.WARNING -> ColorHolder(255, 255, 0) + NotificationType.ERROR -> ColorHolder(255, 0, 0) + } } \ No newline at end of file From 087242b6d190cc96d2590bc0557d28c1b5b54a10 Mon Sep 17 00:00:00 2001 From: urFate Date: Sat, 11 Feb 2023 15:00:29 +0300 Subject: [PATCH 05/14] Make text scale more consistent --- .../com/lambda/client/module/modules/client/Notifications.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/client/Notifications.kt b/src/main/kotlin/com/lambda/client/module/modules/client/Notifications.kt index a7ec25fc9..02d68b2ef 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/client/Notifications.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/client/Notifications.kt @@ -79,7 +79,7 @@ object Notifications : Module( val currentTime = System.currentTimeMillis() val elapsedTime = currentTime - startTime - val textScale = (notificationHeight / 16f).toFloat().coerceAtMost(1.0f) + val textScale = (notificationHeight / 32f).toFloat().coerceAtMost(1.0f) val textWidth = FontRenderAdapter.getStringWidth(notification.text, textScale, CustomFont.isEnabled) val textHeight = FontRenderAdapter.getFontHeight(textScale, CustomFont.isEnabled) val textPosY = ((notificationHeight / 2.5) - (textHeight / 2)).toFloat() From e540b3d8d2350998c5b2960676f41ccf10e7a2c7 Mon Sep 17 00:00:00 2001 From: urFate Date: Sun, 12 Feb 2023 16:29:17 +0300 Subject: [PATCH 06/14] Implement "Fade In" and "Fade Out" effects --- .../module/modules/client/Notifications.kt | 35 ++++++++++++++----- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/client/Notifications.kt b/src/main/kotlin/com/lambda/client/module/modules/client/Notifications.kt index 02d68b2ef..74729cc11 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/client/Notifications.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/client/Notifications.kt @@ -71,8 +71,6 @@ object Notifications : Module( private fun drawNotification(vertexHelper: VertexHelper, notification: Notification) { - val color = colorFromType(notification.type) - val startTime = notification.startTime val duration = notification.duration @@ -98,8 +96,28 @@ object Notifications : Module( val timeoutBarPosEnd = if(renderLocation == RenderLocation.BOTTOM_RIGHT) Vec2d(clearWidth, notificationHeight - 1) else Vec2d(clearWidth - timeoutBarWidth.toDouble(), notificationHeight - 1) + val alpha: Int = when(elapsedTime) { + // "Fade in" alpha + in 0..duration - 200 -> + ((255 * elapsedTime) / 200).toInt().coerceAtMost(255).coerceAtLeast(0) + + // "Fade out" alpha + in duration - 200..duration -> { + val timeLeft = duration - elapsedTime + ((255 * timeLeft) / 200).toInt().coerceAtMost(255).coerceAtLeast(0) + } + else -> 0 + } + + val color = colorFromType(notification.type, alpha) + val backgroundColor: ColorHolder = when(alpha) { + in 0..GuiColors.backGround.a -> ColorHolder(GuiColors.backGround.r, GuiColors.backGround.g, + GuiColors.backGround.b, alpha) + else -> GuiColors.backGround + } + // Draw background - RenderUtils2D.drawRectFilled(vertexHelper, Vec2d.ZERO, Vec2d(width, notificationHeight), GuiColors.backGround) + RenderUtils2D.drawRectFilled(vertexHelper, Vec2d.ZERO, Vec2d(width, notificationHeight), backgroundColor) // Draw timeout bar RenderUtils2D.drawRectFilled(vertexHelper, timeoutBarPosBegin, timeoutBarPosEnd, color) @@ -108,7 +126,8 @@ object Notifications : Module( RenderUtils2D.drawRectFilled(vertexHelper, borderPosBegin, borderPosEnd, color) // Draw text - FontRenderAdapter.drawString(notification.text, 4.0f, textPosY, true, ColorHolder(), textScale, CustomFont.isEnabled) + FontRenderAdapter.drawString(notification.text, 4.0f, textPosY, true, + ColorHolder(255, 255, 255, alpha), textScale, CustomFont.isEnabled) } fun addNotification(notification: Notification) { if (mode == NotificationMode.CHAT || mode == NotificationMode.RENDER_AND_CHAT) { @@ -119,9 +138,9 @@ object Notifications : Module( } } - private fun colorFromType(notificationType: NotificationType): ColorHolder = when (notificationType) { - NotificationType.INFO -> ColorHolder(3, 169, 244) - NotificationType.WARNING -> ColorHolder(255, 255, 0) - NotificationType.ERROR -> ColorHolder(255, 0, 0) + private fun colorFromType(notificationType: NotificationType, alpha: Int = 255): ColorHolder = when (notificationType) { + NotificationType.INFO -> ColorHolder(3, 169, 244, alpha) + NotificationType.WARNING -> ColorHolder(255, 255, 0, alpha) + NotificationType.ERROR -> ColorHolder(255, 0, 0, alpha) } } \ No newline at end of file From 264b14b76a792a8b3de558698ebbac8e860346d2 Mon Sep 17 00:00:00 2001 From: urFate Date: Sun, 12 Feb 2023 16:30:30 +0300 Subject: [PATCH 07/14] Reformat code --- .../module/modules/client/Notifications.kt | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/client/Notifications.kt b/src/main/kotlin/com/lambda/client/module/modules/client/Notifications.kt index 74729cc11..c5b8fe2fe 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/client/Notifications.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/client/Notifications.kt @@ -82,21 +82,21 @@ object Notifications : Module( val textHeight = FontRenderAdapter.getFontHeight(textScale, CustomFont.isEnabled) val textPosY = ((notificationHeight / 2.5) - (textHeight / 2)).toFloat() - val width: Double = if(textWidth > 88) textWidth + 25.0 else 90.0 + val width: Double = if (textWidth > 88) textWidth + 25.0 else 90.0 val clearWidth = width - 2 val timeout = (clearWidth * elapsedTime) / duration val timeoutBarWidth = if (timeout > clearWidth) clearWidth else if (timeout < 0) 0 else timeout - val borderPosBegin = if(renderLocation == RenderLocation.BOTTOM_RIGHT) Vec2d(width, 0.0) else Vec2d(0.0, 0.0) - val borderPosEnd = if(renderLocation == RenderLocation.BOTTOM_RIGHT) Vec2d(clearWidth, notificationHeight) else Vec2d(2.0, notificationHeight) + val borderPosBegin = if (renderLocation == RenderLocation.BOTTOM_RIGHT) Vec2d(width, 0.0) else Vec2d(0.0, 0.0) + val borderPosEnd = if (renderLocation == RenderLocation.BOTTOM_RIGHT) Vec2d(clearWidth, notificationHeight) else Vec2d(2.0, notificationHeight) - val timeoutBarPosBegin = if(renderLocation == RenderLocation.BOTTOM_RIGHT) Vec2d(timeoutBarWidth.toDouble(), notificationHeight) + val timeoutBarPosBegin = if (renderLocation == RenderLocation.BOTTOM_RIGHT) Vec2d(timeoutBarWidth.toDouble(), notificationHeight) else Vec2d(2.0, notificationHeight) - val timeoutBarPosEnd = if(renderLocation == RenderLocation.BOTTOM_RIGHT) Vec2d(clearWidth, notificationHeight - 1) + val timeoutBarPosEnd = if (renderLocation == RenderLocation.BOTTOM_RIGHT) Vec2d(clearWidth, notificationHeight - 1) else Vec2d(clearWidth - timeoutBarWidth.toDouble(), notificationHeight - 1) - val alpha: Int = when(elapsedTime) { + val alpha: Int = when (elapsedTime) { // "Fade in" alpha in 0..duration - 200 -> ((255 * elapsedTime) / 200).toInt().coerceAtMost(255).coerceAtLeast(0) @@ -106,13 +106,15 @@ object Notifications : Module( val timeLeft = duration - elapsedTime ((255 * timeLeft) / 200).toInt().coerceAtMost(255).coerceAtLeast(0) } + else -> 0 } val color = colorFromType(notification.type, alpha) - val backgroundColor: ColorHolder = when(alpha) { + val backgroundColor: ColorHolder = when (alpha) { in 0..GuiColors.backGround.a -> ColorHolder(GuiColors.backGround.r, GuiColors.backGround.g, GuiColors.backGround.b, alpha) + else -> GuiColors.backGround } @@ -129,6 +131,7 @@ object Notifications : Module( FontRenderAdapter.drawString(notification.text, 4.0f, textPosY, true, ColorHolder(255, 255, 255, alpha), textScale, CustomFont.isEnabled) } + fun addNotification(notification: Notification) { if (mode == NotificationMode.CHAT || mode == NotificationMode.RENDER_AND_CHAT) { MessageSendHelper.sendChatMessage(notification.text) From ba169cfaa38db592df8841d01cdc8a46a822bc1d Mon Sep 17 00:00:00 2001 From: urFate Date: Sun, 12 Feb 2023 18:37:22 +0300 Subject: [PATCH 08/14] Add customizable timeout depending on types --- .../manager/managers/NotificationManager.kt | 4 +-- .../module/modules/client/Notifications.kt | 28 +++++++++++++++---- .../client/util/notifications/Notification.kt | 2 +- 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/manager/managers/NotificationManager.kt b/src/main/kotlin/com/lambda/client/manager/managers/NotificationManager.kt index f6d0ee601..fd4e8c168 100644 --- a/src/main/kotlin/com/lambda/client/manager/managers/NotificationManager.kt +++ b/src/main/kotlin/com/lambda/client/manager/managers/NotificationManager.kt @@ -21,10 +21,10 @@ object NotificationManager : Manager { } fun registerNotification(message: String) { - pendingNotifications.add(Notification(message, NotificationType.INFO, 3000)) + pendingNotifications.add(Notification(message, NotificationType.INFO)) } fun registerNotification(message: String, type: NotificationType) { - pendingNotifications.add(Notification(message, type, 3000)) + pendingNotifications.add(Notification(message, type)) } } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/client/module/modules/client/Notifications.kt b/src/main/kotlin/com/lambda/client/module/modules/client/Notifications.kt index c5b8fe2fe..7ff1a27e1 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/client/Notifications.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/client/Notifications.kt @@ -25,11 +25,19 @@ object Notifications : Module( alwaysListening = true, enabledByDefault = true ) { - private val mode by setting("Mode", NotificationMode.RENDER) - private val notificationHeight by setting("Notification Height", 15.0, 13.0..25.0, 1.0) - private val renderLocation by setting("Render Location", RenderLocation.BOTTOM_RIGHT) - private val horizontalPadding by setting("W Padding", 6f, 0f..40f, 1f) - private val verticalPadding by setting("H Padding", 15f, 0f..40f, 1f) + private val page by setting("Page", Page.GENERAL) + + // General settings + private val mode by setting("Mode", NotificationMode.RENDER, { page == Page.GENERAL }) + private val notificationHeight by setting("Notification Height", 15.0, 13.0..25.0, 1.0, { page == Page.GENERAL }) + private val renderLocation by setting("Render Location", RenderLocation.BOTTOM_RIGHT, { page == Page.GENERAL }) + private val horizontalPadding by setting("W Padding", 6f, 0f..40f, 1f, { page == Page.GENERAL }) + private val verticalPadding by setting("H Padding", 15f, 0f..40f, 1f, { page == Page.GENERAL }) + + // Timeout settings + private val infoTimeout by setting("Info Timeout", 3000, 1000..10000, 100, { page == Page.TIMEOUT }) + private val warningTimeout by setting("Warning Timeout", 4000, 1000..10000, 100, { page == Page.TIMEOUT }) + private val errorTimeout by setting("Error Timeout", 7000, 1000..10000, 100, { page == Page.TIMEOUT }) enum class RenderLocation(val renderDirection: Int) { BOTTOM_RIGHT(-1), TOP_RIGHT(1), TOP_LEFT(1) @@ -39,6 +47,10 @@ object Notifications : Module( RENDER, CHAT, RENDER_AND_CHAT } + private enum class Page { + GENERAL, TIMEOUT + } + private val notifications = mutableListOf() init { @@ -133,6 +145,12 @@ object Notifications : Module( } fun addNotification(notification: Notification) { + if (notification.duration == 0) when (notification.type) { + NotificationType.INFO -> notification.duration = infoTimeout + NotificationType.WARNING -> notification.duration = warningTimeout + NotificationType.ERROR -> notification.duration = errorTimeout + } + if (mode == NotificationMode.CHAT || mode == NotificationMode.RENDER_AND_CHAT) { MessageSendHelper.sendChatMessage(notification.text) } diff --git a/src/main/kotlin/com/lambda/client/util/notifications/Notification.kt b/src/main/kotlin/com/lambda/client/util/notifications/Notification.kt index a10a51517..cd793c970 100644 --- a/src/main/kotlin/com/lambda/client/util/notifications/Notification.kt +++ b/src/main/kotlin/com/lambda/client/util/notifications/Notification.kt @@ -3,6 +3,6 @@ package com.lambda.client.util.notifications data class Notification( val text: String, val type: NotificationType, - val duration: Int, + var duration: Int = 0, val startTime: Long = System.currentTimeMillis(), ) \ No newline at end of file From b37f5ef9dfcdd3b206e487667f46f299aa2b6c9b Mon Sep 17 00:00:00 2001 From: urFate Date: Sun, 12 Feb 2023 18:57:25 +0300 Subject: [PATCH 09/14] Fix border direction --- .../lambda/client/module/modules/client/Notifications.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/client/Notifications.kt b/src/main/kotlin/com/lambda/client/module/modules/client/Notifications.kt index 7ff1a27e1..b07093a85 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/client/Notifications.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/client/Notifications.kt @@ -100,12 +100,12 @@ object Notifications : Module( val timeout = (clearWidth * elapsedTime) / duration val timeoutBarWidth = if (timeout > clearWidth) clearWidth else if (timeout < 0) 0 else timeout - val borderPosBegin = if (renderLocation == RenderLocation.BOTTOM_RIGHT) Vec2d(width, 0.0) else Vec2d(0.0, 0.0) - val borderPosEnd = if (renderLocation == RenderLocation.BOTTOM_RIGHT) Vec2d(clearWidth, notificationHeight) else Vec2d(2.0, notificationHeight) + val borderPosBegin = if (renderLocation.name.contains("RIGHT")) Vec2d(width, 0.0) else Vec2d(0.0, 0.0) + val borderPosEnd = if (renderLocation.name.contains("RIGHT")) Vec2d(clearWidth, notificationHeight) else Vec2d(2.0, notificationHeight) - val timeoutBarPosBegin = if (renderLocation == RenderLocation.BOTTOM_RIGHT) Vec2d(timeoutBarWidth.toDouble(), notificationHeight) + val timeoutBarPosBegin = if (renderLocation.name.contains("RIGHT")) Vec2d(timeoutBarWidth.toDouble(), notificationHeight) else Vec2d(2.0, notificationHeight) - val timeoutBarPosEnd = if (renderLocation == RenderLocation.BOTTOM_RIGHT) Vec2d(clearWidth, notificationHeight - 1) + val timeoutBarPosEnd = if (renderLocation.name.contains("RIGHT")) Vec2d(clearWidth, notificationHeight - 1) else Vec2d(clearWidth - timeoutBarWidth.toDouble(), notificationHeight - 1) val alpha: Int = when (elapsedTime) { From ae28bf98175b8f51de47f501c7fb4943fcf4a3e8 Mon Sep 17 00:00:00 2001 From: urFate Date: Sun, 12 Feb 2023 19:02:53 +0300 Subject: [PATCH 10/14] Add "Bottom Left" render direction --- .../com/lambda/client/module/modules/client/Notifications.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/client/Notifications.kt b/src/main/kotlin/com/lambda/client/module/modules/client/Notifications.kt index b07093a85..9b210be83 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/client/Notifications.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/client/Notifications.kt @@ -40,7 +40,7 @@ object Notifications : Module( private val errorTimeout by setting("Error Timeout", 7000, 1000..10000, 100, { page == Page.TIMEOUT }) enum class RenderLocation(val renderDirection: Int) { - BOTTOM_RIGHT(-1), TOP_RIGHT(1), TOP_LEFT(1) + BOTTOM_RIGHT(-1), BOTTOM_LEFT(-1), TOP_RIGHT(1), TOP_LEFT(1) } enum class NotificationMode { @@ -71,6 +71,7 @@ object Notifications : Module( GlStateManager.pushMatrix() when (renderLocation) { RenderLocation.BOTTOM_RIGHT -> GL11.glTranslatef((scaledResolution.scaledWidth_double - horizontalPadding - 90).toFloat(), (scaledResolution.scaledHeight_double - verticalPadding - notificationHeight).toFloat(), 0f) + RenderLocation.BOTTOM_LEFT -> GL11.glTranslatef(horizontalPadding, (scaledResolution.scaledHeight_double - verticalPadding - notificationHeight).toFloat(), 0f) RenderLocation.TOP_RIGHT -> GL11.glTranslatef((scaledResolution.scaledWidth_double - horizontalPadding - 90).toFloat(), verticalPadding, 0f) RenderLocation.TOP_LEFT -> GL11.glTranslatef(horizontalPadding, verticalPadding, 0f) } From 5780b9e96cd5df477ef40ac10e009eef85244820 Mon Sep 17 00:00:00 2001 From: kdh8219 <65698239+kdh8219@users.noreply.github.com> Date: Mon, 20 Mar 2023 21:45:14 +0900 Subject: [PATCH 11/14] add moving animation --- .../module/modules/client/Notifications.kt | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/client/Notifications.kt b/src/main/kotlin/com/lambda/client/module/modules/client/Notifications.kt index 9b210be83..5d2ce4019 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/client/Notifications.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/client/Notifications.kt @@ -4,6 +4,7 @@ import com.lambda.client.event.events.RenderOverlayEvent import com.lambda.client.module.Category import com.lambda.client.module.Module import com.lambda.client.util.color.ColorHolder +import com.lambda.client.util.graphics.AnimationUtils import com.lambda.client.util.graphics.GlStateUtils import com.lambda.client.util.graphics.RenderUtils2D import com.lambda.client.util.graphics.VertexHelper @@ -23,6 +24,7 @@ object Notifications : Module( category = Category.CLIENT, description = "Shows notifications", alwaysListening = true, + showOnArray = false, enabledByDefault = true ) { private val page by setting("Page", Page.GENERAL) @@ -39,8 +41,8 @@ object Notifications : Module( private val warningTimeout by setting("Warning Timeout", 4000, 1000..10000, 100, { page == Page.TIMEOUT }) private val errorTimeout by setting("Error Timeout", 7000, 1000..10000, 100, { page == Page.TIMEOUT }) - enum class RenderLocation(val renderDirection: Int) { - BOTTOM_RIGHT(-1), BOTTOM_LEFT(-1), TOP_RIGHT(1), TOP_LEFT(1) + enum class RenderLocation(val xValue:Int, val yValue: Int) { + BOTTOM_RIGHT(1,-1), BOTTOM_LEFT(-1,-1), TOP_RIGHT(1,1), TOP_LEFT(-1,1) } enum class NotificationMode { @@ -75,7 +77,7 @@ object Notifications : Module( RenderLocation.TOP_RIGHT -> GL11.glTranslatef((scaledResolution.scaledWidth_double - horizontalPadding - 90).toFloat(), verticalPadding, 0f) RenderLocation.TOP_LEFT -> GL11.glTranslatef(horizontalPadding, verticalPadding, 0f) } - GlStateManager.translate(0.0, index * (notificationHeight + 3.0) * renderLocation.renderDirection, 0.0) + GlStateManager.translate(0.0, index * renderLocation.yValue * ((notificationHeight + 3.0) * notification.animate()), 0.0) drawNotification(vertexHelper, notification) GlStateManager.popMatrix() } @@ -131,6 +133,12 @@ object Notifications : Module( else -> GuiColors.backGround } + GlStateManager.pushMatrix() + val animatedPercent = notification.animate() + val animationXOffset = textWidth * renderLocation.xValue *(1.0f - animatedPercent) + GlStateManager.translate(animationXOffset,0.0f,0.0f) + + // Draw background RenderUtils2D.drawRectFilled(vertexHelper, Vec2d.ZERO, Vec2d(width, notificationHeight), backgroundColor) @@ -143,6 +151,8 @@ object Notifications : Module( // Draw text FontRenderAdapter.drawString(notification.text, 4.0f, textPosY, true, ColorHolder(255, 255, 255, alpha), textScale, CustomFont.isEnabled) + + GlStateManager.popMatrix() } fun addNotification(notification: Notification) { @@ -165,4 +175,11 @@ object Notifications : Module( NotificationType.WARNING -> ColorHolder(255, 255, 0, alpha) NotificationType.ERROR -> ColorHolder(255, 0, 0, alpha) } + private fun Notification.animate() : Float{ + return if ((System.currentTimeMillis() - startTime) < (duration.toLong() / 2)){ + AnimationUtils.exponentInc(AnimationUtils.toDeltaTimeFloat(startTime), 200.0f) + }else{ + AnimationUtils.exponentDec(AnimationUtils.toDeltaTimeFloat(startTime + duration - 200), 200.0f) + } + } } \ No newline at end of file From 79ca2b158e886714d6a278ce5dd30a3a3d053fe9 Mon Sep 17 00:00:00 2001 From: urFate Date: Mon, 20 Mar 2023 19:42:25 +0300 Subject: [PATCH 12/14] Implement notifications functionality to some amount of modules --- .../lambda/client/gui/hudgui/AbstractHudElement.kt | 4 ++-- .../com/lambda/client/module/AbstractModule.kt | 5 ++--- .../lambda/client/module/modules/chat/AutoExcuse.kt | 3 ++- .../lambda/client/module/modules/chat/ChatFilter.kt | 8 +++++--- .../client/module/modules/chat/LoginMessage.kt | 7 +++++-- .../com/lambda/client/module/modules/chat/Spammer.kt | 12 ++++++++---- .../client/module/modules/client/Configurations.kt | 11 +++++++---- .../client/module/modules/combat/AutoOffhand.kt | 4 ++-- .../client/module/modules/combat/CrystalAura.kt | 4 ++-- .../client/module/modules/combat/TotemPopCounter.kt | 4 ++-- .../client/module/modules/combat/VisualRange.kt | 5 +++-- 11 files changed, 40 insertions(+), 27 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/gui/hudgui/AbstractHudElement.kt b/src/main/kotlin/com/lambda/client/gui/hudgui/AbstractHudElement.kt index e68c065b8..fd59f8276 100644 --- a/src/main/kotlin/com/lambda/client/gui/hudgui/AbstractHudElement.kt +++ b/src/main/kotlin/com/lambda/client/gui/hudgui/AbstractHudElement.kt @@ -5,6 +5,7 @@ import com.lambda.client.commons.interfaces.DisplayEnum import com.lambda.client.commons.interfaces.Nameable import com.lambda.client.event.LambdaEventBus import com.lambda.client.gui.rgui.windows.BasicWindow +import com.lambda.client.manager.managers.NotificationManager import com.lambda.client.module.modules.client.GuiColors import com.lambda.client.module.modules.client.Hud import com.lambda.client.setting.GuiConfig @@ -16,7 +17,6 @@ import com.lambda.client.util.graphics.VertexHelper import com.lambda.client.util.graphics.font.FontRenderAdapter import com.lambda.client.util.math.Vec2d import com.lambda.client.util.math.Vec2f -import com.lambda.client.util.text.MessageSendHelper import com.lambda.client.util.threads.safeListener import net.minecraftforge.fml.common.gameevent.TickEvent import org.lwjgl.opengl.GL11.glScalef @@ -97,7 +97,7 @@ abstract class AbstractHudElement( if (it) { settingList.filter { it != visibleSetting && it != default }.forEach { it.resetValue() } default.value = false - MessageSendHelper.sendChatMessage("$name Set to defaults!") + NotificationManager.registerNotification("$name Set to defaults!") } } diff --git a/src/main/kotlin/com/lambda/client/module/AbstractModule.kt b/src/main/kotlin/com/lambda/client/module/AbstractModule.kt index 8f1f90040..6474679a5 100644 --- a/src/main/kotlin/com/lambda/client/module/AbstractModule.kt +++ b/src/main/kotlin/com/lambda/client/module/AbstractModule.kt @@ -15,7 +15,6 @@ import com.lambda.client.setting.settings.impl.other.BindSetting import com.lambda.client.setting.settings.impl.primitive.BooleanSetting import com.lambda.client.util.Bind import com.lambda.client.util.notifications.NotificationType -import com.lambda.client.util.text.MessageSendHelper import net.minecraft.client.Minecraft @Suppress("UNCHECKED_CAST") @@ -63,7 +62,7 @@ abstract class AbstractModule( if (enabled.value) clicks.value++ if (this.category != Category.CLIENT) { - NotificationManager.registerNotification("$chatName ${if (enabled.value) "Enabled" else "Disabled"}", NotificationType.INFO) + NotificationManager.registerNotification("$name ${if (enabled.value) "Enabled" else "Disabled"}", NotificationType.INFO) } } @@ -137,7 +136,7 @@ abstract class AbstractModule( if (it) { settingList.forEach { it.resetValue() } default.value = false - MessageSendHelper.sendChatMessage("$chatName Set to defaults!") + NotificationManager.registerNotification("$chatName Set to defaults!") } } diff --git a/src/main/kotlin/com/lambda/client/module/modules/chat/AutoExcuse.kt b/src/main/kotlin/com/lambda/client/module/modules/chat/AutoExcuse.kt index 0501eb9df..7d15a8eef 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/chat/AutoExcuse.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/chat/AutoExcuse.kt @@ -4,6 +4,7 @@ import com.lambda.client.LambdaMod import com.lambda.client.commons.extension.synchronized import com.lambda.client.event.SafeClientEvent import com.lambda.client.event.events.PacketEvent +import com.lambda.client.manager.managers.NotificationManager import com.lambda.client.module.Category import com.lambda.client.module.Module import com.lambda.client.util.FolderUtils @@ -115,7 +116,7 @@ object AutoExcuse : Module( try { file.forEachLine { if (it.isNotBlank()) loadedExcuses.add(it.trim()) } - MessageSendHelper.sendChatMessage("$chatName Loaded excuse messages!") + NotificationManager.registerNotification("$chatName Loaded excuse messages!") } catch (e: Exception) { MessageSendHelper.sendErrorMessage("$chatName Failed loading excuses, $e") disable() diff --git a/src/main/kotlin/com/lambda/client/module/modules/chat/ChatFilter.kt b/src/main/kotlin/com/lambda/client/module/modules/chat/ChatFilter.kt index 74861e861..c24ac8d09 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/chat/ChatFilter.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/chat/ChatFilter.kt @@ -1,9 +1,11 @@ package com.lambda.client.module.modules.chat import com.lambda.client.event.listener.listener +import com.lambda.client.manager.managers.NotificationManager import com.lambda.client.module.Category import com.lambda.client.module.Module import com.lambda.client.util.FolderUtils +import com.lambda.client.util.notifications.NotificationType import com.lambda.client.util.text.MessageDetection import com.lambda.client.util.text.MessageSendHelper import com.lambda.client.util.text.formatValue @@ -26,7 +28,7 @@ object ChatFilter : Module( init { onEnable { try { - MessageSendHelper.sendChatMessage("$chatName Trying to find '&7chat_filter.txt&f'") + NotificationManager.registerNotification("$chatName Trying to find '&7chat_filter.txt&f'") chatFilter.clear() file.bufferedReader().forEachLine { @@ -41,9 +43,9 @@ object ChatFilter : Module( } } - MessageSendHelper.sendChatMessage("$chatName Loaded '&7chat_filter.txt&f'!") + NotificationManager.registerNotification("$chatName Loaded '&7chat_filter.txt&f'!") } catch (exception: FileNotFoundException) { - MessageSendHelper.sendErrorMessage("$chatName Couldn't find a file called '&7chat_filter.txt&f' inside your '&7.minecraft/lambda&f' folder, disabling") + NotificationManager.registerNotification("$chatName Couldn't find a file called '&7chat_filter.txt&f' inside your '&7.minecraft/lambda&f' folder, disabling", NotificationType.ERROR) disable() } catch (exception: Exception) { MessageSendHelper.sendErrorMessage(exception.toString()) diff --git a/src/main/kotlin/com/lambda/client/module/modules/chat/LoginMessage.kt b/src/main/kotlin/com/lambda/client/module/modules/chat/LoginMessage.kt index 7f86ab631..d1f91bc84 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/chat/LoginMessage.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/chat/LoginMessage.kt @@ -2,10 +2,12 @@ package com.lambda.client.module.modules.chat import com.lambda.client.event.events.ConnectionEvent import com.lambda.client.event.listener.listener +import com.lambda.client.manager.managers.NotificationManager import com.lambda.client.module.Category import com.lambda.client.module.Module import com.lambda.client.util.FolderUtils import com.lambda.client.util.MovementUtils.isMoving +import com.lambda.client.util.notifications.NotificationType import com.lambda.client.util.text.MessageDetection import com.lambda.client.util.text.MessageSendHelper import com.lambda.client.util.text.MessageSendHelper.sendServerMessage @@ -39,9 +41,10 @@ object LoginMessage : Module( file.forEachLine { if (it.isNotBlank()) loginMessages.add(it.trim()) } - MessageSendHelper.sendChatMessage("$chatName Loaded ${loginMessages.size} login messages!") + NotificationManager.registerNotification("$chatName Loaded ${loginMessages.size} login messages!") } catch (e: Exception) { - MessageSendHelper.sendErrorMessage("$chatName Failed loading login messages, $e") + NotificationManager.registerNotification("$chatName Failed loading login messages, $e", + NotificationType.ERROR) disable() } } diff --git a/src/main/kotlin/com/lambda/client/module/modules/chat/Spammer.kt b/src/main/kotlin/com/lambda/client/module/modules/chat/Spammer.kt index 202476242..30bc23809 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/chat/Spammer.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/chat/Spammer.kt @@ -1,11 +1,13 @@ package com.lambda.client.module.modules.chat import com.lambda.client.commons.extension.synchronized +import com.lambda.client.manager.managers.NotificationManager import com.lambda.client.module.Category import com.lambda.client.module.Module import com.lambda.client.util.FolderUtils import com.lambda.client.util.TickTimer import com.lambda.client.util.TimeUnit +import com.lambda.client.util.notifications.NotificationType import com.lambda.client.util.text.MessageDetection import com.lambda.client.util.text.MessageSendHelper import com.lambda.client.util.text.MessageSendHelper.sendServerMessage @@ -59,9 +61,10 @@ object Spammer : Module( val text = URL(url).readText() spammer.addAll(text.split("\n")) - MessageSendHelper.sendChatMessage("$chatName Loaded remote spammer messages!") + NotificationManager.registerNotification("$chatName Loaded remote spammer messages!") } catch (e: Exception) { - MessageSendHelper.sendErrorMessage("$chatName Failed loading remote spammer, $e") + NotificationManager.registerNotification("$chatName Failed loading remote spammer, $e", + NotificationType.ERROR) disable() } } @@ -71,9 +74,10 @@ object Spammer : Module( if (file.exists()) { try { file.forEachLine { if (it.isNotBlank()) spammer.add(it.trim()) } - MessageSendHelper.sendChatMessage("$chatName Loaded spammer messages!") + NotificationManager.registerNotification("$chatName Loaded spammer messages!") } catch (e: Exception) { - MessageSendHelper.sendErrorMessage("$chatName Failed loading spammer, $e") + NotificationManager.registerNotification("$chatName Failed loading remote spammer, $e", + NotificationType.ERROR) disable() } } else { diff --git a/src/main/kotlin/com/lambda/client/module/modules/client/Configurations.kt b/src/main/kotlin/com/lambda/client/module/modules/client/Configurations.kt index b0d50a839..1c96e5aa5 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/client/Configurations.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/client/Configurations.kt @@ -5,6 +5,7 @@ import com.lambda.client.commons.interfaces.DisplayEnum import com.lambda.client.event.events.ConnectionEvent import com.lambda.client.event.listener.listener import com.lambda.client.gui.AbstractLambdaGui +import com.lambda.client.manager.managers.NotificationManager import com.lambda.client.module.AbstractModule import com.lambda.client.module.Category import com.lambda.client.setting.ConfigManager @@ -17,6 +18,7 @@ import com.lambda.client.setting.settings.impl.primitive.StringSetting import com.lambda.client.util.ConfigUtils import com.lambda.client.util.TickTimer import com.lambda.client.util.TimeUnit +import com.lambda.client.util.notifications.NotificationType import com.lambda.client.util.text.MessageSendHelper import com.lambda.client.util.text.formatValue import com.lambda.client.util.threads.BackgroundScope @@ -55,7 +57,7 @@ internal object Configurations : AbstractModule( init { BackgroundScope.launchLooping("Config Auto Saving", 60000L) { if (autoSaving && mc.currentScreen !is AbstractLambdaGui<*, *> && timer.tick(savingInterval.toLong())) { - if (savingFeedBack) MessageSendHelper.sendChatMessage("Auto saving settings...") + if (savingFeedBack) NotificationManager.registerNotification("Auto saving settings...") else LambdaMod.LOG.info("Auto saving settings...") ConfigUtils.saveAll() } @@ -85,7 +87,8 @@ internal object Configurations : AbstractModule( val nameWithExtension = "$nameWithoutExtension.json" return if (!ConfigUtils.isPathValid(nameWithExtension)) { - MessageSendHelper.sendChatMessage("${formatValue(nameWithoutExtension)} is not a valid preset name") + NotificationManager.registerNotification("${formatValue(nameWithoutExtension)} is not a valid preset name", + NotificationType.ERROR) false } else { true @@ -174,7 +177,7 @@ internal object Configurations : AbstractModule( var loaded = ConfigManager.load(GenericConfig) loaded = ConfigManager.load(config) || loaded - if (loaded) MessageSendHelper.sendChatMessage("${formatValue(config.name)} config reloaded!") + if (loaded) NotificationManager.registerNotification("${formatValue(config.name)} config reloaded!") else MessageSendHelper.sendErrorMessage("Failed to load ${formatValue(config.name)} config!") } } @@ -184,7 +187,7 @@ internal object Configurations : AbstractModule( var saved = ConfigManager.save(GenericConfig) saved = ConfigManager.save(config) || saved - if (saved) MessageSendHelper.sendChatMessage("${formatValue(config.name)} config saved!") + if (saved) NotificationManager.registerNotification("${formatValue(config.name)} config saved!") else MessageSendHelper.sendErrorMessage("Failed to load ${formatValue(config.name)} config!") } } diff --git a/src/main/kotlin/com/lambda/client/module/modules/combat/AutoOffhand.kt b/src/main/kotlin/com/lambda/client/module/modules/combat/AutoOffhand.kt index 441782e46..c49eb37df 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/combat/AutoOffhand.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/combat/AutoOffhand.kt @@ -3,6 +3,7 @@ package com.lambda.client.module.modules.combat import com.lambda.client.commons.extension.next import com.lambda.client.event.SafeClientEvent import com.lambda.client.manager.managers.CombatManager +import com.lambda.client.manager.managers.NotificationManager import com.lambda.client.module.Category import com.lambda.client.module.Module import com.lambda.client.util.Bind @@ -10,7 +11,6 @@ import com.lambda.client.util.combat.CombatUtils.calcDamageFromMob import com.lambda.client.util.combat.CombatUtils.calcDamageFromPlayer import com.lambda.client.util.combat.CombatUtils.scaledHealth import com.lambda.client.util.items.* -import com.lambda.client.util.text.MessageSendHelper import com.lambda.client.util.threads.safeListener import net.minecraft.entity.item.EntityEnderCrystal import net.minecraft.entity.monster.EntityMob @@ -145,7 +145,7 @@ object AutoOffhand : Module( moveToSlot(this@AutoOffhand, slot, player.offhandSlot) - if (switchMessage) MessageSendHelper.sendChatMessage("$chatName Offhand now has a ${typeAlt.toString().lowercase()}") + if (switchMessage) NotificationManager.registerNotification("$chatName Offhand now has a ${typeAlt.toString().lowercase()}") } } diff --git a/src/main/kotlin/com/lambda/client/module/modules/combat/CrystalAura.kt b/src/main/kotlin/com/lambda/client/module/modules/combat/CrystalAura.kt index a3809183d..e2f1ffec8 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/combat/CrystalAura.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/combat/CrystalAura.kt @@ -13,6 +13,7 @@ import com.lambda.client.manager.managers.HotbarManager import com.lambda.client.manager.managers.HotbarManager.resetHotbar import com.lambda.client.manager.managers.HotbarManager.serverSideItem import com.lambda.client.manager.managers.HotbarManager.spoofHotbar +import com.lambda.client.manager.managers.NotificationManager import com.lambda.client.manager.managers.PlayerPacketManager import com.lambda.client.manager.managers.PlayerPacketManager.sendPlayerPacket import com.lambda.client.mixin.extension.useEntityAction @@ -36,7 +37,6 @@ import com.lambda.client.util.math.VectorUtils.distanceTo import com.lambda.client.util.math.VectorUtils.toBlockPos import com.lambda.client.util.math.VectorUtils.toVec3d import com.lambda.client.util.math.VectorUtils.toVec3dCenter -import com.lambda.client.util.text.MessageSendHelper import com.lambda.client.util.threads.runSafeR import com.lambda.client.util.threads.safeListener import com.lambda.client.util.world.getClosestVisibleSide @@ -192,7 +192,7 @@ object CrystalAura : Module( listener { if (bindForcePlace.isDown(Keyboard.getEventKey())) { forcePlacing = !forcePlacing - MessageSendHelper.sendChatMessage("$chatName Force placing" + if (forcePlacing) " &aenabled" else " &cdisabled") + NotificationManager.registerNotification("$chatName Force placing" + if (forcePlacing) " &aenabled" else " &cdisabled") } } diff --git a/src/main/kotlin/com/lambda/client/module/modules/combat/TotemPopCounter.kt b/src/main/kotlin/com/lambda/client/module/modules/combat/TotemPopCounter.kt index 71ca05d76..14a3fffb5 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/combat/TotemPopCounter.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/combat/TotemPopCounter.kt @@ -6,10 +6,10 @@ import com.lambda.client.event.events.ConnectionEvent import com.lambda.client.event.events.PacketEvent import com.lambda.client.event.listener.listener import com.lambda.client.manager.managers.FriendManager +import com.lambda.client.manager.managers.NotificationManager import com.lambda.client.module.Category import com.lambda.client.module.Module import com.lambda.client.util.color.EnumTextColor -import com.lambda.client.util.text.MessageSendHelper import com.lambda.client.util.text.MessageSendHelper.sendServerMessage import com.lambda.client.util.text.format import com.lambda.client.util.threads.safeListener @@ -117,7 +117,7 @@ object TotemPopCounter : Module( if (public) { sendServerMessage(TextFormatting.getTextWithoutFormattingCodes(message)) } else { - MessageSendHelper.sendChatMessage("$chatName $message") + NotificationManager.registerNotification(message) } } } diff --git a/src/main/kotlin/com/lambda/client/module/modules/combat/VisualRange.kt b/src/main/kotlin/com/lambda/client/module/modules/combat/VisualRange.kt index 6245636ca..b735b2841 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/combat/VisualRange.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/combat/VisualRange.kt @@ -1,6 +1,7 @@ package com.lambda.client.module.modules.combat import com.lambda.client.manager.managers.FriendManager +import com.lambda.client.manager.managers.NotificationManager import com.lambda.client.manager.managers.WaypointManager import com.lambda.client.module.Category import com.lambda.client.module.Module @@ -8,7 +9,7 @@ import com.lambda.client.util.EntityUtils.flooredPosition import com.lambda.client.util.EntityUtils.isFakeOrSelf import com.lambda.client.util.TickTimer import com.lambda.client.util.TimeUnit -import com.lambda.client.util.text.MessageSendHelper +import com.lambda.client.util.notifications.NotificationType import com.lambda.client.util.text.MessageSendHelper.sendServerMessage import com.lambda.client.util.text.format import com.lambda.client.util.threads.safeListener @@ -91,6 +92,6 @@ object VisualRange : Module( private fun sendNotification(message: String) { if (playSound) mc.soundHandler.playSound(PositionedSoundRecord.getRecord(SoundEvents.ENTITY_EXPERIENCE_ORB_PICKUP, 1.0f, 1.0f)) - MessageSendHelper.sendChatMessage(message) + NotificationManager.registerNotification(message, NotificationType.WARNING) } } \ No newline at end of file From ea63fc7f68471767d6edd6a3687fe62362cb2613 Mon Sep 17 00:00:00 2001 From: kdh8219 <65698239+kdh8219@users.noreply.github.com> Date: Tue, 21 Mar 2023 10:38:05 +0900 Subject: [PATCH 13/14] Fix y moving animation --- .../lambda/client/module/modules/client/Notifications.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/client/Notifications.kt b/src/main/kotlin/com/lambda/client/module/modules/client/Notifications.kt index 5d2ce4019..920854e03 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/client/Notifications.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/client/Notifications.kt @@ -69,7 +69,8 @@ object Notifications : Module( val scaledResolution = ScaledResolution(mc) val vertexHelper = VertexHelper(GlStateUtils.useVbo()) - notifications.forEachIndexed { index, notification -> + var y = 0.0 + notifications.forEach { notification -> GlStateManager.pushMatrix() when (renderLocation) { RenderLocation.BOTTOM_RIGHT -> GL11.glTranslatef((scaledResolution.scaledWidth_double - horizontalPadding - 90).toFloat(), (scaledResolution.scaledHeight_double - verticalPadding - notificationHeight).toFloat(), 0f) @@ -77,7 +78,8 @@ object Notifications : Module( RenderLocation.TOP_RIGHT -> GL11.glTranslatef((scaledResolution.scaledWidth_double - horizontalPadding - 90).toFloat(), verticalPadding, 0f) RenderLocation.TOP_LEFT -> GL11.glTranslatef(horizontalPadding, verticalPadding, 0f) } - GlStateManager.translate(0.0, index * renderLocation.yValue * ((notificationHeight + 3.0) * notification.animate()), 0.0) + y += renderLocation.yValue * ((notificationHeight + 3.0) * notification.animate()) + GlStateManager.translate(0.0, y, 0.0) drawNotification(vertexHelper, notification) GlStateManager.popMatrix() } From 2aa958accbe137fe2e3b97072d02073c3ed3533c Mon Sep 17 00:00:00 2001 From: kdh8219 <65698239+kdh8219@users.noreply.github.com> Date: Tue, 21 Mar 2023 22:14:25 +0900 Subject: [PATCH 14/14] Fix Y moving animation --- .../lambda/client/module/modules/client/Notifications.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/client/Notifications.kt b/src/main/kotlin/com/lambda/client/module/modules/client/Notifications.kt index 5d2ce4019..920854e03 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/client/Notifications.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/client/Notifications.kt @@ -69,7 +69,8 @@ object Notifications : Module( val scaledResolution = ScaledResolution(mc) val vertexHelper = VertexHelper(GlStateUtils.useVbo()) - notifications.forEachIndexed { index, notification -> + var y = 0.0 + notifications.forEach { notification -> GlStateManager.pushMatrix() when (renderLocation) { RenderLocation.BOTTOM_RIGHT -> GL11.glTranslatef((scaledResolution.scaledWidth_double - horizontalPadding - 90).toFloat(), (scaledResolution.scaledHeight_double - verticalPadding - notificationHeight).toFloat(), 0f) @@ -77,7 +78,8 @@ object Notifications : Module( RenderLocation.TOP_RIGHT -> GL11.glTranslatef((scaledResolution.scaledWidth_double - horizontalPadding - 90).toFloat(), verticalPadding, 0f) RenderLocation.TOP_LEFT -> GL11.glTranslatef(horizontalPadding, verticalPadding, 0f) } - GlStateManager.translate(0.0, index * renderLocation.yValue * ((notificationHeight + 3.0) * notification.animate()), 0.0) + y += renderLocation.yValue * ((notificationHeight + 3.0) * notification.animate()) + GlStateManager.translate(0.0, y, 0.0) drawNotification(vertexHelper, notification) GlStateManager.popMatrix() }