public void CheckMatchup() { int num = (this.Items.Count / 2) + (this.Items.Count % 2); while (this.Matchups.Count < num) { GPGMatchup item = new GPGMatchup(); this.Matchups.Add(item); } while (this.Matchups.Count > num) { GPGMatchup matchup2 = this.Matchups[this.Matchups.Count - 1]; if (matchup2.Player1 != null) { matchup2.Player1.IsMatched = false; } if (matchup2.Player2 != null) { matchup2.Player2.IsMatched = false; } this.Matchups.RemoveAt(this.Matchups.Count - 1); } }
protected override void OnMouseDown(MouseEventArgs e) { base.OnMouseDown(e); if ((this.State != GPGDragState.NoMove) && (this.mSelectedItem == null)) { if (((e.Button == MouseButtons.Left) || (e.Button == MouseButtons.Right)) && (e.X < this.ItemWidth)) { int num = (int) Math.Truncate((double) (((float) e.Y) / ((float) this.ItemHeight))); if (num < this.Items.Count) { int num2 = 0; foreach (GPGDragItem item in this.Items) { if (!item.IsMatched) { if ((num2 == num) && !item.IsLocked) { this.mSelectedItem = item; } num2++; } } this.mDragRect = new Rectangle(e.X, e.Y, this.ItemWidth, this.ItemHeight); base.Invalidate(); } } else if (e.Button == MouseButtons.Left) { int num3 = 10; int num4 = (this.Items.Count / 2) + (this.Items.Count % 2); int num5 = (this.ItemWidth + 15) + num3; int num6 = num3; for (int i = 0; i < num4; i++) { if (((e.X > num5) && (e.X < (num5 + this.matchwidth))) && ((e.Y > num6) && (e.Y < (num6 + this.matchheight)))) { GPGMatchup matchup = this.Matchups[i]; this.SelectedMatchup = matchup; if (((matchup.Player1 != null) && (e.Y < ((num6 + 3) + this.ItemHeight))) && !matchup.Player1.IsLocked) { this.mSelectedItem = matchup.Player1; matchup.Player1 = null; this.mSelectedItem.IsMatched = false; this.mDragRect = new Rectangle(e.X, e.Y, this.ItemWidth, this.ItemHeight); this.mOverDrop = true; this.mOverX = e.X; this.mOverY = e.Y; this.mOverItem = i; base.Invalidate(); } else if ((matchup.Player2 != null) && !matchup.Player2.IsLocked) { this.mSelectedItem = matchup.Player2; matchup.Player2 = null; this.mSelectedItem.IsMatched = false; this.mDragRect = new Rectangle(e.X, e.Y, this.ItemWidth, this.ItemHeight); this.mOverDrop = true; this.mOverX = e.X; this.mOverY = e.Y; this.mOverItem = i; base.Invalidate(); } } num5 = (num5 + this.matchwidth) + num3; if (num5 > ((base.Width - this.matchwidth) - num3)) { num5 = (this.ItemWidth + 15) + num3; num6 = (num6 + this.matchheight) + num3; } } } } }
private void SetupTestData() { for (int i = 1; i < 6; i++) { for (int j = 0; j < 50; j++) { GPGMatchup matchup = new GPGMatchup(); matchup.Round = i; GPGDragItem item = new GPGDragItem(); item.Label = "Player " + ((j * 2)).ToString(); item.Seed = j + 1; item.Faction = "Aeon"; item.Won = 1; matchup.Player1 = item; item = new GPGDragItem(); item.Label = "Player " + (((j * 2) + 1)).ToString(); item.Seed = j + 0x33; item.Faction = "UEF"; item.Won = 0; matchup.Player2 = item; this.Matchups.Add(matchup); } } }
private void LaunchSelectedGame(GPGMatchup matchup) { WaitCallback callBack = null; WaitCallback callback2 = null; WaitCallback callback3 = null; WaitCallback callback4 = null; if (matchup != null) { if ((matchup.Player1 == null) || (matchup.Player2 == null)) { DlgMessage.ShowDialog(base.MainForm, Loc.Get("<LOC>Warning"), Loc.Get("<LOC>This matchup is not yet complete and you cannot launch.")); } else { int num = 0; int num2 = -1; for (int i = 0; i < this.dragPlayers.Matchups.Count; i++) { if (this.dragPlayers.Matchups[i] == matchup) { num2 = i; break; } } string str = string.Concat(new object[] { "TOURNY-", this.mTournamentID.ToString(), "-", this.Round, "-", num2 }); if (callBack == null) { if (callback3 == null) { callback3 = delegate (object o) { string recipient = (o as object[])[0].ToString(); string str2 = (o as object[])[1].ToString(); int curnum = Convert.ToInt32((o as object[])[2]); if (ConfigSettings.GetBool("Get Tourn Map Old Way", false)) { Messaging.SendCustomCommand(recipient, CustomCommands.TournamentLaunchGame, new object[] { str2, this.mTournamentID, curnum.ToString(), this.mDetails["faction"], this.mDetails["map"] }); } else { Messaging.SendCustomCommand(recipient, CustomCommands.TournamentLaunchGame, new object[] { str2, this.mTournamentID, curnum.ToString(), this.mDetails["faction"], this.cbMap.SelectedItem.ToString() }); } }; } callBack = callback3; } matchup.Player1.PlayerReport = "No Report"; matchup.Player2.PlayerReport = "No Report"; ThreadQueue.QueueUserWorkItem(callBack, new object[] { matchup.Player1.PlayerName, str, num }); num = 0x1388; if (callback2 == null) { if (callback4 == null) { callback4 = delegate (object o) { string recipient = (o as object[])[0].ToString(); string str2 = (o as object[])[1].ToString(); int curnum = Convert.ToInt32((o as object[])[2]); if (ConfigSettings.GetBool("Get Tourn Map Old Way", false)) { Messaging.SendCustomCommand(recipient, CustomCommands.TournamentLaunchGame, new object[] { str2, this.mTournamentID, curnum.ToString(), this.mDetails["faction"], this.mDetails["map"] }); } else { Messaging.SendCustomCommand(recipient, CustomCommands.TournamentLaunchGame, new object[] { str2, this.mTournamentID, curnum.ToString(), this.mDetails["faction"], this.cbMap.SelectedItem.ToString() }); } }; } callback2 = callback4; } ThreadQueue.QueueUserWorkItem(callback2, new object[] { matchup.Player2.PlayerName, str, num }); } } }