From 00c5d1604662af31bfbd3ed151764c414437b721 Mon Sep 17 00:00:00 2001 From: Jordan <77755681+Jordyrat@users.noreply.github.com> Date: Sat, 1 Jun 2024 11:11:05 +0100 Subject: Improvement: Compact Dicer Tracker (#1735) Co-authored-by: BuildTools Co-authored-by: Cal Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../features/garden/DicerRngDropTrackerConfig.java | 7 ++++ .../features/garden/farming/DicerRngDropTracker.kt | 48 +++++++++++++++++----- 2 files changed, 44 insertions(+), 11 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/garden/DicerRngDropTrackerConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/garden/DicerRngDropTrackerConfig.java index c8ce586c7..55dab6c74 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/garden/DicerRngDropTrackerConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/garden/DicerRngDropTrackerConfig.java @@ -6,6 +6,7 @@ import com.google.gson.annotations.Expose; import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean; import io.github.notenoughupdates.moulconfig.annotations.ConfigLink; import io.github.notenoughupdates.moulconfig.annotations.ConfigOption; +import io.github.notenoughupdates.moulconfig.observer.Property; public class DicerRngDropTrackerConfig { @Expose @@ -14,6 +15,12 @@ public class DicerRngDropTrackerConfig { @FeatureToggle public boolean display = true; + @Expose + @ConfigOption(name = "Compact Format", desc = "Compact the Dicer RNG Drop Tracker Display.") + @ConfigEditorBoolean + @FeatureToggle + public Property compact = Property.of(false); + @Expose @ConfigOption(name = "Hide Chat", desc = "Hide the chat message when dropping a RNG Dicer drop.") @ConfigEditorBoolean diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/DicerRngDropTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/DicerRngDropTracker.kt index f0d86d8e5..63b3e9615 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/DicerRngDropTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/DicerRngDropTracker.kt @@ -2,17 +2,19 @@ package at.hannibal2.skyhanni.features.garden.farming import at.hannibal2.skyhanni.config.ConfigManager import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator +import at.hannibal2.skyhanni.events.ConfigLoadEvent import at.hannibal2.skyhanni.events.GardenToolChangeEvent import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.features.garden.CropType import at.hannibal2.skyhanni.features.garden.GardenAPI -import at.hannibal2.skyhanni.utils.CollectionUtils.addAsSingletonList import at.hannibal2.skyhanni.utils.CollectionUtils.addOrPut import at.hannibal2.skyhanni.utils.CollectionUtils.sortedDesc +import at.hannibal2.skyhanni.utils.ConditionalUtils import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher +import at.hannibal2.skyhanni.utils.renderables.Renderable import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import at.hannibal2.skyhanni.utils.tracker.SkyHanniTracker import at.hannibal2.skyhanni.utils.tracker.TrackerData @@ -85,11 +87,11 @@ object DicerRngDropTracker { itemDrops.add(ItemDrop(CropType.PUMPKIN, DropRarity.PRAY_TO_RNGESUS, pumpkinRngesusDropPattern)) } - enum class DropRarity(val displayName: String) { - UNCOMMON("§a§lUNCOMMON DROP"), - RARE("§9§lRARE DROP"), - CRAZY_RARE("§d§lCRAZY RARE DROP"), - PRAY_TO_RNGESUS("§5§lPRAY TO RNGESUS DROP"), + enum class DropRarity(val colorCode: Char, val displayName: String) { + UNCOMMON('a', "UNCOMMON"), + RARE('9', "RARE"), + CRAZY_RARE('d', "CRAZY RARE"), + PRAY_TO_RNGESUS('5', "PRAY TO RNGESUS"), } @SubscribeEvent @@ -109,13 +111,37 @@ object DicerRngDropTracker { } } - private fun drawDisplay(data: Data) = buildList> { + @SubscribeEvent + fun onConfigLoad(event: ConfigLoadEvent) { + ConditionalUtils.onToggle(config.compact) { + tracker.update() + } + } + + private fun drawDisplay(data: Data) = buildList { val cropInHand = cropInHand ?: return@buildList val items = data.drops.getOrPut(cropInHand) { mutableMapOf() } - addAsSingletonList("§7Dicer RNG Drop Tracker for $toolName§7:") - for ((rarity, amount) in items.sortedDesc()) { - val displayName = rarity.displayName - addAsSingletonList(" §7- §e${amount.addSeparators()}x $displayName") + val list = mutableListOf() + val topLine = mutableListOf() + + topLine.add(Renderable.itemStack(cropInHand.icon)) + topLine.add(Renderable.string("§7Dicer Tracker:")) + add(listOf(Renderable.horizontalContainer(topLine))) + if (config.compact.get()) { + + val compactLine = items.sortedDesc().map { (rarity, amount) -> + "§${rarity.colorCode}${amount.addSeparators()}" + }.joinToString("§7/") + list.add(Renderable.string(compactLine)) + add(listOf(Renderable.verticalContainer(list))) + + } else { + for ((rarity, amount) in items.sortedDesc()) { + val colorCode = rarity.colorCode + val displayName = rarity.displayName + list.add(Renderable.string(" §7- §e${amount.addSeparators()}x §$colorCode$displayName")) + } + add(listOf(Renderable.verticalContainer(list))) } } -- cgit