]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Open the guidebook when people with less than an hour playing join the round (#28774)
authorAJCM-git <60196617+AJCM-git@users.noreply.github.com>
Sun, 9 Jun 2024 16:26:48 +0000 (12:26 -0400)
committerGitHub <noreply@github.com>
Sun, 9 Jun 2024 16:26:48 +0000 (12:26 -0400)
* 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>
Content.Client/Guidebook/Controls/GuidebookWindow.xaml
Content.Client/Guidebook/Controls/GuidebookWindow.xaml.cs
Content.Client/UserInterface/Systems/Guidebook/GuidebookUIController.cs
Resources/Locale/en-US/guidebook/guides.ftl
Resources/Prototypes/Guidebook/station.yml

index b52eacfa722617e2377ba389f10a9c6faafaec7d..69534af7f6a39d8309d9a096402a4cfed224020a 100644 (file)
@@ -2,7 +2,7 @@
                 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="850 700"
+                SetSize="900 700"
                 MinSize="100 200"
                 Resizable="True"
                 Title="{Loc 'guidebook-window-title'}">
index 9ff189e79069c05fc0fc2d59a410ed0f35d67ee2..c904a9c78986fad04e15ab8d048a28a96922ae5e 100644 (file)
@@ -18,8 +18,6 @@ namespace Content.Client.Guidebook.Controls;
 [GenerateTypedNameReferences]
 public sealed partial class GuidebookWindow : FancyWindow, ILinkClickHandler
 {
-    [Dependency] private readonly IConfigurationManager _configuration = default!;
-    [Dependency] private readonly IPrototypeManager _prototypeManager = default!;
     [Dependency] private readonly IResourceManager _resourceManager = default!;
     [Dependency] private readonly DocumentParsingManager _parsingMan = default!;
 
@@ -38,20 +36,6 @@ public sealed partial class GuidebookWindow : FancyWindow, ILinkClickHandler
         };
     }
 
-    protected override void Opened()
-    {
-        base.Opened();
-
-        var guideProto = _configuration.GetCVar(CCVars.DefaultGuide);
-        if (_prototypeManager.TryIndex<GuideEntryPrototype>(guideProto, out var guideEntry))
-        {
-            if (Tree.Items.FirstOrDefault(x => x.Metadata is GuideEntry entry && entry.Id == guideProto) is { } item)
-                Tree.SetSelectedIndex(item.Index);
-            else
-                ShowGuide(guideEntry);
-        }
-    }
-
     private void OnSelectionChanged(TreeItem? item)
     {
         if (item != null && item.Metadata is GuideEntry entry)
index 61195f3a9a7e5e6621cd62e69b0ea32390c496f7..03ea47827f6319e0aae4bbc479355b8a83c3e190 100644 (file)
@@ -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>()
index 838d2ce4a620892ef3a5fffb2dde283b6b3326e2..4bef8970b4fc6bad7eb628f1dea88a1fbb35dce8 100644 (file)
@@ -56,7 +56,7 @@ guide-entry-yourfirstcharacter = Your First Character
 guide-entry-controls = Controls
 guide-entry-radio = Radio and Speech
 
-guide-entry-references = Tables and References
+guide-entry-references = Tables & References
 guide-entry-drinks = Drinks
 guide-entry-foodrecipes = Food Recipes
 guide-entry-chemicals = Chemicals
index 9570b617c0c35914cb5a9137b62bb0e19df9b520..d868a6b58fc05c7b149092614322248241bcfaa7 100644 (file)
@@ -3,7 +3,6 @@
   name: guide-entry-ss14
   text: "/ServerInfo/Guidebook/SpaceStation14.xml"
   children:
-  - Controls
   - Jobs
   - Survival
   - Antagonists