public Form2(string demoUrl, NFKProcess np) { InitializeComponent(); this.demoUrl = demoUrl; this.np = np; }
static void Main(string[] args) { // set allowed protocol to download from ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12; Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); if (args.Length == 0) { Application.Run(new Form1()); } else { var np = new NFKProcess(); // connect to server if (args[0].StartsWith("nfk://")) { var serverAddress = getServerAddress(args[0]); var spectator = !args[0].Contains("play"); if (!NFKHelper.SendPing(serverAddress)) { Common.ShowError("Connection timeout", "Could not connect to NFK server " + serverAddress); return; } if (!spectator) { // if play mode then just run a game and exit np.RunGame(serverAddress); return; } // run nfk np.Run(serverAddress, false); np.WatchForExit(); } // play demo else { var demoUrl = getDemoPath(args[0]); Application.Run(new Form2(demoUrl, np)); if (!String.IsNullOrEmpty(NFKHelper.DemoFile)) { // show video intro after the download form if (np.Intro != null && !np.Intro.CloseFlag && np.GameRunning) { Application.Run(np.Intro); } } } // this form is used to keep program running if (np.StubForm != null && !np.StubForm.CloseFlag && np.GameRunning) { Application.Run(np.StubForm); } } }