Open the guidebook when people with less than an hour playing join the round (#28774)
* Open the guidebook when people with less than an hour playing join the round * Filter for gameplayState * Fix tests * tweaks * saltern update (#28773) Co-authored-by: deltanedas <@deltanedas:kde.org> * Fix admin menu objects list (#28787) * Make `MakeAntag()` log errors instead of throwing exceptions (#28771) Make `MakeAntag()` log errors instead of throw * add default page support for the guidebook (#28772) * Probably a better way to handle this --------- Co-authored-by: deltanedas <39013340+deltanedas@users.noreply.github.com> Co-authored-by: Leon Friedrich <60421075+ElectroJr@users.noreply.github.com> Co-authored-by: Nemanja <98561806+EmoGarbage404@users.noreply.github.com>
This commit is contained in:
@@ -3,11 +3,15 @@ using Content.Client.Gameplay;
|
||||
using Content.Client.Guidebook;
|
||||
using Content.Client.Guidebook.Controls;
|
||||
using Content.Client.Lobby;
|
||||
using Content.Client.Players.PlayTimeTracking;
|
||||
using Content.Client.UserInterface.Controls;
|
||||
using Content.Shared.CCVar;
|
||||
using Content.Shared.Guidebook;
|
||||
using Content.Shared.Input;
|
||||
using Robust.Client.State;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Client.UserInterface.Controllers;
|
||||
using Robust.Shared.Configuration;
|
||||
using static Robust.Client.UserInterface.Controls.BaseButton;
|
||||
using Robust.Shared.Input.Binding;
|
||||
using Robust.Shared.Prototypes;
|
||||
@@ -19,21 +23,25 @@ public sealed class GuidebookUIController : UIController, IOnStateEntered<LobbyS
|
||||
{
|
||||
[UISystemDependency] private readonly GuidebookSystem _guidebookSystem = default!;
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
[Dependency] private readonly IConfigurationManager _configuration = default!;
|
||||
[Dependency] private readonly JobRequirementsManager _jobRequirements = default!;
|
||||
|
||||
private const int PlaytimeOpenGuidebook = 60;
|
||||
|
||||
private GuidebookWindow? _guideWindow;
|
||||
private MenuButton? GuidebookButton => UIManager.GetActiveUIWidgetOrNull<MenuBar.Widgets.GameTopMenuBar>()?.GuidebookButton;
|
||||
|
||||
public void OnStateEntered(LobbyState state)
|
||||
{
|
||||
HandleStateEntered();
|
||||
HandleStateEntered(state);
|
||||
}
|
||||
|
||||
public void OnStateEntered(GameplayState state)
|
||||
{
|
||||
HandleStateEntered();
|
||||
HandleStateEntered(state);
|
||||
}
|
||||
|
||||
private void HandleStateEntered()
|
||||
private void HandleStateEntered(State state)
|
||||
{
|
||||
DebugTools.Assert(_guideWindow == null);
|
||||
|
||||
@@ -42,6 +50,14 @@ public sealed class GuidebookUIController : UIController, IOnStateEntered<LobbyS
|
||||
_guideWindow.OnClose += OnWindowClosed;
|
||||
_guideWindow.OnOpen += OnWindowOpen;
|
||||
|
||||
if (state is LobbyState &&
|
||||
_jobRequirements.FetchOverallPlaytime() < TimeSpan.FromMinutes(PlaytimeOpenGuidebook))
|
||||
{
|
||||
OpenGuidebook();
|
||||
_guideWindow.RecenterWindow(new(0.5f, 0.5f));
|
||||
_guideWindow.SetPositionFirst();
|
||||
}
|
||||
|
||||
// setup keybinding
|
||||
CommandBinds.Builder
|
||||
.Bind(ContentKeyFunctions.OpenGuidebook,
|
||||
@@ -160,6 +176,8 @@ 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>()
|
||||
|
||||
Reference in New Issue
Block a user