Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Highlight rabbits with requirement #1874

Merged
merged 5 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,20 @@ public class ChocolateFactoryConfig {
@FeatureToggle
public boolean hoppityMenuShortcut = true;

@Expose
@ConfigOption(name = "Highlight Requirement Rabbits", desc = "Highlight rabbits that have requirements.\n" +
"§cRed: Requirement not met.\n" +
"§aGreen: Requirement met.")
@ConfigEditorBoolean
@FeatureToggle
public boolean highlightRabbitsWithRequirement = false;

@Expose
@ConfigOption(name = "Only Requirement Not Met", desc = "Only highlight the rabbits you don't have the requirement for.")
@ConfigEditorBoolean
@FeatureToggle
public boolean onlyHighlightRequirementNotMet = true;

@Expose
@ConfigOption(name = "Chocolate Shop Price", desc = "")
@Accordion
Expand Down
superhize marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
package at.hannibal2.skyhanni.features.event.hoppity

import at.hannibal2.skyhanni.events.GuiContainerEvent
import at.hannibal2.skyhanni.events.GuiRenderEvent
import at.hannibal2.skyhanni.events.InventoryCloseEvent
import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent
import at.hannibal2.skyhanni.events.ProfileJoinEvent
import at.hannibal2.skyhanni.features.inventory.chocolatefactory.ChocolateFactoryAPI
import at.hannibal2.skyhanni.utils.DisplayTableEntry
import at.hannibal2.skyhanni.utils.InventoryUtils
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.LorenzColor
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzUtils.round
import at.hannibal2.skyhanni.utils.NEUInternalName
import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName
import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
import at.hannibal2.skyhanni.utils.NumberUtil.formatInt
import at.hannibal2.skyhanni.utils.RegexUtils.find
import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher
import at.hannibal2.skyhanni.utils.RegexUtils.matches
import at.hannibal2.skyhanni.utils.RenderUtils.highlight
import at.hannibal2.skyhanni.utils.RenderUtils.renderRenderables
import at.hannibal2.skyhanni.utils.renderables.Renderable
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
Expand Down Expand Up @@ -49,6 +54,14 @@ object HoppityCollectionStats {
"rabbits.found",
"§.§l§m[ §a-z]+§r §.(?<current>[0-9]+)§./§.(?<total>[0-9]+)"
)
private val requirementMet by patternGroup.pattern(
"rabbit.requirement.met",
"§a✔ §7Requirement"
)
private val requirementNotMet by patternGroup.pattern(
"rabbit.requirement.notmet",
"§c✖ §7Requirement.*",
)

private var display = emptyList<Renderable>()
private val loggedRabbits = mutableMapOf<String, RabbitCollectionInfo>()
Expand Down Expand Up @@ -89,6 +102,22 @@ object HoppityCollectionStats {
)
}

@SubscribeEvent
fun onBackgroundDrawn(event: GuiContainerEvent.BackgroundDrawnEvent) {
if (!config.highlightRabbitsWithRequirement) return
if (!inInventory) return

for (slot in InventoryUtils.getItemsInOpenChest()) {
val lore = slot.stack.getLore()
if (lore.any { requirementMet.find(it) } && !config.onlyHighlightRequirementNotMet)
slot highlight LorenzColor.GREEN
if (lore.any { requirementNotMet.find(it) })
slot highlight LorenzColor.RED


}
}

private fun buildDisplay(event: InventoryFullyOpenedEvent): MutableList<Renderable> {
val totalAmount = logRabbits(event)

Expand Down
Loading