From f8f01b9eef8f351138dd209dad91796563cddd02 Mon Sep 17 00:00:00 2001 From: LaughingLeader Date: Fri, 1 Sep 2023 17:30:05 -0500 Subject: [PATCH] Include override mods when resizing name column --- GUI/Views/HorizontalModLayout.xaml.cs | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/GUI/Views/HorizontalModLayout.xaml.cs b/GUI/Views/HorizontalModLayout.xaml.cs index bbd151ce..d74d1049 100644 --- a/GUI/Views/HorizontalModLayout.xaml.cs +++ b/GUI/Views/HorizontalModLayout.xaml.cs @@ -768,17 +768,27 @@ private void Sort(string sortBy, ListSortDirection direction, object sender) public void AutoSizeNameColumn_ActiveMods() { if (ViewModel == null || ActiveModsListView.UserResizedColumns) return; - if (ViewModel.ActiveMods.Count > 0 && ActiveModsListView.View is GridView gridView && gridView.Columns.Count >= 2) + var count = Math.Max(ViewModel.ActiveMods.Count, ViewModel.ForceLoadedMods.Count); + if (count > 0 && ActiveModsListView.View is GridView gridView && gridView.Columns.Count >= 2) { RxApp.MainThreadScheduler.Schedule(TimeSpan.FromMilliseconds(250), () => { - if (ViewModel.ActiveMods.Count > 0) + count = Math.Max(ViewModel.ActiveMods.Count, ViewModel.ForceLoadedMods.Count); + if (count > 0) { - var longestName = ViewModel.ActiveMods.OrderByDescending(m => m.Name.Length).FirstOrDefault()?.Name; - if (!String.IsNullOrEmpty(longestName)) + var longestName = ViewModel.ActiveMods.OrderByDescending(m => m.Name.Length).FirstOrDefault()?.Name ?? ""; + var longestOverrideName = ViewModel.ForceLoadedMods.OrderByDescending(m => m.Name.Length).FirstOrDefault()?.Name ?? ""; + + var sortName = longestName; + if(!String.IsNullOrEmpty(longestOverrideName) && longestOverrideName.Length > longestName.Length) + { + sortName = longestOverrideName; + } + + if (!String.IsNullOrEmpty(sortName)) { //DivinityApp.LogMessage($"Autosizing active mods grid for name {longestName}"); - var targetWidth = MeasureText(ActiveModsListView, longestName, + var targetWidth = MeasureText(ActiveModsListView, sortName, ActiveModsListView.FontFamily, ActiveModsListView.FontStyle, ActiveModsListView.FontWeight,