aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorJuuz <6596629+Juuxel@users.noreply.github.com>2021-06-22 19:33:57 +0300
committerJuuz <6596629+Juuxel@users.noreply.github.com>2021-06-22 19:33:57 +0300
commit1d75b59eaf6ab3a1d73457f5fffe56f23bf1a5f1 (patch)
tree8d6cc5a6abc9215be50dad6f7c993215cf8c1ac3 /src/main/java
parenta8a2d36a9bb32fe15a391a65666717ed26e0eb70 (diff)
downloadLibGui-1d75b59eaf6ab3a1d73457f5fffe56f23bf1a5f1.tar.gz
LibGui-1d75b59eaf6ab3a1d73457f5fffe56f23bf1a5f1.tar.bz2
LibGui-1d75b59eaf6ab3a1d73457f5fffe56f23bf1a5f1.zip
Minor tweaks to WItemSlot.get/setIcon
- JD improvements - Fixed @'since tags - Warning when you're setting an icon for a widget with more than 1 visible slot
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/widget/WItemSlot.java32
1 files changed, 21 insertions, 11 deletions
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WItemSlot.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WItemSlot.java
index e1f0bce..f25a2f2 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WItemSlot.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WItemSlot.java
@@ -13,6 +13,8 @@ import io.github.cottonmc.cotton.gui.GuiDescription;
import io.github.cottonmc.cotton.gui.ValidatedSlot;
import io.github.cottonmc.cotton.gui.client.BackgroundPainter;
import io.github.cottonmc.cotton.gui.widget.icon.Icon;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
@@ -58,6 +60,7 @@ import java.util.function.Predicate;
* </pre>
*/
public class WItemSlot extends WWidget {
+ private static final Logger LOGGER = LogManager.getLogger();
private static final Predicate<ItemStack> DEFAULT_FILTER = stack -> true;
private final List<ValidatedSlot> peers = new ArrayList<>();
@Nullable
@@ -152,24 +155,31 @@ public class WItemSlot extends WWidget {
}
/**
- * Sets the icon to this slot. Can be used for labeling slots for certain activities.
+ * {@return the icon if set, otherwise null}
*
- * @param icon the icon
- * @since 4.0.0
+ * @since 4.1.0
*/
- public WItemSlot setIcon(@Nullable Icon icon) {
- this.icon = icon;
- return this;
+ @Nullable
+ public Icon getIcon() {
+ return this.icon;
}
/**
+ * Sets the icon to this slot. Can be used for labeling slots for certain activities.
*
- * @return icon if set, otherwise null
- * @since 4.0.0
+ * @param icon the icon
+ * @return this slot widget
+ * @since 4.1.0
*/
- @Nullable
- public Icon getIcon() {
- return this.icon;
+ public WItemSlot setIcon(@Nullable Icon icon) {
+ this.icon = icon;
+
+ if (icon != null && (slotsWide * slotsHigh) > 1) {
+ // TODO: Should these types of warnings be visible in the screen itself in a dev env?
+ LOGGER.warn("Setting icon {} for item slot {} with more than 1 slot ({})", icon, this, slotsWide * slotsHigh);
+ }
+
+ return this;
}
/**