aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io
diff options
context:
space:
mode:
authorJuuxel <6596629+Juuxel@users.noreply.github.com>2021-02-27 15:59:19 +0200
committerJuuxel <6596629+Juuxel@users.noreply.github.com>2021-02-27 15:59:19 +0200
commite9c1a13abd8d73267d4846dafb93964646684818 (patch)
tree592158fa1558a0e666b309452860d8446cd85f0b /src/main/java/io
parent554a5877fb12bbfccdbfec2903406675ffc71c31 (diff)
downloadLibGui-e9c1a13abd8d73267d4846dafb93964646684818.tar.gz
LibGui-e9c1a13abd8d73267d4846dafb93964646684818.tar.bz2
LibGui-e9c1a13abd8d73267d4846dafb93964646684818.zip
Move BackgroundPainters to use MatrixStacks
Diffstat (limited to 'src/main/java/io')
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/client/BackgroundPainter.java15
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/client/NinePatch.java3
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/widget/WClippedPanel.java2
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/widget/WItemSlot.java2
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/widget/WPanel.java2
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/widget/WSlider.java2
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/widget/WTabPanel.java4
7 files changed, 16 insertions, 14 deletions
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/client/BackgroundPainter.java b/src/main/java/io/github/cottonmc/cotton/gui/client/BackgroundPainter.java
index 8878a60..a847629 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/client/BackgroundPainter.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/client/BackgroundPainter.java
@@ -1,5 +1,6 @@
package io.github.cottonmc.cotton.gui.client;
+import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.Identifier;
import io.github.cottonmc.cotton.gui.widget.WItemSlot;
@@ -17,7 +18,7 @@ public interface BackgroundPainter {
* @param top The absolute position of the top of the panel, in gui-screen coordinates
* @param panel The panel being painted
*/
- public void paintBackground(int left, int top, WWidget panel);
+ public void paintBackground(MatrixStack matrices, int left, int top, WWidget panel);
/**
* The {@code VANILLA} background painter draws a vanilla-like gui panel using {@linkplain NinePatch nine-patch textures}.
@@ -40,7 +41,7 @@ public interface BackgroundPainter {
/**
* The {@code SLOT} background painter draws item slots or slot-like widgets.
*/
- public static BackgroundPainter SLOT = (left, top, panel) -> {
+ public static BackgroundPainter SLOT = (matrices, left, top, panel) -> {
if (!(panel instanceof WItemSlot)) {
ScreenDrawing.drawBeveledPanel(left-1, top-1, panel.getWidth()+2, panel.getHeight()+2, 0xB8000000, 0x4C000000, 0xB8FFFFFF);
} else {
@@ -88,7 +89,7 @@ public interface BackgroundPainter {
* @see ScreenDrawing#drawGuiPanel(int, int, int, int, int)
*/
public static BackgroundPainter createColorful(int panelColor) {
- return (left, top, panel) -> {
+ return (matrices, left, top, panel) -> {
ScreenDrawing.drawGuiPanel(left-8, top-8, panel.getWidth()+16, panel.getHeight()+16, panelColor);
};
}
@@ -101,7 +102,7 @@ public interface BackgroundPainter {
* @return a colorful gui panel painter
*/
public static BackgroundPainter createColorful(int panelColor, float contrast) {
- return (left, top, panel) -> {
+ return (matrices, left, top, panel) -> {
int shadowColor = ScreenDrawing.multiplyColor(panelColor, 1.0f - contrast);
int hilightColor = ScreenDrawing.multiplyColor(panelColor, 1.0f + contrast);
@@ -146,9 +147,9 @@ public interface BackgroundPainter {
* @since 1.5.0
*/
public static BackgroundPainter createLightDarkVariants(BackgroundPainter light, BackgroundPainter dark) {
- return (left, top, panel) -> {
- if (LibGui.isDarkMode()) dark.paintBackground(left, top, panel);
- else light.paintBackground(left, top, panel);
+ return (matrices, left, top, panel) -> {
+ if (LibGui.isDarkMode()) dark.paintBackground(matrices, left, top, panel);
+ else light.paintBackground(matrices, left, top, panel);
};
}
}
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/client/NinePatch.java b/src/main/java/io/github/cottonmc/cotton/gui/client/NinePatch.java
index 9057739..cdc657e 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/client/NinePatch.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/client/NinePatch.java
@@ -3,6 +3,7 @@ package io.github.cottonmc.cotton.gui.client;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.resource.IdentifiableResourceReloadListener;
+import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.resource.Resource;
import net.minecraft.resource.ResourceManager;
import net.minecraft.resource.SinglePreparationResourceReloadListener;
@@ -167,7 +168,7 @@ public class NinePatch implements BackgroundPainter {
}
@Override
- public void paintBackground(int left, int top, WWidget panel) {
+ public void paintBackground(MatrixStack matrices, int left, int top, WWidget panel) {
int width = panel.getWidth() + leftPadding + rightPadding;
int height = panel.getHeight() + topPadding + bottomPadding;
left = left - leftPadding;
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 6daf600..a594fc2 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
@@ -13,7 +13,7 @@ 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);
+ if (getBackgroundPainter()!=null) getBackgroundPainter().paintBackground(matrices, x, y, this);
Scissors.push(x, y, width, height);
for(WWidget child : children) {
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 45fc896..1667bee 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
@@ -328,7 +328,7 @@ public class WItemSlot extends WWidget {
@Override
public void paint(MatrixStack matrices, int x, int y, int mouseX, int mouseY) {
if (backgroundPainter != null) {
- backgroundPainter.paintBackground(x, y, this);
+ backgroundPainter.paintBackground(matrices, x, y, this);
}
}
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 90ef5d6..09d4ace 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
@@ -194,7 +194,7 @@ public abstract class WPanel extends WWidget {
@Environment(EnvType.CLIENT)
@Override
public void paint(MatrixStack matrices, int x, int y, int mouseX, int mouseY) {
- if (backgroundPainter!=null) backgroundPainter.paintBackground(x, y, this);
+ if (backgroundPainter!=null) backgroundPainter.paintBackground(matrices, x, y, this);
for(WWidget child : children) {
child.paint(matrices, x + child.getX(), y + child.getY(), mouseX-child.getX(), mouseY-child.getY());
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WSlider.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WSlider.java
index 6638fb7..96f5fa5 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WSlider.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WSlider.java
@@ -50,7 +50,7 @@ public class WSlider extends WAbstractSlider {
@Override
public void paint(MatrixStack matrices, int x, int y, int mouseX, int mouseY) {
if (backgroundPainter != null) {
- backgroundPainter.paintBackground(x, y, this);
+ backgroundPainter.paintBackground(matrices, x, y, this);
} else {
float px = 1 / 32f;
// thumbX/Y: thumb position in widget-space
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WTabPanel.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WTabPanel.java
index bc3a742..09e4e1d 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WTabPanel.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WTabPanel.java
@@ -324,9 +324,9 @@ public class WTabPanel extends WPanel {
}
}
- (selected ? Painters.SELECTED_TAB : Painters.UNSELECTED_TAB).paintBackground(x, y, this);
+ (selected ? Painters.SELECTED_TAB : Painters.UNSELECTED_TAB).paintBackground(matrices, x, y, this);
if (isFocused()) {
- (selected ? Painters.SELECTED_TAB_FOCUS_BORDER : Painters.UNSELECTED_TAB_FOCUS_BORDER).paintBackground(x, y, this);
+ (selected ? Painters.SELECTED_TAB_FOCUS_BORDER : Painters.UNSELECTED_TAB_FOCUS_BORDER).paintBackground(matrices, x, y, this);
}
int iconX = 6;