using System;

namespace SharpQuake
{
	internal class MultiPleerMenu : MenuBase
	{
		public override void KeyEvent(int key)
		{
			if (key <= 27)
			{
				if (key != 13)
				{
					if (key != 27)
					{
						return;
					}
					MenuBase.MainMenu.Show();
					return;
				}
				else
				{
					menu.EnterSound = true;
					switch (this._Cursor)
					{
					case 0:
						if (net.TcpIpAvailable)
						{
							MenuBase.LanConfigMenu.Show();
							return;
						}
						break;
					case 1:
						if (net.TcpIpAvailable)
						{
							MenuBase.LanConfigMenu.Show();
							return;
						}
						break;
					case 2:
						MenuBase.SetupMenu.Show();
						break;
					default:
						return;
					}
				}
			}
			else if (key != 128)
			{
				if (key != 129)
				{
					return;
				}
				snd.LocalSound("misc/menu1.wav");
				int num = this._Cursor + 1;
				this._Cursor = num;
				if (num >= 3)
				{
					this._Cursor = 0;
					return;
				}
			}
			else
			{
				snd.LocalSound("misc/menu1.wav");
				int num = this._Cursor - 1;
				this._Cursor = num;
				if (num < 0)
				{
					this._Cursor = 2;
					return;
				}
			}
		}

		public override void Draw()
		{
			menu.DrawTransPic(16, 4, Drawer.CachePic("gfx/qplaque.lmp"));
			glpic_t glpic_t = Drawer.CachePic("gfx/p_multi.lmp");
			menu.DrawPic((320 - glpic_t.width) / 2, 4, glpic_t);
			menu.DrawTransPic(72, 32, Drawer.CachePic("gfx/mp_menu.lmp"));
			float num = (float)((int)(host.Time * 10.0) % 6);
			menu.DrawTransPic(54, 32 + this._Cursor * 20, Drawer.CachePic(string.Format("gfx/menudot{0}.lmp", num + 1f)));
			if (net.TcpIpAvailable)
			{
				return;
			}
			menu.PrintWhite(52, 148, "No Communications Available");
		}

		private const int MULTIPLAYER_ITEMS = 3;
	}
}
