From f518f70869961dc32112e6a7ef6192e6a8ca4db7 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Wed, 7 Sep 2022 09:30:30 +0200 Subject: todo and forge with tab (#255) --- .../listener/NEUEventListener.java | 16 ++++++-- .../options/seperateSections/Mining.java | 10 +++++ .../options/seperateSections/MiscOverlays.java | 9 +++++ .../notenoughupdates/overlays/MiningOverlay.java | 17 +++++--- .../notenoughupdates/overlays/TextTabOverlay.java | 47 ++++++++++++++++++++++ .../notenoughupdates/overlays/TimersOverlay.java | 9 ++++- 6 files changed, 97 insertions(+), 11 deletions(-) create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/overlays/TextTabOverlay.java diff --git a/src/main/java/io/github/moulberry/notenoughupdates/listener/NEUEventListener.java b/src/main/java/io/github/moulberry/notenoughupdates/listener/NEUEventListener.java index 041da446..305135fc 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/listener/NEUEventListener.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/listener/NEUEventListener.java @@ -19,7 +19,6 @@ package io.github.moulberry.notenoughupdates.listener; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.gson.JsonObject; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; @@ -38,6 +37,7 @@ import io.github.moulberry.notenoughupdates.miscgui.GuiCustomEnchant; import io.github.moulberry.notenoughupdates.miscgui.StorageOverlay; import io.github.moulberry.notenoughupdates.overlays.OverlayManager; import io.github.moulberry.notenoughupdates.overlays.TextOverlay; +import io.github.moulberry.notenoughupdates.overlays.TextTabOverlay; import io.github.moulberry.notenoughupdates.util.Constants; import io.github.moulberry.notenoughupdates.util.NotificationHandler; import io.github.moulberry.notenoughupdates.util.ProfileApiSyncer; @@ -45,7 +45,6 @@ import io.github.moulberry.notenoughupdates.util.SBInfo; import io.github.moulberry.notenoughupdates.util.Utils; import io.github.moulberry.notenoughupdates.util.XPInformation; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.inventory.GuiChest; import net.minecraft.event.ClickEvent; import net.minecraft.init.Items; @@ -58,9 +57,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; import org.lwjgl.input.Keyboard; -import java.io.File; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; @@ -149,6 +146,17 @@ public class NEUEventListener { } } + //MiningOverlay and TimersOverlay need real tick speed + if (neu.hasSkyblockScoreboard()) { + for (TextOverlay overlay : OverlayManager.textOverlays) { + if (overlay instanceof TextTabOverlay) { + TextTabOverlay skillOverlay = (TextTabOverlay) overlay; + skillOverlay.realTick(); + } + } + } + + if (longUpdate) { CrystalOverlay.tick(); FairySouls.getInstance().tick(); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Mining.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Mining.java index 2f31261d..727ad329 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Mining.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Mining.java @@ -207,6 +207,16 @@ public class Mining { @ConfigAccordionId(id = 2) public int forgeDisplayEnabledLocations = 0; + @Expose + @ConfigOption( + name = "Forge Tab", + desc = "Only show the forge display when tab list is open\n" + + "\u00A7cThis only works outside of Dwarven Caves!" + ) + @ConfigEditorBoolean + @ConfigAccordionId(id = 2) + public boolean forgeDisplayOnlyShowTab = false; + @ConfigOption( name = "Metal Detector Solver", desc = "" diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/MiscOverlays.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/MiscOverlays.java index d2bfdbd9..18b89733 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/MiscOverlays.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/MiscOverlays.java @@ -50,6 +50,15 @@ public class MiscOverlays { @ConfigAccordionId(id = 0) public boolean todoOverlay2 = false; + @Expose + @ConfigOption( + name = "Todo Overlay Tab", + desc = "Only show the todo overlay when tab list is open" + ) + @ConfigEditorBoolean + @ConfigAccordionId(id = 0) + public boolean todoOverlayOnlyShowTab = false; + @Expose @ConfigOption( name = "Todo Text", diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/MiningOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/MiningOverlay.java index 5dda0d85..d24f005d 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/MiningOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/MiningOverlay.java @@ -43,6 +43,7 @@ import net.minecraft.util.EnumChatFormatting; import net.minecraft.world.WorldSettings; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; +import org.lwjgl.input.Keyboard; import org.lwjgl.util.vector.Vector2f; import java.util.ArrayList; @@ -64,7 +65,7 @@ import static net.minecraft.util.EnumChatFormatting.RED; import static net.minecraft.util.EnumChatFormatting.RESET; import static net.minecraft.util.EnumChatFormatting.YELLOW; -public class MiningOverlay extends TextOverlay { +public class MiningOverlay extends TextTabOverlay { public MiningOverlay( Position position, Supplier> dummyStrings, @@ -440,11 +441,15 @@ public class MiningOverlay extends TextOverlay { } if (forgeDisplay) { overlayStrings = new ArrayList<>(); - if (NotEnoughUpdates.INSTANCE.config.mining.forgeDisplayEnabledLocations == 1 && - !SBInfo.getInstance().isInDungeon) { - overlayStrings.addAll(getForgeStrings(profileConfig.forgeItems)); - } else if (NotEnoughUpdates.INSTANCE.config.mining.forgeDisplayEnabledLocations == 2) { - overlayStrings.addAll(getForgeStrings(profileConfig.forgeItems)); + + if (!NotEnoughUpdates.INSTANCE.config.mining.forgeDisplayOnlyShowTab || + Keyboard.isKeyDown(Minecraft.getMinecraft().gameSettings.keyBindPlayerList.getKeyCode())) { + if (NotEnoughUpdates.INSTANCE.config.mining.forgeDisplayEnabledLocations == 1 && + !SBInfo.getInstance().isInDungeon) { + overlayStrings.addAll(getForgeStrings(profileConfig.forgeItems)); + } else if (NotEnoughUpdates.INSTANCE.config.mining.forgeDisplayEnabledLocations == 2) { + overlayStrings.addAll(getForgeStrings(profileConfig.forgeItems)); + } } } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/TextTabOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/TextTabOverlay.java new file mode 100644 index 00000000..69a0cd00 --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/TextTabOverlay.java @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2022 NotEnoughUpdates contributors + * + * This file is part of NotEnoughUpdates. + * + * NotEnoughUpdates is free software: you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation, either + * version 3 of the License, or (at your option) any later version. + * + * NotEnoughUpdates is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with NotEnoughUpdates. If not, see . + */ + +package io.github.moulberry.notenoughupdates.overlays; + +import io.github.moulberry.notenoughupdates.core.config.Position; +import net.minecraft.client.Minecraft; +import org.lwjgl.input.Keyboard; + +import java.util.List; +import java.util.function.Supplier; + +public abstract class TextTabOverlay extends TextOverlay { + public TextTabOverlay( + Position position, + Supplier> dummyStrings, + Supplier styleSupplier + ) { + super(position, dummyStrings, styleSupplier); + } + + private boolean lastTabState = false; + + public void realTick() { + boolean currentTabState = Keyboard.isKeyDown(Minecraft.getMinecraft().gameSettings.keyBindPlayerList.getKeyCode()); + if (lastTabState != currentTabState) { + lastTabState = currentTabState; + update(); + } + } +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/TimersOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/TimersOverlay.java index d5d8afd7..86df47ff 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/TimersOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/TimersOverlay.java @@ -37,6 +37,7 @@ import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.client.event.ClientChatReceivedEvent; import net.minecraftforge.fml.common.eventhandler.EventPriority; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import org.lwjgl.input.Keyboard; import org.lwjgl.util.vector.Vector2f; import java.time.ZoneId; @@ -50,7 +51,7 @@ import java.util.regex.Pattern; import static net.minecraft.util.EnumChatFormatting.DARK_AQUA; -public class TimersOverlay extends TextOverlay { +public class TimersOverlay extends TextTabOverlay { private static final Pattern PATTERN_ACTIVE_EFFECTS = Pattern.compile( "\u00a7r\u00a7r\u00a77You have a \u00a7r\u00a7cGod Potion \u00a7r\u00a77active! \u00a7r\u00a7d([0-9]*?:?[0-9]*?:?[0-9]*)\u00a7r"); @@ -234,6 +235,12 @@ public class TimersOverlay extends TextOverlay { NEUConfig.HiddenProfileSpecific hidden = NotEnoughUpdates.INSTANCE.config.getProfileSpecific(); if (hidden == null) return; + if (NotEnoughUpdates.INSTANCE.config.miscOverlays.todoOverlayOnlyShowTab && + !Keyboard.isKeyDown(Minecraft.getMinecraft().gameSettings.keyBindPlayerList.getKeyCode())) { + overlayStrings = null; + return; + } + if (Minecraft.getMinecraft().currentScreen instanceof GuiChest) { GuiChest chest = (GuiChest) Minecraft.getMinecraft().currentScreen; ContainerChest container = (ContainerChest) chest.inventorySlots; -- cgit