package com.darkdimension.ritle_run;

import android.graphics.Canvas;
import android.graphics.Paint;

public abstract class Menu
{
    public static enum Action
    {
        TO_MAIN_MENU,
        TO_GAME,
        TO_EXTRA,
        EXIT_GAME,

        TO_FACEBOOK,
        TO_TWITTER,
        TO_TUMBLR,
        TO_PLAY_STORE,

        SHOW_AD,
		CHANGE_CHAR,

        NO_ACTION
    }

    //Create-Destroy
    protected DiAnimation aBasic = new DiAnimation(10);
    protected Paint invisible = new Paint();
    protected Action nMenu = null;

    //Touch
    protected boolean bTouched = false;
    protected int touchX = -1, touchY = -1;

    //Draw
    protected boolean bDraw = true;

    public Menu()
    {
        //Starting invisible
        invisible.setAlpha(0);

        //Starting Menu
        aBasic.startFromBeginning();
    }

    //Input
    protected boolean touch(int x, int y)
    {
        //Apply touch
        bTouched = true;
        touchX = x;
        touchY = y;

        //No sliding
        return false;
    }

    //Update
    protected Action update()
    {
        //Animation
        if (aBasic.update())
        {
            //Invisible animations
            invisible.setAlpha(aBasic.getCounter() * 255 / aBasic.getMax());

            //Draw Changes
            bDraw = true;
        }

        //Nothing happened
        return Action.NO_ACTION;
    }

    //Draw
    protected void draw(Canvas canvas)
    {
        //Don't draw again
        bDraw = false;
    }

    //Actions
    protected void forceDraw() {bDraw = true;}

    public void destroy(Action gMenu)
    {
        //Save next menu
        nMenu = gMenu;

        //Start destroy animation
        aBasic.startFromEnd();
    }

    //Isers
    public boolean isAnimating() {return aBasic.isRunning();}

    public boolean needsToBeDrawn(){return bDraw;}
}