diff options
Diffstat (limited to 'src/main/java/at')
3 files changed, 15 insertions, 27 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/powdertracker/PowderTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/powdertracker/PowderTracker.kt index 35f10ac26..d808566a0 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/powdertracker/PowderTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/powdertracker/PowderTracker.kt @@ -196,7 +196,7 @@ object PowderTracker { private fun drawDisplay() = buildList<List<Any>> { addAsSingletonList("§b§lPowder Tracker") - tracker.addDisplayModeToggle(this, closedText = "") + tracker.addDisplayModeToggle(this) if (!tracker.isInventoryOpen()) { addAsSingletonList("") 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 e1b4c42ad..8af683b16 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniTracker.kt @@ -3,9 +3,8 @@ package at.hannibal2.skyhanni.utils.tracker import at.hannibal2.skyhanni.config.Storage import at.hannibal2.skyhanni.config.core.config.Position import at.hannibal2.skyhanni.data.ProfileStorageData -import at.hannibal2.skyhanni.utils.LorenzUtils.addAsSingletonList +import at.hannibal2.skyhanni.utils.LorenzUtils.addSelector import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems -import at.hannibal2.skyhanni.utils.tracker.TrackerUtils.addDisplayModeToggle import at.hannibal2.skyhanni.utils.tracker.TrackerUtils.addSessionResetButton import net.minecraft.client.Minecraft import net.minecraft.client.gui.inventory.GuiInventory @@ -17,6 +16,7 @@ class SkyHanniTracker<Data : TrackerData>( private val update: () -> Unit, ) { private var inventoryOpen = false + private var displayMode = DisplayMode.TOTAL fun isInventoryOpen() = inventoryOpen @@ -26,26 +26,28 @@ class SkyHanniTracker<Data : TrackerData>( } fun addSessionResetButton(list: MutableList<List<Any>>) { - if (inventoryOpen && TrackerUtils.currentDisplayMode == DisplayMode.SESSION) { + if (inventoryOpen && displayMode == DisplayMode.SESSION) { list.addSessionResetButton(name, getSharedTracker()) { update() } } } - fun addDisplayModeToggle(list: MutableList<List<Any>>, closedText: String? = null) { - if (inventoryOpen) { - list.addDisplayModeToggle { + fun addDisplayModeToggle(list: MutableList<List<Any>>) { + if (!inventoryOpen) return + + list.addSelector<DisplayMode>( + "§7Display Mode: ", + getName = { type -> type.displayName }, + isCurrent = { it == displayMode }, + onChange = { + displayMode = it update() } - } else { - closedText?.let { - list.addAsSingletonList(it) - } - } + ) } - fun currentDisplay() = getSharedTracker()?.get(TrackerUtils.currentDisplayMode) + fun currentDisplay() = getSharedTracker()?.get(displayMode) fun resetCommand(args: Array<String>, command: String) { TrackerUtils.resetCommand(name, command, args, getSharedTracker()) { diff --git a/src/main/java/at/hannibal2/skyhanni/utils/tracker/TrackerUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/tracker/TrackerUtils.kt index ec527c9e5..77074a4b6 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/tracker/TrackerUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/tracker/TrackerUtils.kt @@ -2,23 +2,9 @@ package at.hannibal2.skyhanni.utils.tracker import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.addAsSingletonList -import at.hannibal2.skyhanni.utils.LorenzUtils.addSelector import at.hannibal2.skyhanni.utils.renderables.Renderable object TrackerUtils { - var currentDisplayMode = DisplayMode.TOTAL - - fun MutableList<List<Any>>.addDisplayModeToggle(update: () -> Unit) { - addSelector<DisplayMode>( - "§7Display Mode: ", - getName = { type -> type.displayName }, - isCurrent = { it == currentDisplayMode }, - onChange = { - currentDisplayMode = it - update() - } - ) - } fun MutableList<List<Any>>.addSessionResetButton(name: String, data: SharedTracker<*>?, update: () -> Unit) { addAsSingletonList( |