From 6847a0a5f30fa1d88082f96702ee1760638e1a4e Mon Sep 17 00:00:00 2001 From: Empa <42304516+ItsEmpa@users.noreply.github.com> Date: Tue, 23 Apr 2024 23:20:43 +0200 Subject: Improvement: Infested Plots Display Customization (#1369) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../features/garden/pests/PestFinderConfig.java | 27 +++++++++++++ .../skyhanni/features/garden/pests/PestFinder.kt | 47 ++++++++++++++++------ 2 files changed, 62 insertions(+), 12 deletions(-) (limited to 'src/main') diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/garden/pests/PestFinderConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/garden/pests/PestFinderConfig.java index c6ccfc3e9..ae2819317 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/garden/pests/PestFinderConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/garden/pests/PestFinderConfig.java @@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.config.FeatureToggle; import at.hannibal2.skyhanni.config.core.config.Position; import com.google.gson.annotations.Expose; import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean; +import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorDropdown; import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorKeybind; import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorSlider; import io.github.notenoughupdates.moulconfig.annotations.ConfigLink; @@ -30,6 +31,32 @@ public class PestFinderConfig { @FeatureToggle public boolean showPlotInWorld = true; + @Expose + @ConfigOption( + name = "Plot Visibility Type", + desc = "Choose how to show infested plots in the world." + ) + @ConfigEditorDropdown + public VisibilityType visibilityType = VisibilityType.BOTH; + + public enum VisibilityType { + BORDER("Border"), + NAME("Name"), + BOTH("Both"), + ; + + private final String str; + + VisibilityType(String str) { + this.str = str; + } + + @Override + public String toString() { + return str; + } + } + @Expose @ConfigOption( name = "Only With Vacuum", diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestFinder.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestFinder.kt index 9217f5eb6..289994862 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestFinder.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestFinder.kt @@ -1,5 +1,6 @@ package at.hannibal2.skyhanni.features.garden.pests +import at.hannibal2.skyhanni.config.features.garden.pests.PestFinderConfig.VisibilityType import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.IslandChangeEvent import at.hannibal2.skyhanni.events.ItemInHandChangeEvent @@ -7,6 +8,7 @@ import at.hannibal2.skyhanni.events.LorenzKeyPressEvent import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent import at.hannibal2.skyhanni.events.garden.pests.PestUpdateEvent import at.hannibal2.skyhanni.features.garden.GardenAPI +import at.hannibal2.skyhanni.features.garden.GardenPlotAPI import at.hannibal2.skyhanni.features.garden.GardenPlotAPI.isPestCountInaccurate import at.hannibal2.skyhanni.features.garden.GardenPlotAPI.isPlayerInside import at.hannibal2.skyhanni.features.garden.GardenPlotAPI.name @@ -16,6 +18,7 @@ import at.hannibal2.skyhanni.features.garden.GardenPlotAPI.sendTeleportTo import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.LorenzColor +import at.hannibal2.skyhanni.utils.LorenzVec import at.hannibal2.skyhanni.utils.NEUItems import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText import at.hannibal2.skyhanni.utils.RenderUtils.exactPlayerEyeLocation @@ -111,25 +114,45 @@ class PestFinder { if (config.onlyWithVacuum && !PestAPI.hasVacuumInHand() && (lastTimeVacuumHold.passedSince() > config.showBorderForSeconds.seconds)) return val playerLocation = event.exactPlayerEyeLocation() + val visibility = config.visibilityType + val showBorder = visibility == VisibilityType.BOTH || visibility == VisibilityType.BORDER + val showName = visibility == VisibilityType.BOTH || visibility == VisibilityType.NAME for (plot in PestAPI.getInfestedPlots()) { if (plot.isPlayerInside()) { - event.renderPlot(plot, LorenzColor.RED.toColor(), LorenzColor.DARK_RED.toColor()) + if (showBorder) { + event.renderPlot(plot, LorenzColor.RED.toColor(), LorenzColor.DARK_RED.toColor()) + } continue } - event.renderPlot(plot, LorenzColor.GOLD.toColor(), LorenzColor.RED.toColor()) - - val pests = plot.pests - val pestsName = StringUtils.pluralize(pests, "pest") - val plotName = plot.name - val middle = plot.middle - val isInaccurate = plot.isPestCountInaccurate - val location = playerLocation.copy(x = middle.x, z = middle.z) - event.drawWaypointFilled(location, LorenzColor.RED.toColor()) - val text = "§e" + (if (isInaccurate) "?" else pests) + " §c$pestsName §7in §b$plotName" - event.drawDynamicText(location, text, 1.5) + if (showBorder) { + event.renderPlot(plot, LorenzColor.GOLD.toColor(), LorenzColor.RED.toColor()) + } + if (showName) { + drawName(plot, playerLocation, event) + } } } + private fun drawName( + plot: GardenPlotAPI.Plot, + playerLocation: LorenzVec, + event: LorenzRenderWorldEvent, + ) { + val pests = plot.pests + val pestsName = StringUtils.pluralize(pests, "pest") + val plotName = plot.name + val middle = plot.middle + val isInaccurate = plot.isPestCountInaccurate + val location = playerLocation.copy(x = middle.x, z = middle.z) + event.drawWaypointFilled(location, LorenzColor.RED.toColor()) + val text = "§e" + (if (isInaccurate) "?" else + pests + ) + " §c$pestsName §7in §b$plotName" + event.drawDynamicText( + location, text, 1.5 + ) + } + private var lastKeyPress = SimpleTimeMark.farPast() @SubscribeEvent -- cgit