public override bool Connect(ServerRow server, string password, bool spectate) { // servers with skill restrictions neither allow connections with "steam://connect" nor with an "open ip:port" console command if ((string) this.GetServerCellValue(server, "_skillclass") != "1-12") { var res = XtraMessageBox.Show("This server has a skill restriction.\nOnly the in-game browser can connect to such servers.\nLaunch TOXIKK anyway?", "Toxikk Server", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation); if (res == DialogResult.No) return false; if (FindToxikkWindow() == IntPtr.Zero) StartToxikk(); return true; } if (consoleKey == Keys.None) { using (var dlg = new KeyBindForm("Please press your Toxikk console key...")) { if (dlg.ShowDialog(Application.OpenForms[0]) == DialogResult.Cancel) return false; consoleKey = dlg.Key; Properties.Settings.Default.ToxikkConsoleKey = (int) consoleKey; Properties.Settings.Default.Save(); } } ThreadPool.QueueUserWorkItem(context => ConnectInBackground(server, password, spectate), null); return true; }
public override bool Connect(ServerRow server, string password, bool spectate) { if (consoleKey == Keys.None && (this.useKeystrokesToConnect || spectate)) { using (var dlg = new KeyBindForm("Please press your TOXIKK console key...")) { if (dlg.ShowDialog(Application.OpenForms[0]) == DialogResult.Cancel) { return(false); } this.consoleKey = dlg.Key; } } if (this.useKeystrokesToConnect || spectate) { // don't use the ThreadPool b/c it might be full with waiting server update requests new Thread(ctx => { ConnectInBackground(server, password, spectate); }).Start(); return(true); } return(base.Connect(server, password, false)); }