//Copyright (C) 2007 SiegeLord
//See ReadMe.txt and License.txt for copying information

#include "mainmenu.h"
#include "neonz.h"
#include "sounds.h"

SKeyDummy* g_guiMainMenuDummy;
extern FONT* g_fntFont;
SBitmap* g_bmpTitle;

void InitMainMenu()
{
	g_guiMainMenuDummy = CreateKeyDummy(0, 0, 0, 0, 0);

	const int size = 150;

	g_bmpTitle = FindBitmap("title.tga");

	CreateButton(g_guiMainMenuDummy, SCREEN_W / 2 - size / 2, SCREEN_H / 2, size, 30, GetMask(1), "Single Player", g_fntFont);
	CreateButton(g_guiMainMenuDummy, SCREEN_W / 2 - size / 2, SCREEN_H / 2 + 45, size, 30, GetMask(2), "Multiplayer", g_fntFont);
	CreateButton(g_guiMainMenuDummy, SCREEN_W / 2 - size / 2, SCREEN_H / 2 + 90, size, 30, GetMask(3), "Quit", g_fntFont);
}

int HandleMainMenu()
{
	int ret = DoGUILogic(g_guiMainMenuDummy, 0, 0);

	if(ret & GetMask(1))
	{
		//onto the main game
		PlayButtonSound();
		return 1;
	}
	else if(ret & GetMask(2))
	{
		PlayButtonSound();
		//do nothing... no multiplayer yet :`(    			( .V.)=O#''\../''\../''\../''\0        \( 'o')/
	}
	else if(ret & GetMask(3))//quit
	{
		PlayButtonSound();
		return 2;
	}
	return 0;
}

void DrawMainMenu()
{
	DrawBitmap(g_bmpTitle, SCREEN_W / 2 - g_bmpTitle->w / 2, SCREEN_H / 2 - g_bmpTitle->h - 10, -10);
	DrawGUI(g_guiMainMenuDummy);
}

void DeInitMainMenu()
{
	DestroyGUI(g_guiMainMenuDummy);
}
