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

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.UVWindingOrder

class SpritePanel<out S : Screen>(
	screen: S,
	parent: EditablePanel<*>? = null,
	val sprite: AbstractMatterySprite,
	x: Float = 0f,
	y: Float = 0f,
	width: Float = sprite.width,
	height: Float = sprite.height,
	var winding: UVWindingOrder = sprite.winding,
	var centerSprite: Boolean = false
) : EditablePanel<S>(screen, parent, x, y, width, height) {
	override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {
		if (centerSprite) {
			sprite.render(graphics, width / 2f - sprite.width / 2f, height / 2f - sprite.height / 2f, sprite.width, sprite.height, winding)
		} else {
			sprite.render(graphics, 0f, 0f, width, height, winding)
		}
	}
}
