Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rudimentary approach to alternative install paths. #4

Merged
merged 1 commit into from
Jun 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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