diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-12-01 10:46:15 +0100 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-12-01 10:46:15 +0100 |
commit | 7fe3bd2bafad3b50e425020774c538dbb9e13fc1 (patch) | |
tree | 93e3b1c80e577337d7b1e231ac241f147a97cab6 /src/main/java/at/hannibal2/skyhanni | |
parent | 94292e6cca304546c893d43fc2ee7b066fc9d651 (diff) | |
download | skyhanni-7fe3bd2bafad3b50e425020774c538dbb9e13fc1.tar.gz skyhanni-7fe3bd2bafad3b50e425020774c538dbb9e13fc1.tar.bz2 skyhanni-7fe3bd2bafad3b50e425020774c538dbb9e13fc1.zip |
Hide hidden bingo tips in display. Show the duration until the next hidden personal goal gets a tip revealed.
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni')
3 files changed, 75 insertions, 4 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/event/bingo/BingoCardConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/event/bingo/BingoCardConfig.java index 44dd23ec4..2bc7e1f8f 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/event/bingo/BingoCardConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/event/bingo/BingoCardConfig.java @@ -42,4 +42,9 @@ public class BingoCardConfig { @Expose public Position bingoCardPos = new Position(10, 10, false, true); + + @Expose + @ConfigOption(name = "Next Tip Duration", desc = "Show the duration until the next hidden personal goal gets a tip revealed.") + @ConfigEditorBoolean + public Property<Boolean> nextTipDuration = Property.of(true); } diff --git a/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoCardDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoCardDisplay.kt index ee1fc5874..268f12fb8 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoCardDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoCardDisplay.kt @@ -6,6 +6,7 @@ import at.hannibal2.skyhanni.events.ConfigLoadEvent import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.features.bingo.card.CommunityGoal import at.hannibal2.skyhanni.features.bingo.card.PersonalGoal import at.hannibal2.skyhanni.utils.InventoryUtils @@ -15,11 +16,15 @@ import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.onToggle import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings +import at.hannibal2.skyhanni.utils.SimpleTimeMark import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import at.hannibal2.skyhanni.utils.StringUtils.removeColor +import at.hannibal2.skyhanni.utils.TimeUtils +import at.hannibal2.skyhanni.utils.TimeUtils.format import net.minecraft.client.Minecraft import net.minecraft.client.gui.GuiChat import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import kotlin.time.Duration.Companion.days class BingoCardDisplay { @@ -28,6 +33,9 @@ class BingoCardDisplay { // TODO USE SH-REPO private val goalCompletePattern = "§6§lBINGO GOAL COMPLETE! §r§e(?<name>.*)".toPattern() + private var lastBingoCardOpenTime = SimpleTimeMark.farPast() + private var hasHiddenPersonalGoals = false + init { update() } @@ -36,6 +44,9 @@ class BingoCardDisplay { private const val MAX_PERSONAL_GOALS = 20 private const val MAX_COMMUNITY_GOALS = 5 + val personalHiddenGoalPattern = ("§7This goal is currently §7§chidden§7! " + + "It will be revealed §7to you when you complete it. §7 §7§eThe next hint will unlock in (?<time>.*)").toPattern() + private val config get() = SkyHanniMod.feature.event.bingo.bingoCard private var displayMode = 0 val personalGoals = mutableListOf<PersonalGoal>() @@ -109,10 +120,20 @@ class BingoCardDisplay { communityGoals.add(CommunityGoal(name, description, done)) } } + lastBingoCardOpenTime = SimpleTimeMark.now() update() } + @SubscribeEvent + fun onTick(event: LorenzTickEvent) { + if (event.repeatSeconds(1)) { + if (hasHiddenPersonalGoals) { + update() + } + } + } + private fun update() { display = drawDisplay() } @@ -126,14 +147,54 @@ class BingoCardDisplay { } else { if (!config.hideCommunityGoals.get()) { newList.add("§6Community Goals:") - communityGoals.mapTo(newList) { " " + it.description + if (it.done) " §aDONE" else "" } + val goals = communityGoals.toMutableList() + var hiddenGoals = 0 + for (goal in goals.toList()) { + if (goal.description == "§7This goal will be revealed §7when it hits Tier IV.") { + hiddenGoals++ + goals.remove(goal) + } + } + + goals.mapTo(newList) { " " + it.description + if (it.done) " §aDONE" else "" } + if (hiddenGoals > 0) { + newList.add("§7+ $hiddenGoals hidden community goals.") + } newList.add(" ") } - val todo = personalGoals.filter { !it.done } + val todo = personalGoals.filter { !it.done }.toMutableList() val done = MAX_PERSONAL_GOALS - todo.size newList.add("§6Personal Goals: ($done/$MAX_PERSONAL_GOALS done)") + + var hiddenGoals = 0 + var nextTip = 7.days + for (goal in todo.toList()) { + personalHiddenGoalPattern.matchMatcher(goal.description) { + hiddenGoals++ + todo.remove(goal) + val time = TimeUtils.getDuration(group("time").removeColor()) + if (time < nextTip) { + nextTip = time + } + } + } + todo.mapTo(newList) { " " + it.description } + if (hiddenGoals > 0) { + newList.add("§7+ $hiddenGoals hidden personal goals.") + } + hasHiddenPersonalGoals = config.nextTipDuration.get() && nextTip != 7.days + if (hasHiddenPersonalGoals) { + val nextTipTime = lastBingoCardOpenTime + nextTip + if (nextTipTime.isInPast()) { + newList.add("§eThe next hint got unlocked already!") + newList.add("§eOpen the bingo card to update!") + } else { + val until = nextTipTime.timeUntil() + newList.add("§eThe next hint will unlock in §b${until.format(maxUnits = 2)}") + } + } } return newList } @@ -184,6 +245,7 @@ class BingoCardDisplay { @SubscribeEvent fun onConfigLoad(event: ConfigLoadEvent) { config.hideCommunityGoals.onToggle { update() } + config.nextTipDuration.onToggle { update() } } @SubscribeEvent diff --git a/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoNextStepHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoNextStepHelper.kt index 2960b2d22..9c2b4c1d6 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoNextStepHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoNextStepHelper.kt @@ -22,6 +22,7 @@ import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.editCopy import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import at.hannibal2.skyhanni.utils.StringUtils.matchRegex +import at.hannibal2.skyhanni.utils.StringUtils.matches import at.hannibal2.skyhanni.utils.StringUtils.removeColor import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -228,9 +229,12 @@ class BingoNextStepHelper { dirty = false for (goal in personalGoals) { - val bingoCardStep = readDescription(goal.description.removeColor()) + val description = goal.description + val bingoCardStep = readDescription(description.removeColor()) if (bingoCardStep == null) { - println("Warning: Could not find bingo steps for ${goal.description}") + if (!BingoCardDisplay.personalHiddenGoalPattern.matches(description)) { + println("Warning: Could not find bingo steps for $description") + } } else { finalSteps.add(bingoCardStep) } |