diff --git a/WheelWizard/Features/DolphinInstaller/LinuxDolphinInstaller.cs b/WheelWizard/Features/DolphinInstaller/LinuxDolphinInstaller.cs index af2f5725..c2b3a9be 100644 --- a/WheelWizard/Features/DolphinInstaller/LinuxDolphinInstaller.cs +++ b/WheelWizard/Features/DolphinInstaller/LinuxDolphinInstaller.cs @@ -3,6 +3,7 @@ namespace WheelWizard.DolphinInstaller; public interface ILinuxDolphinInstaller { bool IsDolphinInstalledInFlatpak(); + bool IsDolphinInstalledNative(); bool IsFlatpakInstalled(); Task InstallFlatpak(IProgress? progress = null); Task InstallFlatpakDolphin(IProgress? progress = null); @@ -17,6 +18,11 @@ public bool IsDolphinInstalledInFlatpak() return processResult.IsSuccess && processResult.Value == 0; } + public bool IsDolphinInstalledNative() + { + return commandEnvironment.IsCommandAvailable("dolphin-emu"); + } + public bool IsFlatpakInstalled() { return commandEnvironment.IsCommandAvailable("flatpak"); diff --git a/WheelWizard/Services/PathManager.cs b/WheelWizard/Services/PathManager.cs index 1c9dca03..ff6610c9 100644 --- a/WheelWizard/Services/PathManager.cs +++ b/WheelWizard/Services/PathManager.cs @@ -1,4 +1,5 @@ using System.Runtime.InteropServices; +using Serilog; using WheelWizard.Helpers; using WheelWizard.Settings; #if WINDOWS @@ -849,7 +850,9 @@ private static string TryFindPortableUserFolderPath() return null; } - public static string? TryFindUserFolderPath() + public static string? TryFindUserFolderPath() => TryFindUserFolderPath(DolphinFilePath); + + public static string? TryFindUserFolderPath(string dolphinFilePath) { var portableUserFolderPath = TryFindPortableUserFolderPath(); if (!string.IsNullOrWhiteSpace(portableUserFolderPath)) @@ -880,7 +883,7 @@ private static string TryFindPortableUserFolderPath() } else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { - if (IsFlatpakDolphinFilePath()) + if (IsFlatpakDolphinFilePath(dolphinFilePath)) { return TryFindLinuxFlatpakUserFolderPath(); } diff --git a/WheelWizard/Views/Pages/Settings/WhWzSettings.axaml.cs b/WheelWizard/Views/Pages/Settings/WhWzSettings.axaml.cs index 1e7df351..96ef795a 100644 --- a/WheelWizard/Views/Pages/Settings/WhWzSettings.axaml.cs +++ b/WheelWizard/Views/Pages/Settings/WhWzSettings.axaml.cs @@ -148,10 +148,28 @@ private async void DolphinExeBrowse_OnClick(object sender, RoutedEventArgs e) if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { - if (IsFlatpakDolphinInstalled() && DolphinExeInput.Text == "") + // Made this more extensible for future support for e.g. snap + var dolphinPaths = new (Func IsInstalled, string Path)[] { - DolphinExeInput.Text = "flatpak run org.DolphinEmu.dolphin-emu"; - return; + (IsFlatpakDolphinInstalled, "flatpak run org.DolphinEmu.dolphin-emu"), + (IsNativeDolphinInstalled, "dolphin-emu"), + }; + + foreach (var (isInstalled, path) in dolphinPaths) + { + if (isInstalled()) + { + var result = await new YesNoWindow() + .SetMainText(t("question.dolphin_found.title")) + .SetExtraText($"{t("question.dolphin_found.extra")}\n{path}") + .AwaitAnswer(); + + if (result) + { + DolphinExeInput.Text = path; + return; + } + } } if (!EnvHelper.IsFlatpakSandboxed() && !IsFlatpakDolphinInstalled()) @@ -249,6 +267,11 @@ private bool IsFlatpakDolphinInstalled() return LinuxDolphinInstallerService.IsDolphinInstalledInFlatpak(); } + private bool IsNativeDolphinInstalled() + { + return LinuxDolphinInstallerService.IsDolphinInstalledNative(); + } + private async void GameLocationBrowse_OnClick(object sender, RoutedEventArgs e) { var fileType = new FilePickerFileType("Game files") { Patterns = ["*.iso", "*.wbfs", "*.rvz"] }; @@ -262,8 +285,13 @@ private async void GameLocationBrowse_OnClick(object sender, RoutedEventArgs e) private async void DolphinUserPathBrowse_OnClick(object sender, RoutedEventArgs e) { - // Attempt to find Dolphin's default path if no valid folder is set - var folderPath = PathManager.TryFindUserFolderPath(); + // Detect Data folder based on the Dolphin path currently in the input field + // (which may have been edited but not yet saved) + var currentDolphinPath = DolphinExeInput.Text; + var folderPath = string.IsNullOrWhiteSpace(currentDolphinPath) + ? PathManager.TryFindUserFolderPath() + : PathManager.TryFindUserFolderPath(currentDolphinPath); + if (!string.IsNullOrEmpty(folderPath)) { // Ask the user if they want to use the automatically found folder