package xaero.rotatenjump.gui.elements;

import xaero.rotatenjump.GameView;
import xaero.rotatenjump.game.Level;
import xaero.rotatenjump.game.graphics.Graphics;

/**
 * Created by xaero on 12/07/2017.
 */

public class LevelButton extends Button {

    private static final float[] COLOUR_DARK = {0.39f, 0.39f, 0.39f, 0.39f};
    private static final float[] COLOUR_BRIGHT = {0.86f, 0.86f, 0.86f, 0.86f};

    private Level level;

    public LevelButton(Level level, float x, float y) {
        super(x, y, 200, 200);
        this.level = level;
    }

    @Override
    public void render(float offX, float offY) {
        super.render(offX, offY);

        if(!isDown)
            Graphics.color = COLOUR_DARK;
        else {
            Graphics.color = COLOUR_BRIGHT;
        }
        Graphics.SQUARE.draw(x + offX + w / 2, y + offY + h / 2, 0, 0, 0, w, h, 1);
        Graphics.color = Graphics.DKGRAY;
        Graphics.fontRenderer.drawCenteredGUIString(level.getButtonText(), x + offX + w / 2, y + offY + h / 2 + 7, 1);
       /* paint.setColor(Color.BLACK);
        paint.setTextAlign(Paint.Align.CENTER);
        paint.setTextSize(60);
        SimpleGraphics.scaledText(canvas, paint, level.getButtonText(), x + w / 2, y + h / 2 + 20);*/
    }

    @Override
    public void onRelease(boolean activate) {
        super.onRelease(activate);
        if(activate) {
            GameView.newLevel(level);
            GameView.changeScreen(null);
        }
    }
}
