Skip to content

Commit

Permalink
Enhancement: AddApplication warns for OneDrive and non-ascii paths
Browse files Browse the repository at this point in the history
Resolves #503
  • Loading branch information
dreamsyntax committed Dec 11, 2024
1 parent 646efea commit 54ee2d3
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,23 @@ static string GetProductName(string exePath)
try { exePath = SymlinkResolver.GetFinalPathName(exePath); }
catch (Exception e) { Errors.HandleException(e, Resources.ErrorAddApplicationCantReadSymlink.Get()); }

// Warn if OneDrive or NonAsciiChars detected in Game Path
bool hasNonAsciiChars = exePath.Any(c => c > 127);
if (exePath.Contains("OneDrive") || hasNonAsciiChars)
{
var confirmAddAnyway = Actions.DisplayMessagebox.Invoke(Resources.ProblematicPathTitle.Get(), Resources.ProblematicPathAppDescription.Get(), new Actions.DisplayMessageBoxParams()
{
StartupLocation = Actions.WindowStartupLocation.CenterScreen,
Type = Actions.MessageBoxType.OkCancel
});

if (!confirmAddAnyway)
{
param.ResultCreatedApplication = false;
return;
}
}

var isMsStore = TryUnprotectGamePassGame.TryIt(exePath);
var appId = ApplicationConfig.AliasAppId(Path.GetFileName(exePath).ToLower());
var config = new ApplicationConfig(appId, GetProductName(exePath), exePath, Path.GetDirectoryName(exePath));
Expand Down
4 changes: 4 additions & 0 deletions source/Reloaded.Mod.Launcher.Lib/Static/Resources.cs
Original file line number Diff line number Diff line change
Expand Up @@ -208,4 +208,8 @@ public static void Init(IDictionaryResourceProvider provider)
// Update 1.28.4: Delete Mod Dialog
public static IDictionaryResource<string> DeleteModDialogTitle { get; set; }
public static IDictionaryResource<string> DeleteModDialogDescription { get; set; }

// Update 1.28.6: Problematic Path Warnings
public static IDictionaryResource<string> ProblematicPathTitle { get; set; }
public static IDictionaryResource<string> ProblematicPathAppDescription { get; set; }
}
4 changes: 4 additions & 0 deletions source/Reloaded.Mod.Launcher/Assets/Languages/en-GB.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -719,5 +719,9 @@ For more info, refer to the tutorial. Don't forget to set correct Publish target
<!-- Update 1.28.4: Delete Mod Dialog -->
<sys:String x:Key="DeleteModDialogTitle">Delete Mod</sys:String>
<sys:String x:Key="DeleteModDialogDescription">{0}&#x0a;will be deleted.</sys:String>

<!-- Update 1.28.6: Problematic Path Warnings -->
<sys:String x:Key="ProblematicPathTitle">Potentially Problematic Path Detected</sys:String>
<sys:String x:Key="ProblematicPathAppDescription">The application you selected is in a folder that is managed by OneDrive or contains non-ASCII characters.&#x0a;It is recommended to move the application to a different path, such as "C:\Games\".&#x0a;Using the application in an unsupported path may result in mods not working.&#x0a;&#x0a;Press OK to add the application anyway.</sys:String>

</ResourceDictionary>

0 comments on commit 54ee2d3

Please sign in to comment.