2023-07-08 14:08:32 +10:00
|
|
|
using System.Numerics;
|
2022-09-14 14:34:48 -07:00
|
|
|
using Content.Client.UserInterface.Systems.EscapeMenu;
|
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-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
|
|
|
{
|
2023-11-27 22:12:34 +11:00
|
|
|
[Dependency] private readonly IResourceManager _resourceManager = default!;
|
2021-03-03 06:56:52 +00:00
|
|
|
|
2021-12-09 14:22:49 -08:00
|
|
|
public RulesAndInfoWindow()
|
2021-03-03 06:56:52 +00:00
|
|
|
{
|
|
|
|
|
IoCManager.InjectDependencies(this);
|
|
|
|
|
|
|
|
|
|
Title = Loc.GetString("ui-info-title");
|
|
|
|
|
|
|
|
|
|
var rootContainer = new TabContainer();
|
|
|
|
|
|
2024-06-06 03:11:26 -04:00
|
|
|
var rulesList = new RulesControl
|
|
|
|
|
{
|
|
|
|
|
Margin = new Thickness(10)
|
|
|
|
|
};
|
|
|
|
|
var tutorialList = new Info
|
|
|
|
|
{
|
|
|
|
|
Margin = new Thickness(10)
|
|
|
|
|
};
|
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"));
|
|
|
|
|
|
|
|
|
|
PopulateTutorial(tutorialList);
|
|
|
|
|
|
|
|
|
|
Contents.AddChild(rootContainer);
|
|
|
|
|
|
2023-07-08 14:08:32 +10:00
|
|
|
SetSize = new Vector2(650, 650);
|
2021-03-03 06:56:52 +00:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
2022-10-12 01:16:23 -07:00
|
|
|
infoControlSection.ControlsButton.OnPressed += _ => UserInterfaceManager.GetUIController<OptionsUIController>().OpenWindow();
|
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)
|
|
|
|
|
{
|
2023-04-16 12:55:59 +12:00
|
|
|
return new InfoSection(title, res.ContentFileReadAllText($"/ServerInfo/{path}"), markup);
|
2022-05-27 23:50:11 +02:00
|
|
|
}
|
|
|
|
|
|
2021-03-03 06:56:52 +00:00
|
|
|
}
|
|
|
|
|
}
|