2023-07-08 14:08:32 +10:00
|
|
|
|
using System.Numerics;
|
2024-05-10 19:21:18 -07:00
|
|
|
|
using Content.Client.Guidebook;
|
|
|
|
|
|
using Content.Client.Guidebook.Components;
|
2024-06-07 00:05:58 +12:00
|
|
|
|
using Content.Shared.Guidebook;
|
2023-07-08 14:08:32 +10:00
|
|
|
|
using Robust.Client.AutoGenerated;
|
2021-11-02 01:12:55 +01:00
|
|
|
|
using Robust.Client.UserInterface.CustomControls;
|
|
|
|
|
|
using Robust.Client.UserInterface.XAML;
|
2024-05-10 19:21:18 -07:00
|
|
|
|
using Robust.Shared.Prototypes;
|
2021-11-02 01:12:55 +01:00
|
|
|
|
|
2022-09-11 18:56:21 -07:00
|
|
|
|
namespace Content.Client.UserInterface.Controls
|
2021-11-02 01:12:55 +01:00
|
|
|
|
{
|
|
|
|
|
|
[GenerateTypedNameReferences]
|
2022-02-16 00:23:23 -07:00
|
|
|
|
[Virtual]
|
2021-11-02 01:12:55 +01:00
|
|
|
|
public partial class FancyWindow : BaseWindow
|
|
|
|
|
|
{
|
2024-05-10 19:21:18 -07:00
|
|
|
|
[Dependency] private readonly IEntitySystemManager _sysMan = default!;
|
|
|
|
|
|
private GuidebookSystem? _guidebookSystem;
|
2022-12-06 23:46:07 +00:00
|
|
|
|
private const int DRAG_MARGIN_SIZE = 7;
|
2024-05-10 19:21:18 -07:00
|
|
|
|
public const string StyleClassWindowHelpButton = "windowHelpButton";
|
2022-12-06 23:46:07 +00:00
|
|
|
|
|
2021-11-02 01:12:55 +01:00
|
|
|
|
public FancyWindow()
|
|
|
|
|
|
{
|
|
|
|
|
|
RobustXamlLoader.Load(this);
|
|
|
|
|
|
|
|
|
|
|
|
CloseButton.OnPressed += _ => Close();
|
2024-05-10 19:21:18 -07:00
|
|
|
|
HelpButton.OnPressed += _ => Help();
|
2021-11-02 01:12:55 +01:00
|
|
|
|
XamlChildren = ContentsContainer.Children;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public string? Title
|
|
|
|
|
|
{
|
|
|
|
|
|
get => WindowTitle.Text;
|
|
|
|
|
|
set => WindowTitle.Text = value;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-06-07 00:05:58 +12:00
|
|
|
|
private List<ProtoId<GuideEntryPrototype>>? _helpGuidebookIds;
|
|
|
|
|
|
public List<ProtoId<GuideEntryPrototype>>? HelpGuidebookIds
|
2024-05-10 19:21:18 -07:00
|
|
|
|
{
|
|
|
|
|
|
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);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-11-02 01:12:55 +01:00
|
|
|
|
protected override DragMode GetDragModeFor(Vector2 relativeMousePos)
|
|
|
|
|
|
{
|
2022-12-06 23:46:07 +00:00
|
|
|
|
var mode = DragMode.Move;
|
|
|
|
|
|
|
|
|
|
|
|
if (Resizable)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (relativeMousePos.Y < DRAG_MARGIN_SIZE)
|
|
|
|
|
|
{
|
|
|
|
|
|
mode = DragMode.Top;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (relativeMousePos.Y > Size.Y - DRAG_MARGIN_SIZE)
|
|
|
|
|
|
{
|
|
|
|
|
|
mode = DragMode.Bottom;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (relativeMousePos.X < DRAG_MARGIN_SIZE)
|
|
|
|
|
|
{
|
|
|
|
|
|
mode |= DragMode.Left;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (relativeMousePos.X > Size.X - DRAG_MARGIN_SIZE)
|
|
|
|
|
|
{
|
|
|
|
|
|
mode |= DragMode.Right;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return mode;
|
2021-11-02 01:12:55 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|