Make guidebook start with some entries collapsed (#16181)
This commit is contained in:
@@ -9,7 +9,7 @@
|
|||||||
<SplitContainer Orientation="Horizontal" HorizontalExpand="True" Name="Split">
|
<SplitContainer Orientation="Horizontal" HorizontalExpand="True" Name="Split">
|
||||||
<!-- Guide select -->
|
<!-- Guide select -->
|
||||||
<BoxContainer Orientation="Horizontal" Name="TreeBox">
|
<BoxContainer Orientation="Horizontal" Name="TreeBox">
|
||||||
<fancyTree:FancyTree Name="Tree" VerticalExpand="True" HorizontalExpand="True"/>
|
<fancyTree:FancyTree Name="Tree" VerticalExpand="True" HorizontalExpand="True" Access="Public"/>
|
||||||
<cc:VSeparator StyleClasses="LowDivider" Margin="0 -2"/>
|
<cc:VSeparator StyleClasses="LowDivider" Margin="0 -2"/>
|
||||||
</BoxContainer>
|
</BoxContainer>
|
||||||
<ScrollContainer Name="Scroll" HScrollEnabled="False" HorizontalExpand="True" VerticalExpand="True">
|
<ScrollContainer Name="Scroll" HScrollEnabled="False" HorizontalExpand="True" VerticalExpand="True">
|
||||||
|
|||||||
@@ -176,20 +176,30 @@ public sealed partial class FancyTree : Control
|
|||||||
OnSelectedItemChanged?.Invoke(newSelection);
|
OnSelectedItemChanged?.Invoke(newSelection);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetAllExpanded(bool value)
|
/// <summary>
|
||||||
|
/// Recursively expands or collapse all entries, optionally up to some depth.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="value">Whether to expand or collapse the entries</param>
|
||||||
|
/// <param name="depth">The recursion depth. If negative, implies no limit. Zero will expand only the top-level entries.</param>
|
||||||
|
public void SetAllExpanded(bool value, int depth = -1)
|
||||||
{
|
{
|
||||||
foreach (var item in Body.Children)
|
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);
|
item.SetExpanded(value);
|
||||||
|
|
||||||
|
if (depth == 0)
|
||||||
|
return;
|
||||||
|
depth--;
|
||||||
|
|
||||||
foreach (var child in item.Body.Children)
|
foreach (var child in item.Body.Children)
|
||||||
{
|
{
|
||||||
RecursiveSetExpanded((TreeItem) child, value);
|
RecursiveSetExpanded((TreeItem) child, value, depth);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ public sealed class GuidebookUIController : UIController, IOnStateEntered<LobbyS
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Opens the guidebook.
|
/// Opens or closes the guidebook.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="guides">What guides should be shown. If not specified, this will instead list all the entries</param>
|
/// <param name="guides">What guides should be shown. If not specified, this will instead list all the entries</param>
|
||||||
/// <param name="rootEntries">A list of guides that should form the base of the table of contents. If not specified,
|
/// <param name="rootEntries">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<LobbyS
|
|||||||
}
|
}
|
||||||
|
|
||||||
_guideWindow.UpdateGuides(guides, rootEntries, forceRoot, selected);
|
_guideWindow.UpdateGuides(guides, rootEntries, forceRoot, selected);
|
||||||
|
|
||||||
|
// Expand up to depth-2.
|
||||||
|
_guideWindow.Tree.SetAllExpanded(false);
|
||||||
|
_guideWindow.Tree.SetAllExpanded(true, 1);
|
||||||
|
|
||||||
_guideWindow.OpenCenteredRight();
|
_guideWindow.OpenCenteredRight();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user