package ru.dbotthepony.mc.otm.client.screen.panels.button

import net.minecraft.client.gui.screens.Screen
import ru.dbotthepony.mc.otm.client.render.MGUIGraphics
import ru.dbotthepony.mc.otm.client.render.sprites.MatterySprite
import ru.dbotthepony.mc.otm.client.render.UVWindingOrder
import ru.dbotthepony.mc.otm.client.render.Widgets8
import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel

open class SmallRectangleButtonPanel<out S : Screen>(
	screen: S,
	parent: EditablePanel<*>?,
	x: Float = 0f,
	y: Float = 0f,
	width: Float = SIZE,
	height: Float = SIZE,
	onPress: ((clickButton: Int) -> Unit)? = null,
	val skinElement: MatterySprite? = null,
	val skinElementWinding: UVWindingOrder? = null,
) : RectangleButtonPanel<S>(screen, parent, x, y, width, height, onPress) {
	final override val IDLE = Widgets8.BUTTON_IDLE
	final override val HOVERED = Widgets8.BUTTON_HOVERED
	final override val PRESSED = Widgets8.BUTTON_PRESSED
	final override val DISABLED = Widgets8.BUTTON_DISABLED

	override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {
		super.innerRender(graphics, mouseX, mouseY, partialTick)

		if (skinElementWinding != null) {
			skinElement?.render(graphics, width = width, height = height, winding = skinElementWinding)
		} else {
			skinElement?.render(graphics, width = width, height = height)
		}
	}

	companion object {
		const val SIZE = 8f
	}
}
