diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-11-07 23:16:36 +0100 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-11-07 23:16:36 +0100 |
commit | 1374af98253decb917f6c1605b9a45ce822adc91 (patch) | |
tree | 8fb6da5788de6eb448a1aefe3656b1b472581083 /src/main/java/at/hannibal2/skyhanni/utils | |
parent | cfc760103dc914d5b7456e9cffe06d30f396e029 (diff) | |
download | skyhanni-1374af98253decb917f6c1605b9a45ce822adc91.tar.gz skyhanni-1374af98253decb917f6c1605b9a45ce822adc91.tar.bz2 skyhanni-1374af98253decb917f6c1605b9a45ce822adc91.zip |
added support for different current sessions per profile.
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniTracker.kt | 8 |
1 files changed, 6 insertions, 2 deletions
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 6d0fcedb6..8d5b723df 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniTracker.kt @@ -13,20 +13,24 @@ import net.minecraft.client.gui.inventory.GuiInventory class SkyHanniTracker<Data : TrackerData>( private val name: String, - private val currentSessionData: Data, + private val createNewSession: () -> Data, private val getStorage: (Storage.ProfileSpecific) -> Data, private val update: () -> Unit, ) { private var inventoryOpen = false private var displayMode = DisplayMode.TOTAL + private val currentSessions = mutableMapOf<Storage.ProfileSpecific, Data>() fun isInventoryOpen() = inventoryOpen private fun getSharedTracker(): SharedTracker<Data>? { val profileSpecific = ProfileStorageData.profileSpecific ?: return null - return SharedTracker(getStorage(profileSpecific), currentSessionData) + return SharedTracker(getStorage(profileSpecific), getCurrentSession(profileSpecific)) } + private fun getCurrentSession(profileSpecific: Storage.ProfileSpecific) = + currentSessions.getOrPut(profileSpecific) { createNewSession() } + fun addSessionResetButton(list: MutableList<List<Any>>) { if (!inventoryOpen || displayMode != DisplayMode.SESSION) return |