.float which_mission;
.float menu_screen;
float STARTMENU_OFF = 0;
float STARTMENU_GAMETYPE = 1;
float STARTMENU_OPTIONS = 2;
float STARTMENU_PURCHASE = 4;
float STARTMENU_ABOUT = 8;
float STARTMENU_LAUNCH = 16;
float GAMETYPEMENU_MISSION = 32;
float MISSIONMENU = 64;
void() MainMenu;
void() MenuSelect;

void() Menu_Toggle =
{
	if (!self.menu_screen)
	{
		self.menu_screen = STARTMENU_GAMETYPE;
		MainMenu();
	}
	else
		MenuSelect();
};

void() MainMenu =
{
	//=========
	//Main Menu (start)
	//=========
	if (self.menu_screen == STARTMENU_GAMETYPE)
	{
		centerprint (self, " Main Menu:\n==== ====\n\n    > Game Type\n    Options\n     Purchase\n  About\n         Launch as is");
		return;
	}
	else if (self.menu_screen == STARTMENU_OPTIONS)
	{
		centerprint (self, " Main Menu:\n==== ====\n\n      Game Type\n  > Options\n     Purchase\n  About\n         Launch as is");
		return;
	}
	else if (self.menu_screen == STARTMENU_PURCHASE)
	{
		centerprint (self, " Main Menu:\n==== ====\n\n      Game Type\n    Options\n   > Purchase\n  About\n         Launch as is");
		return;
	}
	else if (self.menu_screen == STARTMENU_ABOUT)
	{
		centerprint (self, " Main Menu:\n==== ====\n\n      Game Type\n    Options\n     Purchase\n> About\n         Launch as is");
		return;
	}
	else if (self.menu_screen == STARTMENU_LAUNCH)
	{
		centerprint (self, " Main Menu:\n==== ====\n\n      Game Type\n    Options\n     Purchase\n  About\n       > Launch as is");
		return;
	}
	//=========
	//Main Menu (end)
	//=========

	//=========
	//Gametype Menu (start)
	//=========
	if (self.menu_screen == GAMETYPEMENU_MISSION)
	{
		centerprint (self, " Game Type:\n==== ====\n\n    > Mission Mode\n    Deathmatch\n          Capture the Flag\nBagman\n      Back to main");
		return;
	}
	//=========
	//Gametype Menu (end)
	//=========

	//=========
	//Mission Menu (start)
	//=========
	if (self.menu_screen == MISSIONMENU)
	{
		if (self.which_mission == 0)
			centerprint (self, " Select a mission:\n====== = =======\n\n(Up & Down scrolls between missions)\n\nMission: 1\nDifficulty: Easy\nLevel: Fast Death\nObjective: Free for all versus 3\n    opponents\nReward: 10 Credits\n");
		else if (self.which_mission == 1)
			centerprint (self, " Select a mission:\n====== = =======\n\n(Up & Down scrolls between missions)\n\n");
		return;
	}
};

void() MenuSelect =
{
	if (!self.menu_screen)
		return;

	if (self.menu_screen == STARTMENU_GAMETYPE)
	{
		self.menu_screen = GAMETYPEMENU_MISSION;
		return;
	}
	else if (self.menu_screen == GAMETYPEMENU_MISSION)
	{
		self.menu_screen = MISSIONMENU;
		return;
	}
	if (self.menu_screen == MISSIONMENU)
	{
		if (self.which_mission == 0)
		{
			BotConnect(0, 0, 0);
			BotConnect(0, 0, 0);
			BotConnect(0, 0, 0);
			localcmd ("changelevel dmarena1\n");
		}
	}
};

// Cursor moves down one
void() MenuDown =
{
	if (!self.menu_screen)
		return;

	if (self.menu_screen == STARTMENU_GAMETYPE)
		self.menu_screen = STARTMENU_OPTIONS;
	else if (self.menu_screen == STARTMENU_OPTIONS)
		self.menu_screen = STARTMENU_PURCHASE;
	else if (self.menu_screen == STARTMENU_PURCHASE)
		self.menu_screen = STARTMENU_ABOUT;
	else if (self.menu_screen == STARTMENU_ABOUT)
		self.menu_screen = STARTMENU_LAUNCH;
	else if (self.menu_screen == STARTMENU_LAUNCH)
		self.menu_screen = STARTMENU_GAMETYPE;

	if (self.menu_screen == MISSIONMENU)
	{
		if (self.which_mission < 1)
			self.which_mission = self.which_mission + 1;
		else
			self.which_mission = 0;
	}
};

void() MenuUp =
{
	if (!self.menu_screen)
		return;

	if (self.menu_screen == STARTMENU_GAMETYPE)
		self.menu_screen = STARTMENU_LAUNCH;
	else if (self.menu_screen == STARTMENU_LAUNCH)
		self.menu_screen = STARTMENU_ABOUT;
	else if (self.menu_screen == STARTMENU_ABOUT)
		self.menu_screen = STARTMENU_PURCHASE;
	else if (self.menu_screen == STARTMENU_PURCHASE)
		self.menu_screen = STARTMENU_OPTIONS;
	else if (self.menu_screen == STARTMENU_OPTIONS)
		self.menu_screen = STARTMENU_GAMETYPE;

	if (self.menu_screen == MISSIONMENU)
	{
		if (self.which_mission > 0)
			self.which_mission = self.which_mission - 1;
		else
			self.which_mission = 1;
	}
};