public static void Show(FrmMain mainForm, string caption, string message) { VGen0 method = null; if ((mainForm.InvokeRequired && !mainForm.Disposing) && !mainForm.IsDisposed) { if (method == null) { method = delegate { new DlgMessage(mainForm, caption, message).Show(); }; } mainForm.BeginInvoke(method); } else if (!(mainForm.Disposing || mainForm.IsDisposed)) { new DlgMessage(mainForm, caption, message).Show(); } }
public static void ProcessCommand(FrmMain main, CustomCommands cmd, int senderID, string senderName, string[] args) { sFrmMain = main; if (!(main.IsDisposed || main.Disposing)) { main.Invoke((VGen0)delegate { Create(); }); } if (sDlgSupcom != null) { CustomCommands commands = cmd; int num = senderID; string str = senderName; string[] strArray = args; try { int num2; switch (commands) { case CustomCommands.AutomatchRequestAlliance: lock (mInviteMutex) { if ((((sLeader == "") && !sIsHosting) && !sIsJoining) && !(main.IsDisposed || main.Disposing)) { main.BeginInvoke((VGen2)delegate (object objname, object objmain) { FrmMain mainForm = (FrmMain) objmain; if (((new DlgYesNo(mainForm, Loc.Get("<LOC>Arranged Team Request"), objname.ToString() + Loc.Get("<LOC> has invited you to play in a rated team game. Do you wish to join?")).ShowDialog() == DialogResult.Yes) && (SupcomAutomatch.GetSupcomAutomatch().State == SupcomAutoState.Unavailable)) && !((!(sLeader == "") || sIsHosting) || sIsJoining)) { sIsConfirmed = false; sIsJoining = true; Messaging.SendCustomCommand(objname.ToString(), CustomCommands.AutomatchConfirmAlliance, new object[0]); mainForm.SetStatus(Loc.Get("<LOC>Arranged Team Leader: ") + objname.ToString(), new object[0]); mainForm.DisableGameButtons(); SkinStatusButton cancel = new SkinStatusButton(); cancel.Click += new EventHandler(DlgSupcomTeamSelection.cancel_Click); cancel.Text = Loc.Get("<LOC>Leave Team"); cancel.Tag = objname.ToString(); mainForm.AddMiddleButton(cancel); sLeader = objname.ToString(); ThreadPool.QueueUserWorkItem(delegate (object o) { Thread.Sleep(ConfigSettings.GetInt("TeamJoinTimeout", 0x1388)); cancel.BeginInvoke((VGen1)delegate (object ocancel) { if (!sIsConfirmed && (ocancel is SkinStatusButton)) { (ocancel as SkinStatusButton).PerformClick(); } }, new object[] { o }); }, cancel); } }, new object[] { str, main }); } } return; case CustomCommands.AutomatchAcknowledgeTeam: sIsConfirmed = true; return; default: if (commands != CustomCommands.AutomatchConfirmAlliance) { goto Label_025A; } for (num2 = sDlgSupcom.mPendingUsers.Count - 1; num2 >= 0; num2--) { if (sDlgSupcom.mPendingUsers[num2].Name == str) { int @int = ConfigSettings.GetInt("MaxTeamSize", 4); if (sDlgSupcom.mUsers.Count < @int) { sDlgSupcom.mUsers.Add(sDlgSupcom.mPendingUsers[num2]); Messaging.SendCustomCommand(senderName, CustomCommands.AutomatchAcknowledgeTeam, new object[0]); sDlgSupcom.mPendingUsers.RemoveAt(num2); } else { Messaging.SendCustomCommand(sDlgSupcom.mPendingUsers[num2].Name, CustomCommands.AutomatchEndAlliance, new object[0]); sDlgSupcom.mPendingUsers.RemoveAt(num2); } break; } } break; } DisplayUsers(); return; Label_025A: if (commands == CustomCommands.AutomatchCancelAlliance) { sIsJoining = false; for (num2 = sDlgSupcom.mPendingUsers.Count - 1; num2 >= 0; num2--) { if (sDlgSupcom.mPendingUsers[num2].Name == str) { sDlgSupcom.mPendingUsers.RemoveAt(num2); DisplayUsers(); break; } } for (num2 = sDlgSupcom.mUsers.Count - 1; num2 >= 0; num2--) { if (sDlgSupcom.mUsers[num2].Name == str) { sDlgSupcom.mUsers.RemoveAt(num2); DisplayUsers(); break; } } if (SupcomAutomatch.GetSupcomAutomatch().State != SupcomAutoState.Unavailable) { sDlgSupcom.BeginInvoke((VGen0)delegate { sDlgSupcom.AbortGame(); }); } } else { switch (commands) { case CustomCommands.AutomatchEndAlliance: sIsJoining = false; if (!(main.IsDisposed || main.Disposing)) { main.BeginInvoke((VGen2)delegate (object objname, object objmain) { FrmMain mainForm = (FrmMain) objmain; DlgMessage.Show(mainForm, Loc.Get("<LOC>The team leader has canceled the arranged team game.")); mainForm.ClearStatus(); mainForm.EnableGameButtons(); }, new object[] { str, main }); } sLeader = ""; sDlgSupcom = null; break; case CustomCommands.AutomatchStatusMessage: if (strArray[0] == "AUTOSEARCH") { SupcomAutomatch.GetSupcomAutomatch().OnExit += new EventHandler(DlgSupcomTeamSelection.DlgSupcomTeamSelection_OnExit); } else if (!(main.IsDisposed || main.Disposing)) { main.BeginInvoke((VGen3)delegate (object objname, object objmain, object objargs) { FrmMain curmain = (FrmMain) objmain; if (objargs.ToString().IndexOf("launch") >= 0) { curmain.ClearStatus(); } curmain.SetStatus(Loc.Get(objargs.ToString()), new object[0]); }, new object[] { str, main, strArray[0] }); } break; } } } catch (Exception exception) { ErrorLog.WriteLine(exception); } } }