package score

import (
	"fmt"
	"image/color"

	"github.com/hajimehoshi/ebiten/v2"
	"github.com/hajimehoshi/ebiten/v2/text"
	"golang.org/x/image/font"

	//"golang.org/x/image/font/gofont/gobold"
	"src.robn.tv/MrDonuts/RGB/assets"
	geom "src.robn.tv/MrDonuts/RGB/geometry"
)

var ScoreMngr ScoreManager

type ScoreManager struct{}

func (sm *ScoreManager) Update() {
}

func (sm *ScoreManager) Draw(screen *ebiten.Image) {

	w, h := ebiten.WindowSize()

	//highScoreStr := fmt.Sprintf("High Score: %v", highScore)
	levelStr := fmt.Sprintf("Level: %v", geom.CurrentLevel)
	face := FaceA //assets.LoadFontFace("fonts/robot.otf", 12)

	//draw high score (i.e. best level)
	//stringWidth := font.MeasureString(face, highScoreStr).Ceil()
	//text.Draw(screen, highScoreStr, face, w-stringWidth-geom.HighScoreOffset, h-geom.HighScoreOffset, color.White)

	//draw current level
	//stringWidth = font.MeasureString(face, levelStr).Ceil()
	text.Draw(screen, levelStr, face, geom.HighScoreOffset, h-geom.HighScoreOffset, color.White)

	//draw energy at the top
	energyStr := fmt.Sprintf("Energy: %v", geom.CurrentEnergy)
	face = FaceB // assets.LoadFontFace("fonts/robot.otf", 20)
	stringWidth := font.MeasureString(face, energyStr).Ceil()
	text.Draw(screen, energyStr, face, w/2-stringWidth/2, geom.ScoreOffset, color.White)

}

var (
	FaceA, FaceB font.Face
)

func init() {
	FaceA = assets.LoadFontFace("fonts/robot.otf", 12)
	FaceB = assets.LoadFontFace("fonts/robot.otf", 20)
}
