Skip to content

Commit

Permalink
Include override mods when resizing name column
Browse files Browse the repository at this point in the history
  • Loading branch information
LaughingLeader committed Sep 1, 2023
1 parent 92f43cb commit f8f01b9
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions GUI/Views/HorizontalModLayout.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit f8f01b9

Please sign in to comment.