Example #1
0
        private void StartPatcher()
        {
            try
            {
                var bgThead = new Thread(() =>
                {
                    LogTextBox("Starting Patcher");

                    var client = new WebClient();
                    client.DownloadProgressChanged += client_DownloadProgressChanged;
                    client.DownloadFileCompleted   += client_DownloadDDragon;
                    client.DownloadProgressChanged +=
                        (o, e) => Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
                    {
                        double bytesIn    = double.Parse(e.BytesReceived.ToString(CultureInfo.InvariantCulture));
                        double totalBytes =
                            double.Parse(e.TotalBytesToReceive.ToString(CultureInfo.InvariantCulture));
                        double percentage            = bytesIn / totalBytes * 100;
                        CurrentProgressLabel.Content = "Downloaded " + e.BytesReceived + " of " +
                                                       e.TotalBytesToReceive;
                        CurrentProgressBar.Value =
                            int.Parse(Math.Truncate(percentage).ToString(CultureInfo.InvariantCulture));
                    }));

                    Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
                    {
                        TotalProgressLabel.Content = "20%";
                        TotalProgessBar.Value      = 20;
                    }));

                    #region idk

                    client = new WebClient();
                    if (!File.Exists(Path.Combine(Client.ExecutingDirectory, "Client", "Login.mp3")))
                    {
                        client.DownloadFile(
                            new Uri(
                                "https://s12.solidfilesusercontent.com/MDE1MWYxZGJmYWFhNzJmNGQ2N2ZhOWE0NzU4Yjk2ZDYwZjY3MGU2OToxWHp3OTk6dUllemo3WDM0RnlScUgxZk1YWXpKYmN0RXBn/7a0671ed14/Login.mp3"),
                            Path.Combine(Client.ExecutingDirectory, "Client", "Login.mp3"));
                    }

                    if (!File.Exists(Path.Combine(Client.ExecutingDirectory, "Client", "Login.mp4")))
                    {
                        client.DownloadFile(
                            new Uri(
                                "https://s8.solidfilesusercontent.com/MzkxMTBjOTllZDczMTBjZDUwNzgwOTc1NTYwZmY1Nzg2YThkZDI5MzoxWHp2eE86alBDQXBkU1FuNmt6R3dsTzcycEtoOXpGdVZr/a38bbf759c/Login.mp4"),
                            Path.Combine(Client.ExecutingDirectory, "Client", "Login.mp4"));
                    }

                    #endregion idk

                    #region DDragon

                    var encoding = new ASCIIEncoding();
                    if (!Directory.Exists(Path.Combine(Client.ExecutingDirectory, "Assets")))
                    {
                        Directory.CreateDirectory(Path.Combine(Client.ExecutingDirectory, "Assets"));
                    }

                    if (!File.Exists(Path.Combine(Client.ExecutingDirectory, "Assets", "VERSION_DDRagon")))
                    {
                        FileStream versionLol =
                            File.Create(Path.Combine(Client.ExecutingDirectory, "Assets", "VERSION_DDRagon"));
                        versionLol.Write(encoding.GetBytes("0.0.0"), 0, encoding.GetBytes("0.0.0").Length);

                        versionLol.Close();
                    }


                    var patcher = new RiotPatcher();
                    string dDragonDownloadUrl = patcher.GetDragon();
                    if (!String.IsNullOrEmpty(dDragonDownloadUrl))
                    {
                        LogTextBox("DataDragon Version: " + patcher.DDragonVersion);
                        string dDragonVersion =
                            File.ReadAllText(Path.Combine(Client.ExecutingDirectory, "Assets", "VERSION_DDragon"));
                        LogTextBox("Current DataDragon Version: " + dDragonVersion);

                        Client.Version = dDragonVersion;
                        Client.Log("DDragon Version (LOL Version) = " + dDragonVersion);

                        LogTextBox("Client Version: " + Client.Version);

                        if (patcher.DDragonVersion != dDragonVersion)
                        {
                            try
                            {
                                if (!Directory.Exists(Path.Combine(Client.ExecutingDirectory, "Assets", "temp")))
                                {
                                    Directory.CreateDirectory(Path.Combine(Client.ExecutingDirectory, "Assets", "temp"));
                                }

                                Dispatcher.BeginInvoke(DispatcherPriority.Input,
                                                       new ThreadStart(() => { CurrentProgressLabel.Content = "Downloading DataDragon"; }));
                                client.DownloadFile(dDragonDownloadUrl,
                                                    Path.Combine(Client.ExecutingDirectory, "Assets",
                                                                 "dragontail-" + patcher.DDragonVersion + ".tgz"));


                                Dispatcher.BeginInvoke(DispatcherPriority.Input,
                                                       new ThreadStart(() => { CurrentProgressLabel.Content = "Extracting DataDragon"; }));

                                Stream inStream =
                                    File.OpenRead(Path.Combine(Client.ExecutingDirectory, "Assets",
                                                               "dragontail-" + patcher.DDragonVersion + ".tgz"));

                                using (var gzipStream = new GZipInputStream(inStream))
                                {
                                    TarArchive tarArchive = TarArchive.CreateInputTarArchive(gzipStream);
                                    tarArchive.ExtractContents(Path.Combine(Client.ExecutingDirectory, "Assets", "temp"));
                                    //tarArchive.Close();
                                }
                                inStream.Close();

                                Copy(
                                    Path.Combine(Client.ExecutingDirectory, "Assets", "temp", patcher.DDragonVersion,
                                                 "data"), Path.Combine(Client.ExecutingDirectory, "Assets", "data"));
                                Copy(
                                    Path.Combine(Client.ExecutingDirectory, "Assets", "temp", patcher.DDragonVersion,
                                                 "img"), Path.Combine(Client.ExecutingDirectory, "Assets"));
                                DeleteDirectoryRecursive(Path.Combine(Client.ExecutingDirectory, "Assets", "temp"));

                                FileStream versionDDragon =
                                    File.Create(Path.Combine(Client.ExecutingDirectory, "Assets", "VERSION_DDRagon"));
                                versionDDragon.Write(encoding.GetBytes(patcher.DDragonVersion), 0,
                                                     encoding.GetBytes(patcher.DDragonVersion).Length);

                                Client.Version = dDragonVersion;
                                versionDDragon.Close();
                            }
                            catch
                            {
                                Client.Log(
                                    "Probably updated version number without actually uploading the files.");
                            }
                        }
                    }
                    else
                    {
                        LogTextBox(
                            "Failed to get DDragon version. Either not able to be found or unknown error (most likely the website is in maitenance, please try again in an hour or so)");
                        LogTextBox(
                            "Continuing could cause errors. Report this as an issue if it occurs again in a few hours.");
                    }

                    #endregion DDragon

                    Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
                    {
                        TotalProgressLabel.Content = "40%";
                        TotalProgessBar.Value      = 40;
                    }));

                    // Try get LoL path from registry

                    //A string that looks like C:\Riot Games\League of Legends\
                    string lolRootPath = GetLolRootPath(false);

                    #region lol_air_client

                    if (!File.Exists(Path.Combine(Client.ExecutingDirectory, "Assets", "VERSION_AIR")))
                    {
                        FileStream versionAir =
                            File.Create(Path.Combine(Client.ExecutingDirectory, "Assets", "VERSION_AIR"));
                        versionAir.Write(encoding.GetBytes("0.0.0.0"), 0, encoding.GetBytes("0.0.0.0").Length);
                        versionAir.Close();
                    }

                    BaseUpdateRegion updateRegion = BaseUpdateRegion.GetUpdateRegion(Client.UpdateRegion);
                    string latestAir = patcher.GetListing(updateRegion.AirListing);
                    LogTextBox("Air Assets Version: " + latestAir);
                    string airVersion =
                        File.ReadAllText(Path.Combine(Client.ExecutingDirectory, "Assets", "VERSION_AIR"));
                    LogTextBox("Current Air Assets Version: " + airVersion);
                    var updateClient = new WebClient();
                    if (airVersion != latestAir)
                    {
                        //Download Air Assists from riot
                        try
                        {
                            string airManifestLink = updateRegion.AirManifest + "releases/" + latestAir + "/packages/files/packagemanifest";
                            string[] allFiles      = patcher.GetManifest(airManifestLink);
                            int i = 0;
                            while (!allFiles[i].Contains("gameStats_en_US.sqlite"))
                            {
                                i++;
                            }

                            updateClient.DownloadFile(new Uri(updateRegion.BaseLink + allFiles[i].Split(',')[0]), Path.Combine(Client.ExecutingDirectory, "gameStats_en_US.sqlite"));

                            GetAllPngs(allFiles);
                            if (File.Exists(Path.Combine(Client.ExecutingDirectory, "Assets", "VERSION_AIR")))
                            {
                                File.Delete(Path.Combine(Client.ExecutingDirectory, "Assets", "VERSION_AIR"));
                            }

                            using (
                                FileStream file =
                                    File.Create(Path.Combine(Client.ExecutingDirectory, "Assets", "VERSION_AIR")))
                                file.Write(encoding.GetBytes(latestAir), 0,
                                           encoding.GetBytes(latestAir).Length);
                        }
                        catch (Exception e)
                        {
                            Client.Log(e.Message);
                        }
                    }

                    if (airVersion != latestAir)
                    {
                        Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
                        {
                            SkipPatchButton.IsEnabled    = true;
                            CurrentProgressLabel.Content = "Retrieving Air Assets";
                        }));
                    }

                    #endregion lol_air_client

                    //string GameVersion = File.ReadAllText(Path.Combine(Client.ExecutingDirectory, "RADS", "VERSION_LOL"));

                    #region lol_game_client

                    LogTextBox("Trying to detect League of Legends GameClient");
                    LogTextBox("League of Legends is located at: " + lolRootPath);
                    //RADS\solutions\lol_game_client_sln\releases
                    string gameLocation = Path.Combine(lolRootPath, "RADS", "solutions", "lol_game_client_sln",
                                                       "releases");

                    string solutionListing =
                        patcher.GetListing(
                            updateRegion.SolutionListing);

                    string solutionVersion = solutionListing.Split(new[] { Environment.NewLine }, StringSplitOptions.None)[0];
                    LogTextBox("Latest League of Legends GameClient: " + solutionVersion);
                    LogTextBox("Checking if League of Legends is Up-To-Date");

                    bool toExit = false;
                    if (Client.UpdateRegion == "Garena")
                    {
                        XmlReader reader     = XmlReader.Create("http://updateres.garenanow.com/im/versions.xml");
                        string garenaVersion = "";
                        while (reader.Read())
                        {
                            if (reader.GetAttribute("name") == "lol")
                            {
                                garenaVersion = reader.GetAttribute("latest_version");
                                break;
                            }
                        }
                        try
                        {
                            if (garenaVersion == File.ReadAllText(Path.Combine(Path.GetDirectoryName(lolRootPath), "lol.version")))
                            {
                                LogTextBox("League of Legends is Up-To-Date");
                                Client.Location     = Path.Combine(lolRootPath, "Game");
                                Client.RootLocation = lolRootPath;
                            }
                            else
                            {
                                LogTextBox("League of Legends is not Up-To-Date. Please Update League Of Legends");
                                Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
                                {
                                    SkipPatchButton.IsEnabled   = true;
                                    FindClientButton.Visibility = Visibility.Visible;
                                }));
                                toExit = true;
                            }
                        }
                        catch
                        {
                            LogTextBox("Can't find League of Legends version file. Make sure you select correct update region.");
                            Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
                            {
                                SkipPatchButton.IsEnabled   = true;
                                FindClientButton.Visibility = Visibility.Visible;
                            }));
                            toExit = true;
                        }
                    }
                    else if (Directory.Exists(Path.Combine(gameLocation, solutionVersion)))
                    {
                        LogTextBox("League of Legends is Up-To-Date");
                        Client.Location = Path.Combine(lolRootPath, "RADS", "solutions", "lol_game_client_sln",
                                                       "releases", solutionVersion, "deploy");
                        Client.RootLocation = lolRootPath;
                    }
                    else
                    {
                        LogTextBox("League of Legends is not Up-To-Date. Please Update League Of Legends");
                        Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
                        {
                            SkipPatchButton.IsEnabled   = true;
                            FindClientButton.Visibility = Visibility.Visible;
                        }));
                        toExit = true;
                    }

                    #endregion lol_game_client

                    if (toExit)
                    {
                        return;
                    }

                    Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
                    {
                        TotalProgressLabel.Content   = "100%";
                        TotalProgessBar.Value        = 100;
                        SkipPatchButton.Content      = "Play";
                        CurrentProgressLabel.Content = "Finished Patching";
                        CurrentStatusLabel.Content   = "Ready To Play";
                        SkipPatchButton.IsEnabled    = true;
                        SkipPatchButton_Click(null, null);
                    }));

                    LogTextBox("LegendaryClient Has Finished Patching");
                })
                {
                    IsBackground = true
                };

                bgThead.Start();
            }
            catch (Exception e)
            {
                Client.Log(e.Message + " - in PatcherPage updating progress.");
            }
        }
Example #2
0
        private void GetAllPngs(string[] packageManifest)
        {
            string[] fileMetaData =
                packageManifest.Skip(1).ToArray();
            var currentVersion =
                new Version(File.ReadAllText(Path.Combine(Client.ExecutingDirectory, "Assets", "VERSION_AIR")));

            if (!Directory.Exists(Path.Combine(Client.ExecutingDirectory, "Assets", "champions")))
            {
                Directory.CreateDirectory(Path.Combine(Client.ExecutingDirectory, "Assets", "champions"));
            }

            if (!Directory.Exists(Path.Combine(Client.ExecutingDirectory, "Assets", "sounds")))
            {
                Directory.CreateDirectory(Path.Combine(Client.ExecutingDirectory, "Assets", "sounds"));
            }

            if (!Directory.Exists(Path.Combine(Client.ExecutingDirectory, "Assets", "sounds", "champions")))
            {
                Directory.CreateDirectory(Path.Combine(Client.ExecutingDirectory, "Assets", "sounds", "champions"));
            }

            if (!Directory.Exists(Path.Combine(Client.ExecutingDirectory, "Assets", "sounds", "ambient")))
            {
                Directory.CreateDirectory(Path.Combine(Client.ExecutingDirectory, "Assets", "sounds", "ambient"));
            }

            if (!Directory.Exists(Path.Combine(Client.ExecutingDirectory, "Assets", "profileicon")))
            {
                Directory.CreateDirectory(Path.Combine(Client.ExecutingDirectory, "Assets", "profileicon"));
            }

            foreach (string s in fileMetaData)
            {
                if (String.IsNullOrEmpty(s))
                {
                    continue;
                }

                //Remove size and type metadata
                string location = s.Split(',')[0];
                //Get save position
                var version = new Version(location.Split(new[] { "/releases/", "/files/" }, StringSplitOptions.None)[1]);
                if (version <= currentVersion)
                {
                    continue;
                }
                BaseUpdateRegion updateRegion = BaseUpdateRegion.GetUpdateRegion(Client.UpdateRegion);

                string savePlace = location.Split(new[] { "/files/" }, StringSplitOptions.None)[1];
                if (!savePlace.EndsWith(".jpg") && !savePlace.EndsWith(".png") && !savePlace.EndsWith(".mp3"))
                {
                    continue;
                }

                if (savePlace.Contains("assets/images/champions/"))
                {
                    using (var newClient = new WebClient())
                    {
                        string saveName = location.Split(new[] { "/champions/" }, StringSplitOptions.None)[1];
                        LogTextBox("Downloading " + saveName + " from http://l3cdn.riotgames.com");
                        newClient.DownloadFile(updateRegion.BaseLink + location,
                                               Path.Combine(Client.ExecutingDirectory, "Assets", "champions", saveName));
                    }
                }
                else if (savePlace.Contains("assets/images/abilities/"))
                {
                    using (var newClient = new WebClient())
                    {
                        string saveName = location.Split(new[] { "/abilities/" }, StringSplitOptions.None)[1];
                        LogTextBox("Downloading " + saveName + " from http://l3cdn.riotgames.com");
                        newClient.DownloadFile(updateRegion.BaseLink + location,
                                               saveName.ToLower().Contains("passive")
                                ? Path.Combine(Client.ExecutingDirectory, "Assets", "passive", saveName)
                                : Path.Combine(Client.ExecutingDirectory, "Assets", "spell", saveName));
                    }
                }
                else if (savePlace.Contains("assets/storeImages/content/summoner_icon/"))
                {
                    using (var newClient = new WebClient())
                    {
                        string saveName = location.Split(new[] { "/summoner_icon/" }, StringSplitOptions.None)[1];
                        LogTextBox("Downloading " + saveName + " from http://l3cdn.riotgames.com");
                        newClient.DownloadFile(updateRegion.BaseLink + location,
                                               saveName.ToLower().Contains("_")
                                ? Path.Combine(Client.ExecutingDirectory, "Assets", "profileicon", saveName.Split(new[] { "_" }, StringSplitOptions.None)[0] + ".png")
                                : Path.Combine(Client.ExecutingDirectory, "Assets", "profileicon", saveName.Replace("profileIcon", string.Empty)));
                    }
                }
                else if (savePlace.Contains("assets/sounds/"))
                {
                    using (var newClient = new WebClient())
                    {
                        if (savePlace.Contains("en_US/champions/"))
                        {
                            string saveName = location.Split(new[] { "/champions/" }, StringSplitOptions.None)[1];
                            LogTextBox("Downloading " + saveName + " from http://l3cdn.riotgames.com");
                            newClient.DownloadFile(updateRegion.BaseLink + location,
                                                   Path.Combine(Client.ExecutingDirectory, "Assets", "sounds", "champions",
                                                                saveName));
                        }
                        else if (savePlace.Contains("assets/sounds/ambient"))
                        {
                            string saveName = location.Split(new[] { "/ambient/" }, StringSplitOptions.None)[1];
                            LogTextBox("Downloading " + saveName + " from http://l3cdn.riotgames.com");
                            newClient.DownloadFile(updateRegion.BaseLink + location,
                                                   Path.Combine(Client.ExecutingDirectory, "Assets", "sounds", "ambient", saveName));
                        }
                        else if (savePlace.Contains("assets/sounds/matchmakingqueued.mp3"))
                        {
                            LogTextBox("Downloading matchmakingqueued.mp3 from http://l3cdn.riotgames.com");
                            newClient.DownloadFile(updateRegion.BaseLink + location,
                                                   Path.Combine(Client.ExecutingDirectory, "Assets", "sounds", "matchmakingqueued.mp3"));
                        }
                    }
                }
            }
        }
Example #3
0
        private void AirPatcher()
        {
            try
            {
                var bgThead = new Thread(() =>
                {
                    Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
                    {
                        TotalProgressLabel.Content = "40%";
                        TotalProgessBar.Value      = 40;
                    }));

                    // Try get LoL path from registry

                    //A string that looks like C:\Riot Games\League of Legends\
                    string lolRootPath = GetLolRootPath(false);

                    #region lol_air_client
                    var encoding = new ASCIIEncoding();
                    if (!File.Exists(Path.Combine(Client.ExecutingDirectory, "Assets", "VERSION_AIR")))
                    {
                        FileStream versionAir =
                            File.Create(Path.Combine(Client.ExecutingDirectory, "Assets", "VERSION_AIR"));
                        versionAir.Write(encoding.GetBytes("0.0.0.0"), 0, encoding.GetBytes("0.0.0.0").Length);
                        versionAir.Close();
                    }

                    BaseUpdateRegion updateRegion = BaseUpdateRegion.GetUpdateRegion(Client.UpdateRegion);
                    string latestAir = patcher.GetListing(updateRegion.AirListing);
                    LogTextBox("Newest Air Assets Version: " + latestAir);
                    string airVersion =
                        File.ReadAllText(Path.Combine(Client.ExecutingDirectory, "Assets", "VERSION_AIR"));
                    LogTextBox("Current Air Assets Version: " + airVersion);

                    downloadTheme(patcher.GetManifest(updateRegion.AirManifest + "releases/" + latestAir + "/packages/files/packagemanifest"));

                    var updateClient = new WebClient();
                    if (airVersion != latestAir)
                    {
                        //Download Air Assists from riot
                        try
                        {
                            string airManifestLink = updateRegion.AirManifest + "releases/" + latestAir + "/packages/files/packagemanifest";
                            string[] allFiles      = patcher.GetManifest(airManifestLink);
                            int i = 0;
                            while (!allFiles[i].Contains("gameStats_en_US.sqlite"))
                            {
                                i++;
                            }

                            updateClient.DownloadFile(new System.Uri(updateRegion.BaseLink + allFiles[i].Split(',')[0]), Path.Combine(Client.ExecutingDirectory, "gameStats_en_US.sqlite"));

                            GetAllPngs(allFiles);
                            if (File.Exists(Path.Combine(Client.ExecutingDirectory, "Assets", "VERSION_AIR")))
                            {
                                File.Delete(Path.Combine(Client.ExecutingDirectory, "Assets", "VERSION_AIR"));
                            }

                            using (
                                FileStream file =
                                    File.Create(Path.Combine(Client.ExecutingDirectory, "Assets", "VERSION_AIR")))
                                file.Write(encoding.GetBytes(latestAir), 0,
                                           encoding.GetBytes(latestAir).Length);
                        }
                        catch (Exception e)
                        {
                            Client.Log(e.Message);
                        }
                    }

                    if (airVersion != latestAir)
                    {
                        Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
                        {
                            SkipPatchButton.IsEnabled    = true;
                            CurrentProgressLabel.Content = "Retrieving Air Assets";
                        }));
                    }

                    #endregion lol_air_client

                    //string GameVersion = File.ReadAllText(Path.Combine(Client.ExecutingDirectory, "RADS", "VERSION_LOL"));

                    #region lol_game_client

                    LogTextBox("Trying to detect League of Legends GameClient");
                    LogTextBox("League of Legends is located at: " + lolRootPath);
                    //RADS\solutions\lol_game_client_sln\releases
                    string gameLocation = Path.Combine(lolRootPath, "RADS", "solutions", "lol_game_client_sln",
                                                       "releases");

                    string solutionListing =
                        patcher.GetListing(
                            updateRegion.SolutionListing);

                    string solutionVersion   = solutionListing.Split(new[] { Environment.NewLine }, StringSplitOptions.None)[0];
                    Client.GameClientVersion = solutionVersion;
                    LogTextBox("Latest League of Legends GameClient: " + solutionVersion);
                    LogTextBox("Checking if League of Legends is Up-To-Date");

                    bool toExit = false;
                    if (Client.UpdateRegion == "Garena")
                    {
                        if (Settings.Default.GarenaLocation == string.Empty)
                        {
                            ClientRegionLocation("Garena");
                        }
                        if (File.Exists(Path.Combine(Settings.Default.GarenaLocation, "Air", "Lib", "ClientLibCommon.dat")))
                        {
                            File.Copy(Path.Combine(Settings.Default.GarenaLocation, "Air", "Lib", "ClientLibCommon.dat"),
                                      Path.Combine(Client.ExecutingDirectory, "ClientLibCommon.dat"), true);

                            LogTextBox("League of Legends is Up-To-Date");
                            Client.Location     = Path.Combine(lolRootPath, "Game");
                            Client.RootLocation = lolRootPath;
                        }
                        else
                        {
                            LogTextBox("League of Legends is not Up-To-Date or location is incorrect");
                            Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
                            {
                                SkipPatchButton.IsEnabled   = true;
                                FindClientButton.Visibility = Visibility.Visible;
                            }));
                            toExit = true;
                        }

                        /*
                         * XmlReader reader = XmlReader.Create("http://updateres.garenanow.com/im/versions.xml");
                         * string garenaVersion = "";
                         * while (reader.Read())
                         * {
                         *  if (reader.GetAttribute("name") == "lol")
                         *  {
                         *      garenaVersion = reader.GetAttribute("latest_version");
                         *      break;
                         *  }
                         * }
                         */
                    }
                    else if (Directory.Exists(Path.Combine(gameLocation, solutionVersion)))
                    {
                        LogTextBox("League of Legends is Up-To-Date");
                        Client.Location = Path.Combine(lolRootPath, "RADS", "solutions", "lol_game_client_sln",
                                                       "releases", solutionVersion, "deploy");
                        Client.RootLocation = lolRootPath;
                    }
                    else
                    {
                        LogTextBox("League of Legends is not Up-To-Date. Please Update League Of Legends");
                        Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
                        {
                            SkipPatchButton.IsEnabled   = true;
                            FindClientButton.Visibility = Visibility.Visible;
                        }));
                        toExit = true;
                    }

                    #endregion lol_game_client

                    if (toExit)
                    {
                        return;
                    }

                    Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
                    {
                        TotalProgressLabel.Content   = "100%";
                        TotalProgessBar.Value        = 100;
                        SkipPatchButton.Content      = "Play";
                        CurrentProgressLabel.Content = "Finished Patching";
                        CurrentStatusLabel.Content   = "Ready To Play";
                        SkipPatchButton.IsEnabled    = true;
                        //SkipPatchButton_Click(null, null);

                        if (Settings.Default.AutoPlay)
                        {
                            SkipPatchButton_Click(null, null);
                        }
                    }));

                    LogTextBox("LegendaryClient Has Finished Patching");
                })
                {
                    IsBackground = true
                };

                bgThead.Start();
            }
            catch (Exception e)
            {
                Client.Log(e.Message + " - in PatcherPage updating progress.");
            }
        }
Example #4
0
        private void downloadTheme(string[] manifest)
        {
            try
            {
                string[]         fileMetaData = manifest.Skip(1).ToArray();
                BaseUpdateRegion updateRegion = BaseUpdateRegion.GetUpdateRegion(Client.UpdateRegion);

                if (!Directory.Exists(Path.Combine(Client.ExecutingDirectory, "Assets", "themes")))
                {
                    Directory.CreateDirectory(Path.Combine(Client.ExecutingDirectory, "Assets", "themes"));
                }

                foreach (string s in fileMetaData)
                {
                    if (string.IsNullOrEmpty(s))
                    {
                        continue;
                    }

                    string location  = s.Split(',')[0];
                    string savePlace = location.Split(new[] { "/files/" }, StringSplitOptions.None)[1];
                    if (savePlace.Contains("theme.properties"))
                    {
                        using (var newClient = new WebClient())
                        {
                            LogTextBox("Checking Theme...");
                            newClient.DownloadFile(updateRegion.BaseLink + location,
                                                   Path.Combine(Client.ExecutingDirectory, "Assets", "themes", "theme.properties"));
                        }
                    }
                }

                if (!File.Exists(Path.Combine(Client.ExecutingDirectory, "Assets", "themes", "theme.properties")))
                {
                    return;
                }

                string[] file =
                    File.ReadAllLines(Path.Combine(Client.ExecutingDirectory, "Assets", "themes", "theme.properties"));
                string theme = "";

                foreach (string s in file)
                {
                    if (s.StartsWith("themeConfig="))
                    {
                        theme = s.Split('=')[1].Split(',')[0];
                    }
                }

                if (theme == "")
                {
                    return;
                }

                if (!Directory.Exists(Path.Combine(Client.ExecutingDirectory, "Assets", "themes", theme)))
                {
                    Directory.CreateDirectory(Path.Combine(Client.ExecutingDirectory, "Assets", "themes", theme));
                }
                else
                {
                    Client.Theme = theme;
                    return;
                }

                List <string> themeLink = fileMetaData.Where(
                    line => (line.Contains("loop") || line.Contains("Loop")) &&
                    line.Contains(theme)).ToList();                    //loop is exacly the same as intro
                themeLink = themeLink.Select(link => link.Split(',')[0]).ToList();

                using (var newClient = new WebClient())
                {
                    foreach (var item in themeLink)
                    {
                        string fileName = item.Split('/').Last();
                        LogTextBox("Downloading " + fileName + " from http://l3cdn.riotgames.com");
                        newClient.DownloadFile(updateRegion.BaseLink + item,
                                               Path.Combine(Client.ExecutingDirectory, "Assets", "themes", theme, fileName));
                    }
                }
                string[] flv = Directory.GetFiles(
                    Path.Combine(Client.ExecutingDirectory, "Assets", "themes", theme), "*.flv");

                foreach (var item in flv)
                {
                    var inputFile = new MediaFile {
                        Filename =
                            Path.Combine(Client.ExecutingDirectory, "Assets", "themes", theme, item)
                    };
                    var outputFile = new MediaFile {
                        Filename =
                            Path.Combine(Client.ExecutingDirectory, "Assets", "themes", theme, item).Replace(".flv", ".mp4")
                    };

                    using (var engine = new Engine())
                    {
                        engine.Convert(inputFile, outputFile);
                    }
                }
                Client.Theme = theme;
            }
            catch
            {
            }
        }
Example #5
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;
        }
Example #6
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 PatcherFile(BaseUpdateRegion r, string line) : this(r, line.Split(',')[0], line.Split(',')[3])
 {
 }
 public PatcherFile(BaseUpdateRegion r, string path, string size) : this(r, path, path.Substring(34).Substring(0, path.Substring(34).IndexOf('/')), size)
 {
 }
 public PatcherFile(BaseUpdateRegion r, string path, string version, string size) : this(r, path, version, Convert.ToInt64(size))
 {
 }
 public PatcherFile(BaseUpdateRegion r, string path, string version, long size)
 {
     RelativePath = path;
     Version = version;
     FileSize = size;
     Region = r;
 }
 public async Task<PatcherFile[]> GetManifest(BaseUpdateRegion updateRegion, string latestAirVersion)
 {
     using (var client = new WebClient())
     {
         try
         {
             var manifestLink = updateRegion.AirManifest + "releases/" + latestAirVersion + "/packages/files/packagemanifest";
             var manifestString = await client.DownloadStringTaskAsync(manifestLink);
             var manifestLines = Regex.Split(manifestString, Environment.NewLine);
             var files = manifestLines.Where(m => m.Contains(',')).Select(m => new PatcherFile(updateRegion, m));
             return files.ToArray();
         }
         catch (WebException e)
         {
             Client.Log(e.Message);
         }
     }
     throw new Exception("Unable to fetch Packagemanifest");
 }