diff options
author | Mikecraft1224 <85994411+Mikecraft1224@users.noreply.github.com> | 2024-02-10 19:55:50 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-10 19:55:50 +0100 |
commit | ffbb693db7921a2d145c545833a98248e4623bf4 (patch) | |
tree | 46115d71b016b7ec5634b35e19b87691509ad16a /src/main/java/at/hannibal2/skyhanni/utils | |
parent | 1af3c89a8daf1eac3921c8b26a49e379f0d18f08 (diff) | |
download | skyhanni-ffbb693db7921a2d145c545833a98248e4623bf4.tar.gz skyhanni-ffbb693db7921a2d145c545833a98248e4623bf4.tar.bz2 skyhanni-ffbb693db7921a2d145c545833a98248e4623bf4.zip |
Hovering on cheap items in an Item Tracker now shows the cheap hidden items. #993
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/tracker/ItemTrackerData.kt | 3 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniItemTracker.kt | 56 |
2 files changed, 31 insertions, 28 deletions
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 @@ -38,9 +38,6 @@ abstract class ItemTrackerData : TrackerData() { class TrackedItem { @Expose - var internalName: NEUInternalName? = null - - @Expose var timesGained: Long = 0 @Expose 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<Data : ItemTrackerData>( lists: MutableList<List<Any>>, ): Double { var profit = 0.0 - val items = mutableMapOf<Renderable, Long>() + val items = mutableMapOf<NEUInternalName, Long>() for ((internalName, itemProfit) in data.items) { if (!filter(internalName)) continue @@ -84,6 +84,23 @@ class SkyHanniItemTracker<Data : ItemTrackerData>( 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<String>() + 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<Data : ItemTrackerData>( } 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<Data : ItemTrackerData>( 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 |