mirror of
https://github.com/DeltaV-Station/Delta-v.git
synced 2026-09-29 23:57:29 +00:00
* somewhat functional yes * some cleanup * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * review * missed one * why not params… * review 2 --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
99 lines
2.6 KiB
C#
99 lines
2.6 KiB
C#
using Content.Client.Guidebook.Richtext;
|
|
using Content.Shared._DV.Tips;
|
|
using Robust.Client.AutoGenerated;
|
|
using Robust.Client.Graphics;
|
|
using Robust.Client.UserInterface;
|
|
using Robust.Client.UserInterface.Controls;
|
|
using Robust.Client.UserInterface.RichText;
|
|
using Robust.Client.UserInterface.XAML;
|
|
using Robust.Shared.Utility;
|
|
|
|
namespace Content.Client._DV.Tips.UI;
|
|
|
|
/// <summary>
|
|
/// Popup control that displays a tip to the player.
|
|
/// Appears in the top-left corner with a semi-transparent background.
|
|
/// </summary>
|
|
[GenerateTypedNameReferences]
|
|
public sealed partial class TipPopup : Control
|
|
{
|
|
/// <summary>
|
|
/// Event raised when the popup is closed. The bool parameter indicates
|
|
/// whether the "Don't show again" checkbox was checked.
|
|
/// </summary>
|
|
public event Action<bool>? OnClose;
|
|
|
|
private readonly TipPrototype _tip;
|
|
|
|
/// <summary>
|
|
/// Whether the "Don't show again" checkbox is checked.
|
|
/// </summary>
|
|
public bool DontShowAgain => DontShowAgainCheckBox.Pressed;
|
|
|
|
public TipPopup(TipPrototype tip)
|
|
{
|
|
RobustXamlLoader.Load(this);
|
|
|
|
_tip = tip;
|
|
|
|
InitializeUI();
|
|
InitializeEvents();
|
|
}
|
|
|
|
private void InitializeUI()
|
|
{
|
|
TitleLabel.Text = Loc.GetString(_tip.Title);
|
|
|
|
var description = Loc.GetString(_tip.Description);
|
|
DescriptionLabel.SetMessage(FormattedMessage.FromMarkupPermissive(description),
|
|
tagsAllowed:
|
|
[
|
|
typeof(ItalicTag),
|
|
typeof(ColorTag),
|
|
typeof(BoldTag),
|
|
typeof(BoldItalicTag),
|
|
typeof(KeyBindTag),
|
|
]);
|
|
|
|
ApplyTransparentStyle();
|
|
}
|
|
|
|
private void ApplyTransparentStyle()
|
|
{
|
|
var styleBox = new StyleBoxFlat
|
|
{
|
|
BackgroundColor = Color.FromHex("#1a1a1a").WithAlpha(0.85f),
|
|
BorderColor = Color.FromHex("#3a3a3a"),
|
|
BorderThickness = new Thickness(1),
|
|
ContentMarginLeftOverride = 0,
|
|
ContentMarginRightOverride = 0,
|
|
ContentMarginTopOverride = 0,
|
|
ContentMarginBottomOverride = 0,
|
|
};
|
|
|
|
BackgroundPanel.PanelOverride = styleBox;
|
|
}
|
|
|
|
private void InitializeEvents()
|
|
{
|
|
OkayButton.OnPressed += OnOkayPressed;
|
|
}
|
|
|
|
private void OnOkayPressed(BaseButton.ButtonEventArgs args)
|
|
{
|
|
Close();
|
|
}
|
|
|
|
public void Close()
|
|
{
|
|
if (Parent == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
var dontShowAgain = DontShowAgain;
|
|
Parent.RemoveChild(this);
|
|
OnClose?.Invoke(dontShowAgain);
|
|
}
|
|
}
|