aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/utils/tracker
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal002@users.noreply.github.com>2024-09-08 13:36:19 +0200
committerGitHub <noreply@github.com>2024-09-08 13:36:19 +0200
commit796ef7ca4139669f15e323c112378125760b5292 (patch)
treef389143acf59ee7a8fd095503c49ddfd16205443 /src/main/java/at/hannibal2/skyhanni/utils/tracker
parent7519ef5249502f9aa14e350e5e5b8b83eab0e1eb (diff)
downloadskyhanni-796ef7ca4139669f15e323c112378125760b5292.tar.gz
skyhanni-796ef7ca4139669f15e323c112378125760b5292.tar.bz2
skyhanni-796ef7ca4139669f15e323c112378125760b5292.zip
Backend: No List<Any> in Trackers (#2474)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Co-authored-by: Cal <cwolfson58@gmail.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils/tracker')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniItemTracker.kt16
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniTracker.kt39
2 files changed, 28 insertions, 27 deletions
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 e7af81cea..8806f3bdb 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniItemTracker.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniItemTracker.kt
@@ -5,14 +5,13 @@ import at.hannibal2.skyhanni.config.storage.ProfileSpecificStorage
import at.hannibal2.skyhanni.data.SlayerAPI
import at.hannibal2.skyhanni.data.TrackerManager
import at.hannibal2.skyhanni.utils.ChatUtils
-import at.hannibal2.skyhanni.utils.CollectionUtils.addAsSingletonList
+import at.hannibal2.skyhanni.utils.CollectionUtils.addSelector
import at.hannibal2.skyhanni.utils.CollectionUtils.sortedDesc
import at.hannibal2.skyhanni.utils.ItemPriceSource
import at.hannibal2.skyhanni.utils.ItemUtils.itemName
import at.hannibal2.skyhanni.utils.ItemUtils.readableInternalName
import at.hannibal2.skyhanni.utils.KeyboardManager
import at.hannibal2.skyhanni.utils.LorenzUtils
-import at.hannibal2.skyhanni.utils.LorenzUtils.addSelector
import at.hannibal2.skyhanni.utils.NEUInternalName
import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
import at.hannibal2.skyhanni.utils.NumberUtil.shortFormat
@@ -24,7 +23,7 @@ class SkyHanniItemTracker<Data : ItemTrackerData>(
name: String,
createNewSession: () -> Data,
getStorage: (ProfileSpecificStorage) -> Data,
- drawDisplay: (Data) -> List<List<Any>>,
+ drawDisplay: (Data) -> List<Renderable>,
) : SkyHanniTracker<Data>(name, createNewSession, getStorage, drawDisplay) {
companion object {
@@ -61,7 +60,7 @@ class SkyHanniItemTracker<Data : ItemTrackerData>(
}
}
- fun addPriceFromButton(lists: MutableList<List<Any>>) {
+ fun addPriceFromButton(lists: MutableList<Renderable>) {
if (isInventoryOpen()) {
lists.addSelector<ItemPriceSource>(
"",
@@ -78,7 +77,7 @@ class SkyHanniItemTracker<Data : ItemTrackerData>(
fun drawItems(
data: Data,
filter: (NEUInternalName) -> Boolean,
- lists: MutableList<List<Any>>,
+ lists: MutableList<Renderable>,
): Double {
var profit = 0.0
val items = mutableMapOf<NEUInternalName, Long>()
@@ -86,8 +85,7 @@ class SkyHanniItemTracker<Data : ItemTrackerData>(
if (!filter(internalName)) continue
val amount = itemProfit.totalAmount
- val pricePer =
- if (internalName == SKYBLOCK_COIN) 1.0 else data.getCustomPricePer(internalName)
+ val pricePer = if (internalName == SKYBLOCK_COIN) 1.0 else data.getCustomPricePer(internalName)
val price = (pricePer * amount).toLong()
val hidden = itemProfit.hidden
@@ -151,11 +149,11 @@ class SkyHanniItemTracker<Data : ItemTrackerData>(
},
) else Renderable.string(displayName)
- lists.addAsSingletonList(renderable)
+ lists.add(renderable)
}
if (hiddenItemTexts.size > 0) {
val text = Renderable.hoverTips(" §7${hiddenItemTexts.size} cheap items are hidden.", hiddenItemTexts)
- lists.addAsSingletonList(text)
+ lists.add(text)
}
return profit
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 345767b05..9d77d4668 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniTracker.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniTracker.kt
@@ -7,11 +7,10 @@ import at.hannibal2.skyhanni.data.ProfileStorageData
import at.hannibal2.skyhanni.data.TrackerManager
import at.hannibal2.skyhanni.features.misc.items.EstimatedItemValue
import at.hannibal2.skyhanni.utils.ChatUtils
-import at.hannibal2.skyhanni.utils.CollectionUtils.addAsSingletonList
-import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.CollectionUtils
import at.hannibal2.skyhanni.utils.NEUInternalName
import at.hannibal2.skyhanni.utils.NEUItems.getPrice
-import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems
+import at.hannibal2.skyhanni.utils.RenderUtils.renderRenderables
import at.hannibal2.skyhanni.utils.SimpleTimeMark
import at.hannibal2.skyhanni.utils.renderables.Renderable
import net.minecraft.client.Minecraft
@@ -24,13 +23,13 @@ open class SkyHanniTracker<Data : TrackerData>(
private val createNewSession: () -> Data,
private val getStorage: (ProfileSpecificStorage) -> Data,
// TODO change to renderable
- private val drawDisplay: (Data) -> List<List<Any>>,
+ private val drawDisplay: (Data) -> List<Renderable>,
) {
private var inventoryOpen = false
private var displayMode: DisplayMode? = null
private val currentSessions = mutableMapOf<ProfileSpecificStorage, Data>()
- private var display = emptyList<List<Any>>()
+ private var display = emptyList<Renderable>()
private var sessionResetTime = SimpleTimeMark.farPast()
private var dirty = false
@@ -84,25 +83,27 @@ open class SkyHanniTracker<Data : TrackerData>(
if (dirty || TrackerManager.dirty) {
display = getSharedTracker()?.let {
- buildFinalDisplay(drawDisplay(it.get(getDisplayMode())))
+ val get = it.get(getDisplayMode())
+ val rawList = drawDisplay(get)
+ buildFinalDisplay(rawList)
} ?: emptyList()
dirty = false
}
- position.renderStringsAndItems(display, posLabel = name)
+ position.renderRenderables(display, posLabel = name)
}
fun update() {
dirty = true
}
- private fun buildFinalDisplay(rawList: List<List<Any>>) = rawList.toMutableList().also {
+ private fun buildFinalDisplay(rawList: List<Renderable>) = rawList.toMutableList().also {
if (it.isEmpty()) return@also
if (inventoryOpen) {
it.add(1, buildDisplayModeView())
}
if (inventoryOpen && getDisplayMode() == DisplayMode.SESSION) {
- it.addAsSingletonList(buildSessionResetButton())
+ it.add(buildSessionResetButton())
}
}
@@ -121,15 +122,17 @@ open class SkyHanniTracker<Data : TrackerData>(
},
)
- private fun buildDisplayModeView() = LorenzUtils.buildSelector<DisplayMode>(
- "§7Display Mode: ",
- getName = { type -> type.displayName },
- isCurrent = { it == getDisplayMode() },
- onChange = {
- displayMode = it
- storedTrackers[name] = it
- update()
- },
+ private fun buildDisplayModeView() = Renderable.horizontalContainer(
+ CollectionUtils.buildSelector<DisplayMode>(
+ "§7Display Mode: ",
+ getName = { type -> type.displayName },
+ isCurrent = { it == getDisplayMode() },
+ onChange = {
+ displayMode = it
+ storedTrackers[name] = it
+ update()
+ },
+ ),
)
protected fun getSharedTracker() = ProfileStorageData.profileSpecific?.let {