Ejemplo n.º 1
0
        private void RecordButton_Click(object sender, RoutedEventArgs e)
        {
            var objectGame = gameList[SelectedGame];
            Dictionary <string, object> SpectatorGame = objectGame as Dictionary <string, object>;
            string key        = "";
            int    gameId     = 0;
            string platformId = "";

            foreach (KeyValuePair <string, object> pair in SpectatorGame)
            {
                if (pair.Key == "gameId")
                {
                    gameId = (int)pair.Value;
                }
                if (pair.Key == "observers")
                {
                    Dictionary <string, object> keyArray = pair.Value as Dictionary <string, object>;
                    foreach (KeyValuePair <string, object> keyArrayPair in keyArray)
                    {
                        if (keyArrayPair.Key == "encryptionKey")
                        {
                            key = keyArrayPair.Value as string;
                        }
                    }
                }
                if (pair.Key == "platformId")
                {
                    platformId = pair.Value as string;
                }
            }

            BaseRegion region = BaseRegion.GetRegion((string)SpectatorComboBox.SelectedValue);
            //region.SpectatorIpAddress, key, gameId, platformId
            var recorder = new ReplayRecorder(region.SpectatorIpAddress + ":8088", gameId, platformId, key);
        }
Ejemplo n.º 2
0
        private void SpectateButton_Click(object sender, RoutedEventArgs e)
        {
            object objectGame    = gameList[SelectedGame];
            var    SpectatorGame = objectGame as Dictionary <string, object>;
            string key           = "";
            int    gameId        = 0;
            string platformId    = "";

            foreach (var pair in SpectatorGame)
            {
                if (pair.Key == "gameId")
                {
                    gameId = (int)pair.Value;
                }
                if (pair.Key == "observers")
                {
                    var keyArray = pair.Value as Dictionary <string, object>;
                    foreach (var keyArrayPair in keyArray)
                    {
                        if (keyArrayPair.Key == "encryptionKey")
                        {
                            key = keyArrayPair.Value as string;
                        }
                    }
                }
                if (pair.Key == "platformId")
                {
                    platformId = pair.Value as string;
                }
            }

            BaseRegion region = BaseRegion.GetRegion((string)SpectatorComboBox.SelectedValue);

            Client.LaunchSpectatorGame(region.SpectatorIpAddress, key, gameId, platformId);
        }
Ejemplo n.º 3
0
 private void SpectatorComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (SpectatorComboBox.SelectedIndex != -1 && SpectatorComboBox.SelectedValue != null)
     {
         BaseRegion region = BaseRegion.GetRegion((string)SpectatorComboBox.SelectedValue);
         ChangeSpectatorRegion(region);
     }
 }
Ejemplo n.º 4
0
 private void RefreshTimer_Tick(object sender, EventArgs e)
 {
     if (SpectatorComboBox.SelectedIndex != -1 && SpectatorComboBox.SelectedValue != null)
     {
         BaseRegion region = BaseRegion.GetRegion((string)SpectatorComboBox.SelectedValue);
         ChangeSpectatorRegion(region);
     }
 }
Ejemplo n.º 5
0
        private void LoginButton_Click(object sender, RoutedEventArgs e)
        {
            Client.PVPNet = null;
            Client.PVPNet = new PVPNetConnect.PVPNetConnection();

            if (string.IsNullOrEmpty(Properties.Settings.Default.Guid))
            {
                Properties.Settings.Default.Guid = Guid.NewGuid().ToString();
            }
            Properties.Settings.Default.Save();
            SHA1 sha = new SHA1CryptoServiceProvider();

            if (RememberPasswordCheckbox.IsChecked == true)
            {
                Properties.Settings.Default.SavedPassword = LoginPasswordBox.Password.EncryptStringAES(sha.ComputeHash(System.Text.Encoding.UTF8.GetBytes(Properties.Settings.Default.Guid)).ToString());
            }
            else
            {
                Properties.Settings.Default.SavedPassword = "";
            }

            if (RememberUsernameCheckbox.IsChecked == true)
            {
                Properties.Settings.Default.SavedUsername = LoginUsernameBox.Text;
            }
            else
            {
                Properties.Settings.Default.SavedUsername = "";
            }

            Properties.Settings.Default.AutoLogin = (bool)AutoLoginCheckBox.IsChecked;
            Properties.Settings.Default.Region    = (string)RegionComboBox.SelectedValue;
            Properties.Settings.Default.Save();

            HideGrid.Visibility              = Visibility.Hidden;
            ErrorTextBox.Visibility          = Visibility.Hidden;
            LoggingInLabel.Visibility        = Visibility.Visible;
            LoggingInProgressRing.Visibility = Visibility.Visible;
            Client.PVPNet.OnError           += PVPNet_OnError;
            Client.PVPNet.OnLogin           += PVPNet_OnLogin;
            Client.PVPNet.OnMessageReceived += Client.OnMessageReceived;
            BaseRegion SelectedRegion = BaseRegion.GetRegion((string)RegionComboBox.SelectedValue);

            Client.Region = SelectedRegion;
            //Client.Version = "4.18.14";
            if (SelectedRegion.PVPRegion != PVPNetConnect.Region.CS)
            {
                Client.PVPNet.Connect(LoginUsernameBox.Text, LoginPasswordBox.Password, SelectedRegion.PVPRegion, Client.Version);
            }
            else
            {
                Dictionary <String, String> settings = SelectedRegion.Location.LeagueSettingsReader();
                Client.PVPNet.Connect(LoginUsernameBox.Text, LoginPasswordBox.Password, SelectedRegion.PVPRegion, Client.Version, true, settings["host"], settings["lq_uri"], SelectedRegion.Locale);
            }
        }
Ejemplo n.º 6
0
        public MainPage()
        {
            InitializeComponent();
            GotPlayerData(Client.LoginPacket);
            SpectatorComboBox.SelectedValue = Client.LoginPacket.CompetitiveRegion;
            BaseRegion region = BaseRegion.GetRegion(Client.LoginPacket.CompetitiveRegion);

            ChangeSpectatorRegion(region);

            GetNews(region);
        }
Ejemplo n.º 7
0
        public MainPage()
        {
            InitializeComponent();
            GotPlayerData(Client.LoginPacket);
            SpectatorComboBox.SelectedValue = Client.Region.RegionName;
            BaseRegion region = BaseRegion.GetRegion(Client.Region.RegionName);

            uiLogic.Profile = new ProfilePage();
            ChangeSpectatorRegion(region);
            GetNews(region);
            GetPendingInvites();
            var update = new Timer
            {
                Interval = 5000
            };

            update.Elapsed +=
                (o, e) =>
                Client.ChatClient.Presence(Client.CurrentPresence, Client.GetPresence(), Client.presenceStatus, 0);
            timer.Interval = (5000);
            //timer.Start();

            timer.Elapsed += (o, e) => Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
            {
                string jid =
                    Client.GetChatroomJID(Client.GetObfuscatedChatroomName("legendaryclient", ChatPrefixes.Public),
                                          string.Empty, true);

                GroupChatItem item = Join(jid, "LegendaryClient");
                var chatGroup      = new NotificationChatGroup
                {
                    Tag            = item,
                    GroupTitle     = item.GroupTitle,
                    Margin         = new Thickness(1, 0, 1, 0),
                    GroupLabelName = { Content = item.GroupTitle }
                };
                if (Client.GroupChatItems.All(i => i.GroupTitle != "LegendaryClient"))
                {
                    Client.ChatListView.Items.Add(chatGroup);
                    Client.GroupChatItems.Add(item);
                }

                timer.Stop();
            }));

            /*if (Client.Dev)
             * {
             *  fakeend.Visibility = Visibility.Visible;
             *  testChat.Visibility = Visibility.Visible;
             *  testInvite.Visibility = Visibility.Visible;
             * }*/
        }
Ejemplo n.º 8
0
 private void SetupProperties()
 {
     region = BaseRegion.GetRegion(Properties.Settings.Default.Region);
     if (region == null)
     {
         region = new NA();
     }
     regionComboBox.SelectedValue = Properties.Settings.Default.Region;
     usernameBox.Text             = Properties.Settings.Default.Username;
     passwordBox.Password         = Properties.Settings.Default.Password;
     usernameCheck.IsChecked      = Properties.Settings.Default.RememberingUsername;
     passwordCheck.IsChecked      = Properties.Settings.Default.RememberingPassword;
 }
Ejemplo n.º 9
0
        private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (loaded)
            {
                var    comboBox   = sender as ComboBox;
                string tempRegion = (String)comboBox.SelectedValue;
                Console.WriteLine("Region is " + tempRegion);
                region = BaseRegion.GetRegion(tempRegion);

                Properties.Settings.Default.Region = tempRegion;
                Properties.Settings.Default.Save();
                ConfigurationManager.RefreshSection("userSettings");
            }
            loaded = true;
        }
Ejemplo n.º 10
0
        public OldVoliBot(string username, string password, console _parent, QueueTypes queue)
        {
            parent                         = _parent;
            ipath                          = parent.lolPath; Accountname = username; Password = password; queueType = queue;
            baseRegion                     = BaseRegion.GetRegion(_parent.region.ToString());
            connection.OnConnect          += new LoLConnection.OnConnectHandler(connection_OnConnect);
            connection.OnDisconnect       += new LoLConnection.OnDisconnectHandler(connection_OnDisconnect);
            connection.OnError            += new LoLConnection.OnErrorHandler(connection_OnError);
            connection.OnLogin            += new LoLConnection.OnLoginHandler(connection_OnLogin);
            connection.OnLoginQueueUpdate += new LoLConnection.OnLoginQueueUpdateHandler(connection_OnLoginQueueUpdate);
            connection.OnMessageReceived  += new LoLConnection.OnMessageReceivedHandler(connection_OnMessageReceived);
            string pass = Regex.Replace(password, @"\s+", "");

            connection.Connect(Accountname, pass, baseRegion.PVPRegion, _parent.currentVersion + "." + Config.clientSubVersion);
        }
Ejemplo n.º 11
0
        public MainPage()
        {
            InitializeComponent();
            curentlyRecording = new List <int>();
            AppDomain current = AppDomain.CurrentDomain;

            GotPlayerData(Client.LoginPacket);
            SpectatorComboBox.SelectedValue = Client.Region.RegionName;
            BaseRegion region = BaseRegion.GetRegion(Client.Region.RegionName);

            uiLogic.CreateProfile(Client.LoginPacket.AllSummonerData.Summoner.Name);
            ChangeSpectatorRegion(region);
            GetNews(region);
            var update = new Timer();

            update.Interval = 5000;
            update.Elapsed +=
                (o, e) =>
            {
                Client.ChatClient.Presence(Client.CurrentPresence, Client.GetPresence(), Client.presenceStatus, 0);
            };
            timer.Interval = (5000);
            //timer.Start();

            timer.Elapsed += (o, e) =>
            {
                Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
                {
                    string JID =
                        Client.GetChatroomJID(Client.GetObfuscatedChatroomName("legendaryclient", ChatPrefixes.Public),
                                              string.Empty, true);

                    GroupChatItem item               = Join(JID, "LegendaryClient");
                    var ChatGroup                    = new NotificationChatGroup();
                    ChatGroup.Tag                    = item;
                    ChatGroup.GroupTitle             = item.GroupTitle;
                    ChatGroup.Margin                 = new Thickness(1, 0, 1, 0);
                    ChatGroup.GroupLabelName.Content = item.GroupTitle;
                    if (!Client.GroupChatItems.Any(i => i.GroupTitle == "LegendaryClient"))
                    {
                        Client.ChatListView.Items.Add(ChatGroup);
                        Client.GroupChatItems.Add(item);
                    }

                    timer.Stop();
                }));
            };
        }
Ejemplo n.º 12
0
        private void SpectateButton_Click(object sender, RoutedEventArgs e)
        {
            object objectGame    = GameList[SelectedGame];
            var    spectatorGame = objectGame as Dictionary <string, object>;
            string key           = "";
            int    gameId        = 0;
            string platformId    = "";

            if (spectatorGame != null)
            {
                foreach (var pair in spectatorGame)
                {
                    switch (pair.Key)
                    {
                    case "gameId":
                        gameId = (int)pair.Value;
                        break;

                    case "observers":
                    {
                        var keyArray = pair.Value as Dictionary <string, object>;
                        if (keyArray != null)
                        {
                            foreach (
                                var keyArrayPair in
                                keyArray.Where(keyArrayPair => keyArrayPair.Key == "encryptionKey"))
                            {
                                key = keyArrayPair.Value as string;
                            }
                        }
                    }
                    break;

                    case "platformId":
                        platformId = pair.Value as string;
                        break;
                    }
                }
            }

            BaseRegion region = BaseRegion.GetRegion((string)SpectatorComboBox.SelectedValue);

            Client.LaunchSpectatorGame(region.SpectatorIpAddress, key, gameId, platformId);
        }
Ejemplo n.º 13
0
        private void RecordButton_Click(object sender, RoutedEventArgs e)
        {
            object objectGame    = GameList[SelectedGame];
            var    spectatorGame = objectGame as Dictionary <string, object>;
            string key           = "";
            int    gameId        = 0;
            string platformId    = "";

            if (spectatorGame != null)
            {
                foreach (var pair in spectatorGame)
                {
                    if (pair.Key == "gameId")
                    {
                        gameId = (int)pair.Value;
                    }

                    if (pair.Key == "observers")
                    {
                        var keyArray = pair.Value as Dictionary <string, object>;
                        if (keyArray != null)
                        {
                            foreach (
                                var keyArrayPair in keyArray.Where(keyArrayPair => keyArrayPair.Key == "encryptionKey"))
                            {
                                key = keyArrayPair.Value as string;
                            }
                        }
                    }
                    if (pair.Key == "platformId")
                    {
                        platformId = pair.Value as string;
                    }
                }
            }

            BaseRegion region = BaseRegion.GetRegion((string)SpectatorComboBox.SelectedValue);

            new ReplayRecorder(region.SpectatorIpAddress, gameId, platformId, key);
            RecordButton.IsEnabled = false;
            RecordButton.Content   = "Recording...";
        }
Ejemplo n.º 14
0
        private void RecordButton_Click(object sender, RoutedEventArgs e)
        {
            object objectGame    = gameList[SelectedGame];
            var    SpectatorGame = objectGame as Dictionary <string, object>;
            string key           = "";
            int    gameId        = 0;
            string platformId    = "";

            foreach (var pair in SpectatorGame)
            {
                if (pair.Key == "gameId")
                {
                    gameId = (int)pair.Value;
                }
                if (pair.Key == "observers")
                {
                    var keyArray = pair.Value as Dictionary <string, object>;
                    foreach (var keyArrayPair in keyArray)
                    {
                        if (keyArrayPair.Key == "encryptionKey")
                        {
                            key = keyArrayPair.Value as string;
                        }
                    }
                }
                if (pair.Key == "platformId")
                {
                    platformId = pair.Value as string;
                }
            }

            BaseRegion region = BaseRegion.GetRegion((string)SpectatorComboBox.SelectedValue);
            //region.SpectatorIpAddress, key, gameId, platformId
            var recorder = new ReplayRecorder(region.SpectatorIpAddress, gameId, platformId, key);

            recorder.OnReplayRecorded += () => { curentlyRecording.Remove(gameId); };
            curentlyRecording.Add(gameId);
            RecordButton.IsEnabled = false;
            RecordButton.Content   = "Recording...";
        }
Ejemplo n.º 15
0
        private void LoginButton_Click(object sender, RoutedEventArgs e)
        {
            if (RememberPasswordCheckbox.IsChecked == true)
            {
                Properties.Settings.Default.SavedPassword = LoginPasswordBox.Password;
            }
            else
            {
                Properties.Settings.Default.SavedPassword = "";
            }

            if (RememberUsernameCheckbox.IsChecked == true)
            {
                Properties.Settings.Default.SavedUsername = LoginUsernameBox.Text;
            }
            else
            {
                Properties.Settings.Default.SavedUsername = "";
            }

            Properties.Settings.Default.AutoLogin = (bool)AutoLoginCheckBox.IsChecked;
            Properties.Settings.Default.Region    = (string)RegionComboBox.SelectedValue;
            Properties.Settings.Default.Save();

            HideGrid.Visibility              = Visibility.Hidden;
            ErrorTextBox.Visibility          = Visibility.Hidden;
            LoggingInLabel.Visibility        = Visibility.Visible;
            LoggingInProgressRing.Visibility = Visibility.Visible;
            Client.PVPNet.OnError           += PVPNet_OnError;
            Client.PVPNet.OnLogin           += PVPNet_OnLogin;
            Client.PVPNet.OnMessageReceived += Client.OnMessageReceived;
            BaseRegion SelectedRegion = BaseRegion.GetRegion((string)RegionComboBox.SelectedValue);

            Client.Region = SelectedRegion;
            //Client.Version = "4.7.8";
            Client.PVPNet.Connect(LoginUsernameBox.Text, LoginPasswordBox.Password, SelectedRegion.PVPRegion, Client.Version);
        }
Ejemplo n.º 16
0
 public static void loadConfiguration()
 {
     try
     {
         IniFile file1 = new IniFile(AppDomain.CurrentDomain.BaseDirectory + "config.ini");
         Config.LauncherPath   = file1.IniReadValue("General", "LauncherPath");
         Config.maxBots        = Convert.ToInt32(file1.IniReadValue("General", "MaxBots"));
         Config.maxLevel       = Convert.ToInt32(file1.IniReadValue("General", "MaxLevel"));
         Config.replaceConfig  = Convert.ToBoolean(file1.IniReadValue("General", "ReplaceConfig"));
         Config.Region         = BaseRegion.GetRegion(file1.IniReadValue("Account", "Region").ToUpper());
         Config.buyBoost       = Convert.ToBoolean(file1.IniReadValue("Account", "BuyBoost"));
         Config.rndIcon        = Convert.ToBoolean(file1.IniReadValue("Account", "RndIcon"));
         Config.championToPick = file1.IniReadValue("Other", "ChampionPick").ToUpper();
         Config.rndSpell       = Convert.ToBoolean(file1.IniReadValue("Other", "RndSpell"));
         Config.spell1         = file1.IniReadValue("Other", "Spell1").ToUpper();
         Config.spell2         = file1.IniReadValue("Other", "Spell2").ToUpper();
     }
     catch (Exception exception1)
     {
         Console.WriteLine(exception1.Message);
         Thread.Sleep(0x2710);
         Application.Exit();
     }
 }
Ejemplo n.º 17
0
        private async Task garenaLogin()
        {
            WindowsIdentity  winIdentity  = WindowsIdentity.GetCurrent();
            WindowsPrincipal winPrincipal = new WindowsPrincipal(winIdentity);

            if (!winPrincipal.IsInRole(WindowsBuiltInRole.Administrator))
            {
                if (await((MetroWindow)Application.Current.MainWindow).ShowMessageAsync("Insufficent Privledges.", "Press OK to restart as admin.") == MessageDialogResult.Affirmative)
                {
                    var info = new ProcessStartInfo(Path.Combine(Client.ExecutingDirectory, "Client", "LegendaryClient.exe"))
                    {
                        UseShellExecute = true,
                        Verb            = "runas"
                    };
                    Process.Start(info);
                    Environment.Exit(0);
                }
            }

            LoggingInLabel.Content    = "Waiting for user to launch League from garena";
            HideGrid.Visibility       = Visibility.Hidden;
            ErrorTextBox.Visibility   = Visibility.Hidden;
            LoggingInLabel.Visibility = Visibility.Visible;
            var garenaregion = BaseRegion.GetRegion((string)RegionComboBox.SelectedValue);

            LoggingInProgressRing.Visibility = Visibility.Visible;
            LoginPasswordBox.Visibility      = Visibility.Hidden;
            shouldExit = false;
            while (!shouldExit)
            {
                await Task.Delay(500);

                foreach (var process in Process.GetProcessesByName("lol"))
                {
                    var s1 = GetCommandLine(process);
                    process.Kill();
                    foreach (var lolclient in Process.GetProcessesByName("LolClient"))
                    {
                        lolclient.Kill();
                    }
                    if (s1.StartsWith("\""))
                    {
                        try
                        {
                            s1 = s1.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries)[1];
                        }
                        catch
                        {
                            Client.Log("Error splitting path from command line.");
                        }
                    }
                    else
                    {
                        s1 = s1.Substring(1);
                    }
                    Client.Log("Received token, it is: " + s1);
                    Client.Region = garenaregion;
                    Dispatcher.BeginInvoke(
                        DispatcherPriority.Input, new ThreadStart(() =>
                    {
                        HideGrid.Visibility              = Visibility.Hidden;
                        ErrorTextBox.Visibility          = Visibility.Hidden;
                        LoggingInLabel.Visibility        = Visibility.Visible;
                        LoggingInLabel.Content           = "Logging in...";
                        LoggingInProgressRing.Visibility = Visibility.Visible;
                    }));
                    var context = RiotCalls.RegisterObjects();
                    Client.RiotConnection = new RtmpClient(new System.Uri("rtmps://" + garenaregion.Server + ":2099"), context, ObjectEncoding.Amf3);
                    Client.RiotConnection.CallbackException += client_CallbackException;
                    Client.RiotConnection.MessageReceived   += client_MessageReceived;
                    await Client.RiotConnection.ConnectAsync();

                    Client.RiotConnection.SetChunkSize(2147483647);

                    AuthenticationCredentials newCredentials = new AuthenticationCredentials
                    {
                        AuthToken = await
                                    RiotCalls.GetRestToken(LoginUsernameBox.Text, LoginPasswordBox.Password, garenaregion.LoginQueue, reToken(s1)),
                        Username           = Client.UID,
                        Password           = null,
                        ClientVersion      = Client.Version,
                        IpAddress          = RiotCalls.GetIpAddress(),
                        Locale             = garenaregion.Locale,
                        PartnerCredentials = "8393 " + s1,
                        OperatingSystem    = "Windows 7",
                        Domain             = "lolclient.lol.riotgames.com",
                    };
                    Session login = await RiotCalls.Login(newCredentials);

                    Client.PlayerSession = login;
                    var           str1      = string.Format("gn-{0}", login.AccountSummary.AccountId);
                    var           str2      = string.Format("cn-{0}", login.AccountSummary.AccountId);
                    var           str3      = string.Format("bc-{0}", login.AccountSummary.AccountId);
                    Task <bool>[] taskArray = { Client.RiotConnection.SubscribeAsync("my-rtmps", "messagingDestination", str1, str1),
                                                Client.RiotConnection.SubscribeAsync("my-rtmps", "messagingDestination", str2, str2),
                                                Client.RiotConnection.SubscribeAsync("my-rtmps", "messagingDestination", "bc", str3) };

                    await Task.WhenAll(taskArray);

                    var LoggedIn = await Client.RiotConnection.LoginAsync(Client.UID, login.Token);

                    //var packet = await RiotCalls.GetLoginDataPacketForUser();
                    DoGetOnLoginPacket();
                }
            }
        }
Ejemplo n.º 18
0
        private void ParseSpectatorGames()
        {
            Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
            {
                try
                {
                    if (GameList == null)
                    {
                        return;
                    }

                    if (GameList.Count <= 0)
                    {
                        return;
                    }

                    BlueBansLabel.Visibility   = Visibility.Hidden;
                    PurpleBansLabel.Visibility = Visibility.Hidden;
                    BlueBanListView.Items.Clear();
                    PurpleBanListView.Items.Clear();
                    BlueListView.Items.Clear();
                    PurpleListView.Items.Clear();
                    int gameId        = 0;
                    object objectGame = GameList[SelectedGame];
                    var spectatorGame = objectGame as Dictionary <string, object>;
                    ImageGrid.Children.Clear();
                    if (spectatorGame != null)
                    {
                        foreach (var pair in spectatorGame)
                        {
                            switch (pair.Key)
                            {
                            case "participants":
                                {
                                    var players = pair.Value as ArrayList;

                                    int i = 0;
                                    foreach (object objectPlayer in players)
                                    {
                                        var playerInfo    = objectPlayer as Dictionary <string, object>;
                                        int teamId        = 100;
                                        int championId    = 0;
                                        int spell1Id      = 0;
                                        int spell2Id      = 0;
                                        string playerName = "";
                                        foreach (var playerPair in playerInfo)
                                        {
                                            switch (playerPair.Key)
                                            {
                                            case "teamId":
                                                teamId = (int)playerPair.Value;
                                                break;

                                            case "championId":
                                                championId = (int)playerPair.Value;
                                                break;

                                            case "summonerName":
                                                playerName = playerPair.Value as string;
                                                break;

                                            case "spell1Id":
                                                spell1Id = (int)playerPair.Value;
                                                break;

                                            case "spell2Id":
                                                spell2Id = (int)playerPair.Value;
                                                break;
                                            }
                                        }
                                        var control = new ChampSelectPlayer
                                        {
                                            ChampionImage = { Source = champions.GetChampion(championId).icon }
                                        };
                                        var uriSource =
                                            new Uri(
                                                Path.Combine(Client.ExecutingDirectory, "Assets", "spell",
                                                             SummonerSpell.GetSpellImageName(spell1Id)), UriKind.Absolute);
                                        control.SummonerSpell1.Source = new BitmapImage(uriSource);
                                        uriSource =
                                            new Uri(
                                                Path.Combine(Client.ExecutingDirectory, "Assets", "spell",
                                                             SummonerSpell.GetSpellImageName(spell2Id)), UriKind.Absolute);
                                        control.SummonerSpell2.Source = new BitmapImage(uriSource);
                                        control.PlayerName.Content    = playerName;

                                        var m = new Image();
                                        Panel.SetZIndex(m, -2); //Put background behind everything
                                        m.Stretch             = Stretch.None;
                                        m.Width               = 100;
                                        m.Opacity             = 0.30;
                                        m.HorizontalAlignment = HorizontalAlignment.Left;
                                        m.VerticalAlignment   = VerticalAlignment.Stretch;
                                        m.Margin              = new Thickness(i++ *100, 0, 0, 0);
                                        var cropRect          = new Rectangle(new Point(100, 0), new Size(100, 560));
                                        var src               =
                                            System.Drawing.Image.FromFile(Path.Combine(Client.ExecutingDirectory,
                                                                                       "Assets",
                                                                                       "champions", champions.GetChampion(championId).portraitPath)) as Bitmap;
                                        var target = new Bitmap(cropRect.Width, cropRect.Height);

                                        using (Graphics g = Graphics.FromImage(target))
                                            g.DrawImage(src, new Rectangle(0, 0, target.Width, target.Height),
                                                        cropRect,
                                                        GraphicsUnit.Pixel);

                                        m.Source = Client.ToWpfBitmap(target);
                                        ImageGrid.Children.Add(m);
                                        if (teamId == 100)
                                        {
                                            BlueListView.Items.Add(control);
                                        }
                                        else
                                        {
                                            PurpleListView.Items.Add(control);
                                        }
                                    }
                                }
                                break;

                            case "gameId":
                                gameId = (int)pair.Value;
                                break;

                            case "mapId":
                                try
                                {
                                    MapLabel.Content = BaseMap.GetMap((int)pair.Value).DisplayName;
                                }
                                catch (Exception e)
                                {
                                    Client.Log(e.Source, "Error");
                                    Client.Log(e.Message, "Error");
                                }
                                break;

                            case "gameLength":
                                {
                                    var seconds = (int)pair.Value;
                                    Client.spectatorTimer.Stop();
                                    Client.spectatorTimer          = new Timer(1000);
                                    Client.spectatorTimer.Elapsed += (s, e) => // Sincerely Idk when to stop it
                                    {
                                        seconds++;
                                        Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
                                        {
                                            TimeSpan ts           = TimeSpan.FromSeconds(seconds);
                                            GameTimeLabel.Content = string.Format("{0:D2}:{1:D2} min", ts.Minutes,
                                                                                  ts.Seconds);
                                        }));
                                    };
                                    Client.spectatorTimer.Start();
                                }
                                break;

                            case "bannedChampions":
                                {
                                    //ArrayList players = pair.Value as ArrayList;
                                    //Dictionary<string, object> playerInfo = objectPlayer as Dictionary<string, object>;
                                    //foreach (KeyValuePair<string, object> playerPair in playerInfo)
                                    var keyArray = pair.Value as ArrayList;
                                    if (keyArray.Count > 0)
                                    {
                                        BlueBansLabel.Visibility   = Visibility.Visible;
                                        PurpleBansLabel.Visibility = Visibility.Visible;
                                    }
                                    foreach (Dictionary <string, object> keyArrayP in keyArray)
                                    //Dictionary<string, object> keyArrayP = keyArray as Dictionary<string, object>;
                                    {
                                        int cid    = 0;
                                        int teamId = 100;
                                        foreach (var keyArrayPair in keyArrayP)
                                        {
                                            switch (keyArrayPair.Key)
                                            {
                                            case "championId":
                                                cid = (int)keyArrayPair.Value;
                                                break;

                                            case "teamId":
                                                teamId = (int)keyArrayPair.Value;
                                                break;
                                            }
                                        }
                                        var item       = new ListViewItem();
                                        var champImage = new Image
                                        {
                                            Height = 58,
                                            Width  = 58
                                        };
                                        //temp
                                        try
                                        {
                                            champImage.Source = champions.GetChampion(cid).icon;
                                        }
                                        catch
                                        {
                                        }

                                        item.Content = champImage;
                                        if (teamId == 100)
                                        {
                                            BlueBanListView.Items.Add(item);
                                        }
                                        else
                                        {
                                            PurpleBanListView.Items.Add(item);
                                        }
                                    }
                                }
                                break;
                            }
                        }
                    }

                    try
                    {
                        BaseRegion region = BaseRegion.GetRegion((string)SpectatorComboBox.SelectedValue);
                        string spectatorJson;
                        string url = region.SpectatorLink + "consumer/getGameMetaData/" + region.InternalName + "/" +
                                     gameId + "/token";
                        using (var client = new WebClient())
                            spectatorJson = client.DownloadString(url);

                        var serializer       = new JavaScriptSerializer();
                        var deserializedJson = serializer.Deserialize <Dictionary <string, object> >(spectatorJson);
                        MMRLabel.Content     = "≈" + deserializedJson["interestScore"];
                    }
                    catch
                    {
                        MMRLabel.Content = "N/A";
                    }

                    if (Client.curentlyRecording.Contains(gameId))
                    {
                        RecordButton.IsEnabled = false;
                        RecordButton.Content   = "Recording...";
                    }
                    else
                    {
                        RecordButton.IsEnabled = true;
                        RecordButton.Content   = "Record";
                    }
                }
                catch (Exception e)
                {
                    Client.Log(e.Message);
                }
            }));
        }
Ejemplo n.º 19
0
        public LoginPage()
        {
            InitializeComponent();
            Change();
            Client.donepatch     = true;
            Client.patching      = false;
            Version.TextChanged += WaterTextbox_TextChanged;
            bool x = Settings.Default.DarkTheme;

            if (!x)
            {
                var bc = new BrushConverter();
                HideGrid.Background = (Brush)bc.ConvertFrom("#B24F4F4F");
                LoggingInProgressRing.Foreground = (Brush)bc.ConvertFrom("#FFFFFFFF");
            }
            //#B2C8C8C8
            UpdateRegionComboBox.SelectedValue = Client.UpdateRegion;
            if (Client.UpdateRegion == "Garena" && !Client.Garena)
            {
                LoadGarena();
            }
            switch (Client.UpdateRegion)
            {
            case "PBE": RegionComboBox.ItemsSource = new[] { "PBE" };
                break;

            case "Live": RegionComboBox.ItemsSource = new[] { "BR", "EUNE", "EUW", "NA", "OCE", "RU", "LAS", "LAN", "TR", "CS" };
                break;

            case "Korea": RegionComboBox.ItemsSource = new[] { "KR" };
                break;

            case "Garena": RegionComboBox.ItemsSource = new[] { "PH", "SG", "SGMY", "TH", "TW", "VN" };
                break;
            }


            if (!Settings.Default.DisableLoginMusic)
            {
                SoundPlayer.Source = new Uri(Path.Combine(Client.ExecutingDirectory, "Client", "Login.mp3"));
                SoundPlayer.Play();
                Sound.IsChecked = false;
            }
            else
            {
                Sound.IsChecked = true;
            }

            if (!String.IsNullOrEmpty(Settings.Default.devKeyLoc))
            {
                if (Client.Authenticate(Settings.Default.devKeyLoc))
                {
                    Client.Dev          = true;
                    devKeyLabel.Content = "Dev";
                }
            }

            if (Settings.Default.LoginPageImage == "")
            {
                LoginPic.Source         = new Uri(Path.Combine(Client.ExecutingDirectory, "Client", "Login.mp4"));
                LoginPic.LoadedBehavior = MediaState.Manual;
                LoginPic.MediaEnded    += LoginPic_MediaEnded;
                SoundPlayer.MediaEnded += SoundPlayer_MediaEnded;
                LoginPic.Play();
            }
            else
            {
                if (
                    File.Exists(Path.Combine(Client.ExecutingDirectory, "Assets", "champions",
                                             Settings.Default.LoginPageImage.Replace("\r\n", ""))))
                {
                    LoginImage.Source =
                        new BitmapImage(
                            new Uri(
                                Path.Combine(Client.ExecutingDirectory, "Assets", "champions",
                                             Settings.Default.LoginPageImage), UriKind.Absolute));
                }
            }

            Video.IsChecked = false;

            //Get client data after patcher completed

            Client.SQLiteDatabase = new SQLiteConnection(Path.Combine(Client.ExecutingDirectory, Client.sqlite));
            Client.Champions      = (from s in Client.SQLiteDatabase.Table <champions>()
                                     orderby s.name
                                     select s).ToList();

            FreeToPlayChampions.GetInstance();

            foreach (champions c in Client.Champions)
            {
                var source = new Uri(Path.Combine(Client.ExecutingDirectory, "Assets", "champions", c.iconPath),
                                     UriKind.Absolute);
                c.icon = new BitmapImage(source);
                Debugger.Log(0, "Log", "Requesting :" + c.name + " champ");
                Debugger.Log(0, "", Environment.NewLine);

                try
                {
                    c.IsFreeToPlay = FreeToPlayChampions.GetInstance().IsFreeToPlay(c);
                    Champions.InsertExtraChampData(c);
                    //why was this ever here? all of the needed info is already in the sqlite file
                }
                catch
                {
                    Client.Log("error, file not found", "NotFound");
                }
            }
            Client.ChampionSkins = (from s in Client.SQLiteDatabase.Table <championSkins>()
                                    orderby s.name
                                    select s).ToList();
            Client.ChampionAbilities = (from s in Client.SQLiteDatabase.Table <championAbilities>()
                                        //Needs Fixed
                                        orderby s.name
                                        select s).ToList();
            Client.SearchTags = (from s in Client.SQLiteDatabase.Table <championSearchTags>()
                                 orderby s.id
                                 select s).ToList();
            Client.Keybinds = (from s in Client.SQLiteDatabase.Table <keybindingEvents>()
                               orderby s.id
                               select s).ToList();
            Client.Items     = Items.PopulateItems();
            Client.Masteries = Masteries.PopulateMasteries();
            Client.Runes     = Runes.PopulateRunes();
            BaseUpdateRegion updateRegion = BaseUpdateRegion.GetUpdateRegion(Client.UpdateRegion);
            var patcher = new RiotPatcher();

            string tempString = patcher.GetListing(updateRegion.AirListing);

            string[] packages = patcher.GetManifest(
                updateRegion.AirManifest + "releases/" + tempString + "/packages/files/packagemanifest");
            foreach (
                string usestring in
                packages.Select(package => package.Split(',')[0])
                .Where(usestring => usestring.Contains("ClientLibCommon.dat")))
            {
                new WebClient().DownloadFile(new Uri(updateRegion.BaseLink + usestring),
                                             Path.Combine(Client.ExecutingDirectory, "ClientLibCommon.dat"));
            }

            var reader = new SWFReader(Path.Combine(Client.ExecutingDirectory, "ClientLibCommon.dat"));

            foreach (var secondSplit in from abcTag in reader.Tags.OfType <DoABC>()
                     where abcTag.Name.Contains("riotgames/platform/gameclient/application/Version")
                     select Encoding.Default.GetString(abcTag.ABCData)
                     into str
                     select str.Split((char)6)
                     into firstSplit

                     select firstSplit[0].Split((char)18))
            {
                try
                {
                    Client.Version = secondSplit[1];
                }
                catch
                {
                    var thirdSplit = secondSplit[0].Split((char)19);
                    Client.Version = thirdSplit[1];
                }
            }


            Version.Text = Client.Version;

            if (!String.IsNullOrWhiteSpace(Settings.Default.SavedUsername))
            {
                RememberUsernameCheckbox.IsChecked = true;
                LoginUsernameBox.Text = Settings.Default.SavedUsername;
            }
            if (!String.IsNullOrWhiteSpace(Settings.Default.SavedPassword))
            {
                SHA1 sha = new SHA1CryptoServiceProvider();
                RememberPasswordCheckbox.IsChecked = true;
                LoginPasswordBox.Password          =
                    Settings.Default.SavedPassword.DecryptStringAES(
                        sha.ComputeHash(Encoding.UTF8.GetBytes(Settings.Default.Guid)).ToString());
            }
            if (!String.IsNullOrWhiteSpace(Settings.Default.Region))
            {
                RegionComboBox.SelectedValue = Settings.Default.Region;
            }

            invisibleLoginCheckBox.IsChecked = Settings.Default.incognitoLogin;

            /*var uriSource =
             *  new Uri(
             *      Path.Combine(Client.ExecutingDirectory, "Assets", "champions",
             *          champions.GetChampion(Client.LatestChamp).splashPath), UriKind.Absolute);
             * LoginImage.Source = new BitmapImage(uriSource);*/
            if (Client.Garena)
            {
                Client.PVPNet = null;
                Client.PVPNet = new PVPNetConnection();
                BaseRegion Garenaregion = BaseRegion.GetRegion(Client.args[1]);
                Client.PVPNet.garenaToken = Client.args[2];
                Client.PVPNet.Connect("", "", Garenaregion.PVPRegion, Client.Version);
                Client.Region                    = Garenaregion;
                HideGrid.Visibility              = Visibility.Hidden;
                ErrorTextBox.Visibility          = Visibility.Hidden;
                LoggingInLabel.Visibility        = Visibility.Visible;
                LoggingInProgressRing.Visibility = Visibility.Visible;
                Client.PVPNet.OnError           += PVPNet_OnError;
                Client.PVPNet.OnLogin           += PVPNet_OnLogin;
                Client.PVPNet.OnMessageReceived += Client.OnMessageReceived;
            }

            if (String.IsNullOrWhiteSpace(Settings.Default.SavedPassword) ||
                String.IsNullOrWhiteSpace(Settings.Default.Region) || !Settings.Default.AutoLogin)
            {
                return;
            }

            AutoLoginCheckBox.IsChecked = true;
            LoginButton_Click(null, null);
        }
Ejemplo n.º 20
0
        private async void ParseSpectatorGames()
        {
            if (gameList == null)
            {
                return;
            }
            if (gameList.Count <= 0)
            {
                return;
            }
            BlueBansLabel.Visibility   = Visibility.Hidden;
            PurpleBansLabel.Visibility = Visibility.Hidden;
            BlueBanListView.Items.Clear();
            PurpleBanListView.Items.Clear();
            BlueListView.Items.Clear();
            PurpleListView.Items.Clear();
            int GameId = 0;

            if (gameList.Count > SelectedGame)
            {
                var objectGame = gameList[SelectedGame];
                Dictionary <string, object> SpectatorGame = objectGame as Dictionary <string, object>;
                foreach (KeyValuePair <string, object> pair in SpectatorGame)
                {
                    if (pair.Key == "participants")
                    {
                        ArrayList players = pair.Value as ArrayList;
                        foreach (var objectPlayer in players)
                        {
                            Dictionary <string, object> playerInfo = objectPlayer as Dictionary <string, object>;
                            int    teamId     = 100;
                            int    championId = 0;
                            int    spell1Id   = 0;
                            int    spell2Id   = 0;
                            string PlayerName = "";
                            foreach (KeyValuePair <string, object> playerPair in playerInfo)
                            {
                                if (playerPair.Key == "teamId")
                                {
                                    teamId = (int)playerPair.Value;
                                }
                                if (playerPair.Key == "championId")
                                {
                                    championId = (int)playerPair.Value;
                                }
                                if (playerPair.Key == "summonerName")
                                {
                                    PlayerName = playerPair.Value as string;
                                }
                                if (playerPair.Key == "spell1Id")
                                {
                                    spell1Id = (int)playerPair.Value;
                                }
                                if (playerPair.Key == "spell2Id")
                                {
                                    spell2Id = (int)playerPair.Value;
                                }
                            }
                            ChampSelectPlayer control = new ChampSelectPlayer();
                            control.ChampionImage.Source = champions.GetChampion(championId).icon;
                            string uriSource = Path.Combine(Client.ExecutingDirectory, "Assets", "spell", SummonerSpell.GetSpellImageName(spell1Id));
                            control.SummonerSpell1.Source = Client.GetImage(uriSource);
                            uriSource = Path.Combine(Client.ExecutingDirectory, "Assets", "spell", SummonerSpell.GetSpellImageName(spell2Id));
                            control.SummonerSpell2.Source = Client.GetImage(uriSource);

                            control.PlayerName.Content = PlayerName;

                            if (teamId == 100)
                            {
                                BlueListView.Items.Add(control);
                            }
                            else
                            {
                                PurpleListView.Items.Add(control);
                            }
                        }
                    }
                    if (pair.Key == "gameId")
                    {
                        GameId = (int)pair.Value;
                    }
                    if (pair.Key == "bannedChampions")
                    {
                        ArrayList keyArray = pair.Value as ArrayList;
                        if (keyArray.Count > 0)
                        {
                            BlueBansLabel.Visibility   = Visibility.Visible;
                            PurpleBansLabel.Visibility = Visibility.Visible;
                        }
                        foreach (Dictionary <string, object> keyArrayP in keyArray)
                        {
                            int cid    = 0;
                            int teamId = 100;
                            foreach (KeyValuePair <string, object> keyArrayPair in keyArrayP)
                            {
                                if (keyArrayPair.Key == "championId")
                                {
                                    cid = (int)keyArrayPair.Value;
                                }
                                if (keyArrayPair.Key == "teamId")
                                {
                                    teamId = (int)keyArrayPair.Value;
                                }
                            }
                            ListViewItem item       = new ListViewItem();
                            Image        champImage = new Image();
                            champImage.Height = 58;
                            champImage.Width  = 58;
                            champImage.Source = champions.GetChampion(cid).icon;
                            item.Content      = champImage;
                            if (teamId == 100)
                            {
                                BlueBanListView.Items.Add(item);
                            }
                            else
                            {
                                PurpleBanListView.Items.Add(item);
                            }
                        }
                    }
                }

                try
                {
                    BaseRegion region        = BaseRegion.GetRegion((string)SpectatorComboBox.SelectedValue);
                    string     spectatorJSON = "";
                    string     url           = region.SpectatorLink + "consumer/getGameMetaData/" + region.InternalName + "/" + GameId + "/token";
                    using (WebClient client = new WebClient())
                    {
                        spectatorJSON = await client.DownloadStringTaskAsync(url);
                    }
                    JavaScriptSerializer        serializer       = new JavaScriptSerializer();
                    Dictionary <string, object> deserializedJSON = serializer.Deserialize <Dictionary <string, object> >(spectatorJSON);
                    MMRLabel.Content = "≈" + deserializedJSON["interestScore"];
                }
                catch { MMRLabel.Content = "N/A"; }
            }
        }
Ejemplo n.º 21
0
        private void ParseSpectatorGames()
        {
            if (gameList == null)
            {
                return;
            }
            if (gameList.Count <= 0)
            {
                return;
            }
            BlueBansLabel.Visibility   = Visibility.Hidden;
            PurpleBansLabel.Visibility = Visibility.Hidden;
            BlueBanListView.Items.Clear();
            PurpleBanListView.Items.Clear();
            BlueListView.Items.Clear();
            PurpleListView.Items.Clear();
            int GameId     = 0;
            var objectGame = gameList[SelectedGame];
            Dictionary <string, object> SpectatorGame = objectGame as Dictionary <string, object>;

            ImageGrid.Children.Clear();
            foreach (KeyValuePair <string, object> pair in SpectatorGame)
            {
                if (pair.Key == "participants")
                {
                    ArrayList players = pair.Value as ArrayList;

                    int i = 0;
                    foreach (var objectPlayer in players)
                    {
                        Dictionary <string, object> playerInfo = objectPlayer as Dictionary <string, object>;
                        int    teamId     = 100;
                        int    championId = 0;
                        int    spell1Id   = 0;
                        int    spell2Id   = 0;
                        string PlayerName = "";
                        foreach (KeyValuePair <string, object> playerPair in playerInfo)
                        {
                            if (playerPair.Key == "teamId")
                            {
                                teamId = (int)playerPair.Value;
                            }
                            if (playerPair.Key == "championId")
                            {
                                championId = (int)playerPair.Value;
                            }
                            if (playerPair.Key == "summonerName")
                            {
                                PlayerName = playerPair.Value as string;
                            }
                            if (playerPair.Key == "spell1Id")
                            {
                                spell1Id = (int)playerPair.Value;
                            }
                            if (playerPair.Key == "spell2Id")
                            {
                                spell2Id = (int)playerPair.Value;
                            }
                        }
                        ChampSelectPlayer control = new ChampSelectPlayer();
                        control.ChampionImage.Source = champions.GetChampion(championId).icon;
                        var uriSource = new Uri(Path.Combine(Client.ExecutingDirectory, "Assets", "spell", SummonerSpell.GetSpellImageName(spell1Id)), UriKind.Absolute);
                        control.SummonerSpell1.Source = new BitmapImage(uriSource);
                        uriSource = new Uri(Path.Combine(Client.ExecutingDirectory, "Assets", "spell", SummonerSpell.GetSpellImageName(spell2Id)), UriKind.Absolute);
                        control.SummonerSpell2.Source = new BitmapImage(uriSource);
                        control.PlayerName.Content    = PlayerName;

                        Image m = new Image();
                        Canvas.SetZIndex(m, -2); //Put background behind everything
                        m.Stretch             = Stretch.None;
                        m.Width               = 100;
                        m.Opacity             = 0.30;
                        m.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
                        m.VerticalAlignment   = System.Windows.VerticalAlignment.Stretch;
                        m.Margin              = new System.Windows.Thickness(i++ *100, 0, 0, 0);
                        System.Drawing.Rectangle cropRect = new System.Drawing.Rectangle(new System.Drawing.Point(100, 0), new System.Drawing.Size(100, 560));
                        System.Drawing.Bitmap    src      = System.Drawing.Image.FromFile(Path.Combine(Client.ExecutingDirectory, "Assets", "champions", champions.GetChampion(championId).portraitPath)) as System.Drawing.Bitmap;
                        System.Drawing.Bitmap    target   = new System.Drawing.Bitmap(cropRect.Width, cropRect.Height);

                        using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(target))
                        {
                            g.DrawImage(src, new System.Drawing.Rectangle(0, 0, target.Width, target.Height),
                                        cropRect,
                                        System.Drawing.GraphicsUnit.Pixel);
                        }

                        m.Source = Client.ToWpfBitmap(target);
                        ImageGrid.Children.Add(m);

                        if (teamId == 100)
                        {
                            BlueListView.Items.Add(control);
                        }
                        else
                        {
                            PurpleListView.Items.Add(control);
                        }
                    }
                }
                else if (pair.Key == "gameId")
                {
                    GameId = (int)pair.Value;
                }
                else if (pair.Key == "mapId")
                {
                    MapLabel.Content = BaseMap.GetMap((int)pair.Value).DisplayName;
                }
                else if (pair.Key == "gameLength")
                {
                    var seconds = (int)pair.Value;
                    GameTimeLabel.Content = string.Format("{0:D}:{1:00} min", seconds / 60, seconds % 60);
                }
                else if (pair.Key == "bannedChampions")
                {
                    //ArrayList players = pair.Value as ArrayList;
                    //Dictionary<string, object> playerInfo = objectPlayer as Dictionary<string, object>;
                    //foreach (KeyValuePair<string, object> playerPair in playerInfo)
                    ArrayList keyArray = pair.Value as ArrayList;
                    if (keyArray.Count > 0)
                    {
                        BlueBansLabel.Visibility   = Visibility.Visible;
                        PurpleBansLabel.Visibility = Visibility.Visible;
                    }
                    foreach (Dictionary <string, object> keyArrayP in keyArray)
                    //Dictionary<string, object> keyArrayP = keyArray as Dictionary<string, object>;
                    {
                        int cid    = 0;
                        int teamId = 100;
                        foreach (KeyValuePair <string, object> keyArrayPair in keyArrayP)
                        {
                            if (keyArrayPair.Key == "championId")
                            {
                                cid = (int)keyArrayPair.Value;
                            }
                            if (keyArrayPair.Key == "teamId")
                            {
                                teamId = (int)keyArrayPair.Value;
                            }
                        }
                        ListViewItem item       = new ListViewItem();
                        Image        champImage = new Image();
                        champImage.Height = 58;
                        champImage.Width  = 58;
                        //temp
                        try
                        {
                            champImage.Source = champions.GetChampion(cid).icon;
                        }
                        catch { }

                        item.Content = champImage;
                        if (teamId == 100)
                        {
                            BlueBanListView.Items.Add(item);
                        }
                        else
                        {
                            PurpleBanListView.Items.Add(item);
                        }
                    }
                }
            }

            try
            {
                BaseRegion region        = BaseRegion.GetRegion((string)SpectatorComboBox.SelectedValue);
                string     spectatorJSON = "";
                string     url           = region.SpectatorLink + "consumer/getGameMetaData/" + region.InternalName + "/" + GameId + "/token";
                using (WebClient client = new WebClient())
                {
                    spectatorJSON = client.DownloadString(url);
                }
                JavaScriptSerializer        serializer       = new JavaScriptSerializer();
                Dictionary <string, object> deserializedJSON = serializer.Deserialize <Dictionary <string, object> >(spectatorJSON);
                MMRLabel.Content = "≈" + deserializedJSON["interestScore"];
            }
            catch { MMRLabel.Content = "N/A"; }
        }
Ejemplo n.º 22
0
        public MainPage()
        {
            InitializeComponent();
            GotPlayerData(Client.LoginPacket);
            SpectatorComboBox.SelectedValue = Client.Region.RegionName.ToUpper();
            BaseRegion region = BaseRegion.GetRegion(Client.Region.RegionName);

            Client.Profile = new ProfilePage();
            GetNews(region);
            ChangeSpectatorRegion(Client.Region);
            var update = new Timer
            {
                Interval = 5000
            };

            update.Elapsed +=
                (o, e) =>
                Client.XmppConnection.Send(new Presence(Client.presenceStatus, Client.GetPresence(), 0));
            timer.Interval = (5000);
            //timer.Start();

            timer.Elapsed += (o, e) => Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
            {
                string Jid =
                    Client.GetChatroomJid(Client.GetObfuscatedChatroomName("legendaryclient", ChatPrefixes.Public),
                                          string.Empty, true);

                GroupChatItem item = Join(Jid, "LegendaryClient");
                var chatGroup      = new NotificationChatGroup
                {
                    Tag            = item,
                    GroupTitle     = item.GroupTitle,
                    Margin         = new Thickness(1, 0, 1, 0),
                    GroupLabelName = { Content = item.GroupTitle }
                };
                if (Client.GroupChatItems.All(i => i.GroupTitle != "LegendaryClient"))
                {
                    Client.ChatListView.Items.Add(chatGroup);
                    Client.GroupChatItems.Add(item);
                }

                timer.Stop();
            }));

            //Update featured games every minute.
            var featuredUpdateTimer = new Timer
            {
                Interval = 60000
            };

            featuredUpdateTimer.Elapsed += (o, e) =>
            {
                Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
                {
                    if (SpectatorComboBox.SelectedIndex == -1 || SpectatorComboBox.SelectedValue == null)
                    {
                        ChangeSpectatorRegion(region);
                    }
                    else
                    {
                        ChangeSpectatorRegion(BaseRegion.GetRegion((string)SpectatorComboBox.SelectedValue));
                    }
                }));
            };
            featuredUpdateTimer.Start();
        }
Ejemplo n.º 23
0
        private async void LoginButton_Click(object sender, RoutedEventArgs e)
        {
            if (RegionComboBox.SelectedIndex == -1)
            {
                return;
            }

            if ((string)UpdateRegionComboBox.SelectedValue == "Garena")
            {
                if (RegionComboBox.SelectedIndex == -1)
                {
                    return;
                }
                if (!string.IsNullOrEmpty(RegionComboBox.SelectedValue.ToString()))
                {
                    Settings.Default.DefaultGarenaRegion = RegionComboBox.SelectedValue.ToString(); // Set default Garena region
                    Settings.Default.Save();
                }
                Client.Garena = true;
                await garenaLogin();

                return;
            }
            string UserName = LoginUsernameBox.Text;

            LoggingInLabel.Content = "Logging in...";
            if (string.IsNullOrEmpty(Settings.Default.Guid))
            {
                Settings.Default.Guid = Guid.NewGuid().ToString();
            }

            Settings.Default.Save();
            SHA1 sha = new SHA1CryptoServiceProvider();

            if (RememberPasswordCheckbox.IsChecked == true)
            {
                Settings.Default.SavedPassword =
                    LoginPasswordBox.Password.EncryptStringAES(
                        sha.ComputeHash(Encoding.UTF8.GetBytes(Settings.Default.Guid)).ToString());
            }
            else
            {
                Settings.Default.SavedPassword = "";
            }

            Settings.Default.SavedUsername = RememberUsernameCheckbox.IsChecked == true ? LoginUsernameBox.Text : "";

            if (invisibleLoginCheckBox.IsChecked != null)
            {
                Settings.Default.incognitoLogin = (bool)invisibleLoginCheckBox.IsChecked;
            }

            Settings.Default.Region = (string)RegionComboBox.SelectedValue;
            Settings.Default.Save();

            HideGrid.Visibility              = Visibility.Hidden;
            ErrorTextBox.Visibility          = Visibility.Hidden;
            LoggingInLabel.Visibility        = Visibility.Visible;
            LoggingInProgressRing.Visibility = Visibility.Visible;
            BaseRegion selectedRegion = BaseRegion.GetRegion((string)RegionComboBox.SelectedValue);

            Client.Region = selectedRegion;
            var context = RiotCalls.RegisterObjects();

            Login();
        }
Ejemplo n.º 24
0
#pragma warning disable 4014 //Code does not need to be awaited
        async void Login()
        {
            BaseRegion selectedRegion = BaseRegion.GetRegion((string)RegionComboBox.SelectedValue);
            var        authToken      = await RiotCalls.GetRestToken(LoginUsernameBox.Text, LoginPasswordBox.Password, selectedRegion.LoginQueue);

            if (authToken == "invalid_credentials")
            {
                ErrorTextBox.Text                = "Wrong login data";
                HideGrid.Visibility              = Visibility.Visible;
                ErrorTextBox.Visibility          = Visibility.Visible;
                LoggingInLabel.Visibility        = Visibility.Hidden;
                LoggingInProgressRing.Visibility = Visibility.Collapsed;
                return;
            }
            Client.RiotConnection = new RtmpClient(new System.Uri("rtmps://" + selectedRegion.Server + ":2099"), RiotCalls.RegisterObjects(), ObjectEncoding.Amf3);
            Client.RiotConnection.CallbackException += client_CallbackException;
            Client.RiotConnection.MessageReceived   += client_MessageReceived;
            try
            {
                await Client.RiotConnection.ConnectAsync();
            }
            catch
            {
                ErrorTextBox.Text                = "Failed to login. SSL error.";
                HideGrid.Visibility              = Visibility.Visible;
                ErrorTextBox.Visibility          = Visibility.Visible;
                LoggingInLabel.Visibility        = Visibility.Hidden;
                LoggingInProgressRing.Visibility = Visibility.Collapsed;
                return;
            }

            Client.RiotConnection.SetChunkSize(2147483647);
            AuthenticationCredentials newCredentials = new AuthenticationCredentials
            {
                Username        = LoginUsernameBox.Text,
                Password        = LoginPasswordBox.Password,
                ClientVersion   = Client.Version,
                IpAddress       = RiotCalls.GetIpAddress(),
                Locale          = selectedRegion.Locale,
                OperatingSystem = "Windows 7",
                Domain          = "lolclient.lol.riotgames.com",
                AuthToken       = authToken
            };
            Session login = await RiotCalls.Login(newCredentials);

            if (login == null)
            {
                Client.Log("Login session is null.");
                var overlay = new MessageOverlay
                {
                    MessageTextBox = { Text = "Login session is null. Login failed. Please check whether the version number is correct or not.", IsReadOnly = true },
                    MessageTitle   = { Content = "Login session is null." }
                };
                Client.OverlayContainer.Content    = overlay.Content;
                Client.OverlayContainer.Visibility = Visibility.Visible;
                ErrorTextBox.Text                = "Failed to login. Login session is null.";
                HideGrid.Visibility              = Visibility.Visible;
                ErrorTextBox.Visibility          = Visibility.Visible;
                LoggingInLabel.Visibility        = Visibility.Hidden;
                LoggingInProgressRing.Visibility = Visibility.Collapsed;
                return;
            }
            Client.PlayerSession = login;
            var str1 = string.Format("gn-{0}", login.AccountSummary.AccountId);
            var str2 = string.Format("cn-{0}", login.AccountSummary.AccountId);
            var str3 = string.Format("bc-{0}", login.AccountSummary.AccountId);

            Task <bool>[] taskArray = { Client.RiotConnection.SubscribeAsync("my-rtmps", "messagingDestination", str1, str1),
                                        Client.RiotConnection.SubscribeAsync("my-rtmps", "messagingDestination", str2, str2),
                                        Client.RiotConnection.SubscribeAsync("my-rtmps", "messagingDestination", "bc", str3) };

            await Task.WhenAll(taskArray);

            //Riot added this for no reason but make it look like the riot client we have to do this
            var plainTextbytes = Encoding.UTF8.GetBytes(login.AccountSummary.Username + ":" + login.Token);

            Client.reconnectToken = Convert.ToBase64String(plainTextbytes);
            //await RiotCalls.Login(result);
            var LoggedIn = await Client.RiotConnection.LoginAsync(LoginUsernameBox.Text.ToLower(), login.Token);

            DoGetOnLoginPacket();
        }
        private async void LoginButton_Click(object sender, RoutedEventArgs args)
        {
            if (RememberPasswordCheckbox.IsChecked == true)
            {
                Properties.Settings.Default.SavedPassword = LoginPasswordBox.Password;
            }
            else
            {
                Properties.Settings.Default.SavedPassword = "";
            }

            if (RememberUsernameCheckbox.IsChecked == true)
            {
                Properties.Settings.Default.SavedUsername = LoginUsernameBox.Text;
            }
            else
            {
                Properties.Settings.Default.SavedUsername = "";
            }

            Properties.Settings.Default.AutoLogin = (bool)AutoLoginCheckBox.IsChecked;
            Properties.Settings.Default.Region    = (string)RegionComboBox.SelectedValue;
            Properties.Settings.Default.Save();

            HideGrid.Visibility              = Visibility.Hidden;
            ErrorTextBox.Visibility          = Visibility.Hidden;
            LoggingInLabel.Visibility        = Visibility.Visible;
            LoggingInProgressRing.Visibility = Visibility.Visible;
            BaseRegion SelectedRegion = BaseRegion.GetRegion((string)RegionComboBox.SelectedValue);

            Client.Region = SelectedRegion;

            var context = RiotCalls.RegisterObjects();

            Client.RtmpConnection = new RtmpClient(new Uri("rtmps://" + SelectedRegion.Server + ":2099"), context, ObjectEncoding.Amf3);
            Client.RtmpConnection.MessageReceived   += Client.OnMessageReceived;
            Client.RtmpConnection.CallbackException += Client.CallbackException;
            RiotCalls.OnInvocationError             += Client.CallbackException;
            await Client.RtmpConnection.ConnectAsync();

            AuthenticationCredentials newCredentials = new AuthenticationCredentials();

            newCredentials.Username      = LoginUsernameBox.Text;
            newCredentials.Password      = LoginPasswordBox.Password;
            newCredentials.ClientVersion = Client.Version;
            newCredentials.IpAddress     = RiotCalls.GetIpAddress();
            newCredentials.Locale        = SelectedRegion.Locale;
            newCredentials.Domain        = "lolclient.lol.riotgames.com";
            try
            {
                newCredentials.AuthToken = RiotCalls.GetAuthKey(LoginUsernameBox.Text, LoginPasswordBox.Password, SelectedRegion.LoginQueue);
            }
            catch (Exception e)
            {
                HideGrid.Visibility              = Visibility.Visible;
                ErrorTextBox.Visibility          = Visibility.Visible;
                LoggingInProgressRing.Visibility = Visibility.Hidden;
                LoggingInLabel.Visibility        = Visibility.Hidden;
                if (e.Message.Contains("The remote name could not be resolved"))
                {
                    ErrorTextBox.Text = "Please make sure you are connected the internet!";
                }
                else if (e.Message.Contains("(403) Forbidden"))
                {
                    ErrorTextBox.Text = "Your username or password is incorrect!";
                }
                else
                {
                    ErrorTextBox.Text = "Unable to get Auth Key";
                }

                ErrorTextBox.Text += string.Format("{0}{1}{0}{2}", Environment.NewLine, e.Message, e.StackTrace);
                return;
            }

            Session login = await RiotCalls.Login(newCredentials);

            Client.PlayerSession = login;
            await Client.RtmpConnection.SubscribeAsync("my-rtmps", "messagingDestination", "bc", "bc-" + login.AccountSummary.AccountId.ToString());

            await Client.RtmpConnection.SubscribeAsync("my-rtmps", "messagingDestination", "gn-" + login.AccountSummary.AccountId.ToString(), "gn-" + login.AccountSummary.AccountId.ToString());

            await Client.RtmpConnection.SubscribeAsync("my-rtmps", "messagingDestination", "cn-" + login.AccountSummary.AccountId.ToString(), "cn-" + login.AccountSummary.AccountId.ToString());

            bool LoggedIn = await Client.RtmpConnection.LoginAsync(LoginUsernameBox.Text.ToLower(), login.Token);

            LoginDataPacket packet = await RiotCalls.GetLoginDataPacketForUser();

            string State = await RiotCalls.GetAccountState();

            if (State != "ENABLED")
            {
                HideGrid.Visibility              = Visibility.Visible;
                ErrorTextBox.Visibility          = Visibility.Visible;
                LoggingInProgressRing.Visibility = Visibility.Hidden;
                LoggingInLabel.Visibility        = Visibility.Hidden;
                ErrorTextBox.Text = "Your account state was invalid: " + State;
                return;
            }

            GotLoginPacket(packet);
        }
Ejemplo n.º 26
0
        public async void AddAccount(object sender, RoutedEventArgs e)
        {
            var        context        = RiotCalls.RegisterObjects();
            Region     Regiondata     = GetRegionFromTag.GetRegion(this.Region.Region.Tag.ToString());
            BaseRegion SelectedRegion = BaseRegion.GetRegion(this.Region.Region.Tag.ToString());

            Client.RtmpConnection = new RtmpClient(new System.Uri("rtmps://" + SelectedRegion.Server + ":2099"), context, ObjectEncoding.Amf3);
            await Client.RtmpConnection.ConnectAsync();

            HintLabel1_Copy.Content = Regiondata.Host;
            HintLabel.Visibility    = Visibility.Visible;

            try
            {
                LegacyPVP.Logic.RiotLogic.Login.AuthenticationCredentials lg = new Logic.RiotLogic.Login.AuthenticationCredentials();
                AuthenticationCredentials newCredentials = new AuthenticationCredentials();

                lg.Username      = LOLUsername.WaterTextbox.Text;
                lg.Password      = LOLPassword.WaterTextbox.Password;
                lg.ClientVersion = GetLatestVersions.GetLatestLolVersion(new System.Uri("http://ll.leagueoflegends.com/landingpage/data/na/en_US.js"));
                lg.IpAddress     = RiotCalls.GetIpAddress();
                lg.Locale        = SelectedRegion.Locale;
                lg.Domain        = "lolclient.lol.riotgames.com";

                try
                {
                    newCredentials.AuthToken = RiotCalls.GetAuthKey(LOLUsername.WaterTextbox.Text, LOLPassword.WaterTextbox.Password, Regiondata.LoginQueue.ToString());
                    HintLabel2.Content       = newCredentials.AuthToken;
                }
                catch (Exception f)
                {
                    HintLabel1.Content = newCredentials.ClientVersion;
                    HintLabel2.Content = newCredentials.Locale;

                    var fadeOutAnimation = new DoubleAnimation(0, TimeSpan.FromSeconds(0.5));
                    fadeOutAnimation.Completed += (x, y) =>
                    {
                        var fadeInAnimation = new DoubleAnimation(1, TimeSpan.FromSeconds(0.5));
                    };

                    if (f.Message.Contains("The remote name could not be resolved"))
                    {
                        HintLabel.Content = "Please make sure you are connected the internet!";
                    }
                    else if (f.Message.Contains("(403) Forbidden"))
                    {
                        HintLabel.Content = "Your username or password is incorrect!";
                    }
                    else
                    {
                        HintLabel.Content = f.Message;
                    }
                    //Client.RtmpConnection.Close();
                    return;
                }

                try
                {
                    LegacyPVP.Logic.RiotLogic.Login.AuthenticationCredentials[] Credentials;
                    Credentials = new LegacyPVP.Logic.RiotLogic.Login.AuthenticationCredentials[] { lg };
                    Session login = await RiotCalls.Login(Credentials);

                    Logic.RtmpsLogic.Logic.PlayerSession = login;
                    await Client.RtmpConnection.SubscribeAsync("my-rtmps", "messagingDestination", "bc", "bc-" + login.AccountSummary.AccountId.ToString());

                    await Client.RtmpConnection.SubscribeAsync("my-rtmps", "messagingDestination", "gn-" + login.AccountSummary.AccountId.ToString(), "gn-" + login.AccountSummary.AccountId.ToString());

                    await Client.RtmpConnection.SubscribeAsync("my-rtmps", "messagingDestination", "cn-" + login.AccountSummary.AccountId.ToString(), "cn-" + login.AccountSummary.AccountId.ToString());

                    bool LoggedIn = await Client.RtmpConnection.LoginAsync(LOLUsername.WaterTextbox.Text.ToLower(), login.Token);

                    LoginDataPacket packet = await RiotCalls.GetLoginDataPacketForUser();

                    string State = await RiotCalls.GetAccountState();

                    if (State != "ENABLED")
                    {
                        return;
                    }
                    Login.AddLolAccount(LOLUsername.WaterTextbox.Text, LOLPassword.WaterTextbox.Password, packet.AllSummonerData.Summoner.Name, Regiondata.RegionTag);
                    Client.RtmpConnection.Close();
                }
                catch (InvocationException getVersion)
                {
                    HintLabel.Content = getVersion.Message;

                    /*
                     * object[] array = (object[])((AsObject)getVersion.RootCause)["substitutionArguments"];
                     * if (array.Length == 2 && (string)array[0] == newCredentials.ClientVersion)
                     * {
                     *  newCredentials.ClientVersion = (string)array[1];
                     * }
                     * //*/
                }
                catch (ClientDisconnectedException error)
                {
                    HintLabel.Content = error.Message;
                }
            }
            catch (Exception x)
            {
                HintLabel.Content = x.Message;
            }
        }