package net.mueller_martin.turirun;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.ScreenAdapter;
import com.badlogic.gdx.audio.Music;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
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.utils.BaseDrawable;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton.TextButtonStyle;

public class GameOverScreen extends ScreenAdapter {
	public final static String TAG = GameOverScreen.class.getName();
	ScreenManager screenManager;
	Stage stage;
	Table table;
	String winner;

	public GameOverScreen(ScreenManager s) {
		this.screenManager = s;

		// Load winner string from main class
		winner = s.game.winner;

		MusicBox.instance.loopTheme(Constants.AUDIO_LOOP1);
		stage = new Stage();
		table = new Table();
		BitmapFont font = new BitmapFont();
		BaseDrawable dummy = new BaseDrawable(); // Replaces cursor, background etc.

		LabelStyle labelStyle = new LabelStyle(font, Color.WHITE);
		Label gameOverLabel = new Label("Game Over", labelStyle);
		Label winnerLabel = new Label(winner + " win", labelStyle);

		TextButtonStyle textButtonStyle = new TextButtonStyle(dummy, dummy, dummy, font);
		TextButton quitButton = new TextButton("Quit", textButtonStyle);
		TextButton menuButton = new TextButton("Menu", textButtonStyle);

		table.setFillParent(true);
		stage.addActor(table);

		table.row();
		table.add(gameOverLabel).expand().colspan(2);
		table.row();
		table.add(winnerLabel).expand().top().colspan(2);
		table.row();
		table.add(quitButton).minHeight(100);
		table.add(menuButton);

		quitButton.addListener(new ClickListener() {
			@Override
			public void clicked(InputEvent event, float x, float y) {
				MusicBox.instance.stopMusic(Constants.AUDIO_LOOP1);
				Gdx.app.exit();
			}
		});

		menuButton.addListener(new ClickListener() {
			@Override
			public void clicked(InputEvent event, float x, float y) {
				//screenManager.game.reset();
				MusicBox.instance.stopMusic(Constants.AUDIO_LOOP1);
				screenManager.setScreenState(Constants.MENUSCREEN);
			}
		});

		Gdx.input.setInputProcessor(stage);

		// Turn on all debug lines (table, cell, and widget)
		//table.setDebug(true);
	}

	public void render(float delta) {
		Gdx.gl.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
		Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
		stage.act(Gdx.graphics.getDeltaTime());
		stage.draw();
	}

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

@@ -1647,75 +1647,8 @@
 le);
-%0A%09%09TextButton menuButton = new TextButton(%22Menu%22, textButtonStyle);
 %0A%0A%09%09
@@ -1750,27 +1750,16 @@
 expand()
-.colspan(2)
 ;%0A%09%09tabl
@@ -1810,19 +1810,8 @@
 op()
-.colspan(2)
 ;%0A%09%09
@@ -1866,33 +1866,8 @@
 00);
-%0A%09%09table.add(menuButton);
 %0A%0A%09%09
@@ -2077,287 +2077,8 @@
 );%0A%0A
-%09%09menuButton.addListener(new ClickListener() %7B%0A%09%09%09@Override%0A%09%09%09public void clicked(InputEvent event, float x, float y) %7B%0A%09%09%09%09//screenManager.game.reset();%0A%09%09%09%09MusicBox.instance.stopMusic(Constants.AUDIO_LOOP1);%0A%09%09%09%09screenManager.setScreenState(Constants.MENUSCREEN);%0A%09%09%09%7D%0A%09%09%7D);%0A%0A
 %09%09Gd

Remove menu button from game over screen as quick & dirty reset