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

import net.minecraft.world.entity.player.Inventory
import ru.dbotthepony.mc.otm.block.entity.storage.StorageBusBlockEntity
import ru.dbotthepony.mc.otm.capability.FlowDirection
import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu
import ru.dbotthepony.mc.otm.menu.input.BooleanInputWithFeedback
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.widget.ProfiledLevelGaugeWidget
import ru.dbotthepony.mc.otm.registry.MMenus

class StorageBusMenu(
	containerId: Int,
	inventory: Inventory,
	tile: StorageBusBlockEntity? = null
) : MatteryPoweredMenu(MMenus.STORAGE_BUS, containerId, inventory, tile)  {
	val busFilterSlots = addFilterSlots(tile?.filter, StorageBusBlockEntity.MAX_FILTERS)
	val busFilterState = BooleanInputWithFeedback(this, tile?.let { it.filter::isWhitelist })
	val insertPriority = IntInputWithFeedback(this, tile?.let { it::insertPriority })
	val extractPriority = IntInputWithFeedback(this, tile?.let { it::extractPriority })
	val profiledEnergy = ProfiledLevelGaugeWidget(this, tile?.energy, energyWidget)
	val energyConfig = EnergyConfigPlayerInput(this, tile?.energyConfig)
	val mode = EnumInputWithFeedback(this, tile?.let { it::mode }, FlowDirection.WITHOUT_NONE)

	init {
		addStorageSlot(batterySlot)
		addInventorySlots()
	}
}
