aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/features/inventory/storageoverlay/StorageOverlayCustom.kt
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/kotlin/features/inventory/storageoverlay/StorageOverlayCustom.kt')
-rw-r--r--src/main/kotlin/features/inventory/storageoverlay/StorageOverlayCustom.kt153
1 files changed, 80 insertions, 73 deletions
diff --git a/src/main/kotlin/features/inventory/storageoverlay/StorageOverlayCustom.kt b/src/main/kotlin/features/inventory/storageoverlay/StorageOverlayCustom.kt
index d0d9114..fc3c4ef 100644
--- a/src/main/kotlin/features/inventory/storageoverlay/StorageOverlayCustom.kt
+++ b/src/main/kotlin/features/inventory/storageoverlay/StorageOverlayCustom.kt
@@ -1,4 +1,3 @@
-
package moe.nea.firmament.features.inventory.storageoverlay
import me.shedaniel.math.Point
@@ -12,87 +11,95 @@ import moe.nea.firmament.mixins.accessor.AccessorHandledScreen
import moe.nea.firmament.util.customgui.CustomGui
class StorageOverlayCustom(
- val handler: StorageBackingHandle,
- val screen: GenericContainerScreen,
- val overview: StorageOverlayScreen,
+ val handler: StorageBackingHandle,
+ val screen: GenericContainerScreen,
+ val overview: StorageOverlayScreen,
) : CustomGui() {
- override fun onVoluntaryExit(): Boolean {
- overview.isExiting = true
- return super.onVoluntaryExit()
- }
+ override fun onVoluntaryExit(): Boolean {
+ overview.isExiting = true
+ return super.onVoluntaryExit()
+ }
+
+ override fun getBounds(): List<Rectangle> {
+ return overview.getBounds()
+ }
+
+ override fun afterSlotRender(context: DrawContext, slot: Slot) {
+ if (slot.inventory !is PlayerInventory)
+ context.disableScissor()
+ }
- override fun getBounds(): List<Rectangle> {
- return overview.getBounds()
- }
+ override fun beforeSlotRender(context: DrawContext, slot: Slot) {
+ if (slot.inventory !is PlayerInventory)
+ overview.createScissors(context)
+ }
- override fun afterSlotRender(context: DrawContext, slot: Slot) {
- if (slot.inventory !is PlayerInventory)
- context.disableScissor()
- }
+ override fun onInit() {
+ overview.init(MinecraftClient.getInstance(), screen.width, screen.height)
+ overview.init()
+ screen as AccessorHandledScreen
+ screen.x_Firmament = overview.measurements.x
+ screen.y_Firmament = overview.measurements.y
+ screen.backgroundWidth_Firmament = overview.measurements.totalWidth
+ screen.backgroundHeight_Firmament = overview.measurements.totalHeight
+ }
- override fun beforeSlotRender(context: DrawContext, slot: Slot) {
- if (slot.inventory !is PlayerInventory)
- overview.createScissors(context)
- }
+ override fun isPointOverSlot(slot: Slot, xOffset: Int, yOffset: Int, pointX: Double, pointY: Double): Boolean {
+ if (!super.isPointOverSlot(slot, xOffset, yOffset, pointX, pointY))
+ return false
+ if (slot.inventory !is PlayerInventory) {
+ if (!overview.getScrollPanelInner().contains(pointX, pointY))
+ return false
+ }
+ return true
+ }
- override fun onInit() {
- overview.init(MinecraftClient.getInstance(), screen.width, screen.height)
- overview.init()
- screen as AccessorHandledScreen
- screen.x_Firmament = overview.measurements.x
- screen.y_Firmament = overview.measurements.y
- screen.backgroundWidth_Firmament = overview.measurements.totalWidth
- screen.backgroundHeight_Firmament = overview.measurements.totalHeight
- }
+ override fun shouldDrawForeground(): Boolean {
+ return false
+ }
- override fun isPointOverSlot(slot: Slot, xOffset: Int, yOffset: Int, pointX: Double, pointY: Double): Boolean {
- if (!super.isPointOverSlot(slot, xOffset, yOffset, pointX, pointY))
- return false
- if (slot.inventory !is PlayerInventory) {
- if (!overview.getScrollPanelInner().contains(pointX, pointY))
- return false
- }
- return true
- }
+ override fun mouseReleased(mouseX: Double, mouseY: Double, button: Int): Boolean {
+ return overview.mouseReleased(mouseX, mouseY, button)
+ }
- override fun shouldDrawForeground(): Boolean {
- return false
- }
+ override fun mouseDragged(mouseX: Double, mouseY: Double, button: Int, deltaX: Double, deltaY: Double): Boolean {
+ return overview.mouseDragged(mouseX, mouseY, button, deltaX, deltaY)
+ }
- override fun mouseClick(mouseX: Double, mouseY: Double, button: Int): Boolean {
- return overview.mouseClicked(mouseX, mouseY, button, (handler as? StorageBackingHandle.Page)?.storagePageSlot)
- }
+ override fun mouseClick(mouseX: Double, mouseY: Double, button: Int): Boolean {
+ return overview.mouseClicked(mouseX, mouseY, button, (handler as? StorageBackingHandle.Page)?.storagePageSlot)
+ }
- override fun render(drawContext: DrawContext, delta: Float, mouseX: Int, mouseY: Int) {
- overview.drawBackgrounds(drawContext)
- overview.drawPages(drawContext,
- mouseX,
- mouseY,
- delta,
- (handler as? StorageBackingHandle.Page)?.storagePageSlot,
- screen.screenHandler.slots.take(screen.screenHandler.rows * 9).drop(9),
- Point((screen as AccessorHandledScreen).x_Firmament, screen.y_Firmament))
- overview.drawScrollBar(drawContext)
- }
+ override fun render(drawContext: DrawContext, delta: Float, mouseX: Int, mouseY: Int) {
+ overview.drawBackgrounds(drawContext)
+ overview.drawPages(drawContext,
+ mouseX,
+ mouseY,
+ delta,
+ (handler as? StorageBackingHandle.Page)?.storagePageSlot,
+ screen.screenHandler.slots.take(screen.screenHandler.rows * 9).drop(9),
+ Point((screen as AccessorHandledScreen).x_Firmament, screen.y_Firmament))
+ overview.drawScrollBar(drawContext)
+ }
- override fun moveSlot(slot: Slot) {
- val index = slot.index
- if (index in 0..<36) {
- val (x, y) = overview.getPlayerInventorySlotPosition(index)
- slot.x = x - (screen as AccessorHandledScreen).x_Firmament
- slot.y = y - screen.y_Firmament
- } else {
- slot.x = -100000
- slot.y = -100000
- }
- }
+ override fun moveSlot(slot: Slot) {
+ val index = slot.index
+ if (index in 0..<36) {
+ val (x, y) = overview.getPlayerInventorySlotPosition(index)
+ slot.x = x - (screen as AccessorHandledScreen).x_Firmament
+ slot.y = y - screen.y_Firmament
+ } else {
+ slot.x = -100000
+ slot.y = -100000
+ }
+ }
- override fun mouseScrolled(
- mouseX: Double,
- mouseY: Double,
- horizontalAmount: Double,
- verticalAmount: Double
- ): Boolean {
- return overview.mouseScrolled(mouseX, mouseY, horizontalAmount, verticalAmount)
- }
+ override fun mouseScrolled(
+ mouseX: Double,
+ mouseY: Double,
+ horizontalAmount: Double,
+ verticalAmount: Double
+ ): Boolean {
+ return overview.mouseScrolled(mouseX, mouseY, horizontalAmount, verticalAmount)
+ }
}