Skip to content

Commit

Permalink
Show troubleshooting link if Legendary isn't installed
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkeye116477 committed Nov 6, 2024
1 parent cff7c5d commit 10ec784
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 14 deletions.
9 changes: 6 additions & 3 deletions src/LegendaryGameController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ public static void LaunchInstaller(List<DownloadManagerData.Download> installDat
var playniteAPI = API.Instance;
if (!LegendaryLauncher.IsInstalled)
{
throw new Exception(ResourceProvider.GetString(LOC.LegendaryLauncherNotInstalled));
LegendaryLauncher.ShowNotInstalledError();
return;
}

Window window = null;
Expand Down Expand Up @@ -103,7 +104,8 @@ public static void LaunchUninstaller(List<Game> games)
{
if (!LegendaryLauncher.IsInstalled)
{
throw new Exception(ResourceProvider.GetString(LOC.LegendaryLauncherNotInstalled));
LegendaryLauncher.ShowNotInstalledError();
return;
}
var playniteAPI = API.Instance;
string gamesCombined = string.Join(", ", games.Select(item => item.Name));
Expand Down Expand Up @@ -224,7 +226,8 @@ public override async void Play(PlayActionArgs args)
InvokeOnStopped(new GameStoppedEventArgs());
if (!LegendaryLauncher.IsInstalled)
{
playniteAPI.Dialogs.ShowErrorMessage(ResourceProvider.GetString(LOC.LegendaryLauncherNotInstalled));
LegendaryLauncher.ShowNotInstalledError();
return;
}
}
}
Expand Down
18 changes: 17 additions & 1 deletion src/LegendaryLauncher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using System.Reflection;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows;

namespace LegendaryLibraryNS
{
Expand Down Expand Up @@ -654,7 +655,8 @@ public static async Task<LauncherVersion> GetVersionInfoContent()
var logger = LogManager.GetLogger();
if (!IsInstalled)
{
throw new Exception(ResourceProvider.GetString(LOC.LegendaryLauncherNotInstalled));
ShowNotInstalledError();
return newVersionInfoContent;
}
var cacheVersionPath = LegendaryLibrary.Instance.GetCachePath("infocache");
if (!Directory.Exists(cacheVersionPath))
Expand Down Expand Up @@ -759,5 +761,19 @@ public static void ClearCache()
}
}

public static void ShowNotInstalledError()
{
var playniteAPI = API.Instance;
var options = new List<MessageBoxOption>
{
new MessageBoxOption(ResourceProvider.GetString(LOC.Legendary3P_PlayniteInstallGame)),
new MessageBoxOption(ResourceProvider.GetString(LOC.Legendary3P_PlayniteOKLabel)),
};
var result = playniteAPI.Dialogs.ShowMessage(ResourceProvider.GetString(LOC.LegendaryLauncherNotInstalled), "Legendary (Epic Games) library integration", MessageBoxImage.Information, options);
if (result == options[0])
{
Playnite.Commands.GlobalCommands.NavigateUrl("https://github.com/hawkeye116477/playnite-legendary-plugin/wiki/Troubleshooting#legendary-launcher-is-not-installed");
}
}
}
}
20 changes: 13 additions & 7 deletions src/LegendaryLibrary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,8 @@ public override IEnumerable<GameMenuItem> GetGameMenuItems(GetGameMenuItemsArgs
{
if (!LegendaryLauncher.IsInstalled)
{
throw new Exception(ResourceProvider.GetString(LOC.LegendaryLauncherNotInstalled));
LegendaryLauncher.ShowNotInstalledError();
return;
}
Window window = PlayniteApi.Dialogs.CreateWindow(new WindowCreationOptions
{
Expand All @@ -644,7 +645,8 @@ public override IEnumerable<GameMenuItem> GetGameMenuItems(GetGameMenuItemsArgs
{
if (!LegendaryLauncher.IsInstalled)
{
throw new Exception(ResourceProvider.GetString(LOC.LegendaryLauncherNotInstalled));
LegendaryLauncher.ShowNotInstalledError();
return;
}

LegendaryUpdateController legendaryUpdateController = new LegendaryUpdateController();
Expand Down Expand Up @@ -694,7 +696,8 @@ public override IEnumerable<GameMenuItem> GetGameMenuItems(GetGameMenuItemsArgs
{
if (!LegendaryLauncher.IsInstalled)
{
throw new Exception(ResourceProvider.GetString(LOC.LegendaryLauncherNotInstalled));
LegendaryLauncher.ShowNotInstalledError();
return;
}

var path = PlayniteApi.Dialogs.SelectFolder();
Expand Down Expand Up @@ -746,7 +749,8 @@ public override IEnumerable<GameMenuItem> GetGameMenuItems(GetGameMenuItemsArgs
{
if (!LegendaryLauncher.IsInstalled)
{
throw new Exception(ResourceProvider.GetString(LOC.LegendaryLauncherNotInstalled));
LegendaryLauncher.ShowNotInstalledError();
return;
}

Window window = PlayniteApi.Dialogs.CreateWindow(new WindowCreationOptions
Expand All @@ -773,7 +777,8 @@ public override IEnumerable<GameMenuItem> GetGameMenuItems(GetGameMenuItemsArgs
{
if (!LegendaryLauncher.IsInstalled)
{
throw new Exception(ResourceProvider.GetString(LOC.LegendaryLauncherNotInstalled));
LegendaryLauncher.ShowNotInstalledError();
return;
}

var newPath = PlayniteApi.Dialogs.SelectFolder();
Expand Down Expand Up @@ -876,7 +881,8 @@ public override IEnumerable<GameMenuItem> GetGameMenuItems(GetGameMenuItemsArgs
{
if (!LegendaryLauncher.IsInstalled)
{
throw new Exception(ResourceProvider.GetString(LOC.LegendaryLauncherNotInstalled));
LegendaryLauncher.ShowNotInstalledError();
return;
}

Window window = PlayniteApi.Dialogs.CreateWindow(new WindowCreationOptions
Expand Down Expand Up @@ -932,7 +938,7 @@ public override IEnumerable<MainMenuItem> GetMainMenuItems(GetMainMenuItemsArgs
{
if (!LegendaryLauncher.IsInstalled)
{
PlayniteApi.Dialogs.ShowErrorMessage(ResourceProvider.GetString(LOC.LegendaryLauncherNotInstalled));
LegendaryLauncher.ShowNotInstalledError();
return;
}

Expand Down
6 changes: 3 additions & 3 deletions src/LegendaryLibrarySettingsView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ private void EOSOInstallBtn_Click(object sender, RoutedEventArgs e)
{
if (!LegendaryLauncher.IsInstalled)
{
playniteAPI.Dialogs.ShowErrorMessage(ResourceProvider.GetString(LOC.LegendaryLauncherNotInstalled));
LegendaryLauncher.ShowNotInstalledError();
return;
}
var window = playniteAPI.Dialogs.CreateWindow(new WindowCreationOptions
Expand Down Expand Up @@ -257,7 +257,7 @@ private void MigrateEpicBtn_Click(object sender, RoutedEventArgs e)
{
if (!LegendaryLauncher.IsInstalled)
{
playniteAPI.Dialogs.ShowErrorMessage(ResourceProvider.GetString(LOC.LegendaryLauncherNotInstalled));
LegendaryLauncher.ShowNotInstalledError();
return;
}
var result = playniteAPI.Dialogs.ShowMessage(ResourceProvider.GetString(LOC.LegendaryMigrationConfirm), ResourceProvider.GetString(LOC.LegendaryMigrateGamesEpic), MessageBoxButton.YesNo, MessageBoxImage.Question);
Expand Down Expand Up @@ -469,7 +469,7 @@ private async void ActivateUbisoftBtn_Click(object sender, RoutedEventArgs e)
{
if (!LegendaryLauncher.IsInstalled)
{
playniteAPI.Dialogs.ShowErrorMessage(ResourceProvider.GetString(LOC.LegendaryLauncherNotInstalled));
LegendaryLauncher.ShowNotInstalledError();
return;
}
var result = playniteAPI.Dialogs.ShowMessage(ResourceProvider.GetString(LOC.LegendaryContinueActivation).Format("Ubisoft"), "", MessageBoxButton.YesNo);
Expand Down

0 comments on commit 10ec784

Please sign in to comment.