Skip to content

Commit

Permalink
Merge pull request #4 from RyadaProductions/DirectoryConfig
Browse files Browse the repository at this point in the history
Rudimentary approach to alternative install paths.
  • Loading branch information
CollinMcKinney authored Jun 1, 2020
2 parents 077f814 + e42d39c commit b969095
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 3 deletions.
8 changes: 6 additions & 2 deletions LeagueLocaleLauncher/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@ public class Config
public string ToolCulture = CultureInfo.CurrentCulture.ToString();
public Region Region = Region.NA;
public Language Language = Language.ENGLISH_UNITED_STATES;
public string LeagueClientSettingsPath = @"C:\Riot Games\League of Legends\Config\LeagueClientSettings.yaml";
public string LeagueClientPath = @"C:\Riot Games\League of Legends\LeagueClient.exe";
public string LeagueBasePath = @"C:\Riot Games\League of Legends\";

public string LeagueClientExecutable { get; } = "LeagueClient.exe";

public string LeagueClientSettingsPath => Path.Combine(LeagueBasePath, @"Config\LeagueClientSettings.yaml");
public string LeagueClientPath => Path.Combine(LeagueBasePath, LeagueClientExecutable);

public HashSet<string> LeagueProcessNames = new HashSet<string> { };

Expand Down
46 changes: 45 additions & 1 deletion LeagueLocaleLauncher/LeagueLocaleLauncher.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System;
using Microsoft.Win32;
using System;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Threading;
using System.Windows.Forms;
Expand All @@ -10,11 +12,53 @@ namespace LeagueLocaleLauncher
{
public partial class LeagueLocaleLauncher : Form
{
private const string _registryKey = @"HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Riot Games, Inc\League of Legends";
private const string _registryName = "Location";

public LeagueLocaleLauncher()
{
InitializeComponent();

Config.Load();

// TODO: Clean this up
if (!File.Exists(Config.Loaded.LeagueClientPath))
{
// League install path is invalid, set new path.
// Check registry for league install location
Config.Loaded.LeagueBasePath = Registry.GetValue(_registryKey, _registryName, Config.Loaded.LeagueClientPath) as string;

if (!File.Exists(Config.Loaded.LeagueClientPath))
{
// League registry location is still invalid, manually setting path
using (var folderBrowserDialog = new FolderBrowserDialog())
{
var result = folderBrowserDialog.ShowDialog();

if (result == DialogResult.OK && !string.IsNullOrWhiteSpace(folderBrowserDialog.SelectedPath))
{
var baseDirectory = folderBrowserDialog.SelectedPath;
var files = Directory.GetFiles(baseDirectory);
if (files.Select(x => Path.GetFileName(x)).Contains(Config.Loaded.LeagueClientExecutable))
{
Config.Loaded.LeagueBasePath = baseDirectory;
}
else
{
MessageBox.Show("Closing application due to no valid location being selected.");
Close();
}
}
else
{
MessageBox.Show("Closing application due to no valid location being selected.");
Close();
}
}
}


}

CultureInfo.CurrentCulture = new CultureInfo(Config.Loaded.ToolCulture);
CultureInfo.CurrentCulture = new CultureInfo(CultureInfo.CurrentCulture.TwoLetterISOLanguageName);
Expand Down

0 comments on commit b969095

Please sign in to comment.