package client.gui.ingame;

import client.gui.Gui;
import client.gui.element.ActButton;
import client.gui.element.ButtonCallback;
import common.util.ExtMath;
import common.util.Color;
import client.gui.element.Label;
import client.gui.element.MultiLabel;
import client.gui.element.PressType;

public class GuiGameOver extends Gui {
	public static final GuiGameOver INSTANCE = new GuiGameOver();
	
	private ActButton button;
	private int timer;
	
	private GuiGameOver() {
	}

	public void init(int width, int height) {
		this.timer = 0;
		this.add(new Label(0, 0, 400, 0, Color.DARK_RED + "Du bist gestorben!"));
		this.add(new MultiLabel(0, 32, 400, 42, String.format(Color.GREEN + "Letzte Position" + Color.GRAY + ":\n" + Color.YELLOW + "%d, %d, %d\n" + Color.YELLOW + "%s", ExtMath.floord(this.gm.player.posX), ExtMath.floord(this.gm.player.posY), ExtMath.floord(this.gm.player.posZ), this.gm.player.worldObj.dimension.getDisplay())));
		this.button = this.add(new ActButton(100, 100, 200, 0, new ButtonCallback() {
			public void use(ActButton elem, PressType action) {
				GuiGameOver.this.gm.player.respawnPlayer();
				GuiGameOver.this.gm.show(null);
			}
		}, "Wiederbeleben"));
		this.shift();
		this.button.enabled = false;
	}
	
	public String getTitle() {
		return "Game over - Wiederbeleben?";
	}
	
	public void updateScreen() {
		if(++this.timer >= 20)
			this.button.enabled = true;
	}
}
