package ru.dbotthepony.mc.otm.menu.storage

import net.minecraft.world.SimpleContainer
import net.minecraft.world.entity.player.Inventory
import ru.dbotthepony.mc.otm.block.entity.storage.DriveRackBlockEntity
import ru.dbotthepony.mc.otm.capability.FlowDirection
import ru.dbotthepony.mc.otm.menu.DriveSlot
import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu
import ru.dbotthepony.mc.otm.menu.input.EnergyConfigPlayerInput
import ru.dbotthepony.mc.otm.menu.input.EnumInputWithFeedback
import ru.dbotthepony.mc.otm.menu.input.IntInputWithFeedback
import ru.dbotthepony.mc.otm.menu.makeSlots
import ru.dbotthepony.mc.otm.menu.widget.ProfiledLevelGaugeWidget
import ru.dbotthepony.mc.otm.registry.game.MMenus

class DriveRackMenu @JvmOverloads constructor(
	containerId: Int,
	inventory: Inventory,
	tile: DriveRackBlockEntity? = null
) : MatteryPoweredMenu(MMenus.DRIVE_RACK, containerId, inventory, tile) {
	val storageSlots = makeSlots(tile?.container ?: SimpleContainer(4), ::DriveSlot)
	val energyConfig = EnergyConfigPlayerInput(this, tile?.energyConfig)
	val profiledEnergy = ProfiledLevelGaugeWidget(this, tile?.energy, energyWidget)
	val insertPriority = IntInputWithFeedback(this, tile?.let { it::insertPriority })
	val extractPriority = IntInputWithFeedback(this, tile?.let { it::extractPriority })
	val mode = EnumInputWithFeedback(this, tile?.let { it::mode }, FlowDirection.WITHOUT_NONE)

	init {
		addStorageSlot(storageSlots)
		addInventorySlots()
	}
}
