63 lines
2.1 KiB
C#
63 lines
2.1 KiB
C#
using Content.Sunrise.Interfaces.Shared;
|
|
using Robust.Client.AutoGenerated;
|
|
using Robust.Client.UserInterface;
|
|
using Robust.Client.UserInterface.XAML;
|
|
using Robust.Shared.Utility;
|
|
|
|
namespace Content.Client.FlavorText
|
|
{
|
|
[GenerateTypedNameReferences]
|
|
public sealed partial class FlavorText : Control
|
|
{
|
|
public Action<string>? OnFlavorTextChanged;
|
|
|
|
private readonly ISharedSponsorsManager? _sponsorsMgr; // Sunrise-Sponsors
|
|
|
|
public FlavorText(ISharedSponsorsManager? sponsorsMgr, bool sponsorOnly, int baseMaxDescLength) // Sunrise-Edit
|
|
{
|
|
RobustXamlLoader.Load(this);
|
|
IoCManager.InjectDependencies(this);
|
|
|
|
_sponsorsMgr = sponsorsMgr;
|
|
|
|
var loc = IoCManager.Resolve<ILocalizationManager>();
|
|
CFlavorTextInput.Placeholder = new Rope.Leaf(loc.GetString("flavor-text-placeholder"));
|
|
CFlavorTextInput.OnTextChanged += _ => FlavorTextChanged();
|
|
|
|
if (_sponsorsMgr != null && _sponsorsMgr.ClientAllowedFlavor())
|
|
{
|
|
var maxDescLength = _sponsorsMgr.ClientGetSizeFlavor();
|
|
LimitLabel.Text = $"{maxDescLength}";
|
|
}
|
|
else
|
|
{
|
|
LimitLabel.Text = $"{baseMaxDescLength}";
|
|
}
|
|
// Sunrise-Start
|
|
if (!sponsorOnly || _sponsorsMgr == null)
|
|
{
|
|
SponsorOnlyNotify.Visible = false;
|
|
CFlavorTextInput.Visible = true;
|
|
LimitBox.Visible = true;
|
|
}
|
|
else if (_sponsorsMgr.ClientAllowedFlavor())
|
|
{
|
|
SponsorOnlyNotify.Visible = false;
|
|
CFlavorTextInput.Visible = true;
|
|
LimitBox.Visible = true;
|
|
}
|
|
else
|
|
{
|
|
SponsorOnlyNotify.Visible = true;
|
|
CFlavorTextInput.Visible = false;
|
|
LimitBox.Visible = false;
|
|
}
|
|
// Sunrise-End
|
|
}
|
|
|
|
public void FlavorTextChanged()
|
|
{
|
|
OnFlavorTextChanged?.Invoke(Rope.Collapse(CFlavorTextInput.TextRope).Trim());
|
|
}
|
|
}
|
|
}
|