From 28672e1ac7159be3dc70e34d9e7dae76bd16dfa4 Mon Sep 17 00:00:00 2001 From: Jesright73 <79653967+Jesright73@users.noreply.github.com> Date: Fri, 3 Mar 2023 17:01:11 -0500 Subject: [PATCH] Ignore casing of profile names when installing/updating mods Windows does not respect casing of folder and file names. This commit works around this by comparing mod profile names as all lowercase when installing and updating mods that are differing in profile name casing. --- AM2RLauncher/AM2RLauncher/MainForm/MainForm.Events.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/AM2RLauncher/AM2RLauncher/MainForm/MainForm.Events.cs b/AM2RLauncher/AM2RLauncher/MainForm/MainForm.Events.cs index 98e5ce3..e1b66bc 100644 --- a/AM2RLauncher/AM2RLauncher/MainForm/MainForm.Events.cs +++ b/AM2RLauncher/AM2RLauncher/MainForm/MainForm.Events.cs @@ -768,7 +768,7 @@ public partial class MainForm : Form } // If mod was installed/added by *name* already, throw error and cleanup - if (profileList.FirstOrDefault(p => p.Name == profile.Name) != null) + if (profileList.FirstOrDefault(p => p.Name.ToLower() == profile.Name.ToLower()) != null) { log.Error(profile.Name + " is already installed."); MessageBox.Show(this, HelperMethods.GetText(Text.ModIsAlreadyInstalledMessage, profile.Name), Text.WarningWindowTitle, MessageBoxType.Warning); @@ -779,7 +779,7 @@ public partial class MainForm : Form // Reload list so mod gets recognized LoadProfilesAndAdjustLists(); // Adjust profileIndex to point to newly added mod. if its not found for whatever reason, we default to first community updates - modSettingsProfileDropDown.SelectedIndex = profileList.IndexOf(profileList.FirstOrDefault(p => p.Name == profile.Name)); + modSettingsProfileDropDown.SelectedIndex = profileList.IndexOf(profileList.FirstOrDefault(p => p.Name.ToLower() == profile.Name.ToLower())); if (modSettingsProfileDropDown.SelectedIndex == -1) modSettingsProfileDropDown.SelectedIndex = 0; @@ -1029,7 +1029,7 @@ public partial class MainForm : Form ProfileXML profile = Serializer.Deserialize(File.ReadAllText(extractedModDir + "/profile.xml")); // If the selected mod is not installed, tell user that they should add it and cleanup - if (profileList.FirstOrDefault(p => p.Name == profile.Name) == null) + if (profileList.FirstOrDefault(p => p.Name.ToLower() == profile.Name.ToLower()) == null) { log.Error("Mod is not installed! Cancelling mod update."); MessageBox.Show(this, HelperMethods.GetText(Text.UpdateModButtonWrongMod, currentProfile.Name).Replace("$SELECT", profile.Name), @@ -1067,7 +1067,7 @@ public partial class MainForm : Form // Adjust our lists so it gets recognized LoadProfilesAndAdjustLists(); - modSettingsProfileDropDown.SelectedIndex = profileList.IndexOf(profileList.FirstOrDefault(p => p.Name == currentProfile.Name)); + modSettingsProfileDropDown.SelectedIndex = profileList.IndexOf(profileList.FirstOrDefault(p => p.Name.ToLower() == currentProfile.Name.ToLower())); if (modSettingsProfileDropDown.SelectedIndex == -1) modSettingsProfileDropDown.SelectedIndex = 0;