From: Leon Friedrich <60421075+ElectroJr@users.noreply.github.com> Date: Sun, 7 May 2023 03:12:29 +0000 (+1200) Subject: Make guidebook start with some entries collapsed (#16181) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=883d6646ea0bf0801c1c6d71d1ef7fd6f88079dd;p=space-station-14.git Make guidebook start with some entries collapsed (#16181) --- diff --git a/Content.Client/Guidebook/Controls/GuidebookWindow.xaml b/Content.Client/Guidebook/Controls/GuidebookWindow.xaml index b8c4f9e251..1d19a92231 100644 --- a/Content.Client/Guidebook/Controls/GuidebookWindow.xaml +++ b/Content.Client/Guidebook/Controls/GuidebookWindow.xaml @@ -9,7 +9,7 @@ - + diff --git a/Content.Client/UserInterface/Controls/FancyTree/FancyTree.xaml.cs b/Content.Client/UserInterface/Controls/FancyTree/FancyTree.xaml.cs index ae50c74929..1df5864926 100644 --- a/Content.Client/UserInterface/Controls/FancyTree/FancyTree.xaml.cs +++ b/Content.Client/UserInterface/Controls/FancyTree/FancyTree.xaml.cs @@ -176,20 +176,30 @@ public sealed partial class FancyTree : Control OnSelectedItemChanged?.Invoke(newSelection); } - public void SetAllExpanded(bool value) + /// + /// Recursively expands or collapse all entries, optionally up to some depth. + /// + /// Whether to expand or collapse the entries + /// The recursion depth. If negative, implies no limit. Zero will expand only the top-level entries. + public void SetAllExpanded(bool value, int depth = -1) { foreach (var item in Body.Children) { - RecursiveSetExpanded((TreeItem) item, value); + RecursiveSetExpanded((TreeItem) item, value, depth); } } - public void RecursiveSetExpanded(TreeItem item, bool value) + public void RecursiveSetExpanded(TreeItem item, bool value, int depth) { item.SetExpanded(value); + + if (depth == 0) + return; + depth--; + foreach (var child in item.Body.Children) { - RecursiveSetExpanded((TreeItem) child, value); + RecursiveSetExpanded((TreeItem) child, value, depth); } } diff --git a/Content.Client/UserInterface/Systems/Guidebook/GuidebookUIController.cs b/Content.Client/UserInterface/Systems/Guidebook/GuidebookUIController.cs index 66376df317..20e3158f74 100644 --- a/Content.Client/UserInterface/Systems/Guidebook/GuidebookUIController.cs +++ b/Content.Client/UserInterface/Systems/Guidebook/GuidebookUIController.cs @@ -116,7 +116,7 @@ public sealed class GuidebookUIController : UIController, IOnStateEntered - /// Opens the guidebook. + /// Opens or closes the guidebook. /// /// What guides should be shown. If not specified, this will instead list all the entries /// A list of guides that should form the base of the table of contents. If not specified, @@ -162,6 +162,11 @@ public sealed class GuidebookUIController : UIController, IOnStateEntered