package ui

import (
	"tetris/engine/render"

	rl "github.com/gen2brain/raylib-go/raylib"
)

type Button struct {
	Text   string
	Action func()
}

func NewButton(text string, action func()) Button {
	return Button{
		Text:   text,
		Action: action,
	}
}

func (b Button) HandleInput() {
	if rl.IsKeyPressed(rl.KeyEnter) {
		b.Action()
	}
}

func (b Button) Draw(x, y int32, selected bool) {
	col := rl.White
	if selected {
		col = rl.Red
	}
	render.DrawTextCenter(x, y, 32, b.Text, col)
}
