using System;

namespace SharpQuake
{
	internal class SearchMenu : MenuBase
	{
		public override void Show()
		{
			base.Show();
			net.SlistSilent = true;
			net.SlistLocal = false;
			this._SearchComplete = false;
			net.Slist_f();
		}

		public override void KeyEvent(int key)
		{
		}

		public override void Draw()
		{
			glpic_t glpic_t = Drawer.CachePic("gfx/p_multi.lmp");
			menu.DrawPic((320 - glpic_t.width) / 2, 4, glpic_t);
			int num = 116;
			menu.DrawTextBox(num - 8, 32, 12, 1);
			menu.Print(num, 40, "Searching...");
			if (net.SlistInProgress)
			{
				net.Poll();
				return;
			}
			if (!this._SearchComplete)
			{
				this._SearchComplete = true;
				this._SearchCompleteTime = host.RealTime;
			}
			if (net.HostCacheCount > 0)
			{
				MenuBase.ServerListMenu.Show();
				return;
			}
			menu.PrintWhite(72, 64, "No Quake servers found");
			if (host.RealTime - this._SearchCompleteTime < 3.0)
			{
				return;
			}
			MenuBase.LanConfigMenu.Show();
		}

		private bool _SearchComplete;

		private double _SearchCompleteTime;
	}
}
