diff --git a/Content.Client/Guidebook/Controls/GuidebookControl.xaml b/Content.Client/Guidebook/Controls/GuidebookControl.xaml
new file mode 100644
index 0000000000..110cf4ea85
--- /dev/null
+++ b/Content.Client/Guidebook/Controls/GuidebookControl.xaml
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Content.Client/Guidebook/Controls/GuidebookControl.xaml.cs b/Content.Client/Guidebook/Controls/GuidebookControl.xaml.cs
new file mode 100644
index 0000000000..b490f8faa6
--- /dev/null
+++ b/Content.Client/Guidebook/Controls/GuidebookControl.xaml.cs
@@ -0,0 +1,187 @@
+using System.Linq;
+using Content.Client.Guidebook.RichText;
+using Content.Client.UserInterface.ControlExtensions;
+using Content.Client.UserInterface.Controls.FancyTree;
+using Robust.Client.AutoGenerated;
+using Robust.Client.Graphics;
+using Robust.Client.UserInterface;
+using Robust.Client.UserInterface.Controls;
+using Robust.Client.UserInterface.XAML;
+using Robust.Shared.ContentPack;
+
+namespace Content.Client.Guidebook.Controls;
+[GenerateTypedNameReferences]
+public sealed partial class GuidebookControl : Control, ILinkClickHandler
+{
+ [Dependency] private readonly IResourceManager _resourceManager = default!;
+ [Dependency] private readonly DocumentParsingManager _parsingMan = default!;
+
+ private Dictionary _entries = new();
+
+ public GuidebookControl()
+ {
+ RobustXamlLoader.Load(this);
+ IoCManager.InjectDependencies(this);
+
+ Tree.OnSelectedItemChanged += OnSelectionChanged;
+
+ SearchBar.OnTextChanged += _ =>
+ {
+ HandleFilter();
+ };
+ }
+
+ private IClydeWindow? ClydeWindow { get; set; }
+
+ private void OnSelectionChanged(TreeItem? item)
+ {
+ if (item != null && item.Metadata is GuideEntry entry)
+ ShowGuide(entry);
+ else
+ ClearSelectedGuide();
+ }
+
+ public void ClearSelectedGuide()
+ {
+ Placeholder.Visible = true;
+ EntryContainer.Visible = false;
+ SearchContainer.Visible = false;
+ EntryContainer.RemoveAllChildren();
+ }
+
+ private void ShowGuide(GuideEntry entry)
+ {
+ Scroll.SetScrollValue(default);
+ Placeholder.Visible = false;
+ EntryContainer.Visible = true;
+ SearchBar.Text = "";
+ EntryContainer.RemoveAllChildren();
+ using var file = _resourceManager.ContentFileReadText(entry.Text);
+
+ SearchContainer.Visible = entry.FilterEnabled;
+
+ if (!_parsingMan.TryAddMarkup(EntryContainer, file.ReadToEnd()))
+ {
+ EntryContainer.AddChild(new Label() { Text = "ERROR: Failed to parse document." });
+ Logger.Error($"Failed to parse contents of guide document {entry.Id}.");
+ }
+ }
+
+ public void UpdateGuides(
+ Dictionary entries,
+ List? rootEntries = null,
+ string? forceRoot = null,
+ string? selected = null)
+ {
+ _entries = entries;
+ RepopulateTree(rootEntries, forceRoot);
+ ClearSelectedGuide();
+
+ Split.State = SplitContainer.SplitState.Auto;
+ if (entries.Count == 1)
+ {
+ TreeBox.Visible = false;
+ Split.ResizeMode = SplitContainer.SplitResizeMode.NotResizable;
+ selected = entries.Keys.First();
+ }
+ else
+ {
+ TreeBox.Visible = true;
+ Split.ResizeMode = SplitContainer.SplitResizeMode.RespectChildrenMinSize;
+ }
+
+ if (selected != null)
+ {
+ var item = Tree.Items.FirstOrDefault(x => x.Metadata is GuideEntry entry && entry.Id == selected);
+ Tree.SetSelectedIndex(item?.Index);
+ }
+ }
+
+ private IEnumerable GetSortedRootEntries(List? rootEntries)
+ {
+ if (rootEntries == null)
+ {
+ HashSet entries = new(_entries.Keys);
+ foreach (var entry in _entries.Values)
+ {
+ entries.ExceptWith(entry.Children);
+ }
+ rootEntries = entries.ToList();
+ }
+
+ return rootEntries
+ .Select(x => _entries[x])
+ .OrderBy(x => x.Priority)
+ .ThenBy(x => Loc.GetString(x.Name));
+ }
+
+ private void RepopulateTree(List? roots = null, string? forcedRoot = null)
+ {
+ Tree.Clear();
+
+ HashSet addedEntries = new();
+
+ TreeItem? parent = forcedRoot == null ? null : AddEntry(forcedRoot, null, addedEntries);
+ foreach (var entry in GetSortedRootEntries(roots))
+ {
+ AddEntry(entry.Id, parent, addedEntries);
+ }
+ Tree.SetAllExpanded(true);
+ }
+
+ private TreeItem? AddEntry(string id, TreeItem? parent, HashSet addedEntries)
+ {
+ if (!_entries.TryGetValue(id, out var entry))
+ return null;
+
+ if (!addedEntries.Add(id))
+ {
+ Logger.Error($"Adding duplicate guide entry: {id}");
+ return null;
+ }
+
+ var item = Tree.AddItem(parent);
+ item.Metadata = entry;
+ var name = Loc.GetString(entry.Name);
+ item.Label.Text = name;
+
+ foreach (var child in entry.Children)
+ {
+ AddEntry(child, item, addedEntries);
+ }
+
+ return item;
+ }
+
+ public void HandleClick(string link)
+ {
+ if (!_entries.TryGetValue(link, out var entry))
+ return;
+
+ if (Tree.TryGetIndexFromMetadata(entry, out var index))
+ {
+ Tree.ExpandParentEntries(index.Value);
+ Tree.SetSelectedIndex(index);
+ }
+ else
+ {
+ ShowGuide(entry);
+ }
+ }
+
+ private void HandleFilter()
+ {
+ var emptySearch = SearchBar.Text.Trim().Length == 0;
+
+ if (Tree.SelectedItem != null && Tree.SelectedItem.Metadata is GuideEntry entry && entry.FilterEnabled)
+ {
+ var foundElements = EntryContainer.GetSearchableControls();
+
+ foreach (var element in foundElements)
+ {
+ element.SetHiddenState(true, SearchBar.Text.Trim());
+ }
+ }
+
+ }
+}
diff --git a/Content.Client/Guidebook/Controls/GuidebookWindow.xaml b/Content.Client/Guidebook/Controls/GuidebookWindow.xaml
index 8dbfde3c47..ceb2b65be8 100644
--- a/Content.Client/Guidebook/Controls/GuidebookWindow.xaml
+++ b/Content.Client/Guidebook/Controls/GuidebookWindow.xaml
@@ -2,34 +2,8 @@
xmlns:cc="clr-namespace:Content.Client.Administration.UI.CustomControls"
xmlns:fancyTree="clr-namespace:Content.Client.UserInterface.Controls.FancyTree"
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
- SetSize="750 700"
- MinSize="100 200"
+ xmlns:controls1="clr-namespace:Content.Client.Guidebook.Controls"
Resizable="True"
Title="{Loc 'guidebook-window-title'}">
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
diff --git a/Content.Client/Guidebook/Controls/GuidebookWindow.xaml.cs b/Content.Client/Guidebook/Controls/GuidebookWindow.xaml.cs
index 113c192beb..0daf413aa2 100644
--- a/Content.Client/Guidebook/Controls/GuidebookWindow.xaml.cs
+++ b/Content.Client/Guidebook/Controls/GuidebookWindow.xaml.cs
@@ -6,6 +6,7 @@ using Content.Client.UserInterface.Controls;
using Content.Client.UserInterface.Controls.FancyTree;
using JetBrains.Annotations;
using Robust.Client.AutoGenerated;
+using Robust.Client.Graphics;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;
@@ -14,175 +15,6 @@ using Robust.Shared.ContentPack;
namespace Content.Client.Guidebook.Controls;
[GenerateTypedNameReferences]
-public sealed partial class GuidebookWindow : FancyWindow, ILinkClickHandler
+public sealed partial class GuidebookWindow : FancyWindow
{
- [Dependency] private readonly IResourceManager _resourceManager = default!;
- [Dependency] private readonly DocumentParsingManager _parsingMan = default!;
-
- private Dictionary _entries = new();
-
- public GuidebookWindow()
- {
- RobustXamlLoader.Load(this);
- IoCManager.InjectDependencies(this);
-
- Tree.OnSelectedItemChanged += OnSelectionChanged;
-
- SearchBar.OnTextChanged += _ =>
- {
- HandleFilter();
- };
- }
-
- private void OnSelectionChanged(TreeItem? item)
- {
- if (item != null && item.Metadata is GuideEntry entry)
- ShowGuide(entry);
- else
- ClearSelectedGuide();
- }
-
- public void ClearSelectedGuide()
- {
- Placeholder.Visible = true;
- EntryContainer.Visible = false;
- SearchContainer.Visible = false;
- EntryContainer.RemoveAllChildren();
- }
-
- private void ShowGuide(GuideEntry entry)
- {
- Scroll.SetScrollValue(default);
- Placeholder.Visible = false;
- EntryContainer.Visible = true;
- SearchBar.Text = "";
- EntryContainer.RemoveAllChildren();
- using var file = _resourceManager.ContentFileReadText(entry.Text);
-
- SearchContainer.Visible = entry.FilterEnabled;
-
- if (!_parsingMan.TryAddMarkup(EntryContainer, file.ReadToEnd()))
- {
- EntryContainer.AddChild(new Label() { Text = "ERROR: Failed to parse document." });
- Logger.Error($"Failed to parse contents of guide document {entry.Id}.");
- }
- }
-
- public void UpdateGuides(
- Dictionary entries,
- List? rootEntries = null,
- string? forceRoot = null,
- string? selected = null)
- {
- _entries = entries;
- RepopulateTree(rootEntries, forceRoot);
- ClearSelectedGuide();
-
- Split.State = SplitContainer.SplitState.Auto;
- if (entries.Count == 1)
- {
- TreeBox.Visible = false;
- Split.ResizeMode = SplitContainer.SplitResizeMode.NotResizable;
- selected = entries.Keys.First();
- }
- else
- {
- TreeBox.Visible = true;
- Split.ResizeMode = SplitContainer.SplitResizeMode.RespectChildrenMinSize;
- }
-
- if (selected != null)
- {
- var item = Tree.Items.FirstOrDefault(x => x.Metadata is GuideEntry entry && entry.Id == selected);
- Tree.SetSelectedIndex(item?.Index);
- }
- }
-
- private IEnumerable GetSortedRootEntries(List? rootEntries)
- {
- if (rootEntries == null)
- {
- HashSet entries = new(_entries.Keys);
- foreach (var entry in _entries.Values)
- {
- entries.ExceptWith(entry.Children);
- }
- rootEntries = entries.ToList();
- }
-
- return rootEntries
- .Select(x => _entries[x])
- .OrderBy(x => x.Priority)
- .ThenBy(x => Loc.GetString(x.Name));
- }
-
- private void RepopulateTree(List? roots = null, string? forcedRoot = null)
- {
- Tree.Clear();
-
- HashSet addedEntries = new();
-
- TreeItem? parent = forcedRoot == null ? null : AddEntry(forcedRoot, null, addedEntries);
- foreach (var entry in GetSortedRootEntries(roots))
- {
- AddEntry(entry.Id, parent, addedEntries);
- }
- Tree.SetAllExpanded(true);
- }
-
- private TreeItem? AddEntry(string id, TreeItem? parent, HashSet addedEntries)
- {
- if (!_entries.TryGetValue(id, out var entry))
- return null;
-
- if (!addedEntries.Add(id))
- {
- Logger.Error($"Adding duplicate guide entry: {id}");
- return null;
- }
-
- var item = Tree.AddItem(parent);
- item.Metadata = entry;
- var name = Loc.GetString(entry.Name);
- item.Label.Text = name;
-
- foreach (var child in entry.Children)
- {
- AddEntry(child, item, addedEntries);
- }
-
- return item;
- }
-
- public void HandleClick(string link)
- {
- if (!_entries.TryGetValue(link, out var entry))
- return;
-
- if (Tree.TryGetIndexFromMetadata(entry, out var index))
- {
- Tree.ExpandParentEntries(index.Value);
- Tree.SetSelectedIndex(index);
- }
- else
- {
- ShowGuide(entry);
- }
- }
-
- private void HandleFilter()
- {
- var emptySearch = SearchBar.Text.Trim().Length == 0;
-
- if (Tree.SelectedItem != null && Tree.SelectedItem.Metadata is GuideEntry entry && entry.FilterEnabled)
- {
- var foundElements = EntryContainer.GetSearchableControls();
-
- foreach (var element in foundElements)
- {
- element.SetHiddenState(true, SearchBar.Text.Trim());
- }
- }
-
- }
}
diff --git a/Content.Client/UserInterface/Systems/Guidebook/GuidebookUIController.cs b/Content.Client/UserInterface/Systems/Guidebook/GuidebookUIController.cs
index 20e3158f74..046ff9663b 100644
--- a/Content.Client/UserInterface/Systems/Guidebook/GuidebookUIController.cs
+++ b/Content.Client/UserInterface/Systems/Guidebook/GuidebookUIController.cs
@@ -5,6 +5,7 @@ using Content.Client.Guidebook.Controls;
using Content.Client.Lobby;
using Content.Client.UserInterface.Controls;
using Content.Shared.Input;
+using Robust.Client.Graphics;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controllers;
using static Robust.Client.UserInterface.Controls.BaseButton;
@@ -17,7 +18,11 @@ namespace Content.Client.UserInterface.Systems.Guidebook;
public sealed class GuidebookUIController : UIController, IOnStateEntered, IOnStateEntered, IOnStateExited, IOnStateExited, IOnSystemChanged
{
[UISystemDependency] private readonly GuidebookSystem _guidebookSystem = default!;
+ [Dependency] private readonly IClyde _clyde = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
+ [Dependency] private readonly IUserInterfaceManager _uiManager = default!;
+
+ private IClydeWindow? ClydeWindow { get; set; }
private GuidebookWindow? _guideWindow;
private MenuButton? GuidebookButton => UIManager.GetActiveUIWidgetOrNull()?.GuidebookButton;
@@ -40,6 +45,7 @@ public sealed class GuidebookUIController : UIController, IOnStateEntered();
_guideWindow.OnClose += OnWindowClosed;
_guideWindow.OnOpen += OnWindowOpen;
+ _guideWindow.Guidebook.PopOutButton.OnPressed += _ => PopOut();
// setup keybinding
CommandBinds.Builder
@@ -135,7 +141,12 @@ public sealed class GuidebookUIController : UIController, IOnStateEntered();
+ _guideWindow.OnClose += OnWindowClosed;
+ _guideWindow.OnOpen += OnWindowOpen;
+ _guideWindow.Guidebook.PopOutButton.OnPressed += _ => PopOut();
+ }
if (_guideWindow.IsOpen)
{
@@ -161,11 +172,11 @@ public sealed class GuidebookUIController : UIController, IOnStateEntered