Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ namespace WheelWizard.DolphinInstaller;
public interface ILinuxDolphinInstaller
{
bool IsDolphinInstalledInFlatpak();
bool IsDolphinInstalledNative();
bool IsFlatpakInstalled();
Task<OperationResult> InstallFlatpak(IProgress<int>? progress = null);
Task<OperationResult> InstallFlatpakDolphin(IProgress<int>? progress = null);
Expand All @@ -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");
Expand Down
7 changes: 5 additions & 2 deletions WheelWizard/Services/PathManager.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Runtime.InteropServices;
using Serilog;
using WheelWizard.Helpers;
using WheelWizard.Settings;
#if WINDOWS
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -880,7 +883,7 @@ private static string TryFindPortableUserFolderPath()
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
if (IsFlatpakDolphinFilePath())
if (IsFlatpakDolphinFilePath(dolphinFilePath))
{
return TryFindLinuxFlatpakUserFolderPath();
}
Expand Down
38 changes: 33 additions & 5 deletions WheelWizard/Views/Pages/Settings/WhWzSettings.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<bool> 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())
Expand Down Expand Up @@ -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"] };
Expand All @@ -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
Expand Down
Loading