2021-06-09 22:19:39 +02:00
|
|
|
using Content.Client.EscapeMenu.UI;
|
2022-05-23 14:43:09 -05:00
|
|
|
using Content.Shared.CCVar;
|
2021-03-03 06:56:52 +00:00
|
|
|
using Robust.Client.ResourceManagement;
|
2022-05-27 23:50:11 +02:00
|
|
|
using Robust.Client.UserInterface;
|
2021-03-03 06:56:52 +00:00
|
|
|
using Robust.Client.UserInterface.Controls;
|
|
|
|
|
using Robust.Client.UserInterface.CustomControls;
|
2022-05-23 14:43:09 -05:00
|
|
|
using Robust.Shared.Configuration;
|
2022-05-27 23:50:11 +02:00
|
|
|
using Robust.Shared.ContentPack;
|
2021-03-03 06:56:52 +00:00
|
|
|
|
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!;
|
2022-05-23 14:43:09 -05:00
|
|
|
[Dependency] private readonly IConfigurationManager _cfgManager = default!;
|
2021-03-03 06:56:52 +00:00
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
{
|
2022-05-27 23:50:11 +02:00
|
|
|
AddSection(rulesList, MakeRules(_cfgManager, _resourceManager));
|
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
|
|
|
}
|
|
|
|
|
|
2022-05-27 23:50:11 +02:00
|
|
|
private static void AddSection(Info info, Control control)
|
|
|
|
|
{
|
|
|
|
|
info.InfoContainer.AddChild(control);
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
{
|
2022-05-27 23:50:11 +02:00
|
|
|
AddSection(info, MakeSection(title, path, markup, _resourceManager));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static Control MakeSection(string title, string path, bool markup, IResourceManager res)
|
|
|
|
|
{
|
|
|
|
|
return new InfoSection(title, res.ContentFileReadAllText($"/Server Info/{path}"), markup);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static Control MakeRules(IConfigurationManager cfg, IResourceManager res)
|
|
|
|
|
{
|
|
|
|
|
return MakeSection(Loc.GetString("ui-rules-header"), cfg.GetCVar(CCVars.RulesFile), true, res);
|
2021-03-03 06:56:52 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|