1
0

FlavorText.xaml.cs 864 B

12345678910111213141516171819202122232425262728
  1. using Robust.Client.AutoGenerated;
  2. using Robust.Client.UserInterface;
  3. using Robust.Client.UserInterface.XAML;
  4. using Robust.Shared.Utility;
  5. namespace Content.Client.FlavorText
  6. {
  7. [GenerateTypedNameReferences]
  8. public sealed partial class FlavorText : Control
  9. {
  10. public Action<string>? OnFlavorTextChanged;
  11. public FlavorText()
  12. {
  13. RobustXamlLoader.Load(this);
  14. IoCManager.InjectDependencies(this);
  15. var loc = IoCManager.Resolve<ILocalizationManager>();
  16. CFlavorTextInput.Placeholder = new Rope.Leaf(loc.GetString("flavor-text-placeholder"));
  17. CFlavorTextInput.OnTextChanged += _ => FlavorTextChanged();
  18. }
  19. public void FlavorTextChanged()
  20. {
  21. OnFlavorTextChanged?.Invoke(Rope.Collapse(CFlavorTextInput.TextRope).Trim());
  22. }
  23. }
  24. }