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 @@ -59,7 +59,7 @@ public void SandboxedWheelWizard_DetectsForkFromUserDirectory_AndUsesBundledComm
"/home/player/.var/app/org.example.DolphinFork/data/dolphin-emu"
);

Assert.Equal("/app/bin/dolphin-emu-wrapper", paths.DolphinFilePath);
Assert.Equal("/app/extensions/backends/dolphin-emu/bin/dolphin-emu-wrapper", paths.DolphinFilePath);
Assert.Equal("/home/player/.var/app/org.example.DolphinFork/config/dolphin-emu", paths.ConfigFolderPath);
Assert.Contains(
"/home/player/.var/app/org.example.WheelWizard/data-dolphin-emu/dolphin-emu",
Expand Down
51 changes: 51 additions & 0 deletions WheelWizard.Test/Shared/Platform/EnvironmentDependencyTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,57 @@ public void SandboxDetection_RequiresLinuxMarkerAndAppId(bool linux, bool marker
Assert.Equal(expected, environment.IsFlatpakSandboxed(fs));
}

[Theory]
[InlineData(true, true, "io.example.App", false, true, false, true)]
[InlineData(true, false, "io.example.App", false, false, false, false)]
[InlineData(false, true, "io.example.App", false, false, false, false)]
[InlineData(false, false, "io.example.App", false, false, false, false)]
[InlineData(true, true, "io.example.App", true, false, false, true)]
[InlineData(true, false, "io.example.App", true, false, false, false)]
[InlineData(false, true, "io.example.App", true, false, false, false)]
[InlineData(false, false, "io.example.App", true, false, false, false)]
[InlineData(true, true, "io.example.App", false, true, true, false)]
[InlineData(true, false, "io.example.App", false, false, true, false)]
[InlineData(false, true, "io.example.App", false, false, true, false)]
[InlineData(false, false, "io.example.App", false, false, true, false)]
[InlineData(true, true, "io.example.App", true, false, true, false)]
[InlineData(true, false, "io.example.App", true, false, true, false)]
[InlineData(false, true, "io.example.App", true, false, true, false)]
[InlineData(false, false, "io.example.App", true, false, true, false)]
public void SandboxExtensions_RequiresDetectedSandboxAndSpecificRequiredExtensionProgram(
bool linux,
bool marker,
string appId,
bool hasDolphinExtensionFile,
bool expectsMissingDolphinExtension,
bool hasRecompExtensionFile,
bool expectsMissingRecompExtension
)
{
// Flatpak environment setup
var fs = new MockFileSystem(options => options.SimulatingOperatingSystem(SimulationMode.Linux));
if (marker)
fs.File.WriteAllText("/.flatpak-info", "sandbox");
var environment = Substitute.For<IRuntimeEnvironment>();
environment.IsLinux.Returns(linux);
environment.GetEnvironmentVariable("FLATPAK_ID").Returns(appId);

if (hasDolphinExtensionFile)
{
fs.Directory.CreateDirectory("/app/extensions/backends/dolphin-emu/bin/");
fs.File.WriteAllText("/app/extensions/backends/dolphin-emu/bin/dolphin-emu-wrapper", "#!/bin/sh\n");
}

if (hasRecompExtensionFile)
{
fs.Directory.CreateDirectory("/app/extensions/backends/wiicompiled/bin/");
fs.File.WriteAllText("/app/extensions/backends/wiicompiled/bin/wiicompiled-setup", "#!/bin/sh\n");
}

Assert.Equal(expectsMissingDolphinExtension, environment.IsMissingDolphinFlatpakExtension(fs));
Assert.Equal(expectsMissingRecompExtension, environment.IsMissingRecompFlatpakExtension(fs));
}

[Fact]
public void ShellQuoting_UsesTargetShellRules_ForApostrophesAndMetacharacters()
{
Expand Down
10 changes: 10 additions & 0 deletions WheelWizard/Features/CustomDistributions/RetroRewind.cs
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,16 @@ public async Task<OperationResult> ReinstallAsync(DistributionOperation operatio

public async Task<OperationResult<WheelWizardStatus>> GetCurrentStatusAsync()
{
switch (_settingsManager.CheckExtensionConfiguration())
{
case ExtensionConfigurationInfo.MissingDolphin:
return WheelWizardStatus.NoDolphinExtension;
case ExtensionConfigurationInfo.MissingRecomp:
return WheelWizardStatus.NoRecompExtension;
case ExtensionConfigurationInfo.ExtensionFoundOrNotNeeded:
break;
}

if (!_settingsManager.PathsSetupCorrectly())
return WheelWizardStatus.ConfigNotFinished;

Expand Down
10 changes: 10 additions & 0 deletions WheelWizard/Features/CustomDistributions/RetroRewindBeta.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,16 @@ public async Task<OperationResult> ReinstallAsync(DistributionOperation operatio

public Task<OperationResult<WheelWizardStatus>> GetCurrentStatusAsync()
{
switch (_settingsManager.CheckExtensionConfiguration())
{
case ExtensionConfigurationInfo.MissingDolphin:
return Task.FromResult(Ok(WheelWizardStatus.NoDolphinExtension));
case ExtensionConfigurationInfo.MissingRecomp:
return Task.FromResult(Ok(WheelWizardStatus.NoRecompExtension));
case ExtensionConfigurationInfo.ExtensionFoundOrNotNeeded:
break;
}

if (!_settingsManager.PathsSetupCorrectly())
return Task.FromResult(Ok(WheelWizardStatus.ConfigNotFinished));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ public sealed class DolphinDiscoveryService(
IDolphinRegistrySettings registry
) : IDolphinDiscoveryService
{
public bool IsMissingDolphinFlatpakExtension()
{
return environment.IsMissingDolphinFlatpakExtension(fileSystem);
}

public string? FindUserDirectory(string dolphinLocation, string currentUserDirectory)
{
var layout = paths.Resolve(dolphinLocation, currentUserDirectory);
Expand Down
2 changes: 1 addition & 1 deletion WheelWizard/Features/Dolphin/Paths/DolphinPathLayout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ string userFolderPath
private string HomeFolderPath => environment.GetFolderPath(System.Environment.SpecialFolder.UserProfile);
private string AppDataFolder => environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData);
private string LocalAppDataFolder => environment.GetFolderPath(System.Environment.SpecialFolder.LocalApplicationData);
public string DolphinFilePath => isFlatpakSandboxed ? "/app/bin/dolphin-emu-wrapper" : dolphinLocation;
public string DolphinFilePath => isFlatpakSandboxed ? "/app/extensions/backends/dolphin-emu/bin/dolphin-emu-wrapper" : dolphinLocation;
public string UserFolderPath => userFolderPath;
private string LinuxDolphinLegacyRelSubFolderPath => ".dolphin-emu";
public string LinuxDolphinLegacyFolderPath => Path.Combine(HomeFolderPath, LinuxDolphinLegacyRelSubFolderPath);
Expand Down
10 changes: 10 additions & 0 deletions WheelWizard/Features/Recomp/RecompEnvironment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ public interface IRecompEnvironment
/// <summary>The directory the recomp is installed into.</summary>
string InstallFolderPath { get; }

/// <summary>
/// Indicates whether Wheel Wizard is missing an extension to be able to run
/// the game with the configured settings.
/// </summary>
ExtensionConfigurationInfo GetExtensionConfigurationInfo { get; }

/// <summary>
/// Whether <see cref="InstallFolderPath"/> is the portable location, which is what decides whether
/// a fresh install is asked to lay itself out portably.
Expand Down Expand Up @@ -66,6 +72,8 @@ ICustomDistributionPaths distributionPaths

public string InstallFolderPath => paths.InstallFolderPath;

public ExtensionConfigurationInfo GetExtensionConfigurationInfo => ExtensionConfigurationInfo.ExtensionFoundOrNotNeeded;

public bool IsPortableInstall => paths.IsPortableInstall;

public string CacheFolderPath => paths.CacheFolderPath;
Expand Down Expand Up @@ -109,6 +117,8 @@ ICustomDistributionPaths distributionPaths

public string InstallFolderPath => paths.LinuxBackendFolderPath;

public ExtensionConfigurationInfo GetExtensionConfigurationInfo => settings.CheckExtensionConfiguration();

public bool IsPortableInstall => false;

public string CacheFolderPath => paths.CacheFolderPath;
Expand Down
16 changes: 15 additions & 1 deletion WheelWizard/Features/Recomp/RecompInstallService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,23 @@ ILogger<RecompInstallService> logger

public async Task<WheelWizardStatus> GetCurrentStatusAsync(CancellationToken cancellationToken = default)
{
// This switch statement should be a no-op on non-Linux/Flatpak systems anyway.
switch (environment.GetExtensionConfigurationInfo)
{
// This would mean that Wheel Wizard is configured to use Dolphin
case Settings.ExtensionConfigurationInfo.MissingDolphin:
return WheelWizardStatus.ConfigNotFinished;

case Settings.ExtensionConfigurationInfo.MissingRecomp:
return WheelWizardStatus.NoRecompExtension;

case Settings.ExtensionConfigurationInfo.ExtensionFoundOrNotNeeded:
break;
}

var state = ReadInstalledState();
var hasInstalledHost = fileSystem.File.Exists(environment.InstalledSetupFilePath);
if (hasInstalledHost && !IsCurrentInstallState(state))
if (hasInstalledHost && state != null && !IsCurrentInstallState(state))
return IsGameFileConfigured() ? WheelWizardStatus.OutOfDate : WheelWizardStatus.ConfigNotFinished;

var installedVersion = IsCurrentInstallState(state) ? state!.SetupVersion : null;
Expand Down
11 changes: 10 additions & 1 deletion WheelWizard/Features/Recomp/RecompLauncher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,14 @@ public async Task<WheelWizardStatus> GetCurrentStatus()

switch (retroRewindStatus.Value)
{
// This would mean that Wheel Wizard is configured to use Dolphin instead
case WheelWizardStatus.NoDolphinExtension:
return WheelWizardStatus.ConfigNotFinished;

case WheelWizardStatus.ConfigNotFinished:
case WheelWizardStatus.NotInstalled:
case WheelWizardStatus.OutOfDate:
case WheelWizardStatus.NoRecompExtension:
case WheelWizardStatus.NoServer:
return retroRewindStatus.Value;
}
Expand Down Expand Up @@ -215,12 +220,16 @@ private async Task<OperationResult<bool>> EnsureRetroRewindCurrentAsync(Distribu
return status.Error;

var requiresCommit = status.Value is WheelWizardStatus.NotInstalled or WheelWizardStatus.OutOfDate;
OperationResult result = status.Value switch
var result = status.Value switch
{
WheelWizardStatus.Ready or WheelWizardStatus.NoServerButInstalled => Ok(),
WheelWizardStatus.NotInstalled => await customDistributions.RetroRewind.InstallAsync(operation),
WheelWizardStatus.OutOfDate => await customDistributions.RetroRewind.UpdateAsync(operation),
WheelWizardStatus.ConfigNotFinished => Fail(t("message_warning.not_find_game.extra")),
WheelWizardStatus.NoRecompExtension => Fail(
"Retro Rewind was not checked because the Wiicompiled Flatpak extension is missing"
),
WheelWizardStatus.NoDolphinExtension => Fail("Retro Rewind was not checked because the Dolphin Flatpak extension is missing"),
WheelWizardStatus.NoServer => Fail("Retro Rewind could not be checked or installed because its update service is unavailable."),
_ => Fail("Retro Rewind is not ready for WiiCompiled."),
};
Expand Down
Loading
Loading