@@ -4,6 +4,7 @@ import com.lambda.client.event.events.RenderOverlayEvent
4
4
import com.lambda.client.module.Category
5
5
import com.lambda.client.module.Module
6
6
import com.lambda.client.util.color.ColorHolder
7
+ import com.lambda.client.util.graphics.AnimationUtils
7
8
import com.lambda.client.util.graphics.GlStateUtils
8
9
import com.lambda.client.util.graphics.RenderUtils2D
9
10
import com.lambda.client.util.graphics.VertexHelper
@@ -23,6 +24,7 @@ object Notifications : Module(
23
24
category = Category .CLIENT ,
24
25
description = " Shows notifications" ,
25
26
alwaysListening = true ,
27
+ showOnArray = false ,
26
28
enabledByDefault = true
27
29
) {
28
30
private val page by setting(" Page" , Page .GENERAL )
@@ -39,8 +41,8 @@ object Notifications : Module(
39
41
private val warningTimeout by setting(" Warning Timeout" , 4000 , 1000 .. 10000 , 100 , { page == Page .TIMEOUT })
40
42
private val errorTimeout by setting(" Error Timeout" , 7000 , 1000 .. 10000 , 100 , { page == Page .TIMEOUT })
41
43
42
- enum class RenderLocation (val renderDirection : Int ) {
43
- BOTTOM_RIGHT (- 1 ), BOTTOM_LEFT (- 1 ), TOP_RIGHT (1 ), TOP_LEFT (1 )
44
+ enum class RenderLocation (val xValue : Int , val yValue : Int ) {
45
+ BOTTOM_RIGHT (1 , - 1 ), BOTTOM_LEFT (- 1 , - 1 ), TOP_RIGHT (1 , 1 ), TOP_LEFT (- 1 , 1 )
44
46
}
45
47
46
48
enum class NotificationMode {
@@ -75,7 +77,7 @@ object Notifications : Module(
75
77
RenderLocation .TOP_RIGHT -> GL11 .glTranslatef((scaledResolution.scaledWidth_double - horizontalPadding - 90 ).toFloat(), verticalPadding, 0f )
76
78
RenderLocation .TOP_LEFT -> GL11 .glTranslatef(horizontalPadding, verticalPadding, 0f )
77
79
}
78
- GlStateManager .translate(0.0 , index * ( notificationHeight + 3.0 ) * renderLocation.renderDirection , 0.0 )
80
+ GlStateManager .translate(0.0 , index * renderLocation.yValue * (( notificationHeight + 3.0 ) * notification.animate()) , 0.0 )
79
81
drawNotification(vertexHelper, notification)
80
82
GlStateManager .popMatrix()
81
83
}
@@ -131,6 +133,12 @@ object Notifications : Module(
131
133
else -> GuiColors .backGround
132
134
}
133
135
136
+ GlStateManager .pushMatrix()
137
+ val animatedPercent = notification.animate()
138
+ val animationXOffset = textWidth * renderLocation.xValue * (1.0f - animatedPercent)
139
+ GlStateManager .translate(animationXOffset,0.0f ,0.0f )
140
+
141
+
134
142
// Draw background
135
143
RenderUtils2D .drawRectFilled(vertexHelper, Vec2d .ZERO , Vec2d (width, notificationHeight), backgroundColor)
136
144
@@ -143,6 +151,8 @@ object Notifications : Module(
143
151
// Draw text
144
152
FontRenderAdapter .drawString(notification.text, 4.0f , textPosY, true ,
145
153
ColorHolder (255 , 255 , 255 , alpha), textScale, CustomFont .isEnabled)
154
+
155
+ GlStateManager .popMatrix()
146
156
}
147
157
148
158
fun addNotification (notification : Notification ) {
@@ -165,4 +175,11 @@ object Notifications : Module(
165
175
NotificationType .WARNING -> ColorHolder (255 , 255 , 0 , alpha)
166
176
NotificationType .ERROR -> ColorHolder (255 , 0 , 0 , alpha)
167
177
}
178
+ private fun Notification.animate () : Float {
179
+ return if ((System .currentTimeMillis() - startTime) < (duration.toLong() / 2 )){
180
+ AnimationUtils .exponentInc(AnimationUtils .toDeltaTimeFloat(startTime), 200.0f )
181
+ }else {
182
+ AnimationUtils .exponentDec(AnimationUtils .toDeltaTimeFloat(startTime + duration - 200 ), 200.0f )
183
+ }
184
+ }
168
185
}
0 commit comments