Skip to content

Commit d1d6a59

Browse files
authored
Merge pull request #516 from dreamsyntax/game-path-check-on-add
Enhancement: AddApplication warns for OneDrive and non-ascii paths
2 parents 646efea + 15f542f commit d1d6a59

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

source/Reloaded.Mod.Launcher.Lib/Commands/Application/AddApplicationCommand.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,23 @@ static string GetProductName(string exePath)
6262
try { exePath = SymlinkResolver.GetFinalPathName(exePath); }
6363
catch (Exception e) { Errors.HandleException(e, Resources.ErrorAddApplicationCantReadSymlink.Get()); }
6464

65+
// Warn if OneDrive or NonAsciiChars detected in Game Path
66+
bool hasNonAsciiChars = exePath.Any(c => c > 127);
67+
if (exePath.Contains("OneDrive") || hasNonAsciiChars)
68+
{
69+
var confirmAddAnyway = Actions.DisplayMessagebox.Invoke(Resources.ProblematicPathTitle.Get(), Resources.ProblematicPathAppDescription.Get(), new Actions.DisplayMessageBoxParams()
70+
{
71+
StartupLocation = Actions.WindowStartupLocation.CenterScreen,
72+
Type = Actions.MessageBoxType.OkCancel
73+
});
74+
75+
if (!confirmAddAnyway)
76+
{
77+
param.ResultCreatedApplication = false;
78+
return;
79+
}
80+
}
81+
6582
var isMsStore = TryUnprotectGamePassGame.TryIt(exePath);
6683
var appId = ApplicationConfig.AliasAppId(Path.GetFileName(exePath).ToLower());
6784
var config = new ApplicationConfig(appId, GetProductName(exePath), exePath, Path.GetDirectoryName(exePath));

source/Reloaded.Mod.Launcher.Lib/Static/Resources.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,4 +208,8 @@ public static void Init(IDictionaryResourceProvider provider)
208208
// Update 1.28.4: Delete Mod Dialog
209209
public static IDictionaryResource<string> DeleteModDialogTitle { get; set; }
210210
public static IDictionaryResource<string> DeleteModDialogDescription { get; set; }
211+
212+
// Update 1.28.6: Problematic Path Warnings
213+
public static IDictionaryResource<string> ProblematicPathTitle { get; set; }
214+
public static IDictionaryResource<string> ProblematicPathAppDescription { get; set; }
211215
}

source/Reloaded.Mod.Launcher/Assets/Languages/en-GB.xaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -719,5 +719,9 @@ For more info, refer to the tutorial. Don't forget to set correct Publish target
719719
<!-- Update 1.28.4: Delete Mod Dialog -->
720720
<sys:String x:Key="DeleteModDialogTitle">Delete Mod</sys:String>
721721
<sys:String x:Key="DeleteModDialogDescription">{0}&#x0a;will be deleted.</sys:String>
722+
723+
<!-- Update 1.28.6: Problematic Path Warnings -->
724+
<sys:String x:Key="ProblematicPathTitle">Potentially Problematic Path Detected</sys:String>
725+
<sys:String x:Key="ProblematicPathAppDescription">The application you selected is in a folder that is managed by OneDrive or contains non-ASCII (special) 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>
722726

723727
</ResourceDictionary>

0 commit comments

Comments
 (0)