Skip to content

Commit

Permalink
Add "remedy" for #29 and other things
Browse files Browse the repository at this point in the history
Say that Legendary Launcher isn't installed if it's needed.
  • Loading branch information
hawkeye116477 committed Nov 30, 2023
1 parent 2d1abd6 commit 504851f
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/LegendaryGameController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public override void Install(InstallActionArgs args)
{
if (!LegendaryLauncher.IsInstalled)
{
throw new Exception("Legendary Launcher is not installed.");
throw new Exception(ResourceProvider.GetString(LOC.LegendaryLauncherNotInstalled));
}

Window window = null;
Expand Down Expand Up @@ -105,7 +105,7 @@ public override async void Uninstall(UninstallActionArgs args)
{
if (!LegendaryLauncher.IsInstalled)
{
throw new Exception("Legendary Launcher is not installed.");
throw new Exception(ResourceProvider.GetString(LOC.LegendaryLauncherNotInstalled));
}

Dispose();
Expand Down
4 changes: 4 additions & 0 deletions src/LegendaryLauncher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ public static string LauncherPath
}
}
}
if (!File.Exists(Path.Combine(launcherPath, "legendary.exe")))
{
launcherPath = "";
}
return launcherPath;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/LegendaryLibrarySettingsView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@
Click="EOSOInstallBtn_Click" HorizontalAlignment="Left"></Button>
<Button Content="{DynamicResource LOCLegendaryDisable}" Grid.Row="0"
Grid.Column="0" Margin="10,0,0,0" Name="EOSOToggleBtn"
Click="EOSOToggleBtn_Click" HorizontalAlignment="Left"></Button>
Click="EOSOToggleBtn_Click" HorizontalAlignment="Left"/>
<Button Content="{DynamicResource LOCLegendary3P_PlayniteUninstallGame}" Name="EOSOUninstallBtn"
Grid.Row="0" Grid.Column="1" Margin="10,0,0,0"
Click="EOSOUninstallBtn_Click" HorizontalAlignment="Left"></Button>
Expand Down
36 changes: 29 additions & 7 deletions src/LegendaryLibrarySettingsView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ private async void EOSOUninstallBtn_Click(object sender, RoutedEventArgs e)

private void EOSOInstallBtn_Click(object sender, RoutedEventArgs e)
{
if (!LegendaryLauncher.IsInstalled)
{
playniteAPI.Dialogs.ShowErrorMessage(ResourceProvider.GetString(LOC.LegendaryLauncherNotInstalled));
return;
}
var window = playniteAPI.Dialogs.CreateWindow(new WindowCreationOptions
{
ShowMaximizeButton = false
Expand Down Expand Up @@ -182,19 +187,31 @@ private async void LegendarySettingsUC_Loaded(object sender, RoutedEventArgs e)
AutoClearCacheCBo.ItemsSource = autoClearOptions;

troubleshootingInformation = new LegendaryTroubleshootingInformation();
var verionCmd = await Cli.Wrap(LegendaryLauncher.ClientExecPath)
.WithArguments(new[] { "-V" })
.WithValidation(CommandResultValidation.None)
.ExecuteBufferedAsync();
if (verionCmd.StandardOutput.Contains("version"))
if (LegendaryLauncher.IsInstalled)
{
troubleshootingInformation.LauncherVersion = Regex.Match(verionCmd.StandardOutput, @"\d+(\.\d+)+").Value;
LauncherVersionTxt.Text = troubleshootingInformation.LauncherVersion;
var verionCmd = await Cli.Wrap(LegendaryLauncher.ClientExecPath)
.WithArguments(new[] { "-V" })
.WithValidation(CommandResultValidation.None)
.ExecuteBufferedAsync();
if (verionCmd.StandardOutput.Contains("version"))
{
troubleshootingInformation.LauncherVersion = Regex.Match(verionCmd.StandardOutput, @"\d+(\.\d+)+").Value;
LauncherVersionTxt.Text = troubleshootingInformation.LauncherVersion;
}
}
else
{
LauncherVersionTxt.Text = ResourceProvider.GetString(LOC.LegendaryLauncherNotInstalled);
}

PlayniteVersionTxt.Text = troubleshootingInformation.PlayniteVersion;
PluginVersionTxt.Text = troubleshootingInformation.PluginVersion;
LauncherBinaryTxt.Text = troubleshootingInformation.LauncherBinary;
if (LauncherBinaryTxt.Text.IsNullOrEmpty())
{
LauncherBinaryTxt.Text = ResourceProvider.GetString(LOC.LegendaryLauncherNotInstalled);
OpenLauncherBinaryBtn.IsEnabled = false;
}
GamesInstallationPathTxt.Text = troubleshootingInformation.GamesInstallationPath;
ReportBugHyp.NavigateUri = new Uri($"https://github.com/hawkeye116477/playnite-legendary-plugin/issues/new?assignees=&labels=bug&projects=&template=bugs.yml&legendaryV={troubleshootingInformation.PluginVersion}&playniteV={troubleshootingInformation.PlayniteVersion}&launcherV={troubleshootingInformation.LauncherVersion}");
}
Expand Down Expand Up @@ -230,6 +247,11 @@ private void SyncGameSavesChk_Click(object sender, RoutedEventArgs e)

private void MigrateEpicBtn_Click(object sender, RoutedEventArgs e)
{
if (!LegendaryLauncher.IsInstalled)
{
playniteAPI.Dialogs.ShowErrorMessage(ResourceProvider.GetString(LOC.LegendaryLauncherNotInstalled));
return;
}
var result = playniteAPI.Dialogs.ShowMessage(ResourceProvider.GetString(LOC.LegendaryMigrationConfirm), ResourceProvider.GetString(LOC.LegendaryMigrateGamesEpic), MessageBoxButton.YesNo, MessageBoxImage.Question);
if (result == MessageBoxResult.No)
{
Expand Down
9 changes: 8 additions & 1 deletion src/LegendaryLibrarySettingsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,14 @@ public RelayCommand<object> LoginCommand
{
get => new RelayCommand<object>(async (a) =>
{
await Login();
if (LegendaryLauncher.IsInstalled)
{
await Login();
}
else
{
PlayniteApi.Dialogs.ShowErrorMessage(ResourceProvider.GetString(LOC.LegendaryLauncherNotInstalled));
}
});
}

Expand Down
4 changes: 2 additions & 2 deletions src/LegendaryTroubleshootingInformation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ public string PluginVersion
return fvi.FileVersion;
}
}
public string LauncherVersion { get; set; }
public string LauncherBinary => LegendaryLauncher.GetExecutablePath(LegendaryLauncher.LauncherPath);
public string LauncherVersion { get; set; } = "";
public string LauncherBinary => LegendaryLauncher.ClientExecPath;
public string GamesInstallationPath => LegendaryLauncher.GamesInstallationPath;
}
}
1 change: 1 addition & 0 deletions src/Localization/en_US.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,5 @@
<sys:String x:Key="LOCLegendaryLogFilesFolder">Log files folder</sys:String>
<sys:String x:Key="LOCLegendaryPathNotExist">The specified path does not exist.</sys:String>
<sys:String x:Key="LOCLegendaryReportBug">Report a bug</sys:String>
<sys:String x:Key="LOCLegendaryLauncherNotInstalled">Legendary Launcher is not installed.</sys:String>
</ResourceDictionary>
4 changes: 4 additions & 0 deletions src/LocalizationKeys.cs
Original file line number Diff line number Diff line change
Expand Up @@ -517,5 +517,9 @@ public static class LOC
/// Report a bug
/// </summary>
public const string LegendaryReportBug = "LOCLegendaryReportBug";
/// <summary>
/// Legendary Launcher is not installed.
/// </summary>
public const string LegendaryLauncherNotInstalled = "LOCLegendaryLauncherNotInstalled";
}
}

0 comments on commit 504851f

Please sign in to comment.