aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/dev/isxander/yacl
diff options
context:
space:
mode:
authorisXander <xandersmith2008@gmail.com>2022-11-17 17:18:19 +0000
committerisXander <xandersmith2008@gmail.com>2022-11-17 17:18:19 +0000
commit3a86e9d2ba89466f7f9ef51c29eb5879bcb8a98e (patch)
treed3617930fed50a945ce4ff9ee76b8dbd7df46968 /src/main/java/dev/isxander/yacl
parentaf4484ecee46300a26952b9b9b41e7a2e80d3f78 (diff)
downloadYetAnotherConfigLib-3a86e9d2ba89466f7f9ef51c29eb5879bcb8a98e.tar.gz
YetAnotherConfigLib-3a86e9d2ba89466f7f9ef51c29eb5879bcb8a98e.tar.bz2
YetAnotherConfigLib-3a86e9d2ba89466f7f9ef51c29eb5879bcb8a98e.zip
22w46a
Diffstat (limited to 'src/main/java/dev/isxander/yacl')
-rw-r--r--src/main/java/dev/isxander/yacl/gui/AbstractWidget.java2
-rw-r--r--src/main/java/dev/isxander/yacl/gui/CategoryListWidget.java4
-rw-r--r--src/main/java/dev/isxander/yacl/gui/LowProfileButtonWidget.java10
-rw-r--r--src/main/java/dev/isxander/yacl/gui/OptionListWidget.java6
-rw-r--r--src/main/java/dev/isxander/yacl/gui/SearchFieldWidget.java2
-rw-r--r--src/main/java/dev/isxander/yacl/gui/TextScaledButtonWidget.java11
-rw-r--r--src/main/java/dev/isxander/yacl/gui/TooltipButtonWidget.java4
-rw-r--r--src/main/java/dev/isxander/yacl/gui/YACLScreen.java9
8 files changed, 25 insertions, 23 deletions
diff --git a/src/main/java/dev/isxander/yacl/gui/AbstractWidget.java b/src/main/java/dev/isxander/yacl/gui/AbstractWidget.java
index 03dc9b9..bede0ae 100644
--- a/src/main/java/dev/isxander/yacl/gui/AbstractWidget.java
+++ b/src/main/java/dev/isxander/yacl/gui/AbstractWidget.java
@@ -82,7 +82,7 @@ public abstract class AbstractWidget implements Element, Drawable, Selectable {
int width = x2 - x1;
int height = y2 - y1;
- RenderSystem.setShader(GameRenderer::getPositionTexShader);
+ RenderSystem.setShader(GameRenderer::getPositionTexProgram);
RenderSystem.setShaderTexture(0, ClickableWidget.WIDGETS_TEXTURE);
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
int i = !enabled ? 0 : hovered ? 2 : 1;
diff --git a/src/main/java/dev/isxander/yacl/gui/CategoryListWidget.java b/src/main/java/dev/isxander/yacl/gui/CategoryListWidget.java
index 2cb6bb6..46a9fdf 100644
--- a/src/main/java/dev/isxander/yacl/gui/CategoryListWidget.java
+++ b/src/main/java/dev/isxander/yacl/gui/CategoryListWidget.java
@@ -15,7 +15,7 @@ public class CategoryListWidget extends ElementListWidget<CategoryListWidget.Cat
private final YACLScreen yaclScreen;
public CategoryListWidget(MinecraftClient client, YACLScreen yaclScreen, int screenWidth, int screenHeight) {
- super(client, screenWidth / 3, yaclScreen.searchFieldWidget.y - 5, 0, yaclScreen.searchFieldWidget.y - 5, 21);
+ super(client, screenWidth / 3, yaclScreen.searchFieldWidget.getY() - 5, 0, yaclScreen.searchFieldWidget.getY() - 5, 21);
this.yaclScreen = yaclScreen;
setRenderBackground(false);
setRenderHorizontalShadows(false);
@@ -75,7 +75,7 @@ public class CategoryListWidget extends ElementListWidget<CategoryListWidget.Cat
mouseY = -20;
}
- categoryButton.y = y;
+ categoryButton.setY(y);
categoryButton.render(matrices, mouseX, mouseY, tickDelta);
}
diff --git a/src/main/java/dev/isxander/yacl/gui/LowProfileButtonWidget.java b/src/main/java/dev/isxander/yacl/gui/LowProfileButtonWidget.java
index 240cfb2..a4d6304 100644
--- a/src/main/java/dev/isxander/yacl/gui/LowProfileButtonWidget.java
+++ b/src/main/java/dev/isxander/yacl/gui/LowProfileButtonWidget.java
@@ -1,6 +1,7 @@
package dev.isxander.yacl.gui;
import net.minecraft.client.MinecraftClient;
+import net.minecraft.client.gui.screen.Tooltip;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.Text;
@@ -8,18 +9,19 @@ import net.minecraft.util.math.MathHelper;
public class LowProfileButtonWidget extends ButtonWidget {
public LowProfileButtonWidget(int x, int y, int width, int height, Text message, PressAction onPress) {
- super(x, y, width, height, message, onPress);
+ super(x, y, width, height, message, onPress, ButtonWidget.DEFAULT_NARRATION_SUPPLIER);
}
- public LowProfileButtonWidget(int x, int y, int width, int height, Text message, PressAction onPress, TooltipSupplier tooltipSupplier) {
- super(x, y, width, height, message, onPress, tooltipSupplier);
+ public LowProfileButtonWidget(int x, int y, int width, int height, Text message, PressAction onPress, Tooltip tooltip) {
+ this(x, y, width, height, message, onPress);
+ setTooltip(tooltip);
}
@Override
public void renderButton(MatrixStack matrices, int mouseX, int mouseY, float delta) {
if (!isHovered()) {
int j = this.active ? 0xFFFFFF : 0xA0A0A0;
- drawCenteredText(matrices, MinecraftClient.getInstance().textRenderer, this.getMessage(), this.x + this.width / 2, this.y + (this.height - 8) / 2, j | MathHelper.ceil(this.alpha * 255.0F) << 24);
+ drawCenteredText(matrices, MinecraftClient.getInstance().textRenderer, this.getMessage(), this.getX() + this.width / 2, this.getY() + (this.height - 8) / 2, j | MathHelper.ceil(this.alpha * 255.0F) << 24);
} else {
super.renderButton(matrices, mouseX, mouseY, delta);
}
diff --git a/src/main/java/dev/isxander/yacl/gui/OptionListWidget.java b/src/main/java/dev/isxander/yacl/gui/OptionListWidget.java
index cf50a58..eed3aff 100644
--- a/src/main/java/dev/isxander/yacl/gui/OptionListWidget.java
+++ b/src/main/java/dev/isxander/yacl/gui/OptionListWidget.java
@@ -312,7 +312,7 @@ public class OptionListWidget extends ElementListWidget<OptionListWidget.Entry>
widget.render(matrices, mouseX, mouseY, tickDelta);
if (resetButton != null) {
- resetButton.y = y;
+ resetButton.setY(y);
resetButton.render(matrices, mouseX, mouseY, tickDelta);
}
}
@@ -402,8 +402,8 @@ public class OptionListWidget extends ElementListWidget<OptionListWidget.Entry>
public void render(MatrixStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
this.y = y;
- expandMinimizeButton.x = x;
- expandMinimizeButton.y = y + entryHeight / 2 - expandMinimizeButton.getHeight() / 2;
+ expandMinimizeButton.setX(x);
+ expandMinimizeButton.setY(y + entryHeight / 2 - expandMinimizeButton.getHeight() / 2);
expandMinimizeButton.render(matrices, mouseX, mouseY, tickDelta);
wrappedName.drawCenterWithShadow(matrices, x + entryWidth / 2, y + getYPadding());
diff --git a/src/main/java/dev/isxander/yacl/gui/SearchFieldWidget.java b/src/main/java/dev/isxander/yacl/gui/SearchFieldWidget.java
index 6184405..5b7c9dc 100644
--- a/src/main/java/dev/isxander/yacl/gui/SearchFieldWidget.java
+++ b/src/main/java/dev/isxander/yacl/gui/SearchFieldWidget.java
@@ -25,7 +25,7 @@ public class SearchFieldWidget extends TextFieldWidget {
public void renderButton(MatrixStack matrices, int mouseX, int mouseY, float delta) {
super.renderButton(matrices, mouseX, mouseY, delta);
if (isVisible() && isEmpty()) {
- textRenderer.drawWithShadow(matrices, emptyText, x + 4, this.y + (this.height - 8) / 2f, 0x707070);
+ textRenderer.drawWithShadow(matrices, emptyText, getX() + 4, this.getY() + (this.height - 8) / 2f, 0x707070);
}
}
diff --git a/src/main/java/dev/isxander/yacl/gui/TextScaledButtonWidget.java b/src/main/java/dev/isxander/yacl/gui/TextScaledButtonWidget.java
index d588d52..197a162 100644
--- a/src/main/java/dev/isxander/yacl/gui/TextScaledButtonWidget.java
+++ b/src/main/java/dev/isxander/yacl/gui/TextScaledButtonWidget.java
@@ -2,6 +2,7 @@ package dev.isxander.yacl.gui;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
+import net.minecraft.client.gui.screen.Tooltip;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.OrderedText;
@@ -12,13 +13,13 @@ public class TextScaledButtonWidget extends ButtonWidget {
public float textScale;
public TextScaledButtonWidget(int x, int y, int width, int height, float textScale, Text message, PressAction onPress) {
- super(x, y, width, height, message, onPress);
+ super(x, y, width, height, message, onPress, ButtonWidget.DEFAULT_NARRATION_SUPPLIER);
this.textScale = textScale;
}
- public TextScaledButtonWidget(int x, int y, int width, int height, float textScale, Text message, PressAction onPress, TooltipSupplier tooltipSupplier) {
- super(x, y, width, height, message, onPress, tooltipSupplier);
- this.textScale = textScale;
+ public TextScaledButtonWidget(int x, int y, int width, int height, float textScale, Text message, PressAction onPress, Tooltip tooltip) {
+ this(x, y, width, height, textScale, message, onPress);
+ setTooltip(tooltip);
}
@Override
@@ -35,7 +36,7 @@ public class TextScaledButtonWidget extends ButtonWidget {
TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer;
matrices.push();
- matrices.translate(((this.x + this.width / 2f) - textRenderer.getWidth(orderedText) * textScale / 2), (float)this.y + (this.height - 8 * textScale) / 2f / textScale, 0);
+ matrices.translate(((this.getX() + this.width / 2f) - textRenderer.getWidth(orderedText) * textScale / 2), (float)this.getY() + (this.height - 8 * textScale) / 2f / textScale, 0);
matrices.scale(textScale, textScale, 1);
textRenderer.drawWithShadow(matrices, orderedText, 0, 0, j | MathHelper.ceil(this.alpha * 255.0F) << 24);
matrices.pop();
diff --git a/src/main/java/dev/isxander/yacl/gui/TooltipButtonWidget.java b/src/main/java/dev/isxander/yacl/gui/TooltipButtonWidget.java
index d105f7b..706765a 100644
--- a/src/main/java/dev/isxander/yacl/gui/TooltipButtonWidget.java
+++ b/src/main/java/dev/isxander/yacl/gui/TooltipButtonWidget.java
@@ -13,14 +13,14 @@ public class TooltipButtonWidget extends ButtonWidget {
protected MultilineText wrappedDescription;
public TooltipButtonWidget(Screen screen, int x, int y, int width, int height, Text message, Text tooltip, PressAction onPress) {
- super(x, y, width, height, message, onPress);
+ super(x, y, width, height, message, onPress, ButtonWidget.DEFAULT_NARRATION_SUPPLIER);
this.screen = screen;
setTooltip(tooltip);
}
public void renderHoveredTooltip(MatrixStack matrices) {
if (isHovered()) {
- YACLScreen.renderMultilineTooltip(matrices, MinecraftClient.getInstance().textRenderer, wrappedDescription, x + width / 2, y - 4, y + height + 4, screen.width, screen.height);
+ YACLScreen.renderMultilineTooltip(matrices, MinecraftClient.getInstance().textRenderer, wrappedDescription, getX() + width / 2, getY() - 4, getY() + height + 4, screen.width, screen.height);
}
}
diff --git a/src/main/java/dev/isxander/yacl/gui/YACLScreen.java b/src/main/java/dev/isxander/yacl/gui/YACLScreen.java
index 629fd4c..e36c8e8 100644
--- a/src/main/java/dev/isxander/yacl/gui/YACLScreen.java
+++ b/src/main/java/dev/isxander/yacl/gui/YACLScreen.java
@@ -13,8 +13,7 @@ import net.minecraft.client.render.*;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
-import net.minecraft.util.math.MathHelper;
-import net.minecraft.util.math.Matrix4f;
+import org.joml.Matrix4f;
import java.util.HashSet;
import java.util.Set;
@@ -85,7 +84,7 @@ public class YACLScreen extends Screen {
OptionUtils.forEachOptions(config, Option::forgetPendingValue);
});
- searchFieldWidget = new SearchFieldWidget(this, textRenderer, width / 3 / 2 - paddedWidth / 2 + 1, undoButton.y - 22, paddedWidth - 2, 18, Text.translatable("gui.recipebook.search_hint"), Text.translatable("gui.recipebook.search_hint"));
+ searchFieldWidget = new SearchFieldWidget(this, textRenderer, width / 3 / 2 - paddedWidth / 2 + 1, undoButton.getY() - 22, paddedWidth - 2, 18, Text.translatable("gui.recipebook.search_hint"), Text.translatable("gui.recipebook.search_hint"));
categoryList = new CategoryListWidget(client, this, width, height);
addSelectableChild(categoryList);
@@ -241,7 +240,7 @@ public class YACLScreen extends Screen {
matrices.push();
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder bufferBuilder = tessellator.getBuffer();
- RenderSystem.setShader(GameRenderer::getPositionColorShader);
+ RenderSystem.setShader(GameRenderer::getPositionColorProgram);
bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR);
Matrix4f matrix4f = matrices.peek().getPositionMatrix();
fillGradient(matrix4f, bufferBuilder, drawX - 3, drawY - 4, drawX + maxWidth + 3, drawY - 3, 400, -267386864, -267386864);
@@ -257,7 +256,7 @@ public class YACLScreen extends Screen {
RenderSystem.disableTexture();
RenderSystem.enableBlend();
RenderSystem.defaultBlendFunc();
- BufferRenderer.drawWithShader(bufferBuilder.end());
+ BufferRenderer.drawWithGlobalProgram(bufferBuilder.end());
RenderSystem.disableBlend();
RenderSystem.enableTexture();
matrices.translate(0.0, 0.0, 400.0);