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

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.Dock
import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel
import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel
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.SpritePanel
import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel
import ru.dbotthepony.mc.otm.client.screen.widget.TallHorizontalProfiledPowerGaugePanel
import ru.dbotthepony.mc.otm.menu.tech.AndroidChargerMenu

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

		frame.height = 42f
		frame.width -= 20f

		val strip = EditablePanel(this, frame, height = AbstractSlotPanel.SIZE)
		strip.dock = Dock.BOTTOM

		BatterySlotPanel(this, strip, menu.batterySlot).also {
			it.dock = Dock.LEFT
			it.dockRight = 2f
		}

		SpritePanel(this, strip, ProgressGaugePanel.GAUGE_BACKGROUND).also {
			it.dock = Dock.LEFT
			it.dockRight = 2f
			it.dockTop = 2f
		}

		TallHorizontalProfiledPowerGaugePanel(this, strip, menu.profiledEnergy).also {
			it.dock = Dock.LEFT
			it.dockRight = 2f
		}

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

		return frame
	}
}
