From 623a5c380e466228b7c9d69217ae1766d1533645 Mon Sep 17 00:00:00 2001 From: Lulonaut Date: Wed, 31 May 2023 13:23:53 +0200 Subject: Only render active overlays in location editor (#694) only render overlays in location editor when they are enabled --- .../core/config/gui/GuiPositionEditor.java | 31 +++++++++++----------- .../miscfeatures/PetInfoOverlay.java | 7 ++++- .../notenoughupdates/options/NEUConfig.java | 8 ++---- .../overlays/BonemerangOverlay.java | 9 +++++-- .../overlays/CombatSkillOverlay.java | 9 +++++-- .../overlays/CrystalHollowOverlay.java | 9 +++++-- .../overlays/FarmingSkillOverlay.java | 9 +++++-- .../overlays/FishingSkillOverlay.java | 10 +++++-- .../notenoughupdates/overlays/FuelBarDummy.java | 11 ++++++-- .../notenoughupdates/overlays/MiningOverlay.java | 7 ++++- .../overlays/MiningSkillOverlay.java | 9 +++++-- .../overlays/PowderGrindingOverlay.java | 9 +++++-- .../notenoughupdates/overlays/SlayerOverlay.java | 9 +++++-- .../notenoughupdates/overlays/TextOverlay.java | 8 +++--- .../notenoughupdates/overlays/TimersOverlay.java | 7 ++++- 15 files changed, 107 insertions(+), 45 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiPositionEditor.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiPositionEditor.java index c7dced22..055ff8e5 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiPositionEditor.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiPositionEditor.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 NotEnoughUpdates contributors + * Copyright (C) 2022-2023 NotEnoughUpdates contributors * * This file is part of NotEnoughUpdates. * @@ -35,13 +35,14 @@ import org.lwjgl.input.Mouse; import java.io.IOException; import java.util.ArrayList; import java.util.LinkedHashMap; +import java.util.function.Supplier; public class GuiPositionEditor extends GuiScreen { private final ArrayList positions; private final ArrayList originalPositions; private final ArrayList elementWidths; private final ArrayList elementHeights; - private final ArrayList renderCallback; + private final ArrayList> shouldRenderSupplier; private final Runnable positionChangedCallback; private final Runnable closedCallback; private int grabbedX = 0; @@ -53,13 +54,12 @@ public class GuiPositionEditor extends GuiScreen { public GuiPositionEditor( LinkedHashMap overlayPositions, - Runnable renderCallback, Runnable positionChangedCallback, Runnable closedCallback ) { + shouldRenderSupplier = new ArrayList<>(); ArrayList pos = new ArrayList<>(); ArrayList ogPos = new ArrayList<>(); - ArrayList renderCallbac = new ArrayList<>(); ArrayList width = new ArrayList<>(); ArrayList height = new ArrayList<>(); for (int i = 0; i < overlayPositions.size(); i++) { @@ -68,18 +68,19 @@ public class GuiPositionEditor extends GuiScreen { ogPos.add(pos.get(i).clone()); width.add((int) overlay.getDummySize().x); height.add((int) overlay.getDummySize().y); - renderCallbac.add(() -> { - if (overlay.shouldRenderInGuiEditor) { + shouldRenderSupplier.add(() -> { + if (overlay.isEnabled()) { overlay.renderDummy(); OverlayManager.dontRenderOverlay.add(overlay.getClass()); + return true; } + return false; }); } this.positions = pos; this.originalPositions = ogPos; - this.renderCallback = renderCallbac; this.elementWidths = width; this.elementHeights = height; this.positionChangedCallback = positionChangedCallback; @@ -119,6 +120,9 @@ public class GuiPositionEditor extends GuiScreen { drawDefaultBackground(); renderDrill = true; for (Position position : positions) { + if (!shouldRenderSupplier.get(positions.indexOf(position)).get()) { + continue; + } int elementHeight = elementHeights.get(positions.indexOf(position)); int elementWidth = elementWidths.get(positions.indexOf(position)); if (position.getClicked()) { @@ -126,21 +130,18 @@ public class GuiPositionEditor extends GuiScreen { grabbedY += position.moveY(mouseY - grabbedY, elementHeight, scaledResolution); } - renderCallback.get(positions.indexOf(position)).run(); - int x = position.getAbsX(scaledResolution, elementWidth); int y = position.getAbsY(scaledResolution, elementHeight); if (position.isCenterX()) x -= elementWidth / 2; if (position.isCenterY()) y -= elementHeight / 2; Gui.drawRect(x, y, x + elementWidth, y + elementHeight, 0x80404040); - - Utils.drawStringCentered("Position Editor", scaledResolution.getScaledWidth() / 2, 8, true, 0xffffff); - Utils.drawStringCentered( - "R to Reset - Arrow keys/mouse to move", - scaledResolution.getScaledWidth() / 2, 18, true, 0xffffff - ); } + Utils.drawStringCentered("Position Editor", scaledResolution.getScaledWidth() / 2, 8, true, 0xffffff); + Utils.drawStringCentered( + "R to Reset - Arrow keys/mouse to move", + scaledResolution.getScaledWidth() / 2, 18, true, 0xffffff + ); GlStateManager.popMatrix(); } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java index ceae782b..693bb3e3 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 NotEnoughUpdates contributors + * Copyright (C) 2022-2023 NotEnoughUpdates contributors * * This file is part of NotEnoughUpdates. * @@ -648,6 +648,11 @@ public class PetInfoOverlay extends TextOverlay { }}; } + @Override + public boolean isEnabled() { + return NotEnoughUpdates.INSTANCE.config.petOverlay.enablePetInfo; + } + public void update() { if (!NotEnoughUpdates.INSTANCE.config.petOverlay.enablePetInfo && !NotEnoughUpdates.INSTANCE.config.itemOverlays.enableMonkeyCheck) { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java b/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java index b5411dcd..ed98fe45 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 NotEnoughUpdates contributors + * Copyright (C) 2022-2023 NotEnoughUpdates contributors * * This file is part of NotEnoughUpdates. * @@ -67,7 +67,6 @@ import io.github.moulberry.notenoughupdates.options.seperateSections.Toolbar; import io.github.moulberry.notenoughupdates.options.seperateSections.TooltipTweaks; import io.github.moulberry.notenoughupdates.options.seperateSections.TradeMenu; import io.github.moulberry.notenoughupdates.options.seperateSections.WardrobeKeybinds; -import io.github.moulberry.notenoughupdates.options.seperateSections.WorldConfig; import io.github.moulberry.notenoughupdates.overlays.MiningOverlay; import io.github.moulberry.notenoughupdates.overlays.OverlayManager; import io.github.moulberry.notenoughupdates.overlays.TextOverlay; @@ -94,10 +93,7 @@ public class NEUConfig extends Config { } GuiScreen savedGui = Minecraft.getMinecraft().currentScreen; Minecraft.getMinecraft().displayGuiScreen(new GuiPositionEditor(overlayPositions, () -> { - }, () -> { - }, () -> { - NotEnoughUpdates.INSTANCE.openGui = savedGui; - })); + }, () -> NotEnoughUpdates.INSTANCE.openGui = savedGui)); } @Override diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/BonemerangOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/BonemerangOverlay.java index e8447699..31af7bfd 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/BonemerangOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/BonemerangOverlay.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 NotEnoughUpdates contributors + * Copyright (C) 2022-2023 NotEnoughUpdates contributors * * This file is part of NotEnoughUpdates. * @@ -54,6 +54,11 @@ public class BonemerangOverlay extends TextOverlay { public final Set bonemeragedEntities = new HashSet<>(); + @Override + public boolean isEnabled() { + return NotEnoughUpdates.INSTANCE.config.itemOverlays.enableBonemerangOverlay; + } + @Override public void updateFrequent() { if (NotEnoughUpdates.INSTANCE.config.itemOverlays.bonemerangFastUpdate) { @@ -69,7 +74,7 @@ public class BonemerangOverlay extends TextOverlay { } private void updateOverlay() { - if (!NotEnoughUpdates.INSTANCE.config.itemOverlays.enableBonemerangOverlay && + if (!isEnabled() && NotEnoughUpdates.INSTANCE.config.itemOverlays.highlightTargeted) { overlayStrings = null; return; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/CombatSkillOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/CombatSkillOverlay.java index 3bd5150f..26704f47 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/CombatSkillOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/CombatSkillOverlay.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 NotEnoughUpdates contributors + * Copyright (C) 2022-2023 NotEnoughUpdates contributors * * This file is part of NotEnoughUpdates. * @@ -78,9 +78,14 @@ public class CombatSkillOverlay return interp; } + @Override + public boolean isEnabled() { + return NotEnoughUpdates.INSTANCE.config.skillOverlays.combatSkillOverlay; + } + @Override public void update() { - if (!NotEnoughUpdates.INSTANCE.config.skillOverlays.combatSkillOverlay) { + if (!isEnabled()) { kill = -1; championXp = -1; overlayStrings = null; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/CrystalHollowOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/CrystalHollowOverlay.java index aae5d028..852a2742 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/CrystalHollowOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/CrystalHollowOverlay.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 NotEnoughUpdates contributors + * Copyright (C) 2022-2023 NotEnoughUpdates contributors * * This file is part of NotEnoughUpdates. * @@ -128,10 +128,15 @@ public class CrystalHollowOverlay extends TextOverlay { } } + @Override + public boolean isEnabled() { + return NotEnoughUpdates.INSTANCE.config.mining.crystalHollowOverlay; + } + @Override public void update() { overlayStrings = null; - if (!NotEnoughUpdates.INSTANCE.config.mining.crystalHollowOverlay || SBInfo.getInstance().getLocation() == null || + if (!isEnabled() || SBInfo.getInstance().getLocation() == null || !SBInfo.getInstance().getLocation().equals("crystal_hollows")) return; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/FarmingSkillOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/FarmingSkillOverlay.java index 30102df0..f1cc060a 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/FarmingSkillOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/FarmingSkillOverlay.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 NotEnoughUpdates contributors + * Copyright (C) 2022-2023 NotEnoughUpdates contributors * * This file is part of NotEnoughUpdates. * @@ -131,9 +131,14 @@ public class FarmingSkillOverlay extends TextOverlay { //Needed due to farming fortune causing inconsistent amounts of crops each block break private static ArrayList cropsOverLastXSeconds = new ArrayList<>(); + @Override + public boolean isEnabled() { + return NotEnoughUpdates.INSTANCE.config.skillOverlays.farmingOverlay; + } + @Override public void update() { - if (!NotEnoughUpdates.INSTANCE.config.skillOverlays.farmingOverlay) { + if (!isEnabled()) { counter = -1; overlayStrings = null; return; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/FishingSkillOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/FishingSkillOverlay.java index b1143042..3a4ea544 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/FishingSkillOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/FishingSkillOverlay.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 NotEnoughUpdates contributors + * Copyright (C) 2022-2023 NotEnoughUpdates contributors * * This file is part of NotEnoughUpdates. * @@ -85,9 +85,15 @@ public class FishingSkillOverlay return interp; } + @Override + public boolean isEnabled() { + // NopoTheGamer named this variable + return NotEnoughUpdates.INSTANCE.config.skillOverlays.FishingSkillOverlay; + } + @Override public void update() { - if (!NotEnoughUpdates.INSTANCE.config.skillOverlays.FishingSkillOverlay) { + if (!isEnabled()) { expertise = -1; overlayStrings = null; return; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/FuelBarDummy.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/FuelBarDummy.java index f1cf4878..d0ca5d1d 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/FuelBarDummy.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/FuelBarDummy.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 NotEnoughUpdates contributors + * Copyright (C) 2022-2023 NotEnoughUpdates contributors * * This file is part of NotEnoughUpdates. * @@ -21,6 +21,7 @@ package io.github.moulberry.notenoughupdates.overlays; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.core.config.Position; +import io.github.moulberry.notenoughupdates.core.config.gui.GuiPositionEditor; import org.lwjgl.util.vector.Vector2f; import java.util.List; @@ -33,13 +34,19 @@ public class FuelBarDummy extends TextOverlay { Supplier styleSupplier ) { super(position, dummyStrings, styleSupplier); - super.shouldRenderInGuiEditor = false; + } + + @Override + public boolean isEnabled() { + GuiPositionEditor.renderDrill = NotEnoughUpdates.INSTANCE.config.mining.drillFuelBar; + return NotEnoughUpdates.INSTANCE.config.mining.drillFuelBar; } @Override public void update() { } + @Override public Vector2f getDummySize() { return new Vector2f(NotEnoughUpdates.INSTANCE.config.mining.drillFuelBarWidth, 12); 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 db1a7755..3492c8c4 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/MiningOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/MiningOverlay.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 NotEnoughUpdates contributors + * Copyright (C) 2022-2023 NotEnoughUpdates contributors * * This file is part of NotEnoughUpdates. * @@ -232,6 +232,11 @@ public class MiningOverlay extends TextTabOverlay { private static final Pattern forgesHeaderPattern = Pattern.compile( "\\xa7r\\xa79\\xa7lForges \\xa7r(?:\\xa7f\\(\\+1 more\\)\\xa7r)?"); + @Override + public boolean isEnabled() { + return NotEnoughUpdates.INSTANCE.config.mining.dwarvenOverlay; + } + @Override public void update() { overlayStrings = null; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/MiningSkillOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/MiningSkillOverlay.java index 4422e3ad..68de64a7 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/MiningSkillOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/MiningSkillOverlay.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 NotEnoughUpdates contributors + * Copyright (C) 2022-2023 NotEnoughUpdates contributors * * This file is part of NotEnoughUpdates. * @@ -78,9 +78,14 @@ public class MiningSkillOverlay return interp; } + @Override + public boolean isEnabled() { + return NotEnoughUpdates.INSTANCE.config.skillOverlays.miningSkillOverlay; + } + @Override public void update() { - if (!NotEnoughUpdates.INSTANCE.config.skillOverlays.miningSkillOverlay) { + if (!isEnabled()) { compact = -1; overlayStrings = null; return; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/PowderGrindingOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/PowderGrindingOverlay.java index 68a0e1f0..ee48b105 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/PowderGrindingOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/PowderGrindingOverlay.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 NotEnoughUpdates contributors + * Copyright (C) 2022-2023 NotEnoughUpdates contributors * * This file is part of NotEnoughUpdates. * @@ -76,9 +76,14 @@ public class PowderGrindingOverlay extends TextTabOverlay { return interp; } + @Override + public boolean isEnabled() { + return NotEnoughUpdates.INSTANCE.config.mining.powderGrindingTrackerEnabled; + } + @Override public void update() { - if (NotEnoughUpdates.INSTANCE.config.mining.powderGrindingTrackerEnabled) { + if (isEnabled()) { lastUpdate = System.currentTimeMillis(); lastMithrilPowderFound = this.mithrilPowderFound; lastMithrilPowderAverage = this.openedChestCount > 0 ? diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/SlayerOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/SlayerOverlay.java index acc9be82..8cc92551 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/SlayerOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/SlayerOverlay.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 NotEnoughUpdates contributors + * Copyright (C) 2022-2023 NotEnoughUpdates contributors * * This file is part of NotEnoughUpdates. * @@ -105,10 +105,15 @@ public class SlayerOverlay extends TextOverlay { return true; } + @Override + public boolean isEnabled() { + return NotEnoughUpdates.INSTANCE.config.slayerOverlay.slayerOverlay; + } + @Override public void update() { shouldUpdate = shouldUpdate(); - if (!NotEnoughUpdates.INSTANCE.config.slayerOverlay.slayerOverlay || !shouldUpdate) { + if (!isEnabled() || !shouldUpdate) { overlayStrings = null; return; } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/TextOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/TextOverlay.java index 28a6bcaa..cefb6929 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/TextOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/TextOverlay.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 NotEnoughUpdates contributors + * Copyright (C) 2022-2023 NotEnoughUpdates contributors * * This file is part of NotEnoughUpdates. * @@ -44,8 +44,6 @@ public abstract class TextOverlay { public boolean shouldUpdateFrequent = false; - public boolean shouldRenderInGuiEditor = true; - private static final int PADDING_X = 5; private static final int PADDING_Y = 5; @@ -68,6 +66,10 @@ public abstract class TextOverlay { return new Vector2f(100, 50); } + public boolean isEnabled() { + return true; + } + public void tick() { 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 1d7126a2..b8f1f6a3 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/TimersOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/TimersOverlay.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 NotEnoughUpdates contributors + * Copyright (C) 2022-2023 NotEnoughUpdates contributors * * This file is part of NotEnoughUpdates. * @@ -243,6 +243,11 @@ public class TimersOverlay extends TextTabOverlay { boolean hasErrorMessage = false; + @Override + public boolean isEnabled() { + return NotEnoughUpdates.INSTANCE.config.miscOverlays.todoOverlay2; + } + @Override public void update() { -- cgit