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

import net.minecraft.network.chat.Component
import net.minecraft.world.entity.player.Inventory
import ru.dbotthepony.mc.otm.client.screen.MatteryScreen
import ru.dbotthepony.mc.otm.core.TranslatableComponent
import ru.dbotthepony.mc.otm.client.screen.panels.*
import ru.dbotthepony.mc.otm.client.screen.panels.button.CheckBoxLabelInputPanel
import ru.dbotthepony.mc.otm.client.screen.panels.button.makeDeviceControls
import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel
import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel
import ru.dbotthepony.mc.otm.client.screen.panels.slot.FilterSlotPanel
import ru.dbotthepony.mc.otm.client.screen.panels.util.GridPanel
import ru.dbotthepony.mc.otm.client.screen.widget.WidePowerGaugePanel

import ru.dbotthepony.mc.otm.menu.storage.StorageImporterExporterMenu

class StorageImporterExporterScreen(menu: StorageImporterExporterMenu, inventory: Inventory, title: Component) : MatteryScreen<StorageImporterExporterMenu>(menu, inventory, title) {
	override fun makeMainFrame(): FramePanel<MatteryScreen<*>> {
		val frame = FramePanel(this, 148f, 130f, title)

		makeBars(frame, profiledEnergy = menu.profiledEnergy, batterySlot = menu.batterySlot)

		val right = EditablePanel(this, frame, width = AbstractSlotPanel.SIZE * 6f)
		right.dock = Dock.RIGHT
		val grid = GridPanel(this, right, columns = 6, rows = 3, height = AbstractSlotPanel.SIZE * 3f)
		grid.dock = Dock.TOP

		for (slot in menu.filterSlots) {
			FilterSlotPanel(this, grid, slot)
		}

		CheckBoxLabelInputPanel(this, right, menu.isWhitelist, TranslatableComponent("otm.gui.filter.is_whitelist")).also {
			it.dock = Dock.BOTTOM
			it.dockTop = 2f
			it.childrenOrder = -1
		}

		CheckBoxLabelInputPanel(this, right, menu.matchNBT, TranslatableComponent("otm.gui.filter.match_nbt")).also {
			it.dock = Dock.BOTTOM
			it.dockTop = 2f
			it.childrenOrder = -2
		}

		CheckBoxLabelInputPanel(this, right, menu.matchTag, TranslatableComponent("otm.gui.filter.match_tag")).also {
			it.dock = Dock.BOTTOM
			it.dockTop = 2f
			it.childrenOrder = -3
		}

		makeDeviceControls(this, frame, redstoneConfig = menu.redstoneConfig, energyConfig = menu.energyConfig)

		return frame
	}
}
