From b403d98f362a9af1841332d10c9e136a880e4135 Mon Sep 17 00:00:00 2001 From: dreamsyntax Date: Wed, 11 Dec 2024 15:26:30 -0700 Subject: [PATCH 1/2] Enhancement: warn on R-II path in OneDrive/non-ascii on startup Resolves https://github.com/Reloaded-Project/Reloaded-II/issues/502 --- .../Reloaded.Mod.Launcher.Lib/Static/Resources.cs | 1 + source/Reloaded.Mod.Launcher/App.xaml.cs | 15 ++++++++++++++- .../Assets/Languages/en-GB.xaml | 1 + 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/source/Reloaded.Mod.Launcher.Lib/Static/Resources.cs b/source/Reloaded.Mod.Launcher.Lib/Static/Resources.cs index 9bf81232..6b112807 100644 --- a/source/Reloaded.Mod.Launcher.Lib/Static/Resources.cs +++ b/source/Reloaded.Mod.Launcher.Lib/Static/Resources.cs @@ -212,4 +212,5 @@ public static void Init(IDictionaryResourceProvider provider) // Update 1.28.6: Problematic Path Warnings public static IDictionaryResource ProblematicPathTitle { get; set; } public static IDictionaryResource ProblematicPathAppDescription { get; set; } + public static IDictionaryResource ProblematicPathReloadedDescription { get; set; } } \ No newline at end of file diff --git a/source/Reloaded.Mod.Launcher/App.xaml.cs b/source/Reloaded.Mod.Launcher/App.xaml.cs index c7062ed5..2bec402c 100644 --- a/source/Reloaded.Mod.Launcher/App.xaml.cs +++ b/source/Reloaded.Mod.Launcher/App.xaml.cs @@ -39,13 +39,26 @@ private void OnStartup(object sender, StartupEventArgs e) StartProfileOptimization(); PrepareWebRequests(); + // Need to construct MainWindow before invoking any dialog, otherwise Shutdown will be called on closing the dialog var window = new MainWindow(); + + // Warn if OneDrive or NonAsciiChars detected in Reloaded-II directory + bool hasNonAsciiChars = AppContext.BaseDirectory.Any(c => c > 127); + if (AppContext.BaseDirectory.Contains("OneDrive") || hasNonAsciiChars) + { + Actions.DisplayMessagebox.Invoke(Lib.Static.Resources.ProblematicPathTitle.Get(), Lib.Static.Resources.ProblematicPathReloadedDescription.Get(), new Actions.DisplayMessageBoxParams() + { + StartupLocation = Actions.WindowStartupLocation.CenterScreen, + Type = Actions.MessageBoxType.Ok + }); + } + window.ShowDialog(); } private void SetupResources() { - var launcherFolder= AppContext.BaseDirectory; + var launcherFolder = AppContext.BaseDirectory; var languageSelector = new XamlFileSelector($"{launcherFolder}\\Assets\\Languages"); var themeSelector = new XamlFileSelector($"{launcherFolder}\\Theme"); diff --git a/source/Reloaded.Mod.Launcher/Assets/Languages/en-GB.xaml b/source/Reloaded.Mod.Launcher/Assets/Languages/en-GB.xaml index 9ce97518..1f388d95 100644 --- a/source/Reloaded.Mod.Launcher/Assets/Languages/en-GB.xaml +++ b/source/Reloaded.Mod.Launcher/Assets/Languages/en-GB.xaml @@ -723,5 +723,6 @@ For more info, refer to the tutorial. Don't forget to set correct Publish target Potentially Problematic Path Detected The application you selected is in a folder that is managed by OneDrive or contains non-ASCII (special) characters. It is recommended to move the application to a different path, such as "C:\Games\". Using the application in an unsupported path may result in mods not working. Press OK to add the application anyway. + Reloaded-II has detected it is installed in a folder that is managed by OneDrive or contains non-ASCII (special) characters. It is recommended to move your Reloaded-II folder to a different path, such as "C:\Reloaded-II\". Keeping Reloaded-II in an unsupported path may result in mods not working. \ No newline at end of file From df2bd58714ed7f5f23287f84aa31ba559f967493 Mon Sep 17 00:00:00 2001 From: dreamsyntax Date: Wed, 11 Dec 2024 16:36:25 -0700 Subject: [PATCH 2/2] Improved: Check Mods folder for OneDrive & specialchars --- .../Static/Resources.cs | 1 + source/Reloaded.Mod.Launcher/App.xaml.cs | 27 +++++++++++++++---- .../Assets/Languages/en-GB.xaml | 1 + 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/source/Reloaded.Mod.Launcher.Lib/Static/Resources.cs b/source/Reloaded.Mod.Launcher.Lib/Static/Resources.cs index 6b112807..fb849863 100644 --- a/source/Reloaded.Mod.Launcher.Lib/Static/Resources.cs +++ b/source/Reloaded.Mod.Launcher.Lib/Static/Resources.cs @@ -213,4 +213,5 @@ public static void Init(IDictionaryResourceProvider provider) public static IDictionaryResource ProblematicPathTitle { get; set; } public static IDictionaryResource ProblematicPathAppDescription { get; set; } public static IDictionaryResource ProblematicPathReloadedDescription { get; set; } + public static IDictionaryResource ProblematicPathModsDescription { get; set; } } \ No newline at end of file diff --git a/source/Reloaded.Mod.Launcher/App.xaml.cs b/source/Reloaded.Mod.Launcher/App.xaml.cs index 2bec402c..3478489d 100644 --- a/source/Reloaded.Mod.Launcher/App.xaml.cs +++ b/source/Reloaded.Mod.Launcher/App.xaml.cs @@ -43,14 +43,31 @@ private void OnStartup(object sender, StartupEventArgs e) var window = new MainWindow(); // Warn if OneDrive or NonAsciiChars detected in Reloaded-II directory - bool hasNonAsciiChars = AppContext.BaseDirectory.Any(c => c > 127); - if (AppContext.BaseDirectory.Contains("OneDrive") || hasNonAsciiChars) + bool reloadedPathHasNonAsciiChars = AppContext.BaseDirectory.Any(c => c > 127); + if (AppContext.BaseDirectory.Contains("OneDrive") || reloadedPathHasNonAsciiChars) { Actions.DisplayMessagebox.Invoke(Lib.Static.Resources.ProblematicPathTitle.Get(), Lib.Static.Resources.ProblematicPathReloadedDescription.Get(), new Actions.DisplayMessageBoxParams() + { + StartupLocation = Actions.WindowStartupLocation.CenterScreen, + Type = Actions.MessageBoxType.Ok + }); + } + else // We only do this check if the Reloaded-II directory check passed + { + // Warn if OneDrive or NonAsciiChars detected in Mods directory + var modsDirectory = Lib.IoC.Get().GetModConfigDirectory(); + if (modsDirectory != null) + { + bool modsDirectoryPathHasNonAsciiChars = modsDirectory.Any(c => c > 127); + if (modsDirectory.Contains("OneDrive") || modsDirectoryPathHasNonAsciiChars) { - StartupLocation = Actions.WindowStartupLocation.CenterScreen, - Type = Actions.MessageBoxType.Ok - }); + Actions.DisplayMessagebox.Invoke(Lib.Static.Resources.ProblematicPathTitle.Get(), Lib.Static.Resources.ProblematicPathModsDescription.Get(), new Actions.DisplayMessageBoxParams() + { + StartupLocation = Actions.WindowStartupLocation.CenterScreen, + Type = Actions.MessageBoxType.Ok + }); + } + } } window.ShowDialog(); diff --git a/source/Reloaded.Mod.Launcher/Assets/Languages/en-GB.xaml b/source/Reloaded.Mod.Launcher/Assets/Languages/en-GB.xaml index 1f388d95..d2dc9542 100644 --- a/source/Reloaded.Mod.Launcher/Assets/Languages/en-GB.xaml +++ b/source/Reloaded.Mod.Launcher/Assets/Languages/en-GB.xaml @@ -724,5 +724,6 @@ For more info, refer to the tutorial. Don't forget to set correct Publish target Potentially Problematic Path Detected The application you selected is in a folder that is managed by OneDrive or contains non-ASCII (special) characters. It is recommended to move the application to a different path, such as "C:\Games\". Using the application in an unsupported path may result in mods not working. Press OK to add the application anyway. Reloaded-II has detected it is installed in a folder that is managed by OneDrive or contains non-ASCII (special) characters. It is recommended to move your Reloaded-II folder to a different path, such as "C:\Reloaded-II\". Keeping Reloaded-II in an unsupported path may result in mods not working. + Reloaded-II has detected your mods folder is managed by OneDrive or contains non-ASCII (special) characters. It is recommended to move your mods folder to a different path. Keeping mods in an unsupported path may result in problems running mods. \ No newline at end of file