package net.minecraft.src;

import java.util.*;

import net.lax1dude.eaglercraft.GuiScreenEditProfile;
import org.lwjgl.opengl.GL11;

public class GuiMainMenu extends GuiScreen {
	private static final Random rand = new Random();
	private float updateCounter = 0.0F;
	private String splashText = "missingno";
	private GuiButton guiButtonMP;

	public GuiMainMenu() {
		ArrayList<String> splashes = new ArrayList<>(Arrays.asList("Darviglet!", "eaglerenophile!", "You Eagler!", "Yeeeeeee!", "yeee", "EEEEEEEEE!", "You Darvig!", "You Vigg!", ":>", "|>", "You Yumpster!", "Poincare", "Socket", "MiG Mad Marine", "Wild Weasel", "YGBSM", "Union Aerospace Corporation"));
		this.splashText = splashes.get(rand.nextInt(splashes.size()));
	}

	public void updateScreen() {
		++this.updateCounter;
	}

	protected void keyTyped(char var1, int var2) {
	}

	public void initGui() {
		Calendar var1 = Calendar.getInstance();
		var1.setTime(new Date());

		if(var1.get(2) + 1 == 12 && var1.get(5) == 24) {
			this.splashText = "Merry X-mas!";
		} else if(var1.get(2) + 1 == 1 && var1.get(5) == 1) {
			this.splashText = "Happy new year!";
		}

		StringTranslate var2 = StringTranslate.getInstance();
		int var4 = this.height / 4 + 48;
		this.controlList.add(new GuiButton(1, this.width / 2 - 100, var4, var2.translateKey("menu.singleplayer")));
		this.controlList.add(this.guiButtonMP = new GuiButton(2, this.width / 2 - 100, var4 + 24, var2.translateKey("menu.multiplayer")));
		this.controlList.add(new GuiButton(3, this.width / 2 - 100, var4 + 48, var2.translateKey("menu.mods")));
        this.controlList.add(new GuiButton(0, this.width / 2 - 100, var4 + 72 + 12, 98, 20, var2.translateKey("menu.options")));
        this.controlList.add(new GuiButton(4, this.width / 2 + 2, var4 + 72 + 12, 98, 20, var2.translateKey("Edit Profile")));

        if(this.mc.session == null) {
			this.guiButtonMP.enabled = false;
		}

	}

	protected void actionPerformed(GuiButton var1) {
		if(var1.id == 0) {
			this.mc.displayGuiScreen(new GuiOptions(this, this.mc.gameSettings));
		}

		if(var1.id == 1) {
			this.mc.displayGuiScreen(new GuiSelectWorld(this));
		}

		if(var1.id == 2) {
			this.mc.displayGuiScreen(new GuiMultiplayer(this));
		}

		if(var1.id == 3) {
			this.mc.displayGuiScreen(new GuiTexturePacks(this));
		}

		if(var1.id == 4) {
			this.mc.displayGuiScreen(new GuiScreenEditProfile(this));
		}

	}

	public void drawScreen(int var1, int var2, float var3) {
		this.drawDefaultBackground();
		Tessellator var4 = Tessellator.instance;
		short var5 = 274;
		int var6 = this.width / 2 - var5 / 2;
		byte var7 = 30;
		GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.mc.renderEngine.getTexture("/title/mclogo.png"));
		GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
		this.drawTexturedModalRect(var6 + 0, var7 + 0, 0, 0, 155, 44);
		this.drawTexturedModalRect(var6 + 155, var7 + 0, 0, 45, 155, 44);
		var4.setColorOpaque_I(16777215);
		GL11.glPushMatrix();
		GL11.glTranslatef((float)(this.width / 2 + 90), 70.0F, 0.0F);
		GL11.glRotatef(-20.0F, 0.0F, 0.0F, 1.0F);
		float var8 = 1.8F - MathHelper.abs(MathHelper.sin((float)(System.currentTimeMillis() % 1000L) / 1000.0F * (float)Math.PI * 2.0F) * 0.1F);
		var8 = var8 * 100.0F / (float)(this.fontRenderer.getStringWidth(this.splashText) + 32);
		GL11.glScalef(var8, var8, var8);
		this.drawCenteredString(this.fontRenderer, this.splashText, 0, -8, 16776960);
		GL11.glPopMatrix();
		this.drawString(this.fontRenderer, "Minecraft Beta 1.4_01", 2, 2, 5263440);
		this.drawString(this.fontRenderer, "Eaglercraft 25w21b", 2, this.height - 10, 16777215);
		this.drawString(this.fontRenderer, "site resources are", this.width - this.fontRenderer.getStringWidth("site resources are") - 2, this.height - 20, 16777215);
		this.drawString(this.fontRenderer, "copyright 2010 Mojang AB", this.width - this.fontRenderer.getStringWidth("copyright 2010 Mojang AB") - 2, this.height - 10, 16777215);

//		String var16;
//		long var17 = EagRuntime.maxMemory();
//		long var9 = EagRuntime.totalMemory();
//		long var11 = EagRuntime.freeMemory();
//		long var13 = var7 - var11;
//		var16 = "Free memory: " + var13 * 100L / var17 + "% of " + var7 / 1024L / 1024L + "MB";
//		this.drawString(this.fontRenderer, var16, this.width - this.fontRenderer.getStringWidth(var16) - 2, 2, 8421504);
//		var16 = "Allocated memory: " + var9 * 100L / var17 + "% (" + var9 / 1024L / 1024L + "MB)";
//		this.drawString(this.fontRenderer, var16, this.width - this.fontRenderer.getStringWidth(var16) - 2, 12, 8421504);

		super.drawScreen(var1, var2, var3);
	}
}
