diff --git a/Content.Client/Guidebook/Controls/GuidebookWindow.xaml.cs b/Content.Client/Guidebook/Controls/GuidebookWindow.xaml.cs index 113c192beb..4776386c1d 100644 --- a/Content.Client/Guidebook/Controls/GuidebookWindow.xaml.cs +++ b/Content.Client/Guidebook/Controls/GuidebookWindow.xaml.cs @@ -98,22 +98,33 @@ public sealed partial class GuidebookWindow : FancyWindow, ILinkClickHandler } } - private IEnumerable GetSortedRootEntries(List? rootEntries) + private IEnumerable GetSortedEntries(List? rootEntries) { if (rootEntries == null) { HashSet entries = new(_entries.Keys); foreach (var entry in _entries.Values) { + if (entry.Children.Count > 0) + { + var sortedChildren = entry.Children + .Select(childId => _entries[childId]) + .OrderBy(childEntry => childEntry.Priority) + .ThenBy(childEntry => Loc.GetString(childEntry.Name)) + .Select(childEntry => childEntry.Id) + .ToList(); + + entry.Children = sortedChildren; + } entries.ExceptWith(entry.Children); } rootEntries = entries.ToList(); } return rootEntries - .Select(x => _entries[x]) - .OrderBy(x => x.Priority) - .ThenBy(x => Loc.GetString(x.Name)); + .Select(rootEntryId => _entries[rootEntryId]) + .OrderBy(rootEntry => rootEntry.Priority) + .ThenBy(rootEntry => Loc.GetString(rootEntry.Name)); } private void RepopulateTree(List? roots = null, string? forcedRoot = null) @@ -123,7 +134,7 @@ public sealed partial class GuidebookWindow : FancyWindow, ILinkClickHandler HashSet addedEntries = new(); TreeItem? parent = forcedRoot == null ? null : AddEntry(forcedRoot, null, addedEntries); - foreach (var entry in GetSortedRootEntries(roots)) + foreach (var entry in GetSortedEntries(roots)) { AddEntry(entry.Id, parent, addedEntries); }