- Fixed appid sorting
This commit is contained in:
pointfeev 2022-03-06 21:43:46 -05:00
parent d8afcac1c3
commit 7c554d02f5
4 changed files with 25 additions and 16 deletions

View file

@ -0,0 +1,19 @@
using System.Collections.Generic;
namespace CreamInstaller.Components;
internal class AppIdComparer : IComparer<string>
{
private static AppIdComparer comparer;
public static AppIdComparer Comparer => comparer ??= new AppIdComparer();
public int Compare(string a, string b) =>
a == "ParadoxLauncher" ? -1
: b == "ParadoxLauncher" ? 1
: !int.TryParse(a, out _) && !int.TryParse(b, out _) ? string.Compare(a, b)
: !int.TryParse(a, out int A) ? 1
: !int.TryParse(b, out int B) ? -1
: A > B ? 1
: A < B ? -1
: 0;
}

View file

@ -5,7 +5,7 @@
<UseWindowsForms>True</UseWindowsForms>
<ApplicationIcon>Resources\ini.ico</ApplicationIcon>
<IncludeAllContentForSelfExtract>true</IncludeAllContentForSelfExtract>
<Version>3.2.0.3</Version>
<Version>3.2.0.4</Version>
<PackageIcon>Resources\ini.ico</PackageIcon>
<PackageIconUrl />
<Description />

View file

@ -3,6 +3,8 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using CreamInstaller.Components;
namespace CreamInstaller;
internal enum DlcType
@ -31,8 +33,8 @@ internal class ProgramSelection
internal bool IsSteam = false;
internal readonly SortedList<string, (DlcType type, string name, string icon)> AllDlc = new();
internal readonly SortedList<string, (DlcType type, string name, string icon)> SelectedDlc = new();
internal readonly SortedList<string, (DlcType type, string name, string icon)> AllDlc = new(AppIdComparer.Comparer);
internal readonly SortedList<string, (DlcType type, string name, string icon)> SelectedDlc = new(AppIdComparer.Comparer);
internal readonly List<Tuple<string, string, SortedList<string, (DlcType type, string name, string icon)>>> ExtraDlc = new(); // for Paradox Launcher
internal bool AreDllsLocked

View file

@ -503,19 +503,7 @@ internal partial class SelectForm : CustomForm
private class TreeNodeSorter : IComparer
{
public int Compare(object a, object b)
{
string aId = (a as TreeNode).Name;
string bId = (b as TreeNode).Name;
return aId == "ParadoxLauncher" ? -1
: bId == "ParadoxLauncher" ? 1
: !int.TryParse(aId, out _) && !int.TryParse(bId, out _) ? string.Compare(aId, bId)
: !int.TryParse(aId, out int A) ? 1
: !int.TryParse(bId, out int B) ? -1
: A > B ? 1
: A < B ? -1
: 0;
}
public int Compare(object a, object b) => AppIdComparer.Comparer.Compare((a as TreeNode).Name, (b as TreeNode).Name);
}
private void ShowProgressBar()