2021-06-09 22:19:39 +02:00
|
|
|
using Content.Client.EscapeMenu.UI;
|
2021-03-03 06:56:52 +00:00
|
|
|
using Robust.Client.ResourceManagement;
|
|
|
|
|
using Robust.Client.UserInterface.Controls;
|
|
|
|
|
using Robust.Client.UserInterface.CustomControls;
|
|
|
|
|
using Robust.Shared.IoC;
|
|
|
|
|
using Robust.Shared.Localization;
|
|
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
namespace Content.Client.Info
|
2021-03-03 06:56:52 +00:00
|
|
|
{
|
2022-01-21 01:38:35 -08:00
|
|
|
public sealed class RulesAndInfoWindow : DefaultWindow
|
2021-03-03 06:56:52 +00:00
|
|
|
{
|
2021-12-09 14:22:49 -08:00
|
|
|
[Dependency] private readonly RulesManager _rulesManager = default!;
|
2021-03-03 06:56:52 +00:00
|
|
|
[Dependency] private readonly IResourceCache _resourceManager = default!;
|
|
|
|
|
|
|
|
|
|
private OptionsMenu optionsMenu;
|
|
|
|
|
|
2021-12-09 14:22:49 -08:00
|
|
|
public RulesAndInfoWindow()
|
2021-03-03 06:56:52 +00:00
|
|
|
{
|
|
|
|
|
IoCManager.InjectDependencies(this);
|
|
|
|
|
|
|
|
|
|
optionsMenu = new OptionsMenu();
|
|
|
|
|
|
|
|
|
|
Title = Loc.GetString("ui-info-title");
|
|
|
|
|
|
|
|
|
|
var rootContainer = new TabContainer();
|
|
|
|
|
|
2021-12-15 22:17:01 -08:00
|
|
|
var rulesList = new Info();
|
|
|
|
|
var tutorialList = new Info();
|
2021-03-03 06:56:52 +00:00
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-15 22:17:01 -08:00
|
|
|
private void PopulateRules(Info rulesList)
|
|
|
|
|
{
|
2021-12-24 17:32:33 -08:00
|
|
|
AddSection(rulesList, Loc.GetString("ui-rules-header"), "Rules.txt", true);
|
2021-12-15 22:17:01 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void PopulateTutorial(Info tutorialList)
|
2021-03-03 06:56:52 +00:00
|
|
|
{
|
2021-12-15 22:17:01 -08:00
|
|
|
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);
|
2021-03-03 06:56:52 +00:00
|
|
|
|
2021-12-15 22:17:01 -08:00
|
|
|
infoControlSection.ControlsButton.OnPressed += _ => optionsMenu.OpenCentered();
|
2021-03-03 06:56:52 +00:00
|
|
|
}
|
|
|
|
|
|
2021-12-15 22:17:01 -08:00
|
|
|
private void AddSection(Info info, string title, string path, bool markup = false)
|
2021-03-03 06:56:52 +00:00
|
|
|
{
|
2021-12-15 22:17:01 -08:00
|
|
|
info.InfoContainer.AddChild(new InfoSection(title,
|
|
|
|
|
_resourceManager.ContentFileReadAllText($"/Server Info/{path}"), markup));
|
2021-03-03 06:56:52 +00:00
|
|
|
}
|
|
|
|
|
|
2021-12-09 14:22:49 -08:00
|
|
|
protected override void Opened()
|
|
|
|
|
{
|
|
|
|
|
base.Opened();
|
|
|
|
|
|
|
|
|
|
_rulesManager.SaveLastReadTime();
|
|
|
|
|
}
|
2021-03-03 06:56:52 +00:00
|
|
|
}
|
|
|
|
|
}
|