ConfigurationComponent.cs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. using System.Text.RegularExpressions;
  2. using Content.Shared.Tools;
  3. using Content.Shared.Tools.Systems;
  4. using Robust.Shared.GameStates;
  5. using Robust.Shared.Serialization;
  6. using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
  7. namespace Content.Shared.Configurable
  8. {
  9. [RegisterComponent, NetworkedComponent]
  10. public sealed partial class ConfigurationComponent : Component
  11. {
  12. [DataField("config")]
  13. public Dictionary<string, string?> Config = new();
  14. [DataField("qualityNeeded", customTypeSerializer: typeof(PrototypeIdSerializer<ToolQualityPrototype>))]
  15. public string QualityNeeded = SharedToolSystem.PulseQuality;
  16. [DataField("validation")]
  17. public Regex Validation = new("^[a-zA-Z0-9 ]*$", RegexOptions.Compiled);
  18. [Serializable, NetSerializable]
  19. public sealed class ConfigurationBoundUserInterfaceState : BoundUserInterfaceState
  20. {
  21. public Dictionary<string, string?> Config { get; }
  22. public ConfigurationBoundUserInterfaceState(Dictionary<string, string?> config)
  23. {
  24. Config = config;
  25. }
  26. }
  27. /// <summary>
  28. /// Message data sent from client to server when the device configuration is updated.
  29. /// </summary>
  30. [Serializable, NetSerializable]
  31. public sealed class ConfigurationUpdatedMessage : BoundUserInterfaceMessage
  32. {
  33. public Dictionary<string, string> Config { get; }
  34. public ConfigurationUpdatedMessage(Dictionary<string, string> config)
  35. {
  36. Config = config;
  37. }
  38. }
  39. [Serializable, NetSerializable]
  40. public sealed class ValidationUpdateMessage : BoundUserInterfaceMessage
  41. {
  42. public string ValidationString { get; }
  43. public ValidationUpdateMessage(string validationString)
  44. {
  45. ValidationString = validationString;
  46. }
  47. }
  48. [Serializable, NetSerializable]
  49. public enum ConfigurationUiKey
  50. {
  51. Key
  52. }
  53. }
  54. }