LESs/MainWindow.xaml.cs
/// <summary>
/// Called when the user looks for their League of Legends installation
/// </summary>
Called when the user looks for their League of Legends installation
Called when the user looks for their League of Legends installation
private void FindButton_Click(object sender, RoutedEventArgs e)
        {
            PatchButton.IsEnabled = false;
            RemoveButton.IsEnabled = false;
            OpenFileDialog findLeagueDialog = new OpenFileDialog();
            findLeagueDialog.DefaultExt = ".exe";
            findLeagueDialog.Filter = "League of Legends Launcher|lol.launcher*.exe|Garena Launcher|lol.exe"; 
            string RiotPath = Path.Combine(Path.GetPathRoot(Environment.SystemDirectory), "Riot Games", "League of Legends");
            string GarenaPath = Path.Combine(Path.GetPathRoot(Environment.SystemDirectory), "Program Files (x86)", "GarenaLoL", "GameData", "Apps", "LoL");
            if (!Directory.Exists(RiotPath))
                findLeagueDialog.InitialDirectory = Path.GetFullPath(GarenaPath);
            else
                findLeagueDialog.InitialDirectory = Path.GetFullPath(RiotPath);
            bool? selectedExectuable = findLeagueDialog.ShowDialog();
            if (selectedExectuable == false || selectedExectuable == null)
                return;
            Uri Location = new Uri(findLeagueDialog.FileName);
            string SelectedLocation = Location.LocalPath.Replace(Location.Segments.Last(), string.Empty);
            string LastSegment = Location.Segments.Last();
            if (!LastSegment.StartsWith("lol.launcher"))
            {
                type = ServerType.GARENA;
                RemoveButton.IsEnabled = true;
                PatchButton.IsEnabled = true;
                LocationTextbox.Text = Path.Combine(SelectedLocation, "Air");
            }
            else
            {
                string radsLocation = Path.Combine(SelectedLocation, "RADS", "projects", "lol_air_client", "releases");
                var versionDirectories = Directory.GetDirectories(radsLocation);
                string finalDirectory = "";
                int BiggestVersion = 0;
                foreach (string x in versionDirectories)
                {
                    string CurrentVersion = new Uri(x).Segments.Last();
                    string[] VersionNumbers = CurrentVersion.Split('.');
                    for (int i = 0; i < VersionNumbers.Length; i++)
                    {
                        VersionNumbers[i] = VersionNumbers[i].PadLeft(3, '0');
                    }
                    int Version = Convert.ToInt32(string.Join("", VersionNumbers));
                    if (Version > BiggestVersion)
                    {
                        BiggestVersion = Version;
                        finalDirectory = x;
                    }
                }
                BackupVersion = BiggestVersion.ToString();
                if (!_supportedVersions.Contains(BiggestVersion) && !Debugger.IsAttached)
                {
                    string Message = "This version of LESs may not support your version of League of Legends. Continue? This could harm your installation.";
                    MessageBoxResult versionMismatchResult = MessageBox.Show(Message, "Invalid Version", MessageBoxButton.YesNo);
                    if (versionMismatchResult == MessageBoxResult.No)
                        return;
                }
                type = ServerType.NORMAL;
                PatchButton.IsEnabled = true;
                RemoveButton.IsEnabled = true;
                LocationTextbox.Text = Path.Combine(finalDirectory, "deploy");
            }
            Directory.CreateDirectory(Path.Combine(LocationTextbox.Text, "LESsBackup"));
            Directory.CreateDirectory(Path.Combine(LocationTextbox.Text, "LESsBackup", BackupVersion));
        }
private void FindButton_Click ( object sender , RoutedEventArgs e ) { PatchButton . IsEnabled = false ; RemoveButton . IsEnabled = false ; OpenFileDialog findLeagueDialog = new OpenFileDialog ( ) ; findLeagueDialog . DefaultExt = " " ; findLeagueDialog . Filter = " " ; string RiotPath = Path . Combine ( Path . GetPathRoot ( Environment . SystemDirectory ) , " " , " " ) ; string GarenaPath = Path . Combine ( Path . GetPathRoot ( Environment . SystemDirectory ) , " " , " " , " " , " " , " " ) ; if ( ! Directory . Exists ( RiotPath ) ) findLeagueDialog . InitialDirectory = Path . GetFullPath ( GarenaPath ) ; else findLeagueDialog . InitialDirectory = Path . GetFullPath ( RiotPath ) ; bool ? selectedExectuable = findLeagueDialog . ShowDialog ( ) ; if ( selectedExectuable == false || selectedExectuable == null ) return ; Uri Location = new Uri ( findLeagueDialog . FileName ) ; string SelectedLocation = Location . LocalPath . Replace ( Location . Segments . Last ( ) , string . Empty ) ; string LastSegment = Location . Segments . Last ( ) ; if ( ! LastSegment . StartsWith ( " " ) ) { type = ServerType . GARENA ; RemoveButton . IsEnabled = true ; PatchButton . IsEnabled = true ; LocationTextbox . Text = Path . Combine ( SelectedLocation , " " ) ; } else { string radsLocation = Path . Combine ( SelectedLocation , " " , " " , " " , " " ) ; var versionDirectories = Directory . GetDirectories ( radsLocation ) ; string finalDirectory = " " ; int BiggestVersion = 0 ; foreach ( string x in versionDirectories ) { string CurrentVersion = new Uri ( x ) . Segments . Last ( ) ; string [ ] VersionNumbers = CurrentVersion . Split ( ' ' ) ; for ( int i = 0 ; i < VersionNumbers . Length ; i ++ ) { VersionNumbers [ i ] = VersionNumbers [ i ] . PadLeft ( 3 , ' ' ) ; } int Version = Convert . ToInt32 ( string . Join ( " " , VersionNumbers ) ) ; if ( Version > BiggestVersion ) { BiggestVersion = Version ; finalDirectory = x ; } } BackupVersion = BiggestVersion . ToString ( ) ; if ( ! _supportedVersions . Contains ( BiggestVersion ) && ! Debugger . IsAttached ) { string Message = " " ; MessageBoxResult versionMismatchResult = MessageBox . Show ( Message , " " , MessageBoxButton . YesNo ) ; if ( versionMismatchResult == MessageBoxResult . No ) return ; } type = ServerType . NORMAL ; PatchButton . IsEnabled = true ; RemoveButton . IsEnabled = true ; LocationTextbox . Text = Path . Combine ( finalDirectory , " " ) ; } Directory . CreateDirectory ( Path . Combine ( LocationTextbox . Text , " " ) ) ; Directory . CreateDirectory ( Path . Combine ( LocationTextbox . Text , " " , BackupVersion ) ) ; }
Called when the user looks for their League of Legends installation
Called when the user looks for their League of Legends installation
//Disable patching if the user selects another league installation. //Create a file dialog for the user to locate their league of legends installation. //Only show the league of legends executables //If they don't have League of Legends in the default path, look for Garena. //Remove the executable from the location //Get the executable name to check for Garena //If the file name is lol.exe, then it's garena //Check each RADS installation to find the latest installation //Compare the version text with format x.x.x.x to get the largest directory //Get the biggest version in the directory //Ensure that numbers like 0.0.2.1 are larger than 0.0.1.999 //If the version isn't the intended version, show a message to the user. This is just a warning and probably can be ignored //Create the LESsBackup directory to allow the user to uninstall if they wish to later on.
sender
object
e
RoutedEventArgs