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.screen.MatteryScreen
import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel
import ru.dbotthepony.mc.otm.client.screen.panels.button.DeviceControls
import ru.dbotthepony.mc.otm.client.screen.panels.util.GridPanel
import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel
import ru.dbotthepony.mc.otm.menu.decorative.MinecartCargoCrateMenu

class MinecartCargoCrateScreen(menu: MinecartCargoCrateMenu, inventory: Inventory, title: Component) : MatteryScreen<MinecartCargoCrateMenu>(menu, inventory, title) {
	override fun makeMainFrame(): FramePanel<MatteryScreen<*>> {
		val frame = FramePanel(this, null, 0f, 0f, INVENTORY_FRAME_WIDTH, 22f + 4f + 6f * 18f, getTitle())

		frame.makeCloseButton()
		frame.onClose { onClose() }

		val grid = GridPanel(this, frame, 8f, 18f, 9f * 18f, 6f * 18f, 9, 6)

		for (slot in menu.storageSlots)
			SlotPanel(this, grid, slot)

		val controls = DeviceControls(this, frame)

		controls.sortingButtons(menu.sort)

		return frame
	}
}
