diff options
author | Lulonaut <lulonaut@tutanota.de> | 2023-05-31 13:23:53 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-31 13:23:53 +0200 |
commit | 623a5c380e466228b7c9d69217ae1766d1533645 (patch) | |
tree | bfd1cbffffa5a66b348c5d54e17fbd52f975ef27 | |
parent | 744e7692843c65049e45f666973e1e37adcc7e9a (diff) | |
download | NotEnoughUpdates-623a5c380e466228b7c9d69217ae1766d1533645.tar.gz NotEnoughUpdates-623a5c380e466228b7c9d69217ae1766d1533645.tar.bz2 NotEnoughUpdates-623a5c380e466228b7c9d69217ae1766d1533645.zip |
Only render active overlays in location editor (#694)
only render overlays in location editor when they are enabled
15 files changed, 107 insertions, 45 deletions
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<Position> positions; private final ArrayList<Position> originalPositions; private final ArrayList<Integer> elementWidths; private final ArrayList<Integer> elementHeights; - private final ArrayList<Runnable> renderCallback; + private final ArrayList<Supplier<Boolean>> 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<TextOverlay, Position> overlayPositions, - Runnable renderCallback, Runnable positionChangedCallback, Runnable closedCallback ) { + shouldRenderSupplier = new ArrayList<>(); ArrayList<Position> pos = new ArrayList<>(); ArrayList<Position> ogPos = new ArrayList<>(); - ArrayList<Runnable> renderCallbac = new ArrayList<>(); ArrayList<Integer> width = new ArrayList<>(); ArrayList<Integer> 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. * @@ -55,6 +55,11 @@ public class BonemerangOverlay extends TextOverlay { public final Set<EntityLivingBase> bonemeragedEntities = new HashSet<>(); @Override + public boolean isEnabled() { + return NotEnoughUpdates.INSTANCE.config.itemOverlays.enableBonemerangOverlay; + } + + @Override public void updateFrequent() { if (NotEnoughUpdates.INSTANCE.config.itemOverlays.bonemerangFastUpdate) { updateOverlay(); @@ -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. * @@ -79,8 +79,13 @@ public class CombatSkillOverlay } @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. * @@ -129,9 +129,14 @@ 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. * @@ -132,8 +132,13 @@ public class FarmingSkillOverlay extends TextOverlay { private static ArrayList<Float> 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. * @@ -86,8 +86,14 @@ public class FishingSkillOverlay } @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<TextOverlayStyle> 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. * @@ -233,6 +233,11 @@ public class MiningOverlay extends TextTabOverlay { "\\xa7r\\xa79\\xa7lForges \\xa7r(?:\\xa7f\\(\\+1 more\\)\\xa7r)?"); @Override + public boolean isEnabled() { + return NotEnoughUpdates.INSTANCE.config.mining.dwarvenOverlay; + } + + @Override public void update() { overlayStrings = null; NEUConfig.HiddenProfileSpecific profileConfig = NotEnoughUpdates.INSTANCE.config.getProfileSpecific(); 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. * @@ -79,8 +79,13 @@ public class MiningSkillOverlay } @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. * @@ -77,8 +77,13 @@ public class PowderGrindingOverlay extends TextTabOverlay { } @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. * @@ -106,9 +106,14 @@ public class SlayerOverlay extends TextOverlay { } @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. * @@ -244,6 +244,11 @@ public class TimersOverlay extends TextTabOverlay { boolean hasErrorMessage = false; @Override + public boolean isEnabled() { + return NotEnoughUpdates.INSTANCE.config.miscOverlays.todoOverlay2; + } + + @Override public void update() { long currentTime = System.currentTimeMillis(); |