2
2
3
3
import com .mojang .blaze3d .systems .RenderSystem ;
4
4
import com .tanishisherewith .dynamichud .DynamicHUD ;
5
+ import com .tanishisherewith .dynamichud .helpers .ColorHelper ;
5
6
import com .tanishisherewith .dynamichud .helpers .DrawHelper ;
6
7
import com .tanishisherewith .dynamichud .utils .contextmenu .ContextMenu ;
7
8
import com .tanishisherewith .dynamichud .utils .contextmenu .layout .LayoutContext ;
@@ -35,18 +36,18 @@ public class MinecraftSkin extends Skin implements GroupableSkin {
35
36
Identifier .ofVanilla ("widget/button_disabled" ),
36
37
Identifier .ofVanilla ("widget/button_highlighted" )
37
38
);
38
- private static final int DEFAULT_SCROLLBAR_WIDTH = 8 ;
39
- private static final int DEFAULT_PANEL_WIDTH = 248 ;
40
- private static final int DEFAULT_PANEL_HEIGHT = 165 ;
41
- private static final Identifier DEFAULT_BACKGROUND_PANEL = Identifier .ofVanilla ("textures/gui/demo_background.png" );
42
- private static final Identifier SCROLLER_TEXTURE = Identifier .ofVanilla ("widget/scroller" );
43
- private static final Identifier SCROLL_BAR_BACKGROUND = Identifier .ofVanilla ("widget/scroller_background" );
44
- private static final Identifier GROUP_BACKGROUND = Identifier .of (DynamicHUD .MOD_ID , "textures/minecraftskin/group_panel.png" );
39
+ public static final int DEFAULT_SCROLLBAR_WIDTH = 8 ;
40
+ public static final int DEFAULT_PANEL_WIDTH = 248 ;
41
+ public static final int DEFAULT_PANEL_HEIGHT = 165 ;
42
+ public static final Identifier DEFAULT_BACKGROUND_PANEL = Identifier .ofVanilla ("textures/gui/demo_background.png" );
43
+ public static final Identifier SCROLLER_TEXTURE = Identifier .ofVanilla ("widget/scroller" );
44
+ public static final Identifier SCROLL_BAR_BACKGROUND = Identifier .ofVanilla ("widget/scroller_background" );
45
+ public static final Identifier GROUP_BACKGROUND = Identifier .of (DynamicHUD .MOD_ID , "textures/minecraftskin/group_panel.png" );
45
46
46
47
private final Identifier BACKGROUND_PANEL ;
47
48
private final int panelWidth ;
48
49
private final int panelHeight ;
49
- private final PanelColor panelColor ;
50
+ private PanelColor panelColor ;
50
51
51
52
private int imageX , imageY ;
52
53
private final ScrollHandler scrollHandler ;
@@ -124,16 +125,12 @@ public void renderContextMenu(DrawContext drawContext, ContextMenu<?> contextMen
124
125
125
126
RenderSystem .enableBlend ();
126
127
RenderSystem .enableDepthTest ();
127
- panelColor .applyColor ();
128
128
129
- drawContext .drawTexture (RenderLayer ::getGuiTextured , BACKGROUND_PANEL , imageX , imageY , 0 , 0 , panelWidth , panelHeight , 256 , 254 );
130
-
131
- RenderSystem .setShaderColor (1.0f , 1.0f , 1.0f , 1.0f );
129
+ drawContext .drawTexture (RenderLayer ::getGuiTextured , BACKGROUND_PANEL , imageX , imageY , 0 , 0 , panelWidth , panelHeight , 256 , 254 ,panelColor .getColor ());
132
130
133
131
drawSingularButton (drawContext , "X" , mouseX , mouseY , imageX + 3 , imageY + 3 , 14 , 14 );
134
132
135
133
//Up and down arrows near the group panel
136
- RenderSystem .setShaderColor (1.0f , 1.0f , 1.0f , 1.0f );
137
134
RenderSystem .disableBlend ();
138
135
RenderSystem .disableDepthTest ();
139
136
@@ -324,6 +321,30 @@ public LayoutContext.Offset getGroupIndent() {
324
321
return LayoutContext .Offset .zero ();
325
322
}
326
323
324
+ public void setPanelColor (PanelColor panelColor ) {
325
+ this .panelColor = panelColor ;
326
+ }
327
+
328
+ public PanelColor getPanelColor () {
329
+ return panelColor ;
330
+ }
331
+
332
+ public int getPanelHeight () {
333
+ return panelHeight ;
334
+ }
335
+
336
+ public int getPanelWidth () {
337
+ return panelWidth ;
338
+ }
339
+
340
+ public int getImageX () {
341
+ return imageX ;
342
+ }
343
+
344
+ public int getImageY () {
345
+ return imageY ;
346
+ }
347
+
327
348
/**
328
349
* Group rendering handled already
329
350
*/
@@ -332,22 +353,22 @@ public void renderGroup(DrawContext drawContext, OptionGroup group, int groupX,
332
353
}
333
354
334
355
public enum PanelColor {
335
- COFFEE_BROWN (0.6f , 0.3f , 0.1f , 0.9f ),
336
- CREAMY (1.0f , 0.9f , 0.8f , 0.9f ),
337
- DARK_PANEL (0.2f , 0.2f , 0.2f , 0.9f ),
338
- FOREST_GREEN (0.0f , 0.6f , 0.2f , 0.9f ),
339
- GOLDEN_YELLOW (1.0f , 0.8f , 0.0f , 0.9f ),
340
- LAVENDER (0.8f , 0.6f , 1.0f , 0.9f ),
341
- LIGHT_BLUE (0.6f , 0.8f , 1.0f , 0.9f ),
342
- LIME_GREEN (0.7f , 1.0f , 0.3f , 0.9f ),
343
- MIDNIGHT_PURPLE (0.3f , 0.0f , 0.5f , 0.9f ),
344
- OCEAN_BLUE (0.0f , 0.5f , 1.0f , 0.9f ),
345
- ROSE_PINK (1.0f , 0.4f , 0.6f , 0.9f ),
346
- SKY_BLUE (0.5f , 0.8f , 1.0f , 0.9f ),
347
- SOFT_GREEN (0.6f , 1.0f , 0.6f , 0.9f ),
348
- SUNSET_ORANGE (1.0f , 0.5f , 0.0f , 0.9f ),
349
- WARM_YELLOW (1.0f , 1.0f , 0.6f , 0.9f ),
350
- CUSTOM (0.0f , 0.0f , 0.0f , 0.0f ); // PlaceHolder for custom colors
356
+ COFFEE_BROWN (0.6f , 0.3f , 0.1f , 1.0f ),
357
+ CREAMY (1.0f , 0.9f , 0.8f , 1.0f ),
358
+ DARK_PANEL (0.2f , 0.2f , 0.2f , 1.0f ),
359
+ FOREST_GREEN (0.0f , 0.6f , 0.2f , 1.0f ),
360
+ GOLDEN_YELLOW (1.0f , 0.8f , 0.0f , 1.0f ),
361
+ LAVENDER (0.8f , 0.6f , 1.0f , 1.0f ),
362
+ LIGHT_BLUE (0.6f , 0.8f , 1.0f , 1.0f ),
363
+ LIME_GREEN (0.7f , 1.0f , 0.3f , 1.0f ),
364
+ MIDNIGHT_PURPLE (0.3f , 0.0f , 0.5f , 1.0f ),
365
+ OCEAN_BLUE (0.0f , 0.5f , 1.0f , 1.0f ),
366
+ ROSE_PINK (1.0f , 0.4f , 0.6f , 1.0f ),
367
+ SKY_BLUE (0.5f , 0.8f , 1.0f , 1.0f ),
368
+ SOFT_GREEN (0.6f , 1.0f , 0.6f , 1.0f ),
369
+ SUNSET_ORANGE (1.0f , 0.5f , 0.0f , 1.0f ),
370
+ WARM_YELLOW (1.0f , 1.0f , 0.6f , 1.0f ),
371
+ CUSTOM (0.0f , 0.0f , 0.0f , 0.0f ); /// PlaceHolder for custom colors
351
372
352
373
private float red ;
353
374
private float green ;
@@ -373,6 +394,9 @@ public static PanelColor custom(float red, float green, float blue, float alpha)
373
394
public void applyColor () {
374
395
RenderSystem .setShaderColor (red , green , blue , alpha );
375
396
}
397
+ public int getColor () {
398
+ return new Color (red ,green ,blue ,alpha ).getRGB ();
399
+ }
376
400
}
377
401
378
402
public class MinecraftBooleanRenderer implements SkinRenderer <BooleanOption > {
@@ -520,7 +544,7 @@ public void render(DrawContext drawContext, EnumOption<E> option, int x, int y,
520
544
option .setHeight (25 );
521
545
option .setWidth (maxWidth );
522
546
523
- drawContext .drawText (mc .textRenderer , option .name + ": " , x + 15 , y + 25 / 2 - 5 , -1 , true );
547
+ drawContext .drawText (mc .textRenderer , option .name . copy (). append ( ": " ) , x + 15 , y + 25 / 2 - 5 , -1 , true );
524
548
525
549
option .setPosition (x + panelWidth - maxWidth - 25 , y );
526
550
@@ -554,7 +578,7 @@ public void render(DrawContext drawContext, ListOption<E> option, int x, int y,
554
578
option .setHeight (25 );
555
579
option .setWidth (maxWidth );
556
580
557
- drawContext .drawText (mc .textRenderer , option .name + ": " , x + 15 , y + 25 / 2 - 5 , -1 , true );
581
+ drawContext .drawText (mc .textRenderer , option .name . copy (). append ( ": " ) , x + 15 , y + 25 / 2 - 5 , -1 , true );
558
582
559
583
option .setPosition (x + panelWidth - maxWidth - 25 , y );
560
584
@@ -601,7 +625,7 @@ public void render(DrawContext drawContext, RunnableOption option, int x, int y,
601
625
option .setHeight (25 );
602
626
option .setWidth (26 );
603
627
604
- drawContext .drawText (mc .textRenderer , option .name + ": " , x + 15 , y + 25 / 2 - 5 , -1 , true );
628
+ drawContext .drawText (mc .textRenderer , option .name . copy (). append ( ": " ) , x + 15 , y + 25 / 2 - 5 , -1 , true );
605
629
606
630
option .setPosition (x + panelWidth - 51 , y );
607
631
@@ -615,4 +639,9 @@ public void render(DrawContext drawContext, RunnableOption option, int x, int y,
615
639
RenderSystem .disableDepthTest ();
616
640
}
617
641
}
642
+
643
+ @ Override
644
+ public Skin clone () {
645
+ return new MinecraftSkin (panelColor );
646
+ }
618
647
}
0 commit comments