11package com.lambda.module.modules.client
22
3+ import com.lambda.event.events.ConnectionEvent
4+ import com.lambda.event.events.TickEvent
5+ import com.lambda.event.listener.UnsafeListener.Companion.unsafeListener
6+ import com.lambda.graphics.animation.Animation.Companion.exp
7+ import com.lambda.graphics.animation.AnimationTicker
8+ import com.lambda.gui.impl.clickgui.LambdaClickGui
39import com.lambda.module.Module
410import com.lambda.module.tag.ModuleTag
511import java.awt.Color
@@ -12,17 +18,21 @@ object GuiSettings : Module(
1218 private val page by setting(" Page" , Page .General )
1319
1420 // General
15- private val scaleSetting by setting(" Scale" , 1.0 , 0.5 .. 3.0 , 0.01 , visibility = { page == Page .General })
21+ private val scaleSetting by setting(" Scale" , 100 , 50 .. 300 , 1 , visibility = { page == Page .General }).apply {
22+ onValueChangeUnsafe { _, _ ->
23+ lastChange = System .currentTimeMillis()
24+ }
25+ }
1626
1727 // Colors
1828 val primaryColor by setting(" Primary Color" , Color (130 , 200 , 255 ), visibility = { page == Page .Colors })
19- val secondaryColor by setting(" Secondary Color" , Color (225 , 130 , 225 ), visibility = { page == Page .Colors && shade })
29+ val secondaryColor by setting(" Secondary Color" , Color (225 , 130 , 225 ), visibility = { page == Page .Colors && ( shade || shadeBackground) })
2030 val backgroundColor by setting(" Background Color" , Color (50 , 50 , 50 ), visibility = { page == Page .Colors })
2131 val shade by setting(" Shade" , true , visibility = { page == Page .Colors })
2232 val shadeBackground by setting(" Shade Background" , true , visibility = { page == Page .Colors })
23- val colorWidth by setting(" Color Width" , 400.0 , 10.0 .. 1000.0 , 10.0 , visibility = { page == Page .Colors && shade })
24- val colorHeight by setting(" Color Height" , 400.0 , 10.0 .. 1000.0 , 10.0 , visibility = { page == Page .Colors && shade })
25- val colorSpeed by setting(" Color Speed" , 1.0 , 0.1 .. 10.0 , 0.1 , visibility = { page == Page .Colors && shade })
33+ val colorWidth by setting(" Color Width" , 400.0 , 10.0 .. 1000.0 , 10.0 , visibility = { page == Page .Colors && ( shade || shadeBackground) })
34+ val colorHeight by setting(" Color Height" , 400.0 , 10.0 .. 1000.0 , 10.0 , visibility = { page == Page .Colors && ( shade || shadeBackground) })
35+ val colorSpeed by setting(" Color Speed" , 1.0 , 0.1 .. 10.0 , 0.1 , visibility = { page == Page .Colors && ( shade || shadeBackground) })
2636
2737 val mainColor: Color get() = if (shade) Color .WHITE else primaryColor
2838
@@ -34,5 +44,24 @@ object GuiSettings : Module(
3444 Colors
3545 }
3646
37- val scale get() = scaleSetting * 2
47+ private var targetScale = 2.0 ; get() {
48+ val update = System .currentTimeMillis() - lastChange > 1000 || ! LambdaClickGui .isOpen
49+ if (update) field = scaleSetting / 100.0 * 2.0
50+ return field
51+ }
52+
53+ private val animation = with (AnimationTicker ()) {
54+ unsafeListener<TickEvent .Pre >(alwaysListen = true ) {
55+ tick()
56+ }
57+
58+ exp({ targetScale }, 0.5 ).apply {
59+ unsafeListener<ConnectionEvent .Connect >(alwaysListen = true ) {
60+ setValue(targetScale)
61+ }
62+ }
63+ }
64+
65+ private var lastChange = 0L
66+ val scale by animation
3867}
0 commit comments