コード例 #1
0
 private void BackoutResults(GPGDragItem player1, GPGDragItem player2)
 {
     if (player1 != null)
     {
         if (player1.Won == 1)
         {
             player1.Wins--;
         }
         if (player1.Won == 0)
         {
             player1.Losses--;
         }
         if (player1.Won == 2)
         {
             player1.Draws--;
         }
         player1.Won = -1;
         player1.PlayerReport = "Backed out result";
     }
     if (player2 != null)
     {
         if (player2.Won == 1)
         {
             player2.Wins--;
         }
         if (player2.Won == 0)
         {
             player2.Losses--;
         }
         if (player2.Won == 2)
         {
             player2.Draws--;
         }
         player2.Won = -1;
         player2.PlayerReport = "Backed out result";
     }
 }
コード例 #2
0
ファイル: GPGDragList.cs プロジェクト: micheljung/gpgnetfix
 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;
                 }
             }
         }
     }
 }
コード例 #3
0
ファイル: GPGDragList.cs プロジェクト: micheljung/gpgnetfix
 protected override void OnMouseUp(MouseEventArgs e)
 {
     base.OnMouseUp(e);
     if ((this.mSelectedItem != null) && this.mOverDrop)
     {
         GPGMatchup matchup = this.Matchups[this.mOverItem];
         if (matchup.Player1 == null)
         {
             matchup.Player1 = this.mSelectedItem;
             this.mSelectedItem.IsMatched = true;
         }
         else if (matchup.Player2 == null)
         {
             matchup.Player2 = this.mSelectedItem;
             this.mSelectedItem.IsMatched = true;
         }
     }
     this.mDragRect = Rectangle.Empty;
     this.mSelectedItem = null;
     this.mOverDrop = false;
     base.Invalidate();
 }
コード例 #4
0
ファイル: GPGDragList.cs プロジェクト: micheljung/gpgnetfix
 protected override void OnMouseMove(MouseEventArgs e)
 {
     base.OnMouseMove(e);
     if (e.Button == MouseButtons.Left)
     {
         if (this.mSelectedItem != null)
         {
             this.mDragRect = new Rectangle(e.X, e.Y, this.ItemWidth, this.ItemHeight);
             this.mOverDrop = false;
             int num = 10;
             int num2 = (this.Items.Count / 2) + (this.Items.Count % 2);
             int num3 = (this.ItemWidth + 15) + num;
             int num4 = num;
             for (int i = 0; i < num2; i++)
             {
                 if (((e.X > num3) && (e.X < (num3 + this.matchwidth))) && ((e.Y > num4) && (e.Y < (num4 + this.matchheight))))
                 {
                     this.mOverDrop = true;
                     this.mOverX = num3;
                     this.mOverY = num4;
                     this.mOverItem = i;
                 }
                 num3 = (num3 + this.matchwidth) + num;
                 if (num3 > ((base.Width - this.matchwidth) - num))
                 {
                     num3 = (this.ItemWidth + 15) + num;
                     num4 = (num4 + this.matchheight) + num;
                 }
             }
             base.Invalidate();
         }
     }
     else
     {
         this.mSelectedItem = null;
     }
 }
コード例 #5
0
ファイル: DlgBrackets.cs プロジェクト: micheljung/gpgnetfix
 public void LoadTournament(int id)
 {
     base.SetStatus(Loc.Get("<LOC>Loading bracket data..."), new object[0]);
     ThreadQueue.QueueUserWorkItem(delegate (object o) {
         int num;
         string str;
         this.mMaxRound = 0;
         int num3 = Convert.ToInt32((o as object[])[0]);
         DataList queryData = DataAccess.GetQueryData("Tournament Round", new object[] { num3 });
         this.gpgBracketGrid1.Matchups.Clear();
         int count = 0;
         List<string> list2 = new List<string>();
         foreach (DataRecord record in queryData)
         {
             num = Convert.ToInt32(record["match_id"]);
             int num5 = Convert.ToInt32(record["round"]);
             str = num5.ToString() + " " + num.ToString();
             if (!list2.Contains(str))
             {
                 list2.Add(str);
             }
             if (num5 > this.mMaxRound)
             {
                 this.mMaxRound = num5;
             }
         }
         count = list2.Count;
         this.SetRoundLinks(this.mMaxRound);
         int num2 = 0;
         while (num2 <= count)
         {
             this.gpgBracketGrid1.Matchups.Add(new GPGMatchup());
             num2++;
         }
         foreach (DataRecord record in queryData)
         {
             VGen0 method = null;
             GPGDragItem ditem = new GPGDragItem {
                 Label = record["name"],
                 Wins = Convert.ToInt32(record["wins"]),
                 Losses = Convert.ToInt32(record["losses"]),
                 Draws = Convert.ToInt32(record["draws"])
             };
             try
             {
                 ditem.Seed = Convert.ToInt32(record["seed"]);
             }
             catch
             {
             }
             num = Convert.ToInt32(record["match_id"]);
             int roundid = Convert.ToInt32(record["round"]);
             str = roundid.ToString() + " " + num.ToString();
             int index = -1;
             for (num2 = 0; num2 < list2.Count; num2++)
             {
                 if (list2[num2] == str)
                 {
                     index = num2;
                 }
             }
             if (index >= 0)
             {
                 if (method == null)
                 {
                     method = delegate {
                         if (this.gpgBracketGrid1.Matchups[index].Player1 == null)
                         {
                             this.gpgBracketGrid1.Matchups[index].Player1 = ditem;
                         }
                         else
                         {
                             this.gpgBracketGrid1.Matchups[index].Player2 = ditem;
                         }
                         this.gpgBracketGrid1.Matchups[index].Round = roundid;
                     };
                 }
                 base.Invoke(method);
             }
         }
         base.Invoke((VGen0)delegate {
             this.gpgBracketGrid1.SetupRounds();
             this.gpgBracketGrid1.Invalidate();
             base.SetStatus(Loc.Get("<LOC>Viewing tournament results."), new object[0]);
         });
     }, new object[] { id });
 }
コード例 #6
0
 private string FormatRecord(GPGDragItem player)
 {
     return (player.Wins.ToString() + "-" + player.Losses.ToString() + "-" + player.Draws.ToString());
 }
コード例 #7
0
 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);
         }
     }
 }
コード例 #8
0
 public void LoadTournament(int tournamentid)
 {
     base.SetStatus(Loc.Get("<LOC>Loading Tournament") + ": " + tournamentid.ToString(), new object[0]);
     this.mTournamentID = tournamentid;
     int seed = 1;
     ThreadQueue.QueueUserWorkItem(delegate (object o) {
         Exception exception;
         VGen1 gen3 = null;
         VGen1 method = null;
         try
         {
             EventLog.WriteLine("Fetching tournament details.", LogCategory.Get("DlgmanageTournament"), new object[0]);
             VGen1 gen = null;
             DataList queryData = DataAccess.GetQueryData("Tournament Details", new object[] { this.mTournamentID });
             this.mDetails = queryData[0];
             using (IEnumerator<object> enumerator = (IEnumerator<object>)this.cbMap.Items.GetEnumerator())
             {
                 VGen0 gen2 = null;
                 while (enumerator.MoveNext())
                 {
                     SupcomMap map = (SupcomMap) enumerator.Current;
                     if (map.ToString() == this.mDetails["map"])
                     {
                         if (gen2 == null)
                         {
                             gen2 = delegate {
                                 this.cbMap.SelectedItem = map;
                             };
                         }
                         this.Invoke(gen2);
                     }
                 }
             }
             try
             {
                 this.Round = Convert.ToInt32(queryData[0]["round"]);
             }
             catch (Exception exception1)
             {
                 exception = exception1;
                 ErrorLog.WriteLine(exception);
                 this.Round = 1;
             }
             if (this.Round < 1)
             {
                 this.Round = 1;
             }
             EventLog.WriteLine("got data", LogCategory.Get("DlgmanageTournament"), new object[0]);
             queryData = DataAccess.GetQueryData("Tournament Participation", new object[] { this.mTournamentID });
             foreach (DataRecord record in queryData)
             {
                 EventLog.WriteLine("Analyzing Record", LogCategory.Get("DlgmanageTournament"), new object[0]);
                 GPGDragItem item = new GPGDragItem {
                     Label = record["name"],
                     Value = record,
                     Seed = seed,
                     Icon = SkinManager.GetImage(@"Supcom\icon_player_sm.png")
                 };
                 EventLog.WriteLine("Item information: " + item.Label, LogCategory.Get("DlgmanageTournament"), new object[0]);
                 if (gen == null)
                 {
                     if (gen3 == null)
                     {
                         gen3 = delegate (object oitem) {
                             GPGDragItem curitem = oitem as GPGDragItem;
                             this.dragPlayers.Items.Add(curitem);
                         };
                     }
                     gen = gen3;
                 }
                 this.Invoke(gen, new object[] { item });
                 seed++;
             }
             DataList list2 = DataAccess.GetQueryData("Tournament Player States", new object[] { this.mTournamentID, this.mDetails["round"] });
             if (method == null)
             {
                 method = delegate (object orounddata) {
                     EventLog.WriteLine("Checking Matchups", LogCategory.Get("DlgmanageTournament"), new object[0]);
                     this.dragPlayers.CheckMatchup();
                     DataList list = orounddata as DataList;
                     foreach (DataRecord record in list)
                     {
                         foreach (GPGDragItem item in this.dragPlayers.Items)
                         {
                             DataRecord record2 = item.Value as DataRecord;
                             if (record2["principal_id"] == record["principal_id"])
                             {
                                 int result = -1;
                                 int num2 = 0;
                                 int num3 = 0;
                                 int num4 = 0;
                                 EventLog.WriteLine("Found a matchup for two players: " + record2["principal_id"] + " " + record["principal_id"], LogCategory.Get("DlgmanageTournament"), new object[0]);
                                 if (int.TryParse(record["match_id"], out result))
                                 {
                                     EventLog.WriteLine("Got a result: " + result, LogCategory.Get("DlgmanageTournament"), new object[0]);
                                     if (result >= 0)
                                     {
                                         if (this.dragPlayers.Matchups[result].Player1 == null)
                                         {
                                             item.IsMatched = true;
                                             this.dragPlayers.Matchups[result].Player1 = item;
                                         }
                                         else
                                         {
                                             item.IsMatched = true;
                                             this.dragPlayers.Matchups[result].Player2 = item;
                                         }
                                     }
                                 }
                                 if (int.TryParse(record["wins"], out num2))
                                 {
                                     EventLog.WriteLine("Got wins: " + num2, LogCategory.Get("DlgmanageTournament"), new object[0]);
                                     item.Wins = num2;
                                 }
                                 if (int.TryParse(record["losses"], out num3))
                                 {
                                     EventLog.WriteLine("Got losses: " + num3, LogCategory.Get("DlgmanageTournament"), new object[0]);
                                     item.Losses = num3;
                                 }
                                 if (int.TryParse(record["draws"], out num4))
                                 {
                                     EventLog.WriteLine("Got draws: " + num4, LogCategory.Get("DlgmanageTournament"), new object[0]);
                                     item.Draws = num4;
                                 }
                             }
                         }
                     }
                 };
             }
             this.Invoke(method, new object[] { list2 });
         }
         catch (Exception exception2)
         {
             exception = exception2;
             ErrorLog.WriteLine(exception);
         }
         this.Invoke((VGen0)delegate {
             this.Text = Loc.Get("<LOC>Tournament Manager") + ": " + this.mDetails["name"];
             this.dragPlayers.Invalidate();
             this.SetButtonState();
         });
     }, new object[0]);
     ThreadPool.QueueUserWorkItem(delegate (object o) {
         VGen0 method = null;
         VGen0 gen3 = null;
         try
         {
             while (!base.IsDisposed && !base.Disposing)
             {
                 Thread.Sleep(ConfigSettings.GetInt("TournamentManagerRefreshRate", 0x2710));
                 if (!base.IsDisposed && !base.Disposing)
                 {
                     if (method == null)
                     {
                         method = delegate {
                             foreach (GPGDragItem item in this.dragPlayers.Items)
                             {
                                 item.PingStatus = "Offline";
                             }
                             foreach (KeyValuePair<string, string> pair in TournamentCommands.sRespondingUsers)
                             {
                                 foreach (GPGDragItem item in this.dragPlayers.Items)
                                 {
                                     if (item.PlayerName == pair.Key)
                                     {
                                         item.PingStatus = pair.Value;
                                     }
                                 }
                             }
                             TournamentCommands.sRespondingUsers.Clear();
                         };
                     }
                     base.Invoke(method);
                 }
                 using (List<GPGDragItem>.Enumerator enumerator = this.dragPlayers.Items.GetEnumerator())
                 {
                     VGen0 gen = null;
                     while (enumerator.MoveNext())
                     {
                         GPGDragItem item = enumerator.Current;
                         Thread.Sleep(250);
                         if (!base.IsDisposed && !base.Disposing)
                         {
                             if (gen == null)
                             {
                                 gen = delegate {
                                     Messaging.SendCustomCommand(item.PlayerName, CustomCommands.TournamentRequestStatus, new object[0]);
                                 };
                             }
                             base.Invoke(gen);
                         }
                     }
                 }
                 if (!base.IsDisposed && !base.Disposing)
                 {
                     if (gen3 == null)
                     {
                         gen3 = delegate {
                             this.dragPlayers.Invalidate();
                         };
                     }
                     base.Invoke(gen3);
                 }
             }
         }
         catch (Exception)
         {
         }
     });
 }
コード例 #9
0
 private void InjectPlayer(string name)
 {
     foreach (GPGDragItem item in this.dragPlayers.Items)
     {
         if (item.PlayerName.ToUpper() == name.ToUpper())
         {
             DlgMessage.ShowDialog(base.MainForm, Loc.Get("<LOC>This player already exists in the tournament."));
             return;
         }
     }
     ThreadQueue.QueueUserWorkItem(delegate (object o) {
         if (DataAccess.GetQueryData("GetPlayerIDFromName", new object[] { name }).Count > 0)
         {
             DataAccess.ExecuteQuery("Tournament Inject Player", new object[] { this.mTournamentID, name });
             DataList queryData = DataAccess.GetQueryData("Tournament Participation", new object[] { this.mTournamentID });
             using (List<DataRecord>.Enumerator enumerator = queryData.GetEnumerator())
             {
                 VGen0 method = null;
                 while (enumerator.MoveNext())
                 {
                     DataRecord record = enumerator.Current;
                     if (record["name"].ToUpper() == name.ToUpper())
                     {
                         if (method == null)
                         {
                             method = delegate {
                                 GPGDragItem item = new GPGDragItem {
                                     Label = name,
                                     Value = record,
                                     Seed = this.dragPlayers.Items.Count + 1,
                                     Icon = SkinManager.GetImage(@"Supcom\icon_player_sm.png")
                                 };
                                 this.dragPlayers.Items.Add(item);
                                 this.dragPlayers.Invalidate();
                             };
                         }
                         this.Invoke(method);
                         return;
                     }
                 }
             }
         }
         else
         {
             this.Invoke((VGen0)delegate {
                 DlgMessage.ShowDialog(Loc.Get("<LOC>This is not a valid player name."));
             });
         }
     }, new object[0]);
 }