package uk.co.rossbinden.transferencevoid.screen

import com.badlogic.gdx.Gdx
import com.badlogic.gdx.ScreenAdapter
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.GL20
import com.badlogic.gdx.graphics.g2d.BitmapFont
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import uk.co.rossbinden.transferencevoid.TransferenceVoid.assetManager


class EndScreen(val score: Int) : ScreenAdapter() {

    val spriteBatch = SpriteBatch()

    init {
        assetManager.load("fonts/envy_code_r_32.fnt", BitmapFont::class.java)
    }

    override fun render(delta: Float) {
        if (assetManager.isLoaded("fonts/envy_code_r_32.fnt")) {
            Gdx.gl.glClearColor(0f, 0f, 0f, 1f)
            Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT)
            val font = assetManager.get("fonts/envy_code_r_32.fnt", BitmapFont::class.java)
            spriteBatch.begin()
            font.color = Color.WHITE
            font.draw(spriteBatch, "Data uploaded: $score", 32f, 64f)
            spriteBatch.end()
        } else {
            assetManager.update()
        }
    }

    override fun dispose() {
        spriteBatch.dispose()
    }

}