diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/VerminTracker.kt | 7 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniTracker.kt | 16 |
2 files changed, 19 insertions, 4 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/VerminTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/VerminTracker.kt index 02644a370..1f2b38122 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/VerminTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/VerminTracker.kt @@ -53,7 +53,8 @@ object VerminTracker { fun onChat(event: LorenzChatEvent) { VerminType.entries.forEach { verminType -> if (verminType.pattern.matches(event.message)) { - addVermin(verminType) + tracker.modify { it.count.addOrPut(verminType, 1) } + if (config.hideChat) { event.blockedReason = "vermin_vacuumed" } @@ -106,11 +107,11 @@ object VerminTracker { } private fun addVermin(vermin: VerminType, count: Int = 1) { - tracker.modify { it.count.addOrPut(vermin, count) } + tracker.modify(SkyHanniTracker.DisplayMode.TOTAL) { it.count.addOrPut(vermin, count) } } private fun setVermin(vermin: VerminType, count: Int) { - tracker.modify { it.count[vermin] = count } + tracker.modify(SkyHanniTracker.DisplayMode.TOTAL) { it.count[vermin] = count } } private fun drawDisplay(data: Data): List<List<Any>> = buildList { diff --git a/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniTracker.kt b/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniTracker.kt index 02ce5129a..ad3418ace 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniTracker.kt @@ -68,6 +68,16 @@ open class SkyHanniTracker<Data : TrackerData>( } } + fun modify(mode: DisplayMode, modifyFunction: (Data) -> Unit) { + val storage = ProfileStorageData.profileSpecific ?: return + val data: Data = when (mode) { + DisplayMode.TOTAL -> storage.getTotal() + DisplayMode.SESSION -> storage.getCurrentSession() + } + modifyFunction(data) + update() + } + fun renderDisplay(position: Position) { if (config.hideInEstimatedItemValue && EstimatedItemValue.isCurrentlyShowing()) return @@ -127,9 +137,13 @@ open class SkyHanniTracker<Data : TrackerData>( ) protected fun getSharedTracker() = ProfileStorageData.profileSpecific?.let { - SharedTracker(getStorage(it), currentSessions.getOrPut(it) { createNewSession() }) + SharedTracker(it.getTotal(), it.getCurrentSession()) } + private fun Storage.ProfileSpecific.getCurrentSession() = currentSessions.getOrPut(this) { createNewSession() } + + private fun Storage.ProfileSpecific.getTotal(): Data = getStorage(this) + private fun reset(displayMode: DisplayMode, message: String) { getSharedTracker()?.let { it.get(displayMode).reset() |