package ru.dbotthepony.mc.otm.client.screen.decorative

import net.minecraft.network.chat.Component
import net.minecraft.world.entity.player.Inventory
import ru.dbotthepony.mc.otm.client.render.UVWindingOrder
import ru.dbotthepony.mc.otm.client.screen.MatteryScreen
import ru.dbotthepony.mc.otm.client.screen.panels.Dock
import ru.dbotthepony.mc.otm.client.screen.panels.DockResizeMode
import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel
import ru.dbotthepony.mc.otm.client.screen.panels.PlayerEquipmentPanel
import ru.dbotthepony.mc.otm.client.screen.panels.button.makeDeviceControls
import ru.dbotthepony.mc.otm.client.screen.panels.makeCuriosPanel
import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel
import ru.dbotthepony.mc.otm.client.screen.panels.SpritePanel
import ru.dbotthepony.mc.otm.client.screen.widget.FluidGaugePanel
import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel
import ru.dbotthepony.mc.otm.menu.decorative.FluidTankMenu

class FluidTankScreen(menu: FluidTankMenu, inventory: Inventory, title: Component) : MatteryScreen<FluidTankMenu>(menu, inventory, title) {
	override fun makeMainFrame(): FramePanel<MatteryScreen<*>> {
		val frame = super.makeMainFrame()!!

		FluidGaugePanel(this, frame, menu.fluid, x = LEFT_MARGIN, y = GAUGE_TOP_WITHOUT_SLOT - 6f)

		val s = SpritePanel(this, frame, ProgressGaugePanel.GAUGE_BACKGROUND, x = 30f, y = 30f)
		SpritePanel(this, frame, ProgressGaugePanel.GAUGE_BACKGROUND, x = 30f, y = 55f, winding = UVWindingOrder.FLOP)

		SlotPanel(this, frame, menu.fillInput, x = 30f + s.width + 4f, y = 28f)
		SlotPanel(this, frame, menu.drainInput, x = 30f + s.width + 4f, y = 53f)

		SlotPanel(this, frame, menu.output, x = 30f + s.width + 4f + 20f, y = 53f)

		makeDeviceControls(this, frame, itemConfig = menu.itemConfig, redstoneConfig = menu.redstoneConfig, fluidConfig = menu.fluidConfig)
		makeCuriosPanel(this, frame, menu.equipment.curiosSlots, autoAlign = true)

		PlayerEquipmentPanel(this, frame, armorSlots = menu.equipment.armorSlots).also {
			it.leftSided = false
			it.dock = Dock.RIGHT
			it.dockResize = DockResizeMode.NONE
		}

		return frame
	}
}
