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

import com.mojang.blaze3d.vertex.PoseStack
import net.minecraft.client.gui.GuiGraphics
import net.minecraft.client.gui.screens.Screen
import ru.dbotthepony.mc.otm.client.render.AbstractMatterySprite
import ru.dbotthepony.mc.otm.client.render.IGUIRenderable
import ru.dbotthepony.mc.otm.client.render.UVWindingOrder
import ru.dbotthepony.mc.otm.client.render.Widgets18
import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel

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

	override fun innerRender(graphics: GuiGraphics, 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 = 18f
	}
}
