aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at
diff options
context:
space:
mode:
authorHiZe_ <superhize@hotmail.com>2023-07-01 00:17:47 +0200
committerGitHub <noreply@github.com>2023-07-01 00:17:47 +0200
commit95601fae4578561ce32391036bbdeaaa1cf0f762 (patch)
tree0e3e0bf482a4e28040e37de1a104e2138e328e83 /src/main/java/at
parente3a4eb852f81b6da8e43305ca9d557f61ee08d07 (diff)
downloadskyhanni-95601fae4578561ce32391036bbdeaaa1cf0f762.tar.gz
skyhanni-95601fae4578561ce32391036bbdeaaa1cf0f762.tar.bz2
skyhanni-95601fae4578561ce32391036bbdeaaa1cf0f762.zip
Crux Talisman Progress Display (#263)
Co-authored-by: superhize <superhize@gmail.com> Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt1
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/RiftConfig.java25
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/rift/CruxTalismanDisplay.kt127
3 files changed, 153 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
index 044338b1c..041dca4f7 100644
--- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
+++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
@@ -313,6 +313,7 @@ class SkyHanniMod {
loadModule(KloonHacking())
loadModule(EnigmaSoulWaypoints)
loadModule(DungeonLividFinder)
+ loadModule(CruxTalismanDisplay)
init()
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/RiftConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/RiftConfig.java
index e8e199388..c6a653ab4 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/RiftConfig.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/RiftConfig.java
@@ -6,6 +6,7 @@ import io.github.moulberry.moulconfig.annotations.Accordion;
import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean;
import io.github.moulberry.moulconfig.annotations.ConfigEditorColour;
import io.github.moulberry.moulconfig.annotations.ConfigOption;
+import io.github.moulberry.moulconfig.observer.Property;
public class RiftConfig {
@@ -68,7 +69,31 @@ public class RiftConfig {
@ConfigOption(name = "Volt mood color", desc = "Change the color of the volt enemy depending on their mood.")
@ConfigEditorBoolean
public boolean voltMoodMeter = false;
+ }
+
+ @ConfigOption(name = "Crux Talisman Progress", desc = "")
+ @Accordion
+ @Expose
+ public CruxTalisman cruxTalisman = new CruxTalisman();
+
+ public static class CruxTalisman {
+ @Expose
+ @ConfigOption(name = "Crux Talisman Display", desc = "Display progress of the Crux Talisman on screen.")
+ @ConfigEditorBoolean
+ public boolean enabled = true;
+ @Expose
+ @ConfigOption(name = "Compact", desc = "Show a compacted version of the overlay when the talisman is maxed.")
+ @ConfigEditorBoolean
+ public boolean compactWhenMaxed = false;
+
+ @Expose
+ @ConfigOption(name = "Show Bonuses", desc = "Show bonuses you get from the talisman.")
+ @ConfigEditorBoolean
+ public Property<Boolean> showBonuses = Property.of(true);
+
+ @Expose
+ public Position position = new Position(144, 139, false, true);
}
@ConfigOption(name = "Larvas", desc = "")
diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/CruxTalismanDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/CruxTalismanDisplay.kt
new file mode 100644
index 000000000..9932c19c0
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/rift/CruxTalismanDisplay.kt
@@ -0,0 +1,127 @@
+package at.hannibal2.skyhanni.features.rift
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.events.ConfigLoadEvent
+import at.hannibal2.skyhanni.events.GuiRenderEvent
+import at.hannibal2.skyhanni.events.LorenzTickEvent
+import at.hannibal2.skyhanni.utils.InventoryUtils
+import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName
+import at.hannibal2.skyhanni.utils.ItemUtils.getLore
+import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.LorenzUtils.addAsSingletonList
+import at.hannibal2.skyhanni.utils.NumberUtil.roundToPrecision
+import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems
+import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
+import at.hannibal2.skyhanni.utils.StringUtils.removeColor
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+
+object CruxTalismanDisplay {
+
+ private val config get() = SkyHanniMod.feature.rift.cruxTalisman
+ private val partialName = "CRUX_TALISMAN"
+ private var display = listOf<List<Any>>()
+ private val displayLine = mutableListOf<Crux>()
+ private val bonusesLine = mutableListOf<String>()
+ private val progressPattern =
+ ".*(?<tier>§[0-9a-z][IV1-4-]+)\\s+(?<name>§[0-9a-z]\\w+)§[0-9a-z]:\\s*(?<progress>§[0-9a-z](?:§[0-9a-z])?MAXED|(?:§[0-9a-z]\\d+§[0-9a-z]\\/§[0-9a-z]\\d+)).*".toPattern()
+ private var maxed = false
+ private var percentValue = 0.0
+
+ @SubscribeEvent
+ fun onRenderOverlay(event: GuiRenderEvent.GameOverlayRenderEvent) {
+ if (!isEnabled()) return
+ config.position.renderStringsAndItems(
+ display,
+ posLabel = "Crux Talisman Display"
+ )
+ }
+
+ private fun update() {
+ display = drawDisplay()
+ }
+
+ private fun drawDisplay() = buildList {
+ var maxedKill = 0
+ var percent = 0
+ for (crux in displayLine)
+ if (crux.maxed)
+ maxedKill++
+ if (maxedKill == 6)
+ maxed = true
+
+ if (!config.compactWhenMaxed && maxed) maxed = false
+
+ if (displayLine.isNotEmpty()) {
+ addAsSingletonList("§7Crux Talisman Progress: ${if (maxed) "§a§lMAXED!" else "§a$percentValue%"}")
+ if (!maxed) {
+ displayLine.forEach {
+ percent += if (config.compactWhenMaxed) {
+ if (!it.maxed) {
+ "(?<progress>\\d+)/\\d+".toRegex().find(it.progress.removeColor())?.groupValues?.get(1)
+ ?.toInt() ?: 0
+ } else 100
+ } else {
+ if (it.progress.contains("MAXED"))
+ 100
+ else {
+ "(?<progress>\\d+)/\\d+".toRegex().find(it.progress.removeColor())?.groupValues?.get(1)
+ ?.toInt() ?: 0
+ }
+ }
+ addAsSingletonList(" ${it.tier} ${it.name}: ${it.progress}")
+ }
+ }
+ }
+ percentValue = ((percent.toDouble() / 600) * 100).roundToPrecision(1)
+ if (bonusesLine.isNotEmpty() && config.showBonuses.get()) {
+ addAsSingletonList("§7Bonuses:")
+ bonusesLine.forEach { addAsSingletonList(" $it") }
+ }
+ }
+
+
+ @SubscribeEvent
+ fun onTick(event: LorenzTickEvent) {
+ if (!isEnabled()) return
+ if (!event.isMod(40)) return
+ if (!InventoryUtils.getItemsInOwnInventory().any { it.getInternalName().startsWith(partialName) }) return
+
+ displayLine.clear()
+ bonusesLine.clear()
+ maxed = false
+ var bonusFound = false
+ val inventoryStack = InventoryUtils.getItemsInOwnInventory()
+ for (stack in inventoryStack) {
+ line@ for (line in stack.getLore()) {
+ progressPattern.matchMatcher(line) {
+ val tier = group("tier").replace("-", "0")
+ val name = group("name")
+ val progress = group("progress")
+ val crux = Crux(name, tier, progress, progress.contains("MAXED"))
+ displayLine.add(crux)
+ }
+ if (line.startsWith("§7Total Bonuses")) {
+ bonusFound = true
+ continue@line
+ }
+ if (bonusFound) {
+ if (line.isEmpty()) {
+ bonusFound = false
+ continue@line
+ }
+ bonusesLine.add(line)
+ }
+ }
+ }
+ update()
+ }
+
+ @SubscribeEvent
+ fun onConfigLoad(event: ConfigLoadEvent) {
+ LorenzUtils.onToggle(config.showBonuses) { update() }
+ }
+
+ data class Crux(val name: String, val tier: String, val progress: String, val maxed: Boolean)
+
+ fun isEnabled() = RiftAPI.inRift() && config.enabled
+} \ No newline at end of file