Files
tbd-station-14/Content.Client/Info/RulesAndInfoWindow.cs
ShadowCommander be6cb75122 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
2021-12-24 17:32:33 -08:00

74 lines
2.4 KiB
C#

using Content.Client.EscapeMenu.UI;
using Robust.Client.ResourceManagement;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
namespace Content.Client.Info
{
public sealed class RulesAndInfoWindow : SS14Window
{
[Dependency] private readonly RulesManager _rulesManager = default!;
[Dependency] private readonly IResourceCache _resourceManager = default!;
private OptionsMenu optionsMenu;
public RulesAndInfoWindow()
{
IoCManager.InjectDependencies(this);
optionsMenu = new OptionsMenu();
Title = Loc.GetString("ui-info-title");
var rootContainer = new TabContainer();
var rulesList = new Info();
var tutorialList = new Info();
rootContainer.AddChild(rulesList);
rootContainer.AddChild(tutorialList);
TabContainer.SetTabTitle(rulesList, Loc.GetString("ui-info-tab-rules"));
TabContainer.SetTabTitle(tutorialList, Loc.GetString("ui-info-tab-tutorial"));
PopulateRules(rulesList);
PopulateTutorial(tutorialList);
Contents.AddChild(rootContainer);
SetSize = (650, 650);
}
private void PopulateRules(Info rulesList)
{
AddSection(rulesList, Loc.GetString("ui-rules-header"), "Rules.txt", true);
}
private void PopulateTutorial(Info tutorialList)
{
AddSection(tutorialList, Loc.GetString("ui-info-header-intro"), "Intro.txt");
var infoControlSection = new InfoControlsSection();
tutorialList.InfoContainer.AddChild(infoControlSection);
AddSection(tutorialList, Loc.GetString("ui-info-header-gameplay"), "Gameplay.txt", true);
AddSection(tutorialList, Loc.GetString("ui-info-header-sandbox"), "Sandbox.txt", true);
infoControlSection.ControlsButton.OnPressed += _ => optionsMenu.OpenCentered();
}
private void AddSection(Info info, string title, string path, bool markup = false)
{
info.InfoContainer.AddChild(new InfoSection(title,
_resourceManager.ContentFileReadAllText($"/Server Info/{path}"), markup));
}
protected override void Opened()
{
base.Opened();
_rulesManager.SaveLastReadTime();
}
}
}