package menus;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;

public class MenuOpcions extends Menu{
	String[] fondos= {"muralla china", "ciudad china", "italia"};
	String[] colores= {"rojo","azul","amarillo"};
	int opcion1;
	int opcion2;
	String fondo;
	boolean pres2;
	Color color;
	public MenuOpcions(Color color) {
		super();
		this.color=color;
		this.pres2=false;
		this.opcion1=0;
		this.opcion2=0;
		this.n_opciones=2;
		this.local=Menu.OPCIONES;
		
	}
	
	@Override
	public int draw(SpriteBatch batch, float delta) {
		Menu.selector.avanzar(10, delta);
		switch(this.position) {
		case 0:{
			Menu.selector.draw(batch, Gdx.graphics.getWidth()/5, Gdx.graphics.getHeight()/2.2f);
			Menu.selector.draw(batch, Gdx.graphics.getWidth()/5+280, Gdx.graphics.getHeight()/2.2f);
			break;
		}
		case 1:{
			Menu.selector.draw(batch, Gdx.graphics.getWidth()/5, Gdx.graphics.getHeight()/3.9f);
			Menu.selector.draw(batch, Gdx.graphics.getWidth()/5+230, Gdx.graphics.getHeight()/3.9f);
		}
		}
		font.draw(batch, "color fondo", Gdx.graphics.getWidth()/3.75f,Gdx.graphics.getHeight()/2);
		font.draw(batch, this.colores[this.opcion1], Gdx.graphics.getWidth()/3.2f,Gdx.graphics.getHeight()/2.3f);
		font.draw(batch, "escenario", Gdx.graphics.getWidth()/3.75f,Gdx.graphics.getHeight()/3.2f);
		font.draw(batch, this.fondos[this.opcion2], Gdx.graphics.getWidth()/4f,Gdx.graphics.getHeight()/5f);
		this.seleccionOpcion();
		return this.cambiarSeleccionado();
	}
	
	int getFondo() {
		return this.opcion2;
	}
	
	void seleccionOpcion(){
		if(this.position==0) {
			if(Gdx.input.isKeyPressed(Input.Keys.RIGHT)) {
				if(!this.pres2) {
					this.opcion1++;
					if(this.opcion1>=this.colores.length) {
						this.opcion1=0;
					}
					this.cambiarColor();
					this.pres2=true;
				}
			}else if(Gdx.input.isKeyPressed(Input.Keys.LEFT)) {
				if(!this.pres2) {
					this.opcion1--;
					if(this.opcion1<0) {
						this.opcion1=this.colores.length;
					}
					this.cambiarColor();
					this.pres2=true;
				}
			}else if(this.pres2) {
				this.pres2=false;
			}
		}else if(this.position==1) {
			if(Gdx.input.isKeyPressed(Input.Keys.RIGHT)) {
				if(!this.pres2) {
					this.opcion2++;
					if(this.opcion2>=this.fondos.length) {
						this.opcion2=0;
					}
					this.pres2=true;
				}
			}else if(Gdx.input.isKeyPressed(Input.Keys.LEFT)) {
				if(!this.pres2) {
					this.opcion2--;
					if(this.opcion2<0) {
						this.opcion2=this.fondos.length;
					}
					this.pres2=true;
				}
			}else if(this.pres2) {
				this.pres2=false;
			}
		}
	}
	
	void cambiarColor() {
		switch(this.opcion1) {
		case 0:this.color.set(0.5f, 0, 0, 1);
			break;
		case 1:this.color.set(0, 0, 0.5f, 1);
			break;
		case 2:	this.color.set(0.5f, 0.5f, 0, 1);
			break;
		}
	}
	
	int darSeleccionado() {
		Menu.menus.get(Menu.INICIAL).pres=true;
		this.pres=true;
		return Menu.INICIAL;
	}

}
