aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io
diff options
context:
space:
mode:
authorJuuz <6596629+Juuxel@users.noreply.github.com>2021-06-04 16:08:18 +0300
committerJuuz <6596629+Juuxel@users.noreply.github.com>2021-06-04 16:08:18 +0300
commit9ab901717e430a48db6e30d5117dd28f15ff8f72 (patch)
treed255710168ffb0e692919c9f173cad0a1aac9d40 /src/main/java/io
parentfdaa5276124335b02ce5631197661f2aa90d165f (diff)
downloadLibGui-9ab901717e430a48db6e30d5117dd28f15ff8f72.tar.gz
LibGui-9ab901717e430a48db6e30d5117dd28f15ff8f72.tar.bz2
LibGui-9ab901717e430a48db6e30d5117dd28f15ff8f72.zip
Make WBar.validate safe to call multiple times
Diffstat (limited to 'src/main/java/io')
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/widget/WBar.java4
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/widget/WWidget.java2
2 files changed, 4 insertions, 2 deletions
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WBar.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WBar.java
index 1b45a5a..60fb7a9 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WBar.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WBar.java
@@ -57,6 +57,7 @@ public class WBar extends WWidget {
*/
protected int maxValue;
protected PropertyDelegate properties;
+ private boolean manuallySetProperties = false;
protected final Direction direction;
protected String tooltipLabel;
protected Text tooltipTextComponent;
@@ -197,7 +198,7 @@ public class WBar extends WWidget {
@Override
public void validate(GuiDescription host) {
super.validate(host);
- if (properties==null) properties = host.getPropertyDelegate();
+ if (properties==null || !manuallySetProperties) properties = host.getPropertyDelegate();
}
/**
@@ -221,6 +222,7 @@ public class WBar extends WWidget {
*/
public WBar setProperties(PropertyDelegate properties) {
this.properties = properties;
+ manuallySetProperties = properties != null;
return this;
}
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WWidget.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WWidget.java
index d94a4b9..1091201 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WWidget.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WWidget.java
@@ -370,7 +370,7 @@ public class WWidget {
if (host != null) {
this.host = host;
} else {
- LOGGER.warn("Validating {} with a null host", this);
+ LOGGER.warn("Validating {} with a null host", this);
}
}