コード例 #1
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            MetroFramework.Controls.MetroLink pinglabel = (panel3.Visible)?metroLink5:pinglb;


            try
            {
                procs = Process.GetProcessesByName("League of Legends");
                if (procs.Length == 0)
                {
                    if (Program.MainFormInstance.Visible)
                    {
                        long ping = RiotTool.PingServer(Program.MainFormInstance.SelectedAccount.Region);
                        pinglabel.BeginInvoke(new MethodInvoker(delegate
                        {
                            if (ping != -1)
                            {
                                if (ping >= 150 && ping <= 300)
                                {
                                    pinglabel.Style = MetroColorStyle.Yellow;
                                }
                                else if (ping > 300)
                                {
                                    pinglabel.Style = MetroColorStyle.Red;
                                }
                                else
                                {
                                    pinglabel.Style = MetroColorStyle.Green;
                                }
                                pinglabel.Text = ping.ToString() + " ms";
                            }
                            else
                            {
                                pinglabel.Text  = ping.ToString() + " ms";
                                pinglabel.Style = MetroColorStyle.Purple;
                            }
                        }));
                    }
                }
                else if (RiotTool.Instance.NeedsToCheckLol(procs[0]))
                {
                    RiotTool.Instance.LolStarted(this, EventArgs.Empty);
                }

                procs = null;
                if (!CollectorThread.IsAlive)
                {
                    GCStack++;
                    if (GCStack >= 5)
                    {
                        CollectorThread.Start();
                    }
                }
            }
            catch
            {
                pinglabel.Style = MetroColorStyle.Magenta;
            }
        }
コード例 #2
0
        private void ginfo_Click(object sender, EventArgs e)
        {
            try
            {
                RiotSharp.Region lolregsharp = RiotTool.PlatformToRegion(CurrentGame.platformId.ToUpper());
                long             sid         = Program.MainFormInstance.API.GetSummoner(lolregsharp, CurrentGame.participants[0].summonerName).Id;

                RootObject rg = Program.MainFormInstance.API.GetCurrentGame(lolregsharp, sid, CurrentGame.platformId.ToUpper());
                UpdateCurrentGameInvoker u = new UpdateCurrentGameInvoker(Program.MainFormInstance.currentGame1.LoadGame);
                u.BeginInvoke(rg, Program.MainFormInstance.API, lolregsharp, 0, null, null);
                Program.MainFormInstance.MainTabControl.SelectedTab = Program.MainFormInstance.GameInfoTab;
            }
            catch
            {
            }
        }
コード例 #3
0
        public void LoadFeatured(GameList game)
        {
            try
            {
                CurrentGame = game;
                ginfo.Text  = RiotTool.ToMapString((RiotSharp.MapType)game.mapId) + ", " + RiotTool.ToQueueString((RiotSharp.MatchEndpoint.QueueType)game.gameQueueConfigId) + " - " + RiotTool.PlatformToString(game.platformId);
                TimeSpan ts = new TimeSpan(game.gameLength * TimeSpan.TicksPerSecond);

                starttime = DateTime.Now.Subtract(ts);

                //              starttime = GetGameTime((long)game.gameStartTime, game.platformId.ToUpper());


                foreach (RiotSharp.Featured.Participant p in game.participants)
                {
                    AddPlayer((p.teamId == 200), p.summonerName, p.championId);
                }
            }
            catch
            {
            }
        }
コード例 #4
0
        public void SetHome(GhostReplay rep, string gid, string reg)
        {
            try
            {
                HomePage = global::GhostReplays.Properties.Resources.HOME;
                HomePage = HomePage.Replace("{$.gid.$}", gid).Replace("{$.reg.$}", reg);
                if (rep.GameStats != null)
                {
                    HomePage = HomePage.Replace("{$.map.$}", RiotTool.ToMapString((RiotSharp.MapType)rep.PlayerInfos.Map));
                    HomePage = HomePage.Replace("{$.queue.$}", rep.GameStats.QueueType);
                    string dur = string.Format("{0:0}:{1:00}", rep.GameLength.Minutes, rep.GameLength.Seconds);
                    HomePage = HomePage.Replace("{$.glength.$}", dur);
                    HomePage = HomePage.Replace("{$.mplayer.$}", rep.SummonerName);
                    if (IsWon(100, rep))
                    {
                        HomePage = HomePage.Replace("{$.winner.$}", "Blue Team");
                    }

                    else
                    {
                        HomePage = HomePage.Replace("{$.winner.$}", "Red Team");
                    }
                }
                else
                {
                    HomePage = HomePage.Replace("{$.map.$}", "Unknown");
                    HomePage = HomePage.Replace("{$.queue.$}", "Unknown");
                    string dur = string.Format("{0:0}:{1:00}", rep.GameLength.Minutes, rep.GameLength.Seconds);
                    HomePage = HomePage.Replace("{$.glength.$}", dur);
                    HomePage = HomePage.Replace("{$.mplayer.$}", rep.SummonerName);

                    HomePage = HomePage.Replace("{$.winner.$}", "Unknown");
                }
            }
            catch
            {
            }
        }
コード例 #5
0
        void LoadEvents()
        {
            try
            {
                string cachefile = Application.StartupPath + @"\Temp\" + META.gameKey.gameId + "-" + META.gameKey.platformId + ".cached";


                StringBuilder sb = new StringBuilder();
                RiotSharp.StaticDataEndpoint.ItemListStatic items = RiotSharp.StaticRiotApi.GetInstance(SettingsManager.Settings.ApiKey).GetItems(RiotTool.PlatformToRegion(META.gameKey.platformId));
                RiotSharp.MatchEndpoint.MatchDetail         m     = Program.MainFormInstance.API.GetMatch(RiotTool.PlatformToRegion(META.gameKey.platformId), META.gameKey.gameId, true, cachefile, true);
                foreach (Participant p in m.Participants)
                {
                    parts.Add(p.ParticipantId, FindParticipant(p.ChampionId, p.TeamId));
                }


                foreach (Frame f in m.Timeline.Frames)
                {
                    sb.AppendLine("***" + string.Format("{0:0}:{1:00}", f.Timestamp.Minutes, f.Timestamp.Seconds) + "***********************************************************************************");
                    if (f.Events != null)
                    {
                        foreach (Event ev in f.Events)
                        {
                            sb.AppendLine(EventToString(ev, items));
                        }
                    }
                }
                metroTabControl1.Invoke(new MethodInvoker(delegate
                {
                    nsTextBox1.Text = sb.ToString();

                    metroTabControl1.TabPages.Add(metroTabPage4);
                    metroTabControl1.SelectedIndex = 0;
                }));
                sb.Length = 0;
                sb        = null;
            }
            catch
            {
            }
        }
コード例 #6
0
        public void LoadGame(EndOfGameStats eog, GameMetaData meta, BasicInfo pi, bool bluewin)
        {
            try
            {
                //   RiotSharp.MatchEndpoint.MatchDetail m = Program.MainFormInstance.API.GetMatch(RiotTool.PlatformToRegion(meta.gameKey.platformId), (long)eog.GameId);

                TeamStats blueteam = new TeamStats();
                TeamStats redteam  = new TeamStats();
                BluePanel.Controls.Clear();
                RedPanel.Controls.Clear();
                if (!bluewin)
                {
                    metroLabel1.Text  = "Red Team Wins";
                    metroLabel1.Style = MetroFramework.MetroColorStyle.Red;
                }
                if (meta.gameKey.platformId != "PBE1")
                {
                    ginfo.Text = RiotTool.ToMapString((RiotSharp.MapType)pi.Map) + ", " + RiotTool.ToQueueString((QueueType)pi.Queue) + " - " + RiotTool.PlatformToRegion(meta.gameKey.platformId).ToString().ToUpper();
                }
                else
                {
                    ginfo.Text = eog.GameMode + ", " + eog.GameType.Replace("_", " ") + " - " + RiotTool.PlatformToRegion(meta.gameKey.platformId).ToString().ToUpper();
                }
                if (eog != null)
                {
                    foreach (PlayerParticipantStatsSummary p in eog.TeamPlayerParticipantStats)
                    {
                        Player2Ctrl p2 = new Player2Ctrl(p.TeamId == 200);

                        p2.LoadPlayer(p, p.SummonerName, p.SkinName, ref blueteam);
                        p2.Dock = DockStyle.Top;
                        if (p.TeamId == 100)
                        {
                            BluePanel.Controls.Add(p2);
                        }
                        else
                        {
                            RedPanel.Controls.Add(p2);
                        }
                    }
                    foreach (PlayerParticipantStatsSummary p in eog.OtherTeamPlayerParticipantStats)
                    {
                        Player2Ctrl p2 = new Player2Ctrl(p.TeamId == 200);

                        p2.LoadPlayer(p, p.SummonerName, p.SkinName, ref redteam);
                        p2.Dock = DockStyle.Top;
                        if (p.TeamId == 100)
                        {
                            BluePanel.Controls.Add(p2);
                        }
                        else
                        {
                            RedPanel.Controls.Add(p2);
                        }
                    }
                }

                bluewk.Text     = blueteam.WD.ToString();
                bluewp.Text     = blueteam.WP.ToString();
                bluecreeps.Text = blueteam.CREEPS.ToString();
                bluekda.Text    = blueteam.Kill + " / " + blueteam.Deaths + " / " + blueteam.Assists;
                bluetd.Text     = blueteam.TD.ToString();

                redwk.Text     = redteam.WD.ToString();
                redwp.Text     = redteam.WP.ToString();
                redcreeps.Text = redteam.CREEPS.ToString();
                redkda.Text    = redteam.Kill + " / " + redteam.Deaths + " / " + redteam.Assists;
                redtd.Text     = redteam.TD.ToString();

                BluePanel.Controls.Add(panel5);
                RedPanel.Controls.Add(panel4);
            }
            catch (Exception ex)
            {
                Logger.Instance.Log.Error("Failed to load game", ex);
            }
        }
コード例 #7
0
        public void LoadGame(RootObject gameinfo, RiotSharp.RiotApi api, RiotSharp.Region reg, long sid)
        {
            try
            {
                BluePanel.BeginInvoke(new MethodInvoker(delegate
                {
                    BluePanel.Controls.Clear();
                    RedPanel.Controls.Clear();
                    ginfo.Text = RiotTool.ToMapString(gameinfo.MapType) + ", " + RiotTool.ToQueueString(gameinfo.gameQueueConfigId) + " - " + RiotTool.PlatformToString(gameinfo.platformId);
                    metroProgressSpinner1.Visible = true;


                    B1.Visible = (gameinfo.bannedChampions.Count != 0);
                    B2.Visible = (gameinfo.bannedChampions.Count != 0);
                    B3.Visible = (gameinfo.bannedChampions.Count != 0);
                    B4.Visible = (gameinfo.bannedChampions.Count != 0);
                    B5.Visible = (gameinfo.bannedChampions.Count != 0);
                    B6.Visible = (gameinfo.bannedChampions.Count != 0);


                    foreach (BannedChampion b in gameinfo.bannedChampions)
                    {
                        Image champ = Image.FromFile(Application.StartupPath + @"\Champions\" + CurrentGame.GetChampion(b.ChampionId) + ".png");
                        switch (b.PickTurn)
                        {
                        case 1:
                            B1.BackgroundImage = champ;
                            break;

                        case 3:
                            B2.BackgroundImage = champ;
                            break;

                        case 5:
                            B3.BackgroundImage = champ;
                            break;

                        case 2:
                            B4.BackgroundImage = champ;
                            break;

                        case 4:
                            B5.BackgroundImage = champ;
                            break;

                        case 6:
                            B6.BackgroundImage = champ;
                            break;
                        }
                    }
                }));
                int c = 0;

                frm.AnimationType = AnimatorNS.AnimationType.Mosaic;
                //foreach (Participant p in gameinfo.participants)
                //{
                ParallelLoopResult pr = Parallel.ForEach(gameinfo.participants, p =>
                {
                    Player pl = new Player(p.TeamId == 200);


                    pl.Dock          = DockStyle.Top;
                    LeaguePlayer pls = new LeaguePlayer();
                    pls.LoadPlayer(reg, api, p, CurrentGame.GetChampion(p.ChampionId));
                    if (pls.SummonerName == "Error occured")
                    {
                        pls.SummonerName = p.Name;
                    }
                    pl.LoadSummonerData(pls);
                    MetroPanel panel = null;
                    if (p.TeamId == 100)
                    {
                        panel = BluePanel;
                    }
                    else
                    {
                        panel = RedPanel;
                    }
                    pls.Dispose();
                    panel.Invoke(new MethodInvoker(delegate
                    {
                        //if (panel == BluePanel && p.TeamId != 100)
                        //    panel = RedPanel;
                        c++;
                        metroProgressSpinner1.Value = (int)((double)((double)c / (double)gameinfo.participants.Count) * 100);

                        panel.Controls.Add(pl);
                        //pl.Visible = false;

                        //frm.Show(pl, Program.MainFormInstance.MainTabControl.SelectedTab == Program.MainFormInstance.GameInfoTab);
                    }));

                    //   }
                });
                while (!pr.IsCompleted)
                {
                    Thread.Sleep(100);
                }

                RedPanel.Invoke(new MethodInvoker(delegate
                {
                    this.RedPanel.Controls.Add(this.RedBan);
                    this.BluePanel.Controls.Add(this.BlueBan);
                    metroProgressSpinner1.Visible = false;
                    metroProgressSpinner1.Value   = 1;
                }));

                Program.MainFormInstance.ShowInfo("Game info", "The current game info are ready to be viewed");
                if (SettingsManager.Settings.Speech)
                {
                    SoundPlayer sp = new SoundPlayer(Application.StartupPath + @"\Data\done.wav");
                    sp.Load();
                    sp.PlaySync();
                    sp.Dispose();
                }
                GC.Collect();
                GC.WaitForPendingFinalizers();
            }
            catch (Exception ex)
            {
                Logger.Instance.Log.Error("Failed to load game", ex);
            }
        }