Add a wait time for the rules popup (#5823)
* Create new rules popup * Implement accept and quit buttons * Add rules accept timer Forces the player to read the rules by making them wait. Speed reading the rules took me just under 45 seconds which means it'll take longer than that if someone's reading this for the first time. * Fix info rules header * Change _rulesPopup to local variable
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using Content.Client.Lobby;
|
||||
using Content.Client.Viewport;
|
||||
using Content.Shared.CCVar;
|
||||
using Robust.Client.Console;
|
||||
using Robust.Client.State;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.ContentPack;
|
||||
using Robust.Shared.IoC;
|
||||
@@ -16,9 +17,9 @@ public sealed class RulesManager
|
||||
{
|
||||
[Dependency] private readonly IResourceManager _resource = default!;
|
||||
[Dependency] private readonly IConfigurationManager _configManager = default!;
|
||||
[Dependency] private readonly IUserInterfaceManager _userInterfaceManager = default!;
|
||||
[Dependency] private readonly IStateManager _stateManager = default!;
|
||||
|
||||
public event Action? OpenRulesAndInfoWindow;
|
||||
[Dependency] private readonly IClientConsoleHost _consoleHost = default!;
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
@@ -39,8 +40,10 @@ public sealed class RulesManager
|
||||
else
|
||||
SaveLastReadTime();
|
||||
|
||||
if (showRules)
|
||||
OpenRulesAndInfoWindow?.Invoke();
|
||||
if (!showRules)
|
||||
return;
|
||||
|
||||
ShowRules(_configManager.GetCVar(CCVars.RulesWaitTime));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -52,4 +55,25 @@ public sealed class RulesManager
|
||||
|
||||
sw.Write(DateTime.UtcNow.ToUniversalTime());
|
||||
}
|
||||
|
||||
private void ShowRules(float time)
|
||||
{
|
||||
var rulesPopup = new RulesPopup
|
||||
{
|
||||
Timer = time
|
||||
};
|
||||
rulesPopup.OnQuitPressed += OnQuitPressed;
|
||||
rulesPopup.OnAcceptPressed += OnAcceptPressed;
|
||||
_userInterfaceManager.RootControl.AddChild(rulesPopup);
|
||||
}
|
||||
|
||||
private void OnQuitPressed()
|
||||
{
|
||||
_consoleHost.ExecuteCommand("quit");
|
||||
}
|
||||
|
||||
private void OnAcceptPressed()
|
||||
{
|
||||
SaveLastReadTime();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user