Skip to content

Commit

Permalink
WIP: Improve Instrument and MusicVenueTool overlays.
Browse files Browse the repository at this point in the history
  • Loading branch information
Aeronica committed Mar 8, 2024
1 parent d04409f commit 2d5a99e
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 16 deletions.
3 changes: 3 additions & 0 deletions src/main/java/aeronicamc/mods/mxtune/gui/Handler.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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))); }
}
64 changes: 64 additions & 0 deletions src/main/java/aeronicamc/mods/mxtune/gui/OverlayManagerScreen.java
Original file line number Diff line number Diff line change
@@ -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);
}
}
4 changes: 3 additions & 1 deletion src/main/java/aeronicamc/mods/mxtune/gui/TestScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -88,7 +90,7 @@ public void init()

public void onButtonOpen()
{
/* NOOP */
openOverlayManagerScreen(this);
}

public void onButtonFile()
Expand Down
16 changes: 1 addition & 15 deletions src/main/java/aeronicamc/mods/mxtune/render/OverlayItemGui.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -62,25 +60,13 @@ public <T extends IOverlayItem> T getOverlay(Class<? extends T> 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;
}
Expand Down

0 comments on commit 2d5a99e

Please sign in to comment.