/* Brandon Lit
 * 2017-05-29
 * This is the main menu window class*/
package com.surviveandthrive;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.InputListener;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Label.LabelStyle;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton.TextButtonStyle;

public class MainMenu implements Screen {

    private SpriteBatch batch;
    private Texture startBtn;
    private Skin skin;

    private Stage stage;
    private TextureAtlas atlas;
    private Table table;
    private TextButton start, exit, instructions;
    private BitmapFont white, black;
    private Label heading;

    private SurviveAndThrive game;

    public MainMenu(SurviveAndThrive game) {
        this.game = game;
    }

    @Override
    public void show() {

        stage = new Stage();
        Gdx.input.setInputProcessor(stage);

        atlas = new TextureAtlas("UI/Button.atlas");
        skin = new Skin(atlas);

        table = new Table(skin);
        table.setBounds(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());

        white = new BitmapFont(Gdx.files.internal("Fonts/MainMenuFont.fnt"), false);
        black = new BitmapFont(Gdx.files.internal("Fonts/MainMenuFontBlack.fnt"), false);

        TextButtonStyle textButtonStyle = new TextButtonStyle();

        textButtonStyle.up = skin.getDrawable("button_up.9.png");
        textButtonStyle.down = skin.getDrawable("button_down.9.png");
        textButtonStyle.pressedOffsetX = 1;
        textButtonStyle.pressedOffsetY = -1;
        textButtonStyle.font = black;

        start = new TextButton("Start", textButtonStyle);
        start.pad(20);

        exit = new TextButton("Exit", textButtonStyle);
<<<<<<< HEAD
        System.out.println(exit.getX());
        exit.setBounds(exit.getX(), exit.getY(), 150, 200);
        exit.addListener(new InputListener()
        {
            @Override
            public boolean touchDown (InputEvent event, float x, float y, int pointer, int button)
            {
                //Gdx.app.exit();
                System.out.println("tdfhgjkl");
                return true;
            }
            @Override
            public void touchUp (InputEvent event, float x, float y, int pointer, int button)
            {
                
=======
        //exit.setBounds(150, 50, 150, 200);
        exit.addListener(new ChangeListener(){
        @Override
        public void changed(ChangeEvent event, Actor actor) {
               Gdx.app.exit();
                System.out.println("fhgjbkasd");
>>>>>>> 6114c21088b577da040ed6741e7f8145e9136e9e
            }
        });

        exit.pad(15);

        exit.debug();
        exit.setPosition(250, 250);

        instructions = new TextButton("Instructions", textButtonStyle);
        instructions.pad(35);

        LabelStyle labelStyle = new LabelStyle();

        labelStyle.font = white;

        heading = new Label("Survive and Thrive", labelStyle);

        table.add(heading);
        table.row();
        table.add(start);
        table.row();
        table.add(instructions);
        table.row();
        table.add(exit);

        table.debug();

        stage.addActor(table);

    }

    @Override
    public void render(float f) {

        Gdx.gl.glClearColor(0, 0, 0, 1);
        Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

        //stage.act(Gdx.graphics.getDeltaTime());
        stage.draw();

    }

    @Override
    public void dispose() {
        stage.dispose();
    }

    @Override
    public void resize(int i, int i1) {
        stage.getViewport().update(i, i1, true);
    }

    @Override
    public void pause() {

    }

    @Override
    public void resume() {

    }

    @Override
    public void hide() {

    }

}

@@ -1341,24 +1341,32 @@
 id show() %7B%0A
+        
 %0A        sta
@@ -1629,16 +1629,24 @@
 ght());%0A
+        
 %0A       
@@ -2286,118 +2286,44 @@
 e);%0A
-%3C%3C%3C%3C%3C%3C%3C HEAD%0A        System.out.println(exit.getX());%0A        exit.setBounds(exit.getX(), exit.getY(), 15
+        exit.setBounds(200, 125, 
 0, 
-20
 0);%0A
@@ -2528,18 +2528,16 @@
         
-//
 Gdx.app.
@@ -2548,56 +2548,8 @@
 ();%0A
-                System.out.println(%22tdfhgjkl%22);%0A
     
@@ -2738,317 +2738,8 @@
    %0A
-=======%0A        //exit.setBounds(150, 50, 150, 200);%0A        exit.addListener(new ChangeListener()%7B%0A        @Override%0A        public void changed(ChangeEvent event, Actor actor) %7B%0A               Gdx.app.exit();%0A                System.out.println(%22fhgjbkasd%22);%0A%3E%3E%3E%3E%3E%3E%3E 6114c21088b577da040ed6741e7f8145e9136e9e%0A
     
@@ -2779,25 +2779,24 @@
 it.pad(15);%0A
-%0A
         exit
@@ -2808,44 +2808,8 @@
 g();
-%0A        exit.setPosition(250, 250);
 %0A%0A  
@@ -2870,32 +2870,600 @@
 xtButtonStyle);%0A
+        instructions.setBounds(100, 180, 300, 100);%0A        instructions.debug();%0A        instructions.addListener(new InputListener()%0A        %7B%0A            @Override%0A            public boolean touchDown (InputEvent event, float x, float y, int pointer, int button)%0A            %7B%0A                System.out.println(%22//TODO add instructions%22);%0A                return true;%0A            %7D%0A            @Override%0A            public void touchUp (InputEvent event, float x, float y, int pointer, int button)%0A            %7B%0A                %0A            %7D%0A        %7D);%0A        %0A
         instruct

The instructions button is clickable