aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2024-01-01 14:20:10 +0100
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2024-01-01 14:20:10 +0100
commit4699fd46b99a869c8817f641cb287d012f60beeb (patch)
tree34516a0f4b3b2f700e9914a8cf1b0081ea62edcd /src/main/java
parentc7fff0313b9f06b4b01ebc93580182b585ec9def (diff)
downloadskyhanni-4699fd46b99a869c8817f641cb287d012f60beeb.tar.gz
skyhanni-4699fd46b99a869c8817f641cb287d012f60beeb.tar.bz2
skyhanni-4699fd46b99a869c8817f641cb287d012f60beeb.zip
Added support for new bingo guide repo format, show guide on hover over missing bingo goal list
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/BingoJson.java8
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/bingo/BingoAPI.kt14
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/bingo/card/BingoCardDisplay.kt14
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/bingo/card/BingoCardReader.kt8
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/bingo/card/BingoCardTips.kt8
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/bingo/card/goals/BingoGoal.kt3
6 files changed, 34 insertions, 21 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/BingoJson.java b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/BingoJson.java
index babe7cc9e..f9e8406eb 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/BingoJson.java
+++ b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/BingoJson.java
@@ -7,14 +7,18 @@ import java.util.Map;
public class BingoJson {
@Expose
- public Map<String, BingoTip> bingo_tips;
+ public Map<String, BingoData> bingo_tips;
- public static class BingoTip {
+ public static class BingoData {
@Expose
public String difficulty;
@Expose
public List<String> note;
+
+ @Expose
+ public List<String> guide;
+
@Expose
public String found;
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoAPI.kt
index 76ed7c684..599b4a306 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoAPI.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoAPI.kt
@@ -17,7 +17,7 @@ import java.time.ZoneOffset
object BingoAPI {
private var ranks = mapOf<String, Int>()
- private var tips: Map<String, BingoJson.BingoTip> = emptyMap()
+ private var data: Map<String, BingoJson.BingoData> = emptyMap()
val bingoGoals get() = bingoStorage.goals
val personalGoals get() = bingoGoals.values.filter { it.type == GoalType.PERSONAL }
@@ -27,7 +27,7 @@ object BingoAPI {
@SubscribeEvent
fun onRepoReload(event: RepositoryReloadEvent) {
ranks = event.getConstant<BingoRanksJson>("BingoRanks").ranks
- tips = event.getConstant<BingoJson>("Bingo").bingo_tips
+ data = event.getConstant<BingoJson>("Bingo").bingo_tips
}
fun getRank(text: String) = ranks.entries.find { text.contains(it.key) }?.value
@@ -35,13 +35,13 @@ object BingoAPI {
fun getIcon(searchRank: Int) = ranks.entries.find { it.value == searchRank }?.key
// We added the suffix (Community Goal) so that older skyhanni versions don't crash with the new repo data.
- fun getTip(itemName: String) =
- tips.filter { itemName.startsWith(it.key.split(" (Community Goal)")[0]) }.values.firstOrNull()
+ fun getData(itemName: String) =
+ data.filter { itemName.startsWith(it.key.split(" (Community Goal)")[0]) }.values.firstOrNull()
- fun BingoGoal.getTip(): BingoJson.BingoTip? = if (type == GoalType.COMMUNITY) {
- getTip(displayName)
+ fun BingoGoal.getData(): BingoJson.BingoData? = if (type == GoalType.COMMUNITY) {
+ getData(displayName)
} else {
- tips[displayName]
+ data[displayName]
}
val bingoStorage: BingoSession by lazy {
diff --git a/src/main/java/at/hannibal2/skyhanni/features/bingo/card/BingoCardDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/bingo/card/BingoCardDisplay.kt
index 520e93b27..94490b1d8 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/bingo/card/BingoCardDisplay.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/bingo/card/BingoCardDisplay.kt
@@ -188,16 +188,20 @@ class BingoCardDisplay {
val clickName = if (currentlyHighlighted) "remove" else "add"
Renderable.clickAndHover(
display,
- listOf(
- "§a" + it.displayName,
- "",
- "§eClick to $clickName this goal as highlight!",
- ),
+ buildList {
+ add("§a" + it.displayName)
+ for (s in it.guide) {
+ add(s)
+ }
+ add("")
+ add("§eClick to $clickName this goal as highlight!")
+ },
onClick = {
if (lastClick.passedSince() < 300.milliseconds) return@clickAndHover
lastClick = SimpleTimeMark.now()
it.highlight = !currentlyHighlighted
+ it.displayName
update()
}
)
diff --git a/src/main/java/at/hannibal2/skyhanni/features/bingo/card/BingoCardReader.kt b/src/main/java/at/hannibal2/skyhanni/features/bingo/card/BingoCardReader.kt
index 0c94a0d15..9dc7ee907 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/bingo/card/BingoCardReader.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/bingo/card/BingoCardReader.kt
@@ -63,16 +63,18 @@ class BingoCardReader {
val done = lore.any { it.contains("GOAL REACHED") }
val communtyGoalPercentage = readCommuntyGoalPercentage(lore)
-
val hiddenGoalData = getHiddenGoalData(name, description, goalType)
val visualDescription = hiddenGoalData.tipNote
+ val guide = BingoAPI.getData(name)?.guide?.map { "§7$it" } ?: listOf("§cNo guide yet!")
+
val bingoGoal = BingoAPI.bingoGoals.getOrPut(slot) { BingoGoal() }
with(bingoGoal) {
this.type = goalType
this.displayName = name
this.description = visualDescription
+ this.guide = guide
this.done = done
this.hiddenGoalData = hiddenGoalData
}
@@ -130,7 +132,7 @@ class BingoCardReader {
}
}
- val description = BingoAPI.getTip(name)?.getDescriptionLine()
+ val description = BingoAPI.getData(name)?.getDescriptionLine()
val tipNote = description?.let {
unknownTip = false
it
@@ -153,5 +155,5 @@ class BingoCardReader {
BingoCardUpdateEvent().postAndCatch()
}
- private fun BingoJson.BingoTip.getDescriptionLine() = "§7" + note.joinToString(" ")
+ private fun BingoJson.BingoData.getDescriptionLine() = "§7" + note.joinToString(" ")
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/bingo/card/BingoCardTips.kt b/src/main/java/at/hannibal2/skyhanni/features/bingo/card/BingoCardTips.kt
index dd4639234..b219f7d44 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/bingo/card/BingoCardTips.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/bingo/card/BingoCardTips.kt
@@ -4,7 +4,7 @@ import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.events.GuiContainerEvent
import at.hannibal2.skyhanni.events.LorenzToolTipEvent
import at.hannibal2.skyhanni.features.bingo.BingoAPI
-import at.hannibal2.skyhanni.features.bingo.BingoAPI.getTip
+import at.hannibal2.skyhanni.features.bingo.BingoAPI.getData
import at.hannibal2.skyhanni.features.bingo.card.goals.GoalType
import at.hannibal2.skyhanni.utils.InventoryUtils
import at.hannibal2.skyhanni.utils.LorenzColor
@@ -28,7 +28,7 @@ class BingoCardTips {
val goal = BingoAPI.bingoGoals[slot.slotNumber] ?: return
val toolTip = event.toolTip
- val bingoTip = goal.getTip() ?: return
+ val bingoTip = goal.getData() ?: return
val communityGoal = goal.type == GoalType.COMMUNITY
val difficulty = Difficulty.valueOf(bingoTip.difficulty.uppercase())
@@ -42,7 +42,7 @@ class BingoCardTips {
toolTip.add(index++, "")
toolTip.add(index++, "§eGuide:")
- for (line in bingoTip.note) {
+ for (line in bingoTip.guide) {
toolTip.add(index++, " $line")
}
bingoTip.found?.let {
@@ -63,7 +63,7 @@ class BingoCardTips {
val goal = BingoAPI.bingoGoals[slot.slotNumber] ?: continue
if (config.hideDoneDifficulty && goal.done) continue
- val color = goal.getTip()?.let {
+ val color = goal.getData()?.let {
val difficulty = Difficulty.valueOf(it.difficulty.uppercase())
difficulty.color
} ?: LorenzColor.GRAY
diff --git a/src/main/java/at/hannibal2/skyhanni/features/bingo/card/goals/BingoGoal.kt b/src/main/java/at/hannibal2/skyhanni/features/bingo/card/goals/BingoGoal.kt
index 58b560905..f6758360b 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/bingo/card/goals/BingoGoal.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/bingo/card/goals/BingoGoal.kt
@@ -13,6 +13,9 @@ class BingoGoal {
var description = ""
@Expose
+ var guide = emptyList<String>()
+
+ @Expose
var done = false
@Expose