Skip to content

Commit

Permalink
Fixed: Updating Install Location of MS Store/Gamepass Games
Browse files Browse the repository at this point in the history
  • Loading branch information
Sewer56 committed Apr 26, 2024
1 parent 32638a2 commit 0a0facd
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 14 deletions.
19 changes: 19 additions & 0 deletions changelog-template.hbs
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
## Changelog (1.27.4)

[Read and Discuss in a Browser](https://github.com/Reloaded-Project/Reloaded-II/discussions/369).
[Previous Changelog](https://github.com/Reloaded-Project/Reloaded-II/releases/tag/1.27.3).

Originally reported as:
- https://github.com/Reloaded-Project/Reloaded-II/issues/368

When changing the install location of a GamePass (Microsoft Store) game within Reloaded-II, the operation will no longer fail if the file is protected/unreadable due to OS' built in Copy Protection/Sandboxing.

This is useful if:

- You have reinstalled the game.
- You have moved the game to another location.

etc.

Instead, the same logic/steps as will be applied as if the game was added for the first time, including ASI Loader re-deployment (if necessary).

## Changelog (1.27.3)

[Read and Discuss in a Browser](https://github.com/Reloaded-Project/Reloaded-II/discussions/365).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,22 @@ static string GetProductName(string exePath)
}

// Try to auto deploy ASI Loader.
HandleAddedMsStoreBinary(isMsStore, applicationConfigFile, config);

// Write file to disk.
Directory.CreateDirectory(applicationDirectory);
IConfig<ApplicationConfig>.ToPath(config, applicationConfigFile);

// Listen to event for when the new application is discovered.
_newConfig = config;
_configService.Items.CollectionChanged += ApplicationsChanged;

// Set return value
param.ResultCreatedApplication = true;
}

internal static void HandleAddedMsStoreBinary(bool isMsStore, string applicationConfigFile, ApplicationConfig config)
{
if (isMsStore)
{
var deployer = new AsiLoaderDeployer(new PathTuple<ApplicationConfig>(applicationConfigFile, config));
Expand All @@ -105,18 +121,8 @@ static string GetProductName(string exePath)
Actions.DisplayMessagebox.Invoke(Resources.AsiLoaderDialogTitle.Get(), Resources.AsiLoaderGamePassAutoInstallFail.Get());
}
}

// Write file to disk.
config.IsMsStore = isMsStore;
Directory.CreateDirectory(applicationDirectory);
IConfig<ApplicationConfig>.ToPath(config, applicationConfigFile);

// Listen to event for when the new application is discovered.
_newConfig = config;
_configService.Items.CollectionChanged += ApplicationsChanged;

// Set return value
param.ResultCreatedApplication = true;
config.IsMsStore = isMsStore;
}

private void ApplicationsChanged(object? sender, NotifyCollectionChangedEventArgs e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,14 @@ public void SetNewExecutablePath()
if (string.IsNullOrEmpty(result))
return;

var isMsStore = TryUnprotectGamePassGame.TryIt(result);
result = SymlinkResolver.GetFinalPathName(result);
if (!Path.GetFileName(Application.Config.AppLocation).Equals(Path.GetFileName(result), StringComparison.OrdinalIgnoreCase))
Actions.DisplayMessagebox(Resources.AddAppWarningTitle.Get(), Resources.AddAppWarning.Get());

Application.Config.AppLocation = result;
AddApplicationCommand.HandleAddedMsStoreBinary(isMsStore, Application.Path, Application.Config);
Application.Save();
}

/// <summary>
Expand Down Expand Up @@ -163,7 +166,10 @@ private void OnAppLocationChanged(object? sender, PropertyChangedEventArgs e)

private string SelectEXEFile()
{
var dialog = new VistaOpenFileDialog();
// This is a Save dialog because Open dialog checks read privileges,
// and that will not work with read protected MS Store/Gamepass executables.
var dialog = new VistaSaveFileDialog();
dialog.OverwritePrompt = false;
dialog.Title = Resources.AddAppExecutableTitle.Get();
dialog.Filter = $"{Resources.AddAppExecutableFilter.Get()} (*.exe)|*.exe";
dialog.FileName = ApplicationConfig.GetAbsoluteAppLocation(Application);
Expand Down
2 changes: 1 addition & 1 deletion source/Reloaded.Mod.Launcher/Reloaded.Mod.Launcher.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<UseWPF>true</UseWPF>
<AssemblyName>Reloaded-II</AssemblyName>
<RootNamespace>Reloaded.Mod.Launcher</RootNamespace>
<Version>1.27.3</Version>
<Version>1.27.4</Version>
<Copyright>Sewer56 ~ $([System.DateTime]::UtcNow.ToString("s")) | $(Version)</Copyright>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<ApplicationIcon>appicon.ico</ApplicationIcon>
Expand Down
2 changes: 1 addition & 1 deletion source/Reloaded.Mod.Loader/Reloaded.Mod.Loader.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<NoWarn>$(NoWarn);NU1605;NU1701</NoWarn>
<Version>1.27.3</Version>
<Version>1.27.4</Version>
<Platforms>x86;x64</Platforms>
<GenerateDepsJson>false</GenerateDepsJson>
<DebugType>portable</DebugType>
Expand Down

0 comments on commit 0a0facd

Please sign in to comment.