public LoginPage()
 {
     InitializeComponent();
     SetupProperties();
     // GetNews(region);
     Client.Region         = region;
     Client.SQLiteDatabase = new SQLite.SQLiteConnection(Path.Combine(Client.ExecutingDirectory, Client.sqlite));
     Client.Champions      = (from s in Client.SQLiteDatabase.Table <champions>() orderby s.name select s).ToList();
     foreach (champions c in Client.Champions)
     {
         Console.WriteLine(Client.ExecutingDirectory);
         Console.Write(c.iconPath);
         var Source = new Uri(Path.Combine(Client.ExecutingDirectory, "Assets", "champions", c.iconPath), UriKind.Absolute);
         c.icon = new BitmapImage(Source);
         Console.WriteLine("Requesting : " + c.name + " champ");
         Champions.InsertExtraChampData(c);
     }
     Client.ChampionSkins     = (from s in Client.SQLiteDatabase.Table <championSkins>() orderby s.name select s).ToList();
     Client.ChampionAbilities = (from s in Client.SQLiteDatabase.Table <championAbilities>() 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();
 }
        public LoginPage()
        {
            InitializeComponent();

            //Get client data after patcher completed
            Client.SQLiteDatabase = new SQLite.SQLiteConnection("gameStats_en_US.sqlite");
            Client.Champions      = (from s in Client.SQLiteDatabase.Table <champions>()
                                     orderby s.name
                                     select s).ToList();

            if (Properties.Settings.Default.FavouriteChamps == null)
            {
                Properties.Settings.Default.FavouriteChamps = new Int32[0];
            }

            foreach (champions c in Client.Champions)
            {
                string Source = Path.Combine(Client.ExecutingDirectory, "Assets", "champions", c.iconPath);
                c.icon = Client.GetImage(Source);
                Champions.InsertExtraChampData(c);
                if (Properties.Settings.Default.FavouriteChamps.Contains(c.id))
                {
                    c.IsFavourite = true;
                }
            }

            Client.ChampionSkins = (from s in Client.SQLiteDatabase.Table <championSkins>()
                                    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();

            //Retrieve latest client version
            SWFReader reader = new SWFReader("ClientLibCommon.dat");

            foreach (Tag tag in reader.Tags)
            {
                if (tag is DoABC)
                {
                    DoABC abcTag = (DoABC)tag;
                    if (abcTag.Name.Contains("riotgames/platform/gameclient/application/Version"))
                    {
                        var str = System.Text.Encoding.Default.GetString(abcTag.ABCData);
                        //Ugly hack ahead - turn back now! (http://pastebin.com/yz1X4HBg)
                        string[] firstSplit  = str.Split((char)6);
                        string[] secondSplit = firstSplit[0].Split((char)18);
                        //Client.Version = secondSplit[1];
                    }
                }
            }

            if (!String.IsNullOrWhiteSpace(Properties.Settings.Default.SavedUsername))
            {
                RememberUsernameCheckbox.IsChecked = true;
                LoginUsernameBox.Text = Properties.Settings.Default.SavedUsername;
            }
            if (!String.IsNullOrWhiteSpace(Properties.Settings.Default.SavedPassword))
            {
                RememberPasswordCheckbox.IsChecked = true;
                LoginPasswordBox.Password          = Properties.Settings.Default.SavedPassword;
            }
            if (!String.IsNullOrWhiteSpace(Properties.Settings.Default.Region))
            {
                RegionComboBox.SelectedValue = Properties.Settings.Default.Region;
            }
            string uriSource = Path.Combine(Client.ExecutingDirectory, "Assets", "champions", champions.GetChampion(Client.LatestChamp).splashPath);

            LoginImage.Source = Client.GetImage(uriSource);
            if (!String.IsNullOrWhiteSpace(Properties.Settings.Default.SavedPassword) &&
                !String.IsNullOrWhiteSpace(Properties.Settings.Default.Region) &&
                Properties.Settings.Default.AutoLogin)
            {
                AutoLoginCheckBox.IsChecked = true;
                LoginButton_Click(null, null);
            }
        }
Exemple #3
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);
        }
        public LoginPage()
        {
            InitializeComponent();
            Version.TextChanged += WaterTextbox_TextChanged;
            Version.Text         = Client.Version;

            WebClient client = new WebClient();

            //var MpFileName = client.DownloadString(new Uri("http://legendaryclient.com/update.html"));
            SoundPlayer.Source = new Uri(Path.Combine(Client.ExecutingDirectory, "aud.mp3"));
            SoundPlayer.Play();
            Sound.IsChecked = false;

            //VideoPlayer.Source = new Uri(Path.Combine(Client.ExecutingDirectory, "login.swf"));
            //VideoPlayer.Play();
            Video.IsChecked = false;

            //Get client data after patcher completed

            //Client.SQLiteDatabase = new SQLite.SQLiteConnection("gameStats_en_US.sqlite");
            Client.SQLiteDatabase = new SQLite.SQLiteConnection(Client.sqlite);
            Client.Champions      = (from s in Client.SQLiteDatabase.Table <champions>()
                                     orderby s.name
                                     select s).ToList();

            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);
                Champions.InsertExtraChampData(c);
            }
            Client.ChampionSkins = (from s in Client.SQLiteDatabase.Table <championSkins>()
                                    orderby s.name
                                    select s).ToList();
            Client.ChampionAbilities = (from s in Client.SQLiteDatabase.Table <championAbilities>()
                                        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();
            Client.StartHeartbeat();

            //Retrieve latest client version

            /*
             * SWFReader reader = new SWFReader("ClientLibCommon.dat");
             * foreach (Tag tag in reader.Tags)
             * {
             *  if (tag is DoABC)
             *  {
             *      DoABC abcTag = (DoABC)tag;
             *      if (abcTag.Name.Contains("riotgames/platform/gameclient/application/Version"))
             *      {
             *          var str = System.Text.Encoding.Default.GetString(abcTag.ABCData);
             *          //Ugly hack ahead - turn back now! (http://pastebin.com/yz1X4HBg)
             *          string[] firstSplit = str.Split((char)6);
             *          string[] secondSplit = firstSplit[0].Split((char)18);
             *          //Client.Version = secondSplit[1];
             *      }
             *  }
             * }*/

            if (!String.IsNullOrWhiteSpace(Properties.Settings.Default.SavedUsername))
            {
                RememberUsernameCheckbox.IsChecked = true;
                LoginUsernameBox.Text = Properties.Settings.Default.SavedUsername;
            }
            if (!String.IsNullOrWhiteSpace(Properties.Settings.Default.SavedPassword))
            {
                RememberPasswordCheckbox.IsChecked = true;
                LoginPasswordBox.Password          = Properties.Settings.Default.SavedPassword;
            }
            if (!String.IsNullOrWhiteSpace(Properties.Settings.Default.Region))
            {
                RegionComboBox.SelectedValue = Properties.Settings.Default.Region;
            }

            var uriSource = new Uri(Path.Combine(Client.ExecutingDirectory, "Assets", "champions", champions.GetChampion(Client.LatestChamp).splashPath), UriKind.Absolute);

            LoginImage.Source = new BitmapImage(uriSource);//*/
            if (!String.IsNullOrWhiteSpace(Properties.Settings.Default.SavedPassword) &&
                !String.IsNullOrWhiteSpace(Properties.Settings.Default.Region) &&
                Properties.Settings.Default.AutoLogin)
            {
                AutoLoginCheckBox.IsChecked = true;
                LoginButton_Click(null, null);
            }
        }
Exemple #5
0
        public LoginPage()
        {
            InitializeComponent();

            //Get client data after patcher completed
            string latestVersion = "0.0.0.0";
            string GameLocation  = Path.Combine("League of Legends", "RADS");

            if (Directory.Exists(GameLocation))
            {
                System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
                DirectoryInfo             dInfo    = new DirectoryInfo(Path.Combine(GameLocation, "projects", "lol_air_client", "releases"));
                DirectoryInfo[]           subdirs  = null;
                try
                {
                    subdirs = dInfo.GetDirectories();
                    foreach (DirectoryInfo info in subdirs)
                    {
                        latestVersion = GetGreaterVersion(latestVersion, info.Name);
                    }
                }
                catch (Exception er) { Console.WriteLine(er.Message); }
            }

            Client.SQLiteDatabase = new SQLite.SQLiteConnection(Path.Combine(GameLocation, "projects", "lol_air_client", "releases", latestVersion, "deploy", "assets", "data", "gameStats", "gameStats_en_US.sqlite"));
            Client.Champions      = (from s in Client.SQLiteDatabase.Table <champions>()
                                     orderby s.name
                                     select s).ToList();

            if (Properties.Settings.Default.FavouriteChamps == null)
            {
                Properties.Settings.Default.FavouriteChamps = new Int32[0];
            }

            foreach (champions c in Client.Champions)
            {
                string Source = Path.Combine(Client.ExecutingDirectory, "Assets", "champions", c.iconPath);
                c.icon = Client.GetImage(Source);
                Champions.InsertExtraChampData(c);
                if (Properties.Settings.Default.FavouriteChamps.Contains(c.id))
                {
                    c.IsFavourite = true;
                }
            }

            Client.ChampionSkins = (from s in Client.SQLiteDatabase.Table <championSkins>()
                                    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();

            //Retrieve latest client version
            SWFReader reader = new SWFReader("ClientLibCommon.dat");

            foreach (Tag tag in reader.Tags)
            {
                if (tag is DoABC)
                {
                    DoABC abcTag = (DoABC)tag;
                    if (abcTag.Name.Contains("riotgames/platform/gameclient/application/Version"))
                    {
                        var str = System.Text.Encoding.Default.GetString(abcTag.ABCData);
                        //Ugly hack ahead - turn back now! (http://pastebin.com/yz1X4HBg)
                        string[] firstSplit  = str.Split((char)6);
                        string[] secondSplit = firstSplit[0].Split((char)19);
                        Client.Version = secondSplit[1];
                    }
                }
            }

            if (!String.IsNullOrWhiteSpace(Properties.Settings.Default.SavedUsername))
            {
                RememberUsernameCheckbox.IsChecked = true;
                LoginUsernameBox.Text = Properties.Settings.Default.SavedUsername;
            }
            if (!String.IsNullOrWhiteSpace(Properties.Settings.Default.SavedPassword))
            {
                RememberPasswordCheckbox.IsChecked = true;
                LoginPasswordBox.Password          = Properties.Settings.Default.SavedPassword;
            }
            if (!String.IsNullOrWhiteSpace(Properties.Settings.Default.Region))
            {
                RegionComboBox.SelectedValue = Properties.Settings.Default.Region;
            }
            champions champ     = champions.GetChampion(Client.LatestChamp);
            string    uriSource = Path.Combine(Client.ExecutingDirectory, "Assets", "champions", champ.splashPath);

            LoginImage.Source = Client.GetImage(uriSource);
            if (!String.IsNullOrWhiteSpace(Properties.Settings.Default.SavedPassword) &&
                !String.IsNullOrWhiteSpace(Properties.Settings.Default.Region) &&
                Properties.Settings.Default.AutoLogin)
            {
                AutoLoginCheckBox.IsChecked = true;
                LoginButton_Click(null, null);
            }
        }
Exemple #6
0
        public LoginPage()
        {
            InitializeComponent();
            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;
            switch (Client.UpdateRegion)
            {
            case "PBE":
                RegionComboBox.ItemsSource          = new[] { "PBE" };
                LoginUsernameBox.Visibility         = Visibility.Visible;
                RememberUsernameCheckbox.Visibility = Visibility.Visible;
                break;

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

            case "Korea":
                RegionComboBox.ItemsSource          = new[] { "KR" };
                LoginUsernameBox.Visibility         = Visibility.Visible;
                RememberUsernameCheckbox.Visibility = Visibility.Visible;
                LoginPasswordBox.Visibility         = Visibility.Visible;
                break;

            case "Garena":
                RegionComboBox.ItemsSource          = new[] { "PH", "SG", "SGMY", "TH", "TW", "VN", "ID" };
                LoginUsernameBox.Visibility         = Visibility.Hidden;
                RememberUsernameCheckbox.Visibility = Visibility.Hidden;
                LoginPasswordBox.Visibility         = Visibility.Hidden;
                if (!string.IsNullOrEmpty(Settings.Default.DefaultGarenaRegion))
                {
                    RegionComboBox.SelectedValue = Settings.Default.DefaultGarenaRegion;      // Default Garena Region
                }
                break;
            }

            string themeLocation = Path.Combine(Client.ExecutingDirectory, "assets", "themes", Client.Theme);

            if (!Settings.Default.DisableLoginMusic)
            {
                string[] music;
                string   soundpath = Path.Combine(Client.ExecutingDirectory, "Assets", "sounds", "sound_o_heaven.ogg");
                if (DateTime.Now.Month == 4 && DateTime.Now.Day == 1)
                {
                    if (!File.Exists(soundpath))
                    {
                        using (WebClient wc = new WebClient())
                        {
                            wc.DownloadFile("http://images.wikia.com/leagueoflegends/images/1/10/Teemo.laugh3.ogg", soundpath);
                        }
                    }
                    music = new[] { soundpath };
                }
                else
                {
                    music = Directory.GetFiles(themeLocation, "*.mp3");
                }
                SoundPlayer.Source = new System.Uri(Path.Combine(themeLocation, music[0]));
                SoundPlayer.Play();
                Sound.IsChecked = false;
            }
            else
            {
                Sound.IsChecked = true;
            }

            if (DateTime.Now.Month == 4 && DateTime.Now.Day == 1)
            {
                string SkinPath = Path.Combine(Client.ExecutingDirectory, "Assets", "champions",
                                               "Teemo_Splash_" + new Random().Next(0, 8) + ".jpg");
                if (File.Exists(SkinPath))
                {
                    LoginImage.Source = new BitmapImage(new System.Uri(SkinPath, UriKind.Absolute));
                }
            }
            else if (Settings.Default.LoginPageImage == "")
            {
                string[] videos = Directory.GetFiles(themeLocation, "*.mp4");
                if (videos.Length > 0 && File.Exists(videos[0]))
                {
                    LoginPic.Source = new System.Uri(videos[0]);
                }
                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 System.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));

            // Check database error
            try
            {
                Client.Champions = (from s in Client.SQLiteDatabase.Table <champions>()
                                    orderby s.name
                                    select s).ToList();

                //* to remove just remove one slash from the comment
                //Pls bard the tard for april fools
                Client.Champions.Find(bard => bard.name == "Bard").displayName = "Tard";
                //*/
            }
            catch (Exception e) // Database broken?
            {
                Client.Log("Database is broken : \r\n" + e.Message + "\r\n" + e.Source);
                var overlay = new MessageOverlay
                {
                    MessageTextBox = { Text = "Database is broken. Click OK to exit LegendaryClient." },
                    MessageTitle   = { Content = "Database Error" }
                };
                Client.SQLiteDatabase.Close();
                File.Delete(Path.Combine(Client.ExecutingDirectory, Client.sqlite));
                overlay.AcceptButton.Click        += (o, i) => { Environment.Exit(0); };
                Client.OverlayContainer.Content    = overlay.Content;
                Client.OverlayContainer.Visibility = Visibility.Visible;
                return;
            }

            var FreeToPlay = FreeToPlayChampions.GetInstance();

            foreach (champions c in Client.Champions)
            {
                var source = new System.Uri(Path.Combine(Client.ExecutingDirectory, "Assets", "champions", c.iconPath),
                                            UriKind.Absolute);
                c.icon = new BitmapImage(source);

                if (FreeToPlay != null)
                {
                    c.IsFreeToPlay = FreeToPlay.IsFreeToPlay(c);
                }
                Champions.InsertExtraChampData(c);
            }

            Client.ChampionSkins = (from s in Client.SQLiteDatabase.Table <championSkins>()
                                    orderby s.name
                                    select s).ToList();
            Client.ChampionAbilities = (from s in Client.SQLiteDatabase.Table <championAbilities>()
                                        orderby s.name
                                        select s).ToList();

            Client.SQLiteDatabase.Close();
            Client.Items     = Items.PopulateItems();
            Client.Masteries = Masteries.PopulateMasteries();
            Client.Runes     = Runes.PopulateRunes();
            BaseUpdateRegion updateRegion = BaseUpdateRegion.GetUpdateRegion(Client.UpdateRegion);
            var patcher = new RiotPatcher();

            if (Client.UpdateRegion != "Garena")
            {
                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 System.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))
            {
                if (secondSplit.Count() > 1)
                {
                    Client.Version = secondSplit[1];
                }
                else
                {
                    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;
        }
Exemple #7
0
        public LoginPage()
        {
            InitializeComponent();
            Version.TextChanged += WaterTextbox_TextChanged;
            if (Client.Version == "4.18.1" || Client.Version == "0.0.0")
            {
                Client.Version = "4.19.1";
            }
            bool x = Properties.Settings.Default.DarkTheme;

            if (!x)
            {
                var bc = new BrushConverter();
                HideGrid.Background = (Brush)bc.ConvertFrom("#B24F4F4F");
                LoggingInProgressRing.Foreground = (Brush)bc.ConvertFrom("#FFFFFFFF");
            }
            //#B2C8C8C8
            Version.Text = Client.Version;

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

            if (Properties.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", Properties.Settings.Default.LoginPageImage.Replace("\r\n", ""))))
                {
                    LoginImage.Source = new BitmapImage(new Uri(Path.Combine(Client.ExecutingDirectory, "Assets", "champions", Properties.Settings.Default.LoginPageImage), UriKind.Absolute));
                }
            }

            Video.IsChecked = false;

            //Get client data after patcher completed

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

            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");

                Champions.InsertExtraChampData(c);
            }
            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();

            //Retrieve latest client version

            /*
             * SWFReader reader = new SWFReader("ClientLibCommon.dat");
             * foreach (Tag tag in reader.Tags)
             * {
             *  if (tag is DoABC)
             *  {
             *      DoABC abcTag = (DoABC)tag;
             *      if (abcTag.Name.Contains("riotgames/platform/gameclient/application/Version"))
             *      {
             *          var str = System.Text.Encoding.Default.GetString(abcTag.ABCData);
             *          //Ugly hack ahead - turn back now! (http://pastebin.com/yz1X4HBg)
             *          string[] firstSplit = str.Split((char)6);
             *          string[] secondSplit = firstSplit[0].Split((char)18);
             *          //Client.Version = secondSplit[1];
             *      }
             *  }
             * }*/

            if (!String.IsNullOrWhiteSpace(Properties.Settings.Default.SavedUsername))
            {
                RememberUsernameCheckbox.IsChecked = true;
                LoginUsernameBox.Text = Properties.Settings.Default.SavedUsername;
            }
            if (!String.IsNullOrWhiteSpace(Properties.Settings.Default.SavedPassword))
            {
                RememberPasswordCheckbox.IsChecked = true;
                LoginPasswordBox.Password          = Properties.Settings.Default.SavedPassword;
            }
            if (!String.IsNullOrWhiteSpace(Properties.Settings.Default.Region))
            {
                RegionComboBox.SelectedValue = Properties.Settings.Default.Region;
            }

            var uriSource = new Uri(Path.Combine(Client.ExecutingDirectory, "Assets", "champions", champions.GetChampion(Client.LatestChamp).splashPath), UriKind.Absolute);

            //LoginImage.Source = new BitmapImage(uriSource);//*/

            if (!String.IsNullOrWhiteSpace(Properties.Settings.Default.SavedPassword) &&
                !String.IsNullOrWhiteSpace(Properties.Settings.Default.Region) &&
                Properties.Settings.Default.AutoLogin)
            {
                AutoLoginCheckBox.IsChecked = true;
                LoginButton_Click(null, null);
            }
        }