aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorFalkreon <falkreon@gmail.com>2019-07-20 14:06:46 -0500
committerFalkreon <falkreon@gmail.com>2019-07-20 14:06:46 -0500
commit82a62cf0c992bb0390814a1d12569fa7f05dfcd9 (patch)
tree3a9cf32a432e9787dd0c42a1ecc22b1f9303f619 /src/main/java
parent4e9dc24dade8b1214e64cf6f3da4bd2e4c6a5fff (diff)
downloadLibGui-82a62cf0c992bb0390814a1d12569fa7f05dfcd9.tar.gz
LibGui-82a62cf0c992bb0390814a1d12569fa7f05dfcd9.tar.bz2
LibGui-82a62cf0c992bb0390814a1d12569fa7f05dfcd9.zip
Add darkmode support to WLabel, fix build, add API badge
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/widget/WLabel.java31
1 files changed, 28 insertions, 3 deletions
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 fb034b8..6c6f82a 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
@@ -1,13 +1,16 @@
package io.github.cottonmc.cotton.gui.widget;
+import io.github.cottonmc.cotton.gui.client.LibGuiClient;
import io.github.cottonmc.cotton.gui.client.ScreenDrawing;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;
public class WLabel extends WWidget {
- protected final Text text;
- protected final int color;
+ protected Text text;
+ protected int color;
+ protected int darkmodeColor;
public static final int DEFAULT_TEXT_COLOR = 0x404040;
+ public static final int DEFAULT_DARKMODE_TEXT_COLOR = 0xbcbcbc;
public WLabel(String text, int color) {
this(new LiteralText(text), color);
@@ -16,6 +19,7 @@ public class WLabel extends WWidget {
public WLabel(Text text, int color) {
this.text = text;
this.color = color;
+ this.darkmodeColor = (color==DEFAULT_TEXT_COLOR) ? DEFAULT_DARKMODE_TEXT_COLOR : color;
}
public WLabel(String text) {
@@ -25,7 +29,7 @@ public class WLabel extends WWidget {
@Override
public void paintBackground(int x, int y) {
String translated = text.asFormattedString();
- ScreenDrawing.drawString(translated, x, y, color);
+ ScreenDrawing.drawString(translated, x, y, LibGuiClient.config.darkMode ? darkmodeColor : color);
}
@Override
@@ -42,4 +46,25 @@ public class WLabel extends WWidget {
public int getHeight() {
return 8;
}
+
+ public WLabel setDarkmodeColor(int color) {
+ darkmodeColor = color;
+ return this;
+ }
+
+ public WLabel disableDarkmode() {
+ this.darkmodeColor = this.color;
+ return this;
+ }
+
+ public WLabel setColor(int color, int darkmodeColor) {
+ this.color = color;
+ this.darkmodeColor = darkmodeColor;
+ return this;
+ }
+
+ public WLabel setText(Text text) {
+ this.text = text;
+ return this;
+ }
} \ No newline at end of file