3
3
import io .github .darkkronicle .darkkore .colors .ExtendedColor ;
4
4
import io .github .darkkronicle .darkkore .config .options .Option ;
5
5
import io .github .darkkronicle .darkkore .gui .Tab ;
6
- import io .github .darkkronicle .darkkore .util .Color ;
7
6
import io .github .darkkronicle .kronhud .config .*;
8
7
import io .github .darkkronicle .kronhud .util .ColorUtil ;
9
8
import io .github .darkkronicle .kronhud .util .DrawPosition ;
10
9
import io .github .darkkronicle .kronhud .util .DrawUtil ;
11
10
import io .github .darkkronicle .kronhud .util .Rectangle ;
11
+ import lombok .Getter ;
12
12
import lombok .Setter ;
13
13
import net .minecraft .client .MinecraftClient ;
14
- import net .minecraft .client .render .BufferBuilder ;
15
- import net .minecraft .client .render .BufferRenderer ;
16
14
import net .minecraft .client .util .math .MatrixStack ;
17
15
import net .minecraft .text .Text ;
18
16
import net .minecraft .util .Identifier ;
@@ -30,16 +28,23 @@ public abstract class AbstractHudEntry extends DrawUtil {
30
28
protected KronBoolean shadow = new KronBoolean ("shadow" , null , getShadowDefault ());
31
29
protected KronBoolean background = new KronBoolean ("background" , null , true );
32
30
protected KronExtendedColor backgroundColor = new KronExtendedColor ("backgroundcolor" , null , new ExtendedColor (0x64000000 , ExtendedColor .ChromaOptions .getDefault ()));
31
+
32
+ protected KronBoolean outline = new KronBoolean ("outline" , null , false );
33
+ protected KronExtendedColor outlineColor = new KronExtendedColor ("outlinecolor" , null , new ExtendedColor (-1 , ExtendedColor .ChromaOptions .getDefault ()));
34
+
33
35
private final KronDouble x = new KronDouble ("x" , null , getDefaultX (), 0 , 1 , this );
34
36
private final KronDouble y = new KronDouble ("y" , null , getDefaultY (), 0 , 1 , this );
35
37
36
- private Rectangle scaledBounds = null ;
37
- private Rectangle unscaledBounds = null ;
38
- private DrawPosition scaledPosition = null ;
39
- private DrawPosition unscaledPosition ;
38
+ private Rectangle trueBounds = null ;
39
+ private Rectangle renderBounds = null ;
40
+ private DrawPosition truePosition = null ;
41
+ private DrawPosition renderPosition ;
42
+
43
+ @ Getter
44
+ protected int width ;
45
+ @ Getter
46
+ protected int height ;
40
47
41
- public int width ;
42
- public int height ;
43
48
@ Setter
44
49
protected boolean hovered = false ;
45
50
protected MinecraftClient client = MinecraftClient .getInstance ();
@@ -57,21 +62,21 @@ public static float intToFloat(int current, int max, int offset) {
57
62
return MathHelper .clamp ((float ) (current ) / (max - offset ), 0 , 1 );
58
63
}
59
64
60
- public void renderHud (MatrixStack matrices ) {
61
- render (matrices );
65
+ public void renderHud (MatrixStack matrices , float delta ) {
66
+ render (matrices , delta );
62
67
}
63
68
64
- public abstract void render (MatrixStack matrices );
69
+ public abstract void render (MatrixStack matrices , float delta );
65
70
66
- public abstract void renderPlaceholder (MatrixStack matrices );
71
+ public abstract void renderPlaceholder (MatrixStack matrices , float delta );
67
72
68
73
public void renderPlaceholderBackground (MatrixStack matrices ) {
69
74
if (hovered ) {
70
- fillRect (matrices , getScaledBounds (), ColorUtil .SELECTOR_BLUE .withAlpha (100 ));
75
+ fillRect (matrices , getTrueBounds (), ColorUtil .SELECTOR_BLUE .withAlpha (100 ));
71
76
} else {
72
- fillRect (matrices , getScaledBounds (), ColorUtil .WHITE .withAlpha (50 ));
77
+ fillRect (matrices , getTrueBounds (), ColorUtil .WHITE .withAlpha (50 ));
73
78
}
74
- outlineRect (matrices , getScaledBounds (), ColorUtil .BLACK );
79
+ outlineRect (matrices , getTrueBounds (), ColorUtil .BLACK );
75
80
}
76
81
77
82
public abstract Identifier getId ();
@@ -91,22 +96,22 @@ public void setXY(int x, int y) {
91
96
}
92
97
93
98
public int getX () {
94
- return getScaledPos ().x ();
99
+ return getPos ().x ();
95
100
}
96
101
97
102
public void setX (int x ) {
98
103
this .x .setValue ((double ) intToFloat (x , client .getWindow ().getScaledWidth (),
99
- Math .round (width * getScale ())
104
+ Math .round (getWidth () * getScale ())
100
105
));
101
106
}
102
107
103
108
public int getY () {
104
- return getScaledPos ().y ();
109
+ return getPos ().y ();
105
110
}
106
111
107
112
public void setY (int y ) {
108
113
this .y .setValue ((double ) intToFloat (y , client .getWindow ().getScaledHeight (),
109
- Math .round (height * getScale ())
114
+ Math .round (getHeight () * getScale ())
110
115
));
111
116
}
112
117
@@ -122,17 +127,17 @@ protected boolean getShadowDefault() {
122
127
return true ;
123
128
}
124
129
125
- public Rectangle getScaledBounds () {
126
- return scaledBounds ;
130
+ public Rectangle getTrueBounds () {
131
+ return trueBounds ;
127
132
}
128
133
129
134
/**
130
135
* Gets the hud's bounds when the matrix has already been scaled.
131
136
*
132
137
* @return The bounds.
133
138
*/
134
- public Rectangle getBounds () {
135
- return unscaledBounds ;
139
+ public Rectangle getRenderBounds () {
140
+ return renderBounds ;
136
141
}
137
142
138
143
public float getScale () {
@@ -144,11 +149,15 @@ public void scale(MatrixStack matrices) {
144
149
}
145
150
146
151
public DrawPosition getPos () {
147
- return unscaledPosition ;
152
+ return renderPosition ;
153
+ }
154
+
155
+ public DrawPosition getTruePos () {
156
+ return truePosition ;
148
157
}
149
158
150
- public DrawPosition getScaledPos () {
151
- return scaledPosition ;
159
+ public void onSizeUpdate () {
160
+ setBounds () ;
152
161
}
153
162
154
163
public void setBounds () {
@@ -157,22 +166,22 @@ public void setBounds() {
157
166
158
167
public void setBounds (float scale ) {
159
168
if (client .getWindow () == null ) {
160
- scaledPosition = new DrawPosition (0 , 0 );
161
- unscaledPosition = new DrawPosition (0 , 0 );
162
- unscaledBounds = new Rectangle (0 , 0 , 1 , 1 );
163
- scaledBounds = new Rectangle (0 , 0 , 1 , 1 );
169
+ truePosition = new DrawPosition (0 , 0 );
170
+ renderPosition = new DrawPosition (0 , 0 );
171
+ renderBounds = new Rectangle (0 , 0 , 1 , 1 );
172
+ trueBounds = new Rectangle (0 , 0 , 1 , 1 );
164
173
return ;
165
174
}
166
175
int scaledX = floatToInt (x .getValue ().floatValue (), client .getWindow ().getScaledWidth (),
167
- Math .round (width * scale )
176
+ Math .round (getWidth () * scale )
168
177
);
169
178
int scaledY = floatToInt (y .getValue ().floatValue (), client .getWindow ().getScaledHeight (),
170
- Math .round (height * scale )
179
+ Math .round (getHeight () * scale )
171
180
);
172
- scaledPosition = new DrawPosition (scaledX , scaledY );
173
- unscaledPosition = scaledPosition .divide (getScale ());
174
- scaledBounds = new Rectangle (getX (), getY () , Math .round (width * getScale ()), Math .round (height * getScale ()));
175
- unscaledBounds = new Rectangle (getX (), getY (), width , height );
181
+ truePosition = new DrawPosition (scaledX , scaledY );
182
+ renderPosition = truePosition .divide (getScale ());
183
+ trueBounds = new Rectangle (scaledX , scaledY , Math .round (getWidth () * getScale ()), Math .round (getHeight () * getScale ()));
184
+ renderBounds = new Rectangle (renderPosition . x (), renderPosition . y (), getWidth (), getHeight () );
176
185
}
177
186
178
187
public Tab getOptionWrapper () {
0 commit comments