aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/features/inventory/JunkHighlighter.kt
blob: e5ab03644f888481738b6349b478fcdf27e67e35 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package moe.nea.firmament.features.inventory

import org.lwjgl.glfw.GLFW
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.SlotRenderEvents
import moe.nea.firmament.features.FirmamentFeature
import moe.nea.firmament.util.data.Config
import moe.nea.firmament.util.data.ManagedConfig
import moe.nea.firmament.util.skyblock.SBItemUtil.getSearchName
import moe.nea.firmament.util.useMatch

object JunkHighlighter : FirmamentFeature {
	override val identifier: String
		get() = "junk-highlighter"

	@Config
	object TConfig : ManagedConfig(identifier, Category.INVENTORY) {
		val junkRegex by string("regex") { "" }
		val highlightBind by keyBinding("highlight") { GLFW.GLFW_KEY_LEFT_CONTROL }
	}

	@Subscribe
	fun onDrawSlot(event: SlotRenderEvents.After) {
		if(!TConfig.highlightBind.isPressed() || TConfig.junkRegex.isEmpty()) return
		val junkRegex = TConfig.junkRegex.toPattern()
		val slot = event.slot
		junkRegex.useMatch(slot.stack.getSearchName()) {
			event.context.fill(slot.x, slot.y, slot.x + 16, slot.y + 16, 0xffff0000.toInt())
		}
	}
}