aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/client/CottonClientScreen.java8
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/client/CottonInventoryScreen.java23
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/impl/client/CottonInventoryScreenImpl.java7
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/impl/mixin/client/HandledScreenMixin.java28
-rw-r--r--src/main/resources/mixins.libgui.json1
5 files changed, 51 insertions, 16 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 9e47c40..ac34d4e 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
@@ -125,9 +125,6 @@ public class CottonClientScreen extends Screen implements CottonScreenImpl {
private void paint(DrawContext context, int mouseX, int mouseY, float delta) {
if (description!=null) {
- context.getMatrices().push();
- context.getMatrices().translate(0f, 0f, 0.01f);
-
WPanel root = description.getRootPanel();
if (root!=null) {
GL11.glEnable(GL11.GL_SCISSOR_TEST);
@@ -141,16 +138,13 @@ public class CottonClientScreen extends Screen implements CottonScreenImpl {
int width = description.getRootPanel().getWidth();
ScreenDrawing.drawString(context, getTitle().asOrderedText(), description.getTitleAlignment(), left + titleX, top + titleY, width - 2 * titleX, description.getTitleColor());
}
-
- context.getMatrices().pop();
}
}
@Override
public void render(DrawContext context, int mouseX, int mouseY, float partialTicks) {
- paint(context, mouseX, mouseY, partialTicks);
-
super.render(context, mouseX, mouseY, partialTicks);
+ paint(context, mouseX, mouseY, partialTicks);
if (description!=null) {
WPanel root = description.getRootPanel();
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 701380d..071d0ca 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
@@ -13,7 +13,7 @@ import net.minecraft.text.Text;
import io.github.cottonmc.cotton.gui.GuiDescription;
import io.github.cottonmc.cotton.gui.SyncedGuiDescription;
import io.github.cottonmc.cotton.gui.impl.VisualLogger;
-import io.github.cottonmc.cotton.gui.impl.client.CottonScreenImpl;
+import io.github.cottonmc.cotton.gui.impl.client.CottonInventoryScreenImpl;
import io.github.cottonmc.cotton.gui.impl.client.FocusElements;
import io.github.cottonmc.cotton.gui.impl.client.MouseInputHandler;
import io.github.cottonmc.cotton.gui.impl.client.NarrationHelper;
@@ -30,7 +30,7 @@ import org.lwjgl.opengl.GL11;
*
* @param <T> the description type
*/
-public class CottonInventoryScreen<T extends SyncedGuiDescription> extends HandledScreen<T> implements CottonScreenImpl {
+public class CottonInventoryScreen<T extends SyncedGuiDescription> extends HandledScreen<T> implements CottonInventoryScreenImpl {
private static final VisualLogger LOGGER = new VisualLogger(CottonInventoryScreen.class);
protected SyncedGuiDescription description;
@Nullable protected WWidget lastResponder = null;
@@ -274,27 +274,32 @@ public class CottonInventoryScreen<T extends SyncedGuiDescription> extends Handl
@Override
protected void drawBackground(DrawContext context, float partialTicks, int mouseX, int mouseY) {} //This is just an AbstractContainerScreen thing; most Screens don't work this way.
-
- private void paint(DrawContext context, int mouseX, int mouseY, float delta) {
+
+ /**
+ * Paints the GUI description of this screen.
+ *
+ * @param context the draw context
+ * @param mouseX the absolute X coordinate of the mouse cursor
+ * @param mouseY the absolute Y coordinate of the mouse cursor
+ * @param delta the tick delta
+ * @since 9.2.0
+ */
+ @Override
+ public void paintDescription(DrawContext context, int mouseX, int mouseY, float delta) {
if (description!=null) {
WPanel root = description.getRootPanel();
if (root!=null) {
- context.getMatrices().push();
- context.getMatrices().translate(0f, 0f, 0.01f);
GL11.glEnable(GL11.GL_SCISSOR_TEST);
Scissors.refreshScissors();
root.paint(context, x, y, mouseX-x, mouseY-y);
GL11.glDisable(GL11.GL_SCISSOR_TEST);
Scissors.checkStackIsEmpty();
- context.getMatrices().pop();
}
}
}
@Override
public void render(DrawContext context, int mouseX, int mouseY, float partialTicks) {
- paint(context, mouseX, mouseY, partialTicks);
-
super.render(context, mouseX, mouseY, partialTicks);
DiffuseLighting.disableGuiDepthLighting(); //Needed because super.render leaves dirty state
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/impl/client/CottonInventoryScreenImpl.java b/src/main/java/io/github/cottonmc/cotton/gui/impl/client/CottonInventoryScreenImpl.java
new file mode 100644
index 0000000..877c92a
--- /dev/null
+++ b/src/main/java/io/github/cottonmc/cotton/gui/impl/client/CottonInventoryScreenImpl.java
@@ -0,0 +1,7 @@
+package io.github.cottonmc.cotton.gui.impl.client;
+
+import net.minecraft.client.gui.DrawContext;
+
+public interface CottonInventoryScreenImpl extends CottonScreenImpl {
+ void paintDescription(DrawContext context, int mouseX, int mouseY, float delta);
+}
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/impl/mixin/client/HandledScreenMixin.java b/src/main/java/io/github/cottonmc/cotton/gui/impl/mixin/client/HandledScreenMixin.java
new file mode 100644
index 0000000..1697ab6
--- /dev/null
+++ b/src/main/java/io/github/cottonmc/cotton/gui/impl/mixin/client/HandledScreenMixin.java
@@ -0,0 +1,28 @@
+package io.github.cottonmc.cotton.gui.impl.mixin.client;
+
+import net.minecraft.client.gui.DrawContext;
+import net.minecraft.client.gui.screen.ingame.HandledScreen;
+
+import io.github.cottonmc.cotton.gui.impl.client.CottonInventoryScreenImpl;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Inject;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
+
+@Mixin(HandledScreen.class)
+abstract class HandledScreenMixin {
+ @Inject(
+ method = "render",
+ at = @At(
+ value = "INVOKE",
+ target = "Lnet/minecraft/client/gui/screen/Screen;render(Lnet/minecraft/client/gui/DrawContext;IIF)V",
+ shift = At.Shift.AFTER
+ ),
+ allow = 1
+ )
+ private void onSuperRender(DrawContext context, int mouseX, int mouseY, float delta, CallbackInfo info) {
+ if (this instanceof CottonInventoryScreenImpl cottonInventoryScreen) {
+ cottonInventoryScreen.paintDescription(context, mouseX, mouseY, delta);
+ }
+ }
+}
diff --git a/src/main/resources/mixins.libgui.json b/src/main/resources/mixins.libgui.json
index d72e129..226bd52 100644
--- a/src/main/resources/mixins.libgui.json
+++ b/src/main/resources/mixins.libgui.json
@@ -6,6 +6,7 @@
"plugin": "io.github.cottonmc.cotton.gui.impl.LibGuiMixinPlugin",
"client": [
+ "client.HandledScreenMixin",
"client.MinecraftClientMixin",
"client.PressableWidgetAccessor",
"client.ScreenAccessor",