package com.iofferyoutea.WitchQueen

import com.badlogic.gdx.graphics.Texture
import com.badlogic.gdx.graphics.g2d.BitmapFont
import com.badlogic.gdx.scenes.scene2d.ui.Container
import com.badlogic.gdx.scenes.scene2d.ui.TextButton
import com.badlogic.gdx.scenes.scene2d.ui.TextButton.TextButtonStyle
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable
import ktx.assets.toInternalFile

open class Button(val upTexturePath: String, val downTexturePath: String, val fontPath: String, val defaultText: String = "New Button", val useDefaultFont: Boolean = true, val fontScale: Float = 1f) {
    val buttonText = defaultText
    val buttonUp = TextureRegionDrawable(Texture(upTexturePath))
    val buttonDown = TextureRegionDrawable(Texture(downTexturePath))
    val buttonFont = (if (useDefaultFont) BitmapFont() else BitmapFont(fontPath.toInternalFile())).apply { data.scale(fontScale) }

    val buttonStyle = TextButtonStyle().apply { up = buttonUp; down = buttonDown; font = buttonFont }

    val button = TextButton(defaultText, buttonStyle)
    val container = Container<TextButton>(button)
}
