9
9
import dev .heliosclient .managers .EventManager ;
10
10
import dev .heliosclient .managers .ModuleManager ;
11
11
import dev .heliosclient .module .Module_ ;
12
- import dev .heliosclient .util .ColorUtils ;
13
- import dev .heliosclient .util .TimerUtils ;
12
+ import dev .heliosclient .module .settings .CycleSetting ;
13
+ import dev .heliosclient .module .settings .DoubleSetting ;
14
+ import dev .heliosclient .module .settings .SettingGroup ;
14
15
import dev .heliosclient .util .render .Renderer2D ;
15
16
import net .minecraft .client .font .TextRenderer ;
16
17
import net .minecraft .client .gui .DrawContext ;
17
18
18
19
import java .awt .*;
19
20
import java .util .ArrayList ;
20
- import java .util .Collections ;
21
21
import java .util .Comparator ;
22
+ import java .util .List ;
22
23
24
+ import static dev .heliosclient .hud .hudelements .ModuleList .ColorMode .METEOR ;
25
+ import static dev .heliosclient .hud .hudelements .ModuleList .Sort .*;
23
26
27
+ /**
28
+ * Color credits: <a href="https://github.com/MeteorDevelopment/meteor-client/">Meteor-Client</a>
29
+ */
24
30
public class ModuleList extends HudElement implements Listener {
25
31
26
32
private ArrayList <Module_ > enabledModules = ModuleManager .INSTANCE .getEnabledModules ();
27
33
private Color rainbow = new Color (255 , 255 , 255 );
28
34
private double rainbowHue1 ;
29
35
private double rainbowHue2 ;
30
36
37
+ public SettingGroup sgSettings = new SettingGroup ("Settings" );
38
+
39
+ private final CycleSetting sort = sgSettings .add (new CycleSetting .Builder ()
40
+ .name ("Sort" )
41
+ .description ("Sorting method used for displaying modules" )
42
+ .value (List .of (Sort .values ()))
43
+ .onSettingChange (this )
44
+ .defaultListOption (Biggest )
45
+ .build ()
46
+ );
47
+ private final CycleSetting colorMode = sgSettings .add (new CycleSetting .Builder ()
48
+ .name ("Color Mode" )
49
+ .description ("Mode of the color displayed" )
50
+ .value (List .of (ColorMode .values ()))
51
+ .onSettingChange (this )
52
+ .defaultListOption (METEOR )
53
+ .build ()
54
+ );
55
+
56
+ private final DoubleSetting rainbowSpeed = sgSettings .add (new DoubleSetting .Builder ()
57
+ .name ("Rainbow Speed" )
58
+ .description ("Speed of rainbow" )
59
+ .onSettingChange (this )
60
+ .min (0.001d )
61
+ .max (0.2d )
62
+ .roundingPlace (3 )
63
+ .value (0.05d )
64
+ .shouldRender (()-> (ColorMode ) colorMode .getOption () == METEOR )
65
+ .build ()
66
+ );
67
+ private final DoubleSetting rainbowSpread = sgSettings .add (new DoubleSetting .Builder ()
68
+ .name ("Rainbow Spread" )
69
+ .description ("Spread of rainbow" )
70
+ .onSettingChange (this )
71
+ .min (0.001f )
72
+ .max (0.05f )
73
+ .roundingPlace (3 )
74
+ .value (0.1d )
75
+ .shouldRender (()-> (ColorMode ) colorMode .getOption () == METEOR )
76
+ .build ()
77
+ );
78
+ private final DoubleSetting rainbowSaturation = sgSettings .add (new DoubleSetting .Builder ()
79
+ .name ("Rainbow Saturation" )
80
+ .description ("Saturation of rainbow" )
81
+ .onSettingChange (this )
82
+ .min (0.0 )
83
+ .max (1d )
84
+ .roundingPlace (2 )
85
+ .value (1d )
86
+ .defaultValue (1d )
87
+ .shouldRender (()-> (ColorMode ) colorMode .getOption () == METEOR )
88
+ .build ()
89
+ );
90
+ private final DoubleSetting rainbowBrightness = sgSettings .add (new DoubleSetting .Builder ()
91
+ .name ("Rainbow Brightness" )
92
+ .description ("Brightness of rainbow" )
93
+ .onSettingChange (this )
94
+ .min (0.0 )
95
+ .max (1d )
96
+ .roundingPlace (2 )
97
+ .value (1d )
98
+ .defaultValue (1d )
99
+ .shouldRender (()-> (ColorMode ) colorMode .getOption () == METEOR )
100
+ .build ()
101
+ );
102
+
31
103
public ModuleList () {
32
104
super (DATA );
33
105
this .width = 50 ;
34
106
EventManager .register (this );
107
+ addSettingGroup (sgSettings );
35
108
}
36
109
37
110
public static HudElementData <ModuleList > DATA = new HudElementData <>("Module List" , "Shows enabled modules" , ModuleList ::new );
@@ -46,11 +119,13 @@ public void renderElement(DrawContext drawContext, TextRenderer textRenderer) {
46
119
int nameWidth = Math .round (Renderer2D .getStringWidth (m .name ));
47
120
maxWidth = Math .max (maxWidth , nameWidth );
48
121
}
49
- rainbowHue1 += 0.01f * mc .getTickDelta ();
50
- if (rainbowHue1 > 1 ) rainbowHue1 -= 1 ;
51
- else if (rainbowHue1 < -1 ) rainbowHue1 += 1 ;
122
+ if (colorMode .getOption () == METEOR ) {
123
+ rainbowHue1 += rainbowSpeed .value * mc .getTickDelta ();
124
+ if (rainbowHue1 > 1 ) rainbowHue1 -= 1 ;
125
+ else if (rainbowHue1 < -1 ) rainbowHue1 += 1 ;
52
126
53
- rainbowHue2 = rainbowHue1 ;
127
+ rainbowHue2 = rainbowHue1 ;
128
+ }
54
129
55
130
// Render each module with a different color
56
131
this .width = maxWidth + 5 ;
@@ -70,8 +145,10 @@ public void renderElement(DrawContext drawContext, TextRenderer textRenderer) {
70
145
x - 2 + width , yOffset , 2 ,
71
146
Math .round (Renderer2D .getStringHeight ()) + 3 , HeliosClient .uiColor );
72
147
73
- rainbowHue2 += 2f ;
74
- rainbow = new Color (Color .HSBtoRGB ((float ) rainbowHue2 , 1f , 1f ));
148
+ if (colorMode .getOption () == METEOR ) {
149
+ rainbowHue2 += rainbowSpread .value ;
150
+ rainbow = new Color (Color .HSBtoRGB ((float ) rainbowHue2 , (float ) rainbowSaturation .value , (float ) rainbowBrightness .value ));
151
+ }
75
152
// Draw the module name
76
153
Renderer2D .drawString (drawContext .getMatrices (), m .name ,
77
154
x - 4 + width - nameWidth , 1 + yOffset ,
@@ -85,6 +162,19 @@ public void renderElement(DrawContext drawContext, TextRenderer textRenderer) {
85
162
@ SubscribeEvent
86
163
public void update (TickEvent .CLIENT event ) {
87
164
enabledModules = ModuleManager .INSTANCE .getEnabledModules ();
88
- enabledModules .sort (Comparator .comparing (module -> Renderer2D .getStringWidth (module .name ), Comparator .reverseOrder ()));
165
+ enabledModules .sort ((mod1 , mod2 ) -> switch ((Sort )sort .getOption ()) {
166
+ case Alphabetical -> mod1 .name .compareTo (mod2 .name );
167
+ case Biggest -> Double .compare ( Renderer2D .getStringWidth (mod2 .name ), Renderer2D .getStringWidth (mod1 .name ));
168
+ case Smallest -> Double .compare (Renderer2D .getStringWidth (mod1 .name ), Renderer2D .getStringWidth (mod2 .name ));
169
+ });
170
+ }
171
+
172
+ public enum Sort {
173
+ Alphabetical ,
174
+ Biggest ,
175
+ Smallest
176
+ }
177
+ public enum ColorMode {
178
+ METEOR
89
179
}
90
180
}
0 commit comments