aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/utils
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal002@users.noreply.github.com>2024-03-11 17:54:47 +0100
committerGitHub <noreply@github.com>2024-03-11 17:54:47 +0100
commit25f3a0fb99e3adee364f34cb2580440025417768 (patch)
treebaa3ee51ce15e1f5dfa571d0a332b257371a0e01 /src/main/java/at/hannibal2/skyhanni/utils
parent1ec9aef89d420a1be55871e774fb9aea8384297a (diff)
downloadskyhanni-25f3a0fb99e3adee364f34cb2580440025417768.tar.gz
skyhanni-25f3a0fb99e3adee364f34cb2580440025417768.tar.bz2
skyhanni-25f3a0fb99e3adee364f34cb2580440025417768.zip
improvement: Anita and SkyMart calculation breakdowns (#1116)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/DisplayTableEntry.kt9
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt18
2 files changed, 17 insertions, 10 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/DisplayTableEntry.kt b/src/main/java/at/hannibal2/skyhanni/utils/DisplayTableEntry.kt
new file mode 100644
index 000000000..d78a32f31
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/utils/DisplayTableEntry.kt
@@ -0,0 +1,9 @@
+package at.hannibal2.skyhanni.utils
+
+class DisplayTableEntry(
+ val left: String,
+ val right: String,
+ val sort: Double,
+ val item: NEUInternalName,
+ val hover: List<String>,
+)
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
index 7df997f0d..a2788a6fa 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
@@ -10,7 +10,6 @@ import at.hannibal2.skyhanni.features.dungeon.DungeonAPI
import at.hannibal2.skyhanni.mixins.transformers.AccessorGuiEditSign
import at.hannibal2.skyhanni.test.TestBingo
import at.hannibal2.skyhanni.utils.ChatUtils.lastButtonClicked
-import at.hannibal2.skyhanni.utils.CollectionUtils.sortedDesc
import at.hannibal2.skyhanni.utils.ItemUtils.getItemCategoryOrNull
import at.hannibal2.skyhanni.utils.NEUItems.getItemStackOrNull
import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
@@ -157,21 +156,20 @@ object LorenzUtils {
fun getPlayerName(): String = Minecraft.getMinecraft().thePlayer.name
- // (key -> value) -> (sorting value -> key item icon)
- fun fillTable(list: MutableList<List<Any>>, data: MutableMap<Pair<String, String>, Pair<Double, NEUInternalName>>) {
- val keys = data.mapValues { (_, v) -> v.first }.sortedDesc().keys
+ fun MutableList<List<Any>>.fillTable(data: List<DisplayTableEntry>) {
+ val sorted = data.sortedByDescending { it.sort }
val renderer = Minecraft.getMinecraft().fontRendererObj
- val longest = keys.map { it.first }.maxOfOrNull { renderer.getStringWidth(it.removeColor()) } ?: 0
+ val longest = sorted.maxOfOrNull { renderer.getStringWidth(it.left.removeColor()) } ?: 0
- for (pair in keys) {
- val (name, second) = pair
- var displayName = name
+ for (entry in sorted) {
+ var displayName = entry.left
while (renderer.getStringWidth(displayName.removeColor()) < longest) {
displayName += " "
}
- data[pair]!!.second.getItemStackOrNull()?.let {
- list.add(listOf(it, "$displayName $second"))
+ val hover = entry.hover
+ entry.item.getItemStackOrNull()?.let {
+ add(listOf(it, Renderable.hoverTips("$displayName ${entry.right}", tips = hover)))
}
}
}