diff options
author | Juuxel <6596629+Juuxel@users.noreply.github.com> | 2020-08-04 20:54:56 +0300 |
---|---|---|
committer | Juuxel <6596629+Juuxel@users.noreply.github.com> | 2020-08-04 20:54:56 +0300 |
commit | 26d373fcceeebe0065b7fb76904addb3bde6e2b5 (patch) | |
tree | a8bf68e9209dfa08135158747d23e8d0315d316b /src/main/java/io | |
parent | fd45e13d7bbc14cde3aba99bcf1f9a5dc2bc26b1 (diff) | |
download | LibGui-26d373fcceeebe0065b7fb76904addb3bde6e2b5.tar.gz LibGui-26d373fcceeebe0065b7fb76904addb3bde6e2b5.tar.bz2 LibGui-26d373fcceeebe0065b7fb76904addb3bde6e2b5.zip |
Revert "Make layout() client-only, add missing Environment(CLIENT) annotations to paint() overrides"
This reverts commit 0b3c68e0
Diffstat (limited to 'src/main/java/io')
12 files changed, 6 insertions, 34 deletions
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<T extends SyncedGuiDescription> 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<getWidth() && mouseY<getHeight()); diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WClippedPanel.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WClippedPanel.java index 9a93c7a..531ae85 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WClippedPanel.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WClippedPanel.java @@ -1,15 +1,12 @@ package io.github.cottonmc.cotton.gui.widget; import io.github.cottonmc.cotton.gui.client.Scissors; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; import net.minecraft.client.util.math.MatrixStack; /** * A panel that is clipped to only render widgets inside its bounds. */ public class WClippedPanel extends WPanel { - @Environment(EnvType.CLIENT) @Override public void paint(MatrixStack matrices, int x, int y, int mouseX, int mouseY) { if (getBackgroundPainter()!=null) getBackgroundPainter().paintBackground(x, y, this); 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 0412b83..a3adac9 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 @@ -1,7 +1,5 @@ package io.github.cottonmc.cotton.gui.widget; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; import net.minecraft.client.util.math.MatrixStack; import io.github.cottonmc.cotton.gui.client.LibGuiClient; @@ -36,7 +34,6 @@ public class WDynamicLabel extends WWidget { this(text, DEFAULT_TEXT_COLOR); } - @Environment(EnvType.CLIENT) @Override public void paint(MatrixStack matrices, int x, int y, int mouseX, int mouseY) { String tr = text.get(); 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 7cc76e9..fddc09a 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 @@ -79,7 +79,6 @@ public class WLabel extends WWidget { this(text, DEFAULT_TEXT_COLOR); } - @Environment(EnvType.CLIENT) @Override public void paint(MatrixStack matrices, int x, int y, int mouseX, int mouseY) { MinecraftClient mc = MinecraftClient.getInstance(); diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WListPanel.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WListPanel.java index 9bef3e0..bcfbf2b 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WListPanel.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WListPanel.java @@ -1,7 +1,5 @@ package io.github.cottonmc.cotton.gui.widget; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; import net.minecraft.client.util.math.MatrixStack; import io.github.cottonmc.cotton.gui.widget.data.Axis; @@ -71,8 +69,7 @@ public class WListPanel<D, W extends WWidget> 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<D, W extends WWidget> 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) { |