Skip to content

Commit

Permalink
Make CustomFontFiles a HashSet + Sort CustomFontFiles
Browse files Browse the repository at this point in the history
  • Loading branch information
cooolbros committed Dec 30, 2023
1 parent 8e58dd5 commit a56d209
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/HUDMerger/Models/Scheme/SchemeBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public abstract class SchemeBase : IScheme
private readonly Dictionary<KeyValue, dynamic> Borders = new(KeyValueComparer.KeyComparer);
private readonly Dictionary<KeyValue, HashSet<KeyValue>?> Fonts = new(KeyValueComparer.KeyComparer);

public List<KeyValue> CustomFontFiles { get; } = [];
public HashSet<KeyValue> CustomFontFiles { get; } = [];

private record class SchemeFile
{
Expand Down Expand Up @@ -325,10 +325,23 @@ static KeyValues ConvertSchemeToKeyValues<T>(Dictionary<KeyValue, T> dictionary)

if (CustomFontFiles.Count != 0)
{
List<KeyValue> customFontFilesList = [..CustomFontFiles];
customFontFilesList.Sort((a, b) =>
{
if (int.TryParse(a.Key, out int first) && int.TryParse(b.Key, out int second))
{
return first - second;
}
else
{
return (b.Conditional?.Length ?? 0) - (a.Conditional?.Length ?? 0);
}
});

keyValues.Add(new KeyValue
{
Key = "CustomFontFiles",
Value = CustomFontFiles,
Value = customFontFilesList,
Conditional = null
});
}
Expand Down

0 comments on commit a56d209

Please sign in to comment.