@@ -50,7 +50,7 @@ static UITexture icon(String name, int x, int y) {
5050 @ Nullable public final ColorType colorType ;
5151 public final boolean nonOpaque ;
5252
53- private int colorOverride = 0 ;
53+ protected int colorOverride ;
5454
5555 /**
5656 * Creates a drawable texture
@@ -63,7 +63,7 @@ static UITexture icon(String name, int x, int y) {
6363 * @param colorType a function to get which color from a widget theme should be used to color this texture. Can be null.
6464 */
6565 public UITexture (ResourceLocation location , float u0 , float v0 , float u1 , float v1 , @ Nullable ColorType colorType ) {
66- this (location , u0 , v0 , u1 , v1 , colorType , false );
66+ this (location , u0 , v0 , u1 , v1 , colorType , false , 0 );
6767 }
6868
6969 /**
@@ -78,6 +78,22 @@ public UITexture(ResourceLocation location, float u0, float v0, float u1, float
7878 * @param nonOpaque whether the texture should draw with blend (if true) or not (if false).
7979 */
8080 public UITexture (ResourceLocation location , float u0 , float v0 , float u1 , float v1 , @ Nullable ColorType colorType , boolean nonOpaque ) {
81+ this (location , u0 , v0 , u1 , v1 , colorType , nonOpaque , 0 );
82+ }
83+
84+ /**
85+ * Creates a drawable texture
86+ *
87+ * @param location location of the texture
88+ * @param u0 x offset of the image (0-1)
89+ * @param v0 y offset of the image (0-1)
90+ * @param u1 x end offset of the image (0-1)
91+ * @param v1 y end offset of the image (0-1)
92+ * @param colorType a function to get which color from a widget theme should be used to color this texture. Can be null.
93+ * @param nonOpaque whether the texture should draw with blend (if true) or not (if false).
94+ * @param colorOverride color override for the texture in ARGB format. 0 means no override
95+ */
96+ public UITexture (ResourceLocation location , float u0 , float v0 , float u1 , float v1 , @ Nullable ColorType colorType , boolean nonOpaque , int colorOverride ) {
8197 this .colorType = colorType ;
8298 boolean png = !location .getPath ().endsWith (".png" );
8399 boolean textures = !location .getPath ().startsWith ("textures/" );
@@ -92,6 +108,7 @@ public UITexture(ResourceLocation location, float u0, float v0, float u1, float
92108 this .u1 = u1 ;
93109 this .v1 = v1 ;
94110 this .nonOpaque = nonOpaque ;
111+ this .colorOverride = colorOverride ;
95112 }
96113
97114 public static Builder builder () {
@@ -281,7 +298,7 @@ public int hashCode() {
281298 }
282299
283300 protected UITexture copy () {
284- return new UITexture (this .location , this .u0 , this .v0 , this .u1 , this .v1 , this .colorType );
301+ return new UITexture (this .location , this .u0 , this .v0 , this .u1 , this .v1 , this .colorType , this . nonOpaque , this . colorOverride );
285302 }
286303
287304 public UITexture withColorOverride (int color ) {
@@ -312,6 +329,7 @@ public static class Builder {
312329 private boolean tiled = false ;
313330 private ColorType colorType = null ;
314331 private boolean nonOpaque = false ;
332+ private int colorOverride = 0 ;
315333
316334 /**
317335 * @param loc location of the image to draw
@@ -603,13 +621,13 @@ private UITexture create() {
603621 throw new IllegalArgumentException ("UV values must be 0 - 1" );
604622 if (this .bl > 0 || this .bt > 0 || this .br > 0 || this .bb > 0 ) {
605623 return new AdaptableUITexture (this .location , this .u0 , this .v0 , this .u1 , this .v1 , this .colorType , this .nonOpaque ,
606- this .iw , this .ih , this .bl , this .bt , this .br , this .bb , this .tiled );
624+ this .colorOverride , this . iw , this .ih , this .bl , this .bt , this .br , this .bb , this .tiled );
607625 }
608626 if (this .tiled ) {
609- return new TiledUITexture (this .location , this .u0 , this .v0 , this .u1 , this .v1 , this .iw , this .ih , this . colorType ,
610- this .nonOpaque );
627+ return new TiledUITexture (this .location , this .u0 , this .v0 , this .u1 , this .v1 , this .colorType , this .nonOpaque ,
628+ this .colorOverride , this . iw , this . ih );
611629 }
612- return new UITexture (this .location , this .u0 , this .v0 , this .u1 , this .v1 , this .colorType , this .nonOpaque );
630+ return new UITexture (this .location , this .u0 , this .v0 , this .u1 , this .v1 , this .colorType , this .nonOpaque , this . colorOverride );
613631 }
614632 throw new IllegalStateException ();
615633 }
0 commit comments