From 2d5a99e691ecaca5f6628cd010a7249d6993ad61 Mon Sep 17 00:00:00 2001 From: Aeronica Date: Thu, 7 Mar 2024 19:49:27 -0600 Subject: [PATCH] WIP: Improve Instrument and MusicVenueTool overlays. --- .../aeronicamc/mods/mxtune/gui/Handler.java | 3 + .../mods/mxtune/gui/OverlayManagerScreen.java | 64 +++++++++++++++++++ .../mods/mxtune/gui/TestScreen.java | 4 +- .../mods/mxtune/render/OverlayItemGui.java | 16 +---- 4 files changed, 71 insertions(+), 16 deletions(-) create mode 100644 src/main/java/aeronicamc/mods/mxtune/gui/OverlayManagerScreen.java diff --git a/src/main/java/aeronicamc/mods/mxtune/gui/Handler.java b/src/main/java/aeronicamc/mods/mxtune/gui/Handler.java index 511048fd..30c2652f 100644 --- a/src/main/java/aeronicamc/mods/mxtune/gui/Handler.java +++ b/src/main/java/aeronicamc/mods/mxtune/gui/Handler.java @@ -5,6 +5,7 @@ import aeronicamc.mods.mxtune.gui.mml.GuiMXT; import aeronicamc.mods.mxtune.util.Misc; import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.screen.Screen; public class Handler { @@ -31,4 +32,6 @@ public static void openTestScreen() { mc.tell(() -> mc.setScreen(new TestScreen())); } + + public static void openOverlayManagerScreen(Screen parent) { mc.tell(() -> mc.setScreen(new OverlayManagerScreen(parent))); } } diff --git a/src/main/java/aeronicamc/mods/mxtune/gui/OverlayManagerScreen.java b/src/main/java/aeronicamc/mods/mxtune/gui/OverlayManagerScreen.java new file mode 100644 index 00000000..10fff39b --- /dev/null +++ b/src/main/java/aeronicamc/mods/mxtune/gui/OverlayManagerScreen.java @@ -0,0 +1,64 @@ +package aeronicamc.mods.mxtune.gui; + +import aeronicamc.mods.mxtune.gui.widget.MXButton; +import com.mojang.blaze3d.matrix.MatrixStack; +import net.minecraft.client.gui.screen.Screen; +import net.minecraft.util.text.StringTextComponent; +import net.minecraft.util.text.TranslationTextComponent; + +public class OverlayManagerScreen extends MXScreen { + + private final Screen parent; + public OverlayManagerScreen(Screen parent) { + super(StringTextComponent.EMPTY); + this.parent=parent; + } + + @Override + protected void init() { + super.init(); + this.addButton(new MXButton(((width/2) - 25), height-100, 50, 20, new TranslationTextComponent("gui.done"), + done -> onClose())); + } + + @Override + public boolean isPauseScreen() + { + return false; + } + + @Override + public void onClose() { + getMinecraft().setScreen(parent); + } + + @Override + public boolean mouseClicked(double pMouseX, double pMouseY, int pButton) { + return super.mouseClicked(pMouseX, pMouseY, pButton); + } + + @Override + public boolean mouseReleased(double pMouseX, double pMouseY, int pButton) { + return super.mouseReleased(pMouseX, pMouseY, pButton); + } + + @Override + public boolean mouseDragged(double pMouseX, double pMouseY, int pButton, double pDragX, double pDragY) { + return super.mouseDragged(pMouseX, pMouseY, pButton, pDragX, pDragY); + } + + @Override + public boolean mouseScrolled(double pMouseX, double pMouseY, double pDelta) { + return super.mouseScrolled(pMouseX, pMouseY, pDelta); + } + + @Override + public void renderBackground(MatrixStack pMatrixStack) { + net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.GuiScreenEvent.BackgroundDrawnEvent(this, pMatrixStack)); + } + + @Override + public void render(MatrixStack pMatrixStack, int pMouseX, int pMouseY, float pPartialTicks) { + super.render(pMatrixStack, pMouseX, pMouseY, pPartialTicks); + } +} diff --git a/src/main/java/aeronicamc/mods/mxtune/gui/TestScreen.java b/src/main/java/aeronicamc/mods/mxtune/gui/TestScreen.java index efc2786e..4bf05f31 100644 --- a/src/main/java/aeronicamc/mods/mxtune/gui/TestScreen.java +++ b/src/main/java/aeronicamc/mods/mxtune/gui/TestScreen.java @@ -21,6 +21,8 @@ import java.util.Objects; +import static aeronicamc.mods.mxtune.gui.Handler.openOverlayManagerScreen; + public class TestScreen extends Screen { private static final Logger LOGGER = LogManager.getLogger(); @@ -88,7 +90,7 @@ public void init() public void onButtonOpen() { - /* NOOP */ + openOverlayManagerScreen(this); } public void onButtonFile() diff --git a/src/main/java/aeronicamc/mods/mxtune/render/OverlayItemGui.java b/src/main/java/aeronicamc/mods/mxtune/render/OverlayItemGui.java index 061abe6b..ba3efe20 100644 --- a/src/main/java/aeronicamc/mods/mxtune/render/OverlayItemGui.java +++ b/src/main/java/aeronicamc/mods/mxtune/render/OverlayItemGui.java @@ -13,18 +13,16 @@ import javax.annotation.Nullable; import java.util.Arrays; -; public class OverlayItemGui extends AbstractGui { private final Minecraft minecraft; private final OverlayInstance[] visible = { null, null, null, null }; + private int lastSlot = -1; public OverlayItemGui(Minecraft pMinecraft) { this.minecraft = pMinecraft; } - private int lastSlot = -1; - public void render(MatrixStack pPoseStack) { if (!this.minecraft.options.hideGui) { OverlayInstance overlayInstance; @@ -62,25 +60,13 @@ public T getOverlay(Class pIOverlayItem, O return (T)overlayInstance.getOverlayItem(); } } - -// for(IOverlayItem overlayItem : this.queued) { -// if (pIOverlayItem.isAssignableFrom(overlayItem.getClass()) && overlayItem.getToken().equals(pToken)) { -// return (T)overlayItem; -// } -// } - return (T)null; } public void clear() { Arrays.fill(this.visible, (Object)null); -// this.queued.clear(); } -// public void addOverlay(IOverlayItem overlayItem) { -// this.queued.add(overlayItem); -// } - public Minecraft getMinecraft() { return this.minecraft; }