feat: highlight storage search results
This commit is contained in:
@@ -11,6 +11,7 @@ import net.minecraft.network.packet.c2s.play.CloseHandledScreenC2SPacket
|
|||||||
import moe.nea.firmament.annotations.Subscribe
|
import moe.nea.firmament.annotations.Subscribe
|
||||||
import moe.nea.firmament.events.ScreenChangeEvent
|
import moe.nea.firmament.events.ScreenChangeEvent
|
||||||
import moe.nea.firmament.events.SlotClickEvent
|
import moe.nea.firmament.events.SlotClickEvent
|
||||||
|
import moe.nea.firmament.events.SlotRenderEvents
|
||||||
import moe.nea.firmament.events.TickEvent
|
import moe.nea.firmament.events.TickEvent
|
||||||
import moe.nea.firmament.features.FirmamentFeature
|
import moe.nea.firmament.features.FirmamentFeature
|
||||||
import moe.nea.firmament.gui.config.ManagedConfig
|
import moe.nea.firmament.gui.config.ManagedConfig
|
||||||
@@ -45,8 +46,24 @@ object StorageOverlay : FirmamentFeature {
|
|||||||
val padding by integer("padding", 1, 20) { 5 }
|
val padding by integer("padding", 1, 20) { 5 }
|
||||||
val margin by integer("margin", 1, 60) { 20 }
|
val margin by integer("margin", 1, 60) { 20 }
|
||||||
val itemsBlockScrolling by toggle("block-item-scrolling") { true }
|
val itemsBlockScrolling by toggle("block-item-scrolling") { true }
|
||||||
|
val highlightSearchResults by toggle("highlight-search-results") { true }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
fun highlightSlots(event: SlotRenderEvents.Before) {
|
||||||
|
if (!TConfig.highlightSearchResults) return
|
||||||
|
val storageOverlayScreen =
|
||||||
|
(MC.screen as? StorageOverlayScreen)
|
||||||
|
?: (MC.handledScreen?.customGui as? StorageOverlayCustom)?.overview
|
||||||
|
?: return
|
||||||
|
val stack = event.slot.stack ?: return
|
||||||
|
val search = storageOverlayScreen.searchText.get().takeIf { it.isNotBlank() } ?: return
|
||||||
|
if (storageOverlayScreen.matchesSearch(stack, search)) {
|
||||||
|
event.context.fill(event.slot.x, event.slot.y, event.slot.x + 16, event.slot.y + 16, 0xFF00B000.toInt())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
fun adjustScrollSpeed(amount: Double): Double {
|
fun adjustScrollSpeed(amount: Double): Double {
|
||||||
return amount * TConfig.scrollSpeed * (if (TConfig.inverseScroll) 1 else -1)
|
return amount * TConfig.scrollSpeed * (if (TConfig.inverseScroll) 1 else -1)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import net.minecraft.item.ItemStack
|
|||||||
import net.minecraft.screen.slot.Slot
|
import net.minecraft.screen.slot.Slot
|
||||||
import net.minecraft.text.Text
|
import net.minecraft.text.Text
|
||||||
import net.minecraft.util.Identifier
|
import net.minecraft.util.Identifier
|
||||||
|
import moe.nea.firmament.annotations.Subscribe
|
||||||
import moe.nea.firmament.events.SlotRenderEvents
|
import moe.nea.firmament.events.SlotRenderEvents
|
||||||
import moe.nea.firmament.gui.EmptyComponent
|
import moe.nea.firmament.gui.EmptyComponent
|
||||||
import moe.nea.firmament.gui.FirmButtonComponent
|
import moe.nea.firmament.gui.FirmButtonComponent
|
||||||
|
|||||||
@@ -363,6 +363,8 @@
|
|||||||
"firmament.config.storage-overlay.block-item-scrolling.description": "Disables scrolling the storage overlay screen while you are hovering over an item. Useful if you have a tooltip scrolling mod.",
|
"firmament.config.storage-overlay.block-item-scrolling.description": "Disables scrolling the storage overlay screen while you are hovering over an item. Useful if you have a tooltip scrolling mod.",
|
||||||
"firmament.config.storage-overlay.height": "Storage Height",
|
"firmament.config.storage-overlay.height": "Storage Height",
|
||||||
"firmament.config.storage-overlay.height.description": "The height of the scrollable storage panel.",
|
"firmament.config.storage-overlay.height.description": "The height of the scrollable storage panel.",
|
||||||
|
"firmament.config.storage-overlay.highlight-search-results": "Highlight Search Results",
|
||||||
|
"firmament.config.storage-overlay.highlight-search-results.description": "Highlight the search results in the ender chest overlay.",
|
||||||
"firmament.config.storage-overlay.inverse-scroll": "Invert Scroll",
|
"firmament.config.storage-overlay.inverse-scroll": "Invert Scroll",
|
||||||
"firmament.config.storage-overlay.inverse-scroll.description": "Invert the mouse wheel scrolling in Firmament's storage overlay.",
|
"firmament.config.storage-overlay.inverse-scroll.description": "Invert the mouse wheel scrolling in Firmament's storage overlay.",
|
||||||
"firmament.config.storage-overlay.margin": "Margin",
|
"firmament.config.storage-overlay.margin": "Margin",
|
||||||
|
|||||||
Reference in New Issue
Block a user