From 26d373fcceeebe0065b7fb76904addb3bde6e2b5 Mon Sep 17 00:00:00 2001 From: Juuxel <6596629+Juuxel@users.noreply.github.com> Date: Tue, 4 Aug 2020 20:54:56 +0300 Subject: Revert "Make layout() client-only, add missing Environment(CLIENT) annotations to paint() overrides" This reverts commit 0b3c68e0 --- .../github/cottonmc/cotton/gui/client/CottonClientScreen.java | 2 -- .../cottonmc/cotton/gui/client/CottonInventoryScreen.java | 4 ---- src/main/java/io/github/cottonmc/cotton/gui/widget/WBox.java | 3 --- .../java/io/github/cottonmc/cotton/gui/widget/WButton.java | 1 - .../io/github/cottonmc/cotton/gui/widget/WClippedPanel.java | 3 --- .../io/github/cottonmc/cotton/gui/widget/WDynamicLabel.java | 3 --- .../java/io/github/cottonmc/cotton/gui/widget/WLabel.java | 1 - .../java/io/github/cottonmc/cotton/gui/widget/WListPanel.java | 6 +----- .../java/io/github/cottonmc/cotton/gui/widget/WPanel.java | 2 +- .../java/io/github/cottonmc/cotton/gui/widget/WScrollBar.java | 1 - .../io/github/cottonmc/cotton/gui/widget/WScrollPanel.java | 11 +++-------- .../java/io/github/cottonmc/cotton/gui/widget/WTextField.java | 3 +-- 12 files changed, 6 insertions(+), 34 deletions(-) (limited to 'src') diff --git a/src/main/java/io/github/cottonmc/cotton/gui/client/CottonClientScreen.java b/src/main/java/io/github/cottonmc/cotton/gui/client/CottonClientScreen.java index 84e4f1d..6adf34e 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/client/CottonClientScreen.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/client/CottonClientScreen.java @@ -87,8 +87,6 @@ public class CottonClientScreen extends Screen implements TextHoverRendererScree root.setSize(screenWidth, screenHeight); } - - root.layout(); } } } diff --git a/src/main/java/io/github/cottonmc/cotton/gui/client/CottonInventoryScreen.java b/src/main/java/io/github/cottonmc/cotton/gui/client/CottonInventoryScreen.java index d039061..e69755d 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/client/CottonInventoryScreen.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/client/CottonInventoryScreen.java @@ -120,10 +120,6 @@ public class CottonInventoryScreen extends Handl basePanel.setSize(screenWidth, screenHeight); } } - - if (basePanel != null) { - basePanel.layout(); - } } @Override diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WBox.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WBox.java index eb1d3b5..261e2f2 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WBox.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WBox.java @@ -3,8 +3,6 @@ package io.github.cottonmc.cotton.gui.widget; import io.github.cottonmc.cotton.gui.widget.data.Axis; import io.github.cottonmc.cotton.gui.widget.data.HorizontalAlignment; import io.github.cottonmc.cotton.gui.widget.data.VerticalAlignment; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; import java.util.Objects; @@ -74,7 +72,6 @@ public class WBox extends WPanel { add(widget, 18, 18); } - @Environment(EnvType.CLIENT) @Override public void layout() { int dimension = 0; diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WButton.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WButton.java index 016eceb..719f88e 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WButton.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WButton.java @@ -73,7 +73,6 @@ public class WButton extends WWidget { return true; } - @Environment(EnvType.CLIENT) @Override public void paint(MatrixStack matrices, int x, int y, int mouseX, int mouseY) { boolean hovered = (mouseX>=0 && mouseY>=0 && mouseX extends WClippedPanel { scrollBar.setMaxValue(data.size()); scrollBar.setParent(this); } - - @Environment(EnvType.CLIENT) + @Override public void paint(MatrixStack matrices, int x, int y, int mouseX, int mouseY) { if (scrollBar.getValue()!=lastScroll) { @@ -107,7 +104,6 @@ public class WListPanel extends WClippedPanel { return child; } - @Environment(EnvType.CLIENT) @Override public void layout() { diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WPanel.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WPanel.java index b204945..10725ee 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WPanel.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WPanel.java @@ -75,7 +75,6 @@ public abstract class WPanel extends WWidget { /** * Uses this Panel's layout rules to reposition and resize components to fit nicely in the panel. */ - @Environment(EnvType.CLIENT) public void layout() { for(WWidget child : children) { if (child instanceof WPanel) ((WPanel) child).layout(); @@ -186,6 +185,7 @@ public abstract class WPanel extends WWidget { @Override public void validate(GuiDescription c) { super.validate(c); + layout(); for (WWidget child : children) { child.validate(c); } diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WScrollBar.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WScrollBar.java index 233a90a..3ed7e2d 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WScrollBar.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WScrollBar.java @@ -32,7 +32,6 @@ public class WScrollBar extends WWidget { this.axis = axis; } - @Environment(EnvType.CLIENT) @Override public void paint(MatrixStack matrices, int x, int y, int mouseX, int mouseY) { if (LibGuiClient.config.darkMode) { diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WScrollPanel.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WScrollPanel.java index e4db5a6..b4addcc 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WScrollPanel.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WScrollPanel.java @@ -1,7 +1,5 @@ package io.github.cottonmc.cotton.gui.widget; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.util.TriState; import net.minecraft.client.util.math.MatrixStack; @@ -31,7 +29,6 @@ public class WScrollPanel extends WClippedPanel { private int lastHorizontalScroll = -1; private int lastVerticalScroll = -1; - private boolean needsLayout = false; /** * Creates a vertically scrolling panel. @@ -63,7 +60,7 @@ public class WScrollPanel extends WClippedPanel { public WScrollPanel setScrollingHorizontally(TriState scrollingHorizontally) { if (scrollingHorizontally != this.scrollingHorizontally) { this.scrollingHorizontally = scrollingHorizontally; - needsLayout = true; + layout(); } return this; @@ -83,7 +80,7 @@ public class WScrollPanel extends WClippedPanel { public WScrollPanel setScrollingVertically(TriState scrollingVertically) { if (scrollingVertically != this.scrollingVertically) { this.scrollingVertically = scrollingVertically; - needsLayout = true; + layout(); } return this; @@ -91,17 +88,15 @@ public class WScrollPanel extends WClippedPanel { @Override public void paint(MatrixStack matrices, int x, int y, int mouseX, int mouseY) { - if (needsLayout || verticalScrollBar.getValue() != lastVerticalScroll || horizontalScrollBar.getValue() != lastHorizontalScroll) { + if (verticalScrollBar.getValue() != lastVerticalScroll || horizontalScrollBar.getValue() != lastHorizontalScroll) { layout(); lastHorizontalScroll = horizontalScrollBar.getValue(); lastVerticalScroll = verticalScrollBar.getValue(); - needsLayout = false; } super.paint(matrices, x, y, mouseX, mouseY); } - @Environment(EnvType.CLIENT) @Override public void layout() { children.clear(); diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WTextField.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WTextField.java index 93ebdcb..191c609 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WTextField.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WTextField.java @@ -513,8 +513,7 @@ public class WTextField extends WWidget { @Override public void onFocusGained() { } - - @Environment(EnvType.CLIENT) + @Override public void paint(MatrixStack matrices, int x, int y, int mouseX, int mouseY) { -- cgit