Adds Support for Guidebook Buttons in UIs (#27891)
* Adds Support for Guidebook Buttons in UIs * read it from the component * the code is perfect * moony review --------- Co-authored-by: ike709 <ike709@github.com>
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
using System.Numerics;
|
||||
using Content.Client.Guidebook;
|
||||
using Content.Client.Guidebook.Components;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Client.UserInterface.Controls
|
||||
{
|
||||
@@ -9,13 +12,17 @@ namespace Content.Client.UserInterface.Controls
|
||||
[Virtual]
|
||||
public partial class FancyWindow : BaseWindow
|
||||
{
|
||||
[Dependency] private readonly IEntitySystemManager _sysMan = default!;
|
||||
private GuidebookSystem? _guidebookSystem;
|
||||
private const int DRAG_MARGIN_SIZE = 7;
|
||||
public const string StyleClassWindowHelpButton = "windowHelpButton";
|
||||
|
||||
public FancyWindow()
|
||||
{
|
||||
RobustXamlLoader.Load(this);
|
||||
|
||||
CloseButton.OnPressed += _ => Close();
|
||||
HelpButton.OnPressed += _ => Help();
|
||||
XamlChildren = ContentsContainer.Children;
|
||||
}
|
||||
|
||||
@@ -25,6 +32,26 @@ namespace Content.Client.UserInterface.Controls
|
||||
set => WindowTitle.Text = value;
|
||||
}
|
||||
|
||||
private List<string>? _helpGuidebookIds;
|
||||
public List<string>? HelpGuidebookIds
|
||||
{
|
||||
get => _helpGuidebookIds;
|
||||
set
|
||||
{
|
||||
_helpGuidebookIds = value;
|
||||
HelpButton.Disabled = _helpGuidebookIds == null;
|
||||
HelpButton.Visible = !HelpButton.Disabled;
|
||||
}
|
||||
}
|
||||
|
||||
public void Help()
|
||||
{
|
||||
if (HelpGuidebookIds is null)
|
||||
return;
|
||||
_guidebookSystem ??= _sysMan.GetEntitySystem<GuidebookSystem>();
|
||||
_guidebookSystem.OpenHelp(HelpGuidebookIds);
|
||||
}
|
||||
|
||||
protected override DragMode GetDragModeFor(Vector2 relativeMousePos)
|
||||
{
|
||||
var mode = DragMode.Move;
|
||||
|
||||
Reference in New Issue
Block a user