diff options
| author | nea <nea@nea.moe> | 2023-01-20 07:32:37 +0100 |
|---|---|---|
| committer | nea <nea@nea.moe> | 2023-01-20 07:34:07 +0100 |
| commit | 3067e07062e35767dcc2d5aa4109c3b142da728e (patch) | |
| tree | bf281d1b08ee7382a55afc8941cbc43c241c6990 | |
| parent | bfda1556b1f690c99d2eddb1ad034bdf25625607 (diff) | |
| download | NotEnoughUpdates-luloeventlistener.tar.gz NotEnoughUpdates-luloeventlistener.tar.bz2 NotEnoughUpdates-luloeventlistener.zip | |
Add ButtonExclusionZoneEventluloeventlistener
11 files changed, 414 insertions, 301 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java index 6160ac8d..049955de 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java @@ -75,6 +75,7 @@ import io.github.moulberry.notenoughupdates.miscfeatures.updater.AutoUpdater; import io.github.moulberry.notenoughupdates.miscfeatures.world.EnderNodeHighlighter; import io.github.moulberry.notenoughupdates.miscfeatures.world.FrozenTreasuresHighlighter; import io.github.moulberry.notenoughupdates.miscfeatures.world.GlowingMushroomHighlighter; +import io.github.moulberry.notenoughupdates.miscgui.AccessoryBagOverlay; import io.github.moulberry.notenoughupdates.miscgui.CalendarOverlay; import io.github.moulberry.notenoughupdates.miscgui.InventoryStorageSelector; import io.github.moulberry.notenoughupdates.miscgui.SignCalculator; @@ -357,6 +358,7 @@ public class NotEnoughUpdates { MinecraftForge.EVENT_BUS.register(MuseumItemHighlighter.INSTANCE); MinecraftForge.EVENT_BUS.register(MuseumCheapestItemOverlay.INSTANCE); MinecraftForge.EVENT_BUS.register(new WardrobeMouseButtons()); + MinecraftForge.EVENT_BUS.register(AccessoryBagOverlay.INSTANCE); if (Minecraft.getMinecraft().getResourceManager() instanceof IReloadableResourceManager) { IReloadableResourceManager manager = (IReloadableResourceManager) Minecraft.getMinecraft().getResourceManager(); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/listener/RenderListener.java b/src/main/java/io/github/moulberry/notenoughupdates/listener/RenderListener.java index f15a26a7..a35c9a6c 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/listener/RenderListener.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/listener/RenderListener.java @@ -29,6 +29,7 @@ import io.github.moulberry.notenoughupdates.auction.CustomAHGui; import io.github.moulberry.notenoughupdates.commands.profile.ViewProfileCommand; import io.github.moulberry.notenoughupdates.core.GuiScreenElementWrapper; import io.github.moulberry.notenoughupdates.dungeons.DungeonWin; +import io.github.moulberry.notenoughupdates.events.ButtonExclusionZoneEvent; import io.github.moulberry.notenoughupdates.miscfeatures.AbiphoneWarning; import io.github.moulberry.notenoughupdates.miscfeatures.AuctionBINWarning; import io.github.moulberry.notenoughupdates.miscfeatures.AuctionProfit; @@ -59,6 +60,7 @@ import io.github.moulberry.notenoughupdates.overlays.TextOverlay; import io.github.moulberry.notenoughupdates.profileviewer.GuiProfileViewer; import io.github.moulberry.notenoughupdates.util.ItemUtils; import io.github.moulberry.notenoughupdates.util.NotificationHandler; +import io.github.moulberry.notenoughupdates.util.Rectangle; import io.github.moulberry.notenoughupdates.util.SBInfo; import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.client.Minecraft; @@ -105,6 +107,7 @@ import java.util.Map; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; +import java.util.function.BiConsumer; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -484,96 +487,70 @@ public class RenderListener { if (CalendarOverlay.isEnabled() || event.isCanceled()) return; if (NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() && NotificationHandler.shouldRenderOverlay(event.gui) && event.gui instanceof GuiContainer) { - doInventoryButtons = true; - - int zOffset = 50; - - GlStateManager.translate(0, 0, zOffset); - - int xSize = ((AccessorGuiContainer) event.gui).getXSize(); - int ySize = ((AccessorGuiContainer) event.gui).getYSize(); - int guiLeft = ((AccessorGuiContainer) event.gui).getGuiLeft(); - int guiTop = ((AccessorGuiContainer) event.gui).getGuiTop(); + renderButtons((GuiContainer) event.gui); + } + } - if (!NEUApi.disableInventoryButtons) { - if (!EnchantingSolvers.disableButtons()) { - for (NEUConfig.InventoryButton button : NotEnoughUpdates.INSTANCE.config.hidden.inventoryButtons) { - if (!button.isActive()) continue; - if (button.playerInvOnly && !(event.gui instanceof GuiInventory)) continue; + public void iterateButtons(GuiContainer gui, BiConsumer<NEUConfig.InventoryButton, Rectangle> acceptButton) { + if (NEUApi.disableInventoryButtons || EnchantingSolvers.disableButtons()) { + return; + } - int x = guiLeft + button.x; - int y = guiTop + button.y; - if (button.anchorRight) { - x += xSize; - } - if (button.anchorBottom) { - y += ySize; - } - if (AccessoryBagOverlay.isInAccessoryBag()) { - if (x > guiLeft + xSize && x < guiLeft + xSize + 80 + 28 + 5 && y > guiTop - 18 && y < guiTop + 150) { - x += 80 + 28; - } - } - if (TrophyRewardOverlay.inTrophyFishingInventory()) { - int diffX = 162; - if (x > guiLeft + xSize && x < guiLeft + xSize + diffX + 5 && y > guiTop - 18 && y < guiTop + 120) { - x += diffX; - } - } - if (MinionHelperManager.getInstance().inCraftedMinionsInventory()) { - int diffX = 172; - if (x > guiLeft + xSize && x < guiLeft + xSize + diffX + 5 && y > guiTop - 18 && y < guiTop + 128) { - x += diffX; - } - } - if (AuctionProfit.inAuctionPage()) { - if (x + 18 > guiLeft + xSize && x + 18 < guiLeft + xSize + 4 + 28 + 20 && y > guiTop - 180 && - y < guiTop + 56) { - x -= 68 - 200; - } - } - if (EquipmentOverlay.isRenderingArmorHud()) { - if (x < guiLeft + xSize - 150 && x > guiLeft + xSize - 200 && y > guiTop && y < guiTop + 84) { - x -= 25; - } - } - if (EquipmentOverlay.isRenderingPetHud()) { - if (x < guiLeft + xSize - 150 && x > guiLeft + xSize - 200 && y > guiTop + 60 && y < guiTop + 120) { - x -= 25; - } - } - if (inDungeonPage || DungeonNpcProfitOverlay.isRendering()) { - if (x + 10 > guiLeft + xSize && x + 18 < guiLeft + xSize + 4 + 28 + 20 && y > guiTop - 180 && - y < guiTop + 100) { - x += 185; - } - } + AccessorGuiContainer accessor = (AccessorGuiContainer) gui; + Rectangle guiRectangle = new Rectangle( + accessor.getGuiLeft(), + accessor.getGuiTop(), + accessor.getXSize(), + accessor.getYSize() + ); + + ButtonExclusionZoneEvent buttonExclusionZoneEvent = new ButtonExclusionZoneEvent(gui, guiRectangle); + buttonExclusionZoneEvent.post(); + for (NEUConfig.InventoryButton button : NotEnoughUpdates.INSTANCE.config.hidden.inventoryButtons) { + if (!button.isActive()) continue; + if (button.playerInvOnly && !(gui instanceof GuiInventory)) continue; + + Rectangle buttonPosition = buttonExclusionZoneEvent.findButtonPosition(new Rectangle( + accessor.getGuiLeft() + button.x + (button.anchorRight ? accessor.getXSize() : 0), + accessor.getGuiTop() + button.y + (button.anchorBottom ? accessor.getYSize() : 0), + 18, 18 + ) + ); + acceptButton.accept(button, buttonPosition); + } + } - GlStateManager.color(1, 1, 1, 1f); - - GlStateManager.enableDepth(); - GlStateManager.enableAlpha(); - Minecraft.getMinecraft().getTextureManager().bindTexture(EDITOR); - Utils.drawTexturedRect( - x, - y, - 18, - 18, - button.backgroundIndex * 18 / 256f, - (button.backgroundIndex * 18 + 18) / 256f, - 18 / 256f, - 36 / 256f, - GL11.GL_NEAREST - ); + public void renderButtons(GuiContainer gui) { + doInventoryButtons = true; - if (button.icon != null && !button.icon.trim().isEmpty()) { - GuiInvButtonEditor.renderIcon(button.icon, x + 1, y + 1); - } - } - } + int zOffset = 50; + GlStateManager.pushMatrix(); + GlStateManager.pushAttrib(); + GlStateManager.translate(0, 0, zOffset); + iterateButtons(gui, (button, buttonPosition) -> { + GlStateManager.color(1, 1, 1, 1f); + GlStateManager.enableDepth(); + GlStateManager.enableAlpha(); + + Minecraft.getMinecraft().getTextureManager().bindTexture(EDITOR); + Utils.drawTexturedRect( + buttonPosition.getX(), + buttonPosition.getY(), + 18, + 18, + button.backgroundIndex * 18 / 256f, + (button.backgroundIndex * 18 + 18) / 256f, + 18 / 256f, + 36 / 256f, + GL11.GL_NEAREST + ); + + if (button.icon != null && !button.icon.trim().isEmpty()) { + GuiInvButtonEditor.renderIcon(button.icon, buttonPosition.getX() + 1, buttonPosition.getY() + 1); } - GlStateManager.translate(0, 0, -zOffset); - } + }); + GlStateManager.popMatrix(); + GlStateManager.popAttrib(); } /** @@ -620,105 +597,51 @@ public class RenderListener { } } - boolean hoveringButton = false; + final boolean[] hoveringButton = {false}; if (!doInventoryButtons) return; if (NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() && NotificationHandler.shouldRenderOverlay(event.gui) && event.gui instanceof GuiContainer) { - int xSize = ((AccessorGuiContainer) event.gui).getXSize(); - int ySize = ((AccessorGuiContainer) event.gui).getYSize(); - int guiLeft = ((AccessorGuiContainer) event.gui).getGuiLeft(); - int guiTop = ((AccessorGuiContainer) event.gui).getGuiTop(); - - if (!NEUApi.disableInventoryButtons) { - if (!EnchantingSolvers.disableButtons()) { - for (NEUConfig.InventoryButton button : NotEnoughUpdates.INSTANCE.config.hidden.inventoryButtons) { - if (!button.isActive()) continue; - if (button.playerInvOnly && !(event.gui instanceof GuiInventory)) continue; - - int x = guiLeft + button.x; - int y = guiTop + button.y; - if (button.anchorRight) { - x += xSize; - } - if (button.anchorBottom) { - y += ySize; - } - if (AccessoryBagOverlay.isInAccessoryBag()) { - if (x > guiLeft + xSize && x < guiLeft + xSize + 80 + 28 + 5 && y > guiTop - 18 && y < guiTop + 150) { - x += 80 + 28; - } - } - if (TrophyRewardOverlay.inTrophyFishingInventory()) { - int diffX = 162; - if (x > guiLeft + xSize && x < guiLeft + xSize + diffX + 5 && y > guiTop - 18 && y < guiTop + 120) { - x += diffX; - } - } - if (MinionHelperManager.getInstance().inCraftedMinionsInventory()) { - int diffX = 172; - if (x > guiLeft + xSize && x < guiLeft + xSize + diffX + 5 && y > guiTop - 18 && y < guiTop + 128) { - x += diffX; - } - } - if (AuctionProfit.inAuctionPage()) { - if (x + 18 > guiLeft + xSize && x + 18 < guiLeft + xSize + 4 + 28 + 20 && y > guiTop - 180 && - y < guiTop + 56) { - x -= 68 - 200; - } - } - if (EquipmentOverlay.isRenderingArmorHud()) { - if (x < guiLeft + xSize - 150 && x > guiLeft + xSize - 200 && y > guiTop && y < guiTop + 84) { - x -= 25; - } - } - if (EquipmentOverlay.isRenderingPetHud()) { - if (x < guiLeft + xSize - 150 && x > guiLeft + xSize - 200 && y > guiTop + 60 && y < guiTop + 120) { - x -= 25; - } - } - - if (inDungeonPage || DungeonNpcProfitOverlay.isRendering()) { - if (x + 10 > guiLeft + xSize && x + 18 < guiLeft + xSize + 4 + 28 + 20 && y > guiTop - 180 && - y < guiTop + 100) { - x += 185; - } - } - - if (x - guiLeft >= 85 && x - guiLeft <= 115 && y - guiTop >= 4 && y - guiTop <= 25) { - disableCraftingText = true; - } + AccessorGuiContainer acc = (AccessorGuiContainer) event.gui; + Rectangle mousePosition = new Rectangle(event.mouseX, event.mouseY, 0, 0); + Rectangle craftingTextRectangle = new Rectangle(acc.getGuiLeft() + 85, acc.getGuiTop() + 4, 30, 21); + iterateButtons((GuiContainer) guiScreen, (button, buttonPosition) -> { - if (event.mouseX >= x && event.mouseX <= x + 18 && event.mouseY >= y && event.mouseY <= y + 18) { - hoveringButton = true; - long currentTime = System.currentTimeMillis(); + if (buttonPosition.intersects(craftingTextRectangle)) { + disableCraftingText = true; + } - if (buttonHovered != button) { - buttonHoveredMillis = currentTime; - buttonHovered = button; - } + if (!buttonPosition.intersects(mousePosition)) { + return; + } + hoveringButton[0] = true; + long currentTime = System.currentTimeMillis(); - if (currentTime - buttonHoveredMillis > NotEnoughUpdates.INSTANCE.config.inventoryButtons.tooltipDelay) { - String command = button.command.trim(); - if (!command.startsWith("/")) { - command = "/" + command; - } + if (buttonHovered != button) { + buttonHoveredMillis = currentTime; + buttonHovered = button; + } - Utils.drawHoveringText( - Lists.newArrayList("\u00a77" + command), - event.mouseX, - event.mouseY, - event.gui.width, - event.gui.height, - -1, - Minecraft.getMinecraft().fontRendererObj - ); - } - } - } + if (currentTime - buttonHoveredMillis <= NotEnoughUpdates.INSTANCE.config.inventoryButtons.tooltipDelay) { + return; } - } + String command = button.command.trim(); + if (!command.startsWith("/")) { + command = "/" + command; + } + + Utils.drawHoveringText( + Lists.newArrayList("\u00a77" + command), + event.mouseX, + event.mouseY, + event.gui.width, + event.gui.height, + -1, + Minecraft.getMinecraft().fontRendererObj + ); + + }); } - if (!hoveringButton) buttonHovered = null; + if (!hoveringButton[0]) buttonHovered = null; if (AuctionBINWarning.getInstance().shouldShow()) { AuctionBINWarning.getInstance().render(); @@ -1107,85 +1030,28 @@ public class RenderListener { if (!doInventoryButtons) return; if (NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() && NotificationHandler.shouldRenderOverlay(event.gui) && Mouse.getEventButton() >= 0 && event.gui instanceof GuiContainer) { - int xSize = ((AccessorGuiContainer) event.gui).getXSize(); - int ySize = ((AccessorGuiContainer) event.gui).getYSize(); - int guiLeft = ((AccessorGuiContainer) event.gui).getGuiLeft(); - int guiTop = ((AccessorGuiContainer) event.gui).getGuiTop(); - if (!NEUApi.disableInventoryButtons) { - if (!EnchantingSolvers.disableButtons()) { - for (NEUConfig.InventoryButton button : NotEnoughUpdates.INSTANCE.config.hidden.inventoryButtons) { - if (!button.isActive()) continue; - if (button.playerInvOnly && !(event.gui instanceof GuiInventory)) continue; - - int x = guiLeft + button.x; - int y = guiTop + button.y; - if (button.anchorRight) { - x += xSize; - } - if (button.anchorBottom) { - y += ySize; - } - if (AccessoryBagOverlay.isInAccessoryBag()) { - if (x > guiLeft + xSize && x < guiLeft + xSize + 80 + 28 + 5 && y > guiTop - 18 && y < guiTop + 150) { - x += 80 + 28; - } - } - if (TrophyRewardOverlay.inTrophyFishingInventory()) { - int diffX = 162; - if (x > guiLeft + xSize && x < guiLeft + xSize + diffX + 5 && y > guiTop - 18 && y < guiTop + 120) { - x += diffX; - } - } - if (MinionHelperManager.getInstance().inCraftedMinionsInventory()) { - int diffX = 172; - if (x > guiLeft + xSize && x < guiLeft + xSize + diffX + 5 && y > guiTop - 18 && y < guiTop + 128) { - x += diffX; - } - } - if (AuctionProfit.inAuctionPage()) { - if (x + 18 > guiLeft + xSize && x + 18 < guiLeft + xSize + 4 + 28 + 20 && y > guiTop - 180 && - y < guiTop + 56) { - x -= 68 - 200; - } - } - if (EquipmentOverlay.isRenderingArmorHud()) { - if (x < guiLeft + xSize - 150 && x > guiLeft + xSize - 200 && y > guiTop && y < guiTop + 84) { - x -= 25; - } + Rectangle mouseRect = new Rectangle(mouseX, mouseY, 0, 0); + iterateButtons((GuiContainer) event.gui, (button, buttonPositon) -> { + if (!buttonPositon.intersects(mouseRect)) { + return; + } + if (Minecraft.getMinecraft().thePlayer.inventory.getItemStack() == null) { + int clickType = NotEnoughUpdates.INSTANCE.config.inventoryButtons.clickType; + if ((clickType == 0 && Mouse.getEventButtonState()) || + (clickType == 1 && !Mouse.getEventButtonState())) { + String command = button.command.trim(); + if (!command.startsWith("/")) { + command = "/" + command; } - if (EquipmentOverlay.isRenderingPetHud()) { - if (x < guiLeft + xSize - 150 && x > guiLeft + xSize - 200 && y > guiTop + 60 && y < guiTop + 120) { - x -= 25; - } - } - if (inDungeonPage || DungeonNpcProfitOverlay.isRendering()) { - if (x + 10 > guiLeft + xSize && x + 18 < guiLeft + xSize + 4 + 28 + 20 && y > guiTop - 180 && - y < guiTop + 100) { - x += 185; - } - } - - if (mouseX >= x && mouseX <= x + 18 && mouseY >= y && mouseY <= y + 18) { - if (Minecraft.getMinecraft().thePlayer.inventory.getItemStack() == null) { - int clickType = NotEnoughUpdates.INSTANCE.config.inventoryButtons.clickType; - if ((clickType == 0 && Mouse.getEventButtonState()) || - (clickType == 1 && !Mouse.getEventButtonState())) { - String command = button.command.trim(); - if (!command.startsWith("/")) { - command = "/" + command; - } - if (ClientCommandHandler.instance.executeCommand(Minecraft.getMinecraft().thePlayer, command) == 0) { - NotEnoughUpdates.INSTANCE.sendChatMessage(command); - } - } - } else { - event.setCanceled(true); - } - return; + if (ClientCommandHandler.instance.executeCommand(Minecraft.getMinecraft().thePlayer, command) == 0) { + NotEnoughUpdates.INSTANCE.sendChatMessage(command); } } + } else { + event.setCanceled(true); } - } + + }); } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AuctionProfit.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AuctionProfit.java index 82c392e4..894d48f8 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AuctionProfit.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AuctionProfit.java @@ -21,7 +21,9 @@ package io.github.moulberry.notenoughupdates.miscfeatures; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.core.util.StringUtils; +import io.github.moulberry.notenoughupdates.events.ButtonExclusionZoneEvent; import io.github.moulberry.notenoughupdates.mixins.AccessorGuiContainer; +import io.github.moulberry.notenoughupdates.util.Rectangle; import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; @@ -45,6 +47,20 @@ public class AuctionProfit { new ResourceLocation("notenoughupdates:auction_profit.png"); @SubscribeEvent + public void onButtonExclusionZones(ButtonExclusionZoneEvent event) { + if (inAuctionPage()) { + event.blockArea( + new Rectangle( + event.getGuiBaseRect().getRight(), + event.getGuiBaseRect().getTop(), + 128 /*width*/ + 4 /*space*/, 56 + ), + ButtonExclusionZoneEvent.PushDirection.TOWARDS_RIGHT + ); + } + } + + @SubscribeEvent public void onDrawBackground(GuiScreenEvent.BackgroundDrawnEvent event) { if (!inAuctionPage()) return; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DungeonNpcProfitOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DungeonNpcProfitOverlay.java index 34a40c2f..f32f89af 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DungeonNpcProfitOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DungeonNpcProfitOverlay.java @@ -23,8 +23,10 @@ import com.google.gson.JsonArray; import com.google.gson.JsonObject; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.core.util.StringUtils; +import io.github.moulberry.notenoughupdates.events.ButtonExclusionZoneEvent; import io.github.moulberry.notenoughupdates.mixins.AccessorGuiContainer; import io.github.moulberry.notenoughupdates.util.ItemUtils; +import io.github.moulberry.notenoughupdates.util.Rectangle; import io.github.moulberry.notenoughupdates.util.SBInfo; import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.client.Minecraft; @@ -98,6 +100,19 @@ public class DungeonNpcProfitOverlay { } @SubscribeEvent + public void onButtonExclusionZones(ButtonExclusionZoneEvent event) { + if (isRendering()) + event.blockArea( + new Rectangle( + event.getGuiBaseRect().getRight(), + event.getGuiBaseRect().getTop(), + 180 /*width*/ + 4 /*space*/, 101 + ), + ButtonExclusionZoneEvent.PushDirection.TOWARDS_RIGHT + ); + } + + @SubscribeEvent public void onDrawBackground(GuiScreenEvent.BackgroundDrawnEvent event) { if (!NotEnoughUpdates.INSTANCE.config.dungeons.croesusProfitOverlay || !(event.gui instanceof GuiChest)) { chestProfits = null; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/AccessoryBagOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/AccessoryBagOverlay.java index 530dcfd1..02f81f8f 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/AccessoryBagOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/AccessoryBagOverlay.java @@ -25,9 +25,11 @@ import com.google.gson.JsonObject; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.auction.APIManager; import io.github.moulberry.notenoughupdates.core.util.StringUtils; +import io.github.moulberry.notenoughupdates.events.ButtonExclusionZoneEvent; import io.github.moulberry.notenoughupdates.listener.RenderListener; import io.github.moulberry.notenoughupdates.profileviewer.PlayerStats; import io.github.moulberry.notenoughupdates.util.Constants; +import io.github.moulberry.notenoughupdates.util.Rectangle; import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Gui; @@ -45,6 +47,7 @@ import net.minecraft.nbt.CompressedStreamTools; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL14; @@ -73,6 +76,22 @@ public class AccessoryBagOverlay { private static final int TAB_MISSING = 4; private static final int TAB_OPTIMIZER = 5; + public static final AccessoryBagOverlay INSTANCE = new AccessoryBagOverlay(); + + @SubscribeEvent + public void onButtonExclusionZones(ButtonExclusionZoneEvent event) { + if (isInAccessoryBag()) { + event.blockArea( + new Rectangle( + event.getGuiBaseRect().getRight(), + event.getGuiBaseRect().getTop(), + 80 /*pane*/ + 24 /*tabs*/ + 4 /*space*/, 150 + ), + ButtonExclusionZoneEvent.PushDirection.TOWARDS_RIGHT + ); + } + } + private static final ItemStack[] TAB_STACKS = new ItemStack[]{ Utils.createItemStack(Items.dye, EnumChatFormatting.DARK_AQUA + "Basic Information", 10, EnumChatFormatting.GREEN + "- Talis count by rarity" @@ -576,15 +595,9 @@ public class AccessoryBagOverlay { int yIndex = 0; long currentTime = System.currentTimeMillis(); - int marqueeOffset = (int) (currentTime / 500 % 100); for (ItemStack missingStack : missing) { String s = missingStack.getDisplayName(); - //int marueeOffset - //if(s.length()) { - - //} - s = Minecraft.getMinecraft().fontRendererObj.trimStringToWidth(s, 70); String clean = StringUtils.cleanColourNotModifiers(s); @@ -1018,51 +1031,8 @@ public class AccessoryBagOverlay { } } - /*private static void renderAlignedString(String first, String second, float x, float y, int length) { - FontRenderer fontRendererObj = Minecraft.getMinecraft().fontRendererObj; - - if(fontRendererObj.getStringWidth(first + " " + second) >= length) { - for(int xOff=-2; xOff<=2; xOff++) { - for(int yOff=-2; yOff<=2; yOff++) { - if(Math.abs(xOff) != Math.abs(yOff)) { - Utils.drawStringCenteredScaledMaxWidth(Utils.cleanColourNotModifiers(first + " " + second), Minecraft.getMinecraft().fontRendererObj, - x+length/2f+xOff/2f, y+4+yOff/2f, false, length, - new Color(0, 0, 0, 200/Math.max(Math.abs(xOff), Math.abs(yOff))).getRGB()); - } - } - } - - GlStateManager.color(1, 1, 1, 1); - Utils.drawStringCenteredScaledMaxWidth(first + " " + second, Minecraft.getMinecraft().fontRendererObj, - x+length/2f, y+4, false, length, 4210752); - } else { - for(int xOff=-2; xOff<=2; xOff++) { - for(int yOff=-2; yOff<=2; yOff++) { - if(Math.abs(xOff) != Math.abs(yOff)) { - fontRendererObj.drawString(Utils.cleanColourNotModifiers(first), - x+xOff/2f, y+yOff/2f, - new Color(0, 0, 0, 200/Math.max(Math.abs(xOff), Math.abs(yOff))).getRGB(), false); - } - } - } - - int secondLen = fontRendererObj.getStringWidth(second); - GlStateManager.color(1, 1, 1, 1); - fontRendererObj.drawString(first, x, y, 4210752, false); - for(int xOff=-2; xOff<=2; xOff++) { - for(int yOff=-2; yOff<=2; yOff++) { - if(Math.abs(xOff) != Math.abs(yOff)) { - fontRendererObj.drawString(Utils.cleanColourNotModifiers(second), - x+length-secondLen+xOff/2f, y+yOff/2f, - new Color(0, 0, 0, 200/Math.max(Math.abs(xOff), Math.abs(yOff))).getRGB(), false); - } - } - } - - GlStateManager.color(1, 1, 1, 1); - fontRendererObj.drawString(second, x+length-secondLen, y, 4210752, false); - } - }*/ + + private static final HashMap<String, Pattern> STAT_PATTERN_MAP_BONUS = new HashMap<String, Pattern>() {{ String STAT_PATTERN_BONUS_END = ": (?:\\+|-)[0-9]+(?:\\.[0-9]+)?\\%? \\(((?:\\+|-)[0-9]+)%?"; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/TrophyRewardOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/TrophyRewardOverlay.java index 828e50b1..a14f0101 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/TrophyRewardOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/TrophyRewardOverlay.java @@ -22,9 +22,11 @@ package io.github.moulberry.notenoughupdates.miscgui; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; +import io.github.moulberry.notenoughupdates.events.ButtonExclusionZoneEvent; import io.github.moulberry.notenoughupdates.events.RepositoryReloadEvent; import io.github.moulberry.notenoughupdates.mixins.AccessorGuiContainer; import io.github.moulberry.notenoughupdates.util.Constants; +import io.github.moulberry.notenoughupdates.util.Rectangle; import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; @@ -95,6 +97,21 @@ public class TrophyRewardOverlay { return line.get(1); } + @SubscribeEvent + public void onButtonExclusionZones(ButtonExclusionZoneEvent event) { + if (inTrophyFishingInventory()) { + event.blockArea( + new Rectangle( + event.getGuiBaseRect().getRight(), + event.getGuiBaseRect().getTop(), + 168 /*width*/ + 4 /*space*/, + 128 + ), + ButtonExclusionZoneEvent.PushDirection.TOWARDS_RIGHT + ); + } + } + @SubscribeEvent(priority = EventPriority.LOWEST) public void onDrawBackground(GuiScreenEvent.BackgroundDrawnEvent event) { if (!inTrophyFishingInventory()) return; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/render/MinionHelperOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/render/MinionHelperOverlay.java index 33753d6c..6ba285df 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/render/MinionHelperOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/render/MinionHelperOverlay.java @@ -23,6 +23,7 @@ import com.google.common.collect.Lists; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.core.util.ArrowPagesUtils; import io.github.moulberry.notenoughupdates.core.util.StringUtils; +import io.github.moulberry.notenoughupdates.events.ButtonExclusionZoneEvent; import io.github.moulberry.notenoughupdates.miscgui.TrophyRewardOverlay; import io.github.moulberry.notenoughupdates.miscgui.minionhelper.Minion; import io.github.moulberry.notenoughupdates.miscgui.minionhelper.MinionHelperManager; @@ -31,6 +32,7 @@ import io.github.moulberry.notenoughupdates.miscgui.minionhelper.render.renderab import io.github.moulberry.notenoughupdates.mixins.AccessorGuiContainer; import io.github.moulberry.notenoughupdates.util.ItemUtils; import io.github.moulberry.notenoughupdates.util.NotificationHandler; +import io.github.moulberry.notenoughupdates.util.Rectangle; import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; @@ -91,6 +93,20 @@ public class MinionHelperOverlay { } @SubscribeEvent + public void onButtonExclusionZones(ButtonExclusionZoneEvent event) { + if (manager.inCraftedMinionsInventory() && NotEnoughUpdates.INSTANCE.config.minionHelper.gui) { + event.blockArea( + new Rectangle( + event.getGuiBaseRect().getRight(), + event.getGuiBaseRect().getTop(), + 168 /*width*/ |
