From ffbb693db7921a2d145c545833a98248e4623bf4 Mon Sep 17 00:00:00 2001 From: Mikecraft1224 <85994411+Mikecraft1224@users.noreply.github.com> Date: Sat, 10 Feb 2024 19:55:50 +0100 Subject: Hovering on cheap items in an Item Tracker now shows the cheap hidden items. #993 --- .../skyhanni/utils/tracker/ItemTrackerData.kt | 3 -- .../skyhanni/utils/tracker/SkyHanniItemTracker.kt | 56 ++++++++++++---------- 2 files changed, 31 insertions(+), 28 deletions(-) (limited to 'src/main/java/at/hannibal2/skyhanni/utils') diff --git a/src/main/java/at/hannibal2/skyhanni/utils/tracker/ItemTrackerData.kt b/src/main/java/at/hannibal2/skyhanni/utils/tracker/ItemTrackerData.kt index 8aeec5f32..5fa12dbb6 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/tracker/ItemTrackerData.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/tracker/ItemTrackerData.kt @@ -37,9 +37,6 @@ abstract class ItemTrackerData : TrackerData() { class TrackedItem { - @Expose - var internalName: NEUInternalName? = null - @Expose var timesGained: Long = 0 diff --git a/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniItemTracker.kt b/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniItemTracker.kt index ce10ecbee..6c6ca77ff 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniItemTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniItemTracker.kt @@ -76,7 +76,7 @@ class SkyHanniItemTracker( lists: MutableList>, ): Double { var profit = 0.0 - val items = mutableMapOf() + val items = mutableMapOf() for ((internalName, itemProfit) in data.items) { if (!filter(internalName)) continue @@ -84,6 +84,23 @@ class SkyHanniItemTracker( val pricePer = if (internalName == SKYBLOCK_COIN) 1.0 else data.getCustomPricePer(internalName) val price = (pricePer * amount).toLong() + val hidden = itemProfit.hidden + + if (isInventoryOpen() || !hidden) { + items[internalName] = price + } + if (!hidden || !config.excludeHiddenItemsInPrice) { + profit += price + } + } + + val limitList = config.hideCheapItems + var pos = 0 + val hiddenItemTexts = mutableListOf() + for ((internalName, price) in items.sortedDesc()) { + val itemProfit = data.items[internalName] ?: error("Item not found for $internalName") + + val amount = itemProfit.totalAmount val displayAmount = if (internalName == SKYBLOCK_COIN) itemProfit.timesGained else amount val cleanName = if (internalName == SKYBLOCK_COIN) { @@ -102,8 +119,17 @@ class SkyHanniItemTracker( } else cleanName displayName = " $numberColor${displayAmount.addSeparators()}x $displayName§7: §6$priceFormat" - val lore = buildLore(data, itemProfit, hidden, newDrop, internalName) + pos++ + if (limitList.enabled.get()) { + if (pos > limitList.alwaysShowBest.get()) { + if (price < limitList.minPrice.get() * 1000) { + hiddenItemTexts += displayName + continue + } + } + } + val lore = buildLore(data, itemProfit, hidden, newDrop, internalName) val renderable = if (isInventoryOpen()) Renderable.clickAndHover(displayName, lore) { if (System.currentTimeMillis() > lastClickDelay + 150) { if (KeyboardManager.isModifierKeyDown()) { @@ -119,31 +145,11 @@ class SkyHanniItemTracker( update() } } else Renderable.string(displayName) - if (isInventoryOpen() || !hidden) { - items[renderable] = price - } - if (!hidden || !config.excludeHiddenItemsInPrice) { - profit += price - } - } - val limitList = config.hideCheapItems - var pos = 0 - var hiddenItems = 0 - for ((text, pricePer) in items.sortedDesc()) { - pos++ - if (limitList.enabled.get()) { - if (pos > limitList.alwaysShowBest.get()) { - if (pricePer < limitList.minPrice.get() * 1000) { - hiddenItems++ - continue - } - } - } - lists.addAsSingletonList(text) + lists.addAsSingletonList(renderable) } - if (hiddenItems > 0) { - lists.addAsSingletonList(" §7$hiddenItems cheap items are hidden.") + if (hiddenItemTexts.size > 0) { + lists.addAsSingletonList(Renderable.hoverTips(" §7${hiddenItemTexts.size} cheap items are hidden.", hiddenItemTexts)) } return profit -- cgit