QuickDialogOpenEvent.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. using Robust.Shared.Serialization;
  2. namespace Content.Shared.Administration;
  3. /// <summary>
  4. /// A networked event raised when the server wants to open a quick dialog.
  5. /// </summary>
  6. [Serializable, NetSerializable]
  7. public sealed class QuickDialogOpenEvent : EntityEventArgs
  8. {
  9. /// <summary>
  10. /// The title of the dialog.
  11. /// </summary>
  12. public string Title;
  13. /// <summary>
  14. /// The internal dialog ID.
  15. /// </summary>
  16. public int DialogId;
  17. /// <summary>
  18. /// The prompts to show the user.
  19. /// </summary>
  20. public List<QuickDialogEntry> Prompts;
  21. /// <summary>
  22. /// The buttons presented for the user.
  23. /// </summary>
  24. public QuickDialogButtonFlag Buttons = QuickDialogButtonFlag.OkButton | QuickDialogButtonFlag.CancelButton;
  25. public QuickDialogOpenEvent(string title, List<QuickDialogEntry> prompts, int dialogId, QuickDialogButtonFlag buttons)
  26. {
  27. Title = title;
  28. Prompts = prompts;
  29. Buttons = buttons;
  30. DialogId = dialogId;
  31. }
  32. }
  33. /// <summary>
  34. /// A networked event raised when the client replies to a quick dialog.
  35. /// </summary>
  36. [Serializable, NetSerializable]
  37. public sealed class QuickDialogResponseEvent : EntityEventArgs
  38. {
  39. /// <summary>
  40. /// The internal dialog ID.
  41. /// </summary>
  42. public int DialogId;
  43. /// <summary>
  44. /// The responses to the prompts.
  45. /// </summary>
  46. public Dictionary<string, string> Responses;
  47. /// <summary>
  48. /// The button pressed when responding.
  49. /// </summary>
  50. public QuickDialogButtonFlag ButtonPressed;
  51. public QuickDialogResponseEvent(int dialogId, Dictionary<string, string> responses, QuickDialogButtonFlag buttonPressed)
  52. {
  53. DialogId = dialogId;
  54. Responses = responses;
  55. ButtonPressed = buttonPressed;
  56. }
  57. }
  58. /// <summary>
  59. /// An entry in a quick dialog.
  60. /// </summary>
  61. [Serializable, NetSerializable]
  62. public sealed class QuickDialogEntry
  63. {
  64. /// <summary>
  65. /// ID of the dialog field.
  66. /// </summary>
  67. public string FieldId;
  68. /// <summary>
  69. /// Type of the field, for checks.
  70. /// </summary>
  71. public QuickDialogEntryType Type;
  72. /// <summary>
  73. /// The prompt to show the user.
  74. /// </summary>
  75. public string Prompt;
  76. /// <summary>
  77. /// String to replace the type-specific placeholder with.
  78. /// </summary>
  79. public string? Placeholder;
  80. public QuickDialogEntry(string fieldId, QuickDialogEntryType type, string prompt, string? placeholder = null)
  81. {
  82. FieldId = fieldId;
  83. Type = type;
  84. Prompt = prompt;
  85. Placeholder = placeholder;
  86. }
  87. }
  88. /// <summary>
  89. /// The buttons available in a quick dialog.
  90. /// </summary>
  91. [Flags]
  92. public enum QuickDialogButtonFlag
  93. {
  94. OkButton = 1,
  95. CancelButton = 2,
  96. }
  97. /// <summary>
  98. /// The entry types for a quick dialog.
  99. /// </summary>
  100. public enum QuickDialogEntryType
  101. {
  102. /// <summary>
  103. /// Any integer.
  104. /// </summary>
  105. Integer,
  106. /// <summary>
  107. /// Any floating point value.
  108. /// </summary>
  109. Float,
  110. /// <summary>
  111. /// Maximum of 100 characters string.
  112. /// </summary>
  113. ShortText,
  114. /// <summary>
  115. /// Maximum of 2,000 characters string.
  116. /// </summary>
  117. LongText,
  118. }