Skip to content

Commit

Permalink
Merge pull request #518 from dreamsyntax/rii-path-check
Browse files Browse the repository at this point in the history
Enhancement: Warn on R-II path in OneDrive/non-ascii on startup
  • Loading branch information
Sewer56 authored Dec 11, 2024
2 parents d1d6a59 + df2bd58 commit 03dd9e9
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
2 changes: 2 additions & 0 deletions source/Reloaded.Mod.Launcher.Lib/Static/Resources.cs
Original file line number Diff line number Diff line change
Expand Up @@ -212,4 +212,6 @@ public static void Init(IDictionaryResourceProvider provider)
// Update 1.28.6: Problematic Path Warnings
public static IDictionaryResource<string> ProblematicPathTitle { get; set; }
public static IDictionaryResource<string> ProblematicPathAppDescription { get; set; }
public static IDictionaryResource<string> ProblematicPathReloadedDescription { get; set; }
public static IDictionaryResource<string> ProblematicPathModsDescription { get; set; }
}
32 changes: 31 additions & 1 deletion source/Reloaded.Mod.Launcher/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,43 @@ 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 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<LoaderConfig>().GetModConfigDirectory();
if (modsDirectory != null)
{
bool modsDirectoryPathHasNonAsciiChars = modsDirectory.Any(c => c > 127);
if (modsDirectory.Contains("OneDrive") || modsDirectoryPathHasNonAsciiChars)
{
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();
}

private void SetupResources()
{
var launcherFolder= AppContext.BaseDirectory;
var launcherFolder = AppContext.BaseDirectory;
var languageSelector = new XamlFileSelector($"{launcherFolder}\\Assets\\Languages");
var themeSelector = new XamlFileSelector($"{launcherFolder}\\Theme");

Expand Down
2 changes: 2 additions & 0 deletions source/Reloaded.Mod.Launcher/Assets/Languages/en-GB.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -723,5 +723,7 @@ For more info, refer to the tutorial. Don't forget to set correct Publish target
<!-- 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 (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>
<sys:String x:Key="ProblematicPathReloadedDescription">Reloaded-II has detected it is installed in a folder that is managed by OneDrive or contains non-ASCII (special) characters.&#x0a;It is recommended to move your Reloaded-II folder to a different path, such as "C:\Reloaded-II\".&#x0a;Keeping Reloaded-II in an unsupported path may result in mods not working.</sys:String>
<sys:String x:Key="ProblematicPathModsDescription">Reloaded-II has detected your mods folder is managed by OneDrive or contains non-ASCII (special) characters.&#x0a;It is recommended to move your mods folder to a different path.&#x0a;Keeping mods in an unsupported path may result in problems running mods.</sys:String>

</ResourceDictionary>

0 comments on commit 03dd9e9

Please sign in to comment.