diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WDynamicLabel.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WDynamicLabel.java index 7f0aa7e9..6696c0e5 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WDynamicLabel.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WDynamicLabel.java @@ -21,6 +21,7 @@ public class WDynamicLabel extends WWidget { protected HorizontalAlignment alignment = HorizontalAlignment.LEFT; protected int color; protected int darkmodeColor; + protected boolean drawShadows; public static final int DEFAULT_TEXT_COLOR = 0x404040; public static final int DEFAULT_DARKMODE_TEXT_COLOR = 0xbcbcbc; @@ -39,7 +40,11 @@ public WDynamicLabel(Supplier text) { @Override public void paint(DrawContext context, int x, int y, int mouseX, int mouseY) { String tr = text.get(); - ScreenDrawing.drawString(context, tr, alignment, x, y, this.getWidth(), shouldRenderInDarkMode() ? darkmodeColor : color); + if (getDrawShadows()) { + ScreenDrawing.drawStringWithShadow(context, tr, alignment, x, y, this.getWidth(), shouldRenderInDarkMode() ? darkmodeColor : color); + } else { + ScreenDrawing.drawString(context, tr, alignment, x, y, this.getWidth(), shouldRenderInDarkMode() ? darkmodeColor : color); + } } @Override @@ -67,6 +72,28 @@ public WDynamicLabel setColor(int color, int darkmodeColor) { this.darkmodeColor = darkmodeColor; return this; } + + /** + * Checks whether shadows should be drawn for this label. + * + * @return {@code true} shadows should be drawn, {@code false} otherwise + * @since 11.1.0 + */ + public boolean getDrawShadows() { + return drawShadows; + } + + /** + * Sets whether shadows should be drawn for this labbel. + * + * @param drawShadows {@code true} if shadows should be drawn, {@code false} otherwise + * @return this label + * @since 11.1.0 + */ + public WLabel setDrawShadows(boolean drawShadows) { + this.drawShadows = drawShadows; + return this; + } public WDynamicLabel setText(Supplier text) { this.text = text; diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WLabel.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WLabel.java index c1b31a59..52b15212 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WLabel.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WLabel.java @@ -184,9 +184,9 @@ public WLabel setColor(int color, int darkmodeColor) { * Checks whether shadows should be drawn for this label. * * @return {@code true} shadows should be drawn, {@code false} otherwise - * @since 11.0.1 + * @since 11.1.0 */ - public boolean areShadowsDrawn() { + public boolean getDrawShadows() { return drawShadows; } @@ -195,7 +195,7 @@ public boolean areShadowsDrawn() { * * @param drawShadows {@code true} if shadows should be drawn, {@code false} otherwise * @return this label - * @since 11.0.1 + * @since 11.1.0 */ public WLabel setDrawShadows(boolean drawShadows) { this.drawShadows = drawShadows; diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WText.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WText.java index b2a44eb4..429ac913 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WText.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WText.java @@ -30,6 +30,7 @@ public class WText extends WWidget { protected Text text; protected int color; protected int darkmodeColor; + protected boolean drawShadows; protected HorizontalAlignment horizontalAlignment = HorizontalAlignment.LEFT; protected VerticalAlignment verticalAlignment = VerticalAlignment.TOP; @Environment(EnvType.CLIENT) @@ -101,7 +102,11 @@ public void paint(DrawContext context, int x, int y, int mouseX, int mouseY) { OrderedText line = wrappedLines.get(i); int c = shouldRenderInDarkMode() ? darkmodeColor : color; - ScreenDrawing.drawString(context, line, horizontalAlignment, x, y + yOffset + i * font.fontHeight, width, c); + if (getDrawShadows()) { + ScreenDrawing.drawStringWithShadow(context, line, horizontalAlignment, x, y + yOffset + i * font.fontHeight, width, c); + } else { + ScreenDrawing.drawString(context, line, horizontalAlignment, x, y + yOffset + i * font.fontHeight, width, c); + } } Style hoveredTextStyle = getTextStyleAt(mouseX, mouseY); @@ -199,6 +204,28 @@ public WText setColor(int color, int darkmodeColor) { return this; } + /** + * Checks whether shadows should be drawn for this label. + * + * @return {@code true} shadows should be drawn, {@code false} otherwise + * @since 11.1.0 + */ + public boolean getDrawShadows() { + return drawShadows; + } + + /** + * Sets whether shadows should be drawn for this labbel. + * + * @param drawShadows {@code true} if shadows should be drawn, {@code false} otherwise + * @return this label + * @since 11.1.0 + */ + public WLabel setDrawShadows(boolean drawShadows) { + this.drawShadows = drawShadows; + return this; + } + /** * Disables separate dark mode coloring by copying the dark color to be the light color. *