From 4699fd46b99a869c8817f641cb287d012f60beeb Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Mon, 1 Jan 2024 14:20:10 +0100 Subject: Added support for new bingo guide repo format, show guide on hover over missing bingo goal list --- .../skyhanni/data/jsonobjects/repo/BingoJson.java | 8 ++++++-- .../java/at/hannibal2/skyhanni/features/bingo/BingoAPI.kt | 14 +++++++------- .../skyhanni/features/bingo/card/BingoCardDisplay.kt | 14 +++++++++----- .../skyhanni/features/bingo/card/BingoCardReader.kt | 8 +++++--- .../skyhanni/features/bingo/card/BingoCardTips.kt | 8 ++++---- .../skyhanni/features/bingo/card/goals/BingoGoal.kt | 3 +++ 6 files changed, 34 insertions(+), 21 deletions(-) (limited to 'src/main/java/at/hannibal2') 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 bingo_tips; + public Map bingo_tips; - public static class BingoTip { + public static class BingoData { @Expose public String difficulty; @Expose public List note; + + @Expose + public List 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() - private var tips: Map = emptyMap() + private var data: Map = 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("BingoRanks").ranks - tips = event.getConstant("Bingo").bingo_tips + data = event.getConstant("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 @@ -12,6 +12,9 @@ class BingoGoal { @Expose var description = "" + @Expose + var guide = emptyList() + @Expose var done = false -- cgit