Make guidebook remember where you left off (#31375)
* Guidebook tracks last read entry * Persistent guidebook fixes * Persistent guidebook requested changes * Update Content.Client/UserInterface/Systems/Guidebook/GuidebookUIController.cs --------- Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com>
This commit is contained in:
@@ -23,6 +23,8 @@ public sealed partial class GuidebookWindow : FancyWindow, ILinkClickHandler
|
||||
|
||||
private readonly ISawmill _sawmill;
|
||||
|
||||
public ProtoId<GuideEntryPrototype> LastEntry;
|
||||
|
||||
public GuidebookWindow()
|
||||
{
|
||||
RobustXamlLoader.Load(this);
|
||||
@@ -90,6 +92,8 @@ public sealed partial class GuidebookWindow : FancyWindow, ILinkClickHandler
|
||||
|
||||
_sawmill.Error($"Failed to parse contents of guide document {entry.Id}.");
|
||||
}
|
||||
|
||||
LastEntry = entry.Id;
|
||||
}
|
||||
|
||||
public void UpdateGuides(
|
||||
|
||||
@@ -30,6 +30,7 @@ public sealed class GuidebookUIController : UIController, IOnStateEntered<LobbyS
|
||||
|
||||
private GuidebookWindow? _guideWindow;
|
||||
private MenuButton? GuidebookButton => UIManager.GetActiveUIWidgetOrNull<MenuBar.Widgets.GameTopMenuBar>()?.GuidebookButton;
|
||||
private ProtoId<GuideEntryPrototype>? _lastEntry;
|
||||
|
||||
public void OnStateEntered(LobbyState state)
|
||||
{
|
||||
@@ -142,7 +143,10 @@ public sealed class GuidebookUIController : UIController, IOnStateEntered<LobbyS
|
||||
GuidebookButton.Pressed = false;
|
||||
|
||||
if (_guideWindow != null)
|
||||
{
|
||||
_guideWindow.ReturnContainer.Visible = false;
|
||||
_lastEntry = _guideWindow.LastEntry;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnWindowOpen()
|
||||
@@ -176,8 +180,6 @@ public sealed class GuidebookUIController : UIController, IOnStateEntered<LobbyS
|
||||
if (GuidebookButton != null)
|
||||
GuidebookButton.SetClickPressed(!_guideWindow.IsOpen);
|
||||
|
||||
selected ??= _configuration.GetCVar(CCVars.DefaultGuide);
|
||||
|
||||
if (guides == null)
|
||||
{
|
||||
guides = _prototypeManager.EnumeratePrototypes<GuideEntryPrototype>()
|
||||
@@ -193,6 +195,17 @@ public sealed class GuidebookUIController : UIController, IOnStateEntered<LobbyS
|
||||
}
|
||||
}
|
||||
|
||||
if (selected == null)
|
||||
{
|
||||
if (_lastEntry is { } lastEntry && guides.ContainsKey(lastEntry))
|
||||
{
|
||||
selected = _lastEntry;
|
||||
}
|
||||
else
|
||||
{
|
||||
selected = _configuration.GetCVar(CCVars.DefaultGuide);
|
||||
}
|
||||
}
|
||||
_guideWindow.UpdateGuides(guides, rootEntries, forceRoot, selected);
|
||||
|
||||
// Expand up to depth-2.
|
||||
|
||||
Reference in New Issue
Block a user