DFLayoutStringFieldProperties.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. namespace InABox.Core
  2. {
  3. public class DFLayoutStringFieldProperties : DFLayoutFieldProperties<string, string?>
  4. {
  5. [EditorSequence(3)]
  6. [CheckBoxEditor(Caption = "Allow Wrap?")]
  7. public bool TextWrapping { get; set; }
  8. [EditorSequence(4)]
  9. [CheckBoxEditor(Caption = "Popup Editor?")]
  10. public bool PopupEditor { get; set; }
  11. protected override void Init()
  12. {
  13. base.Init();
  14. PopupEditor = false;
  15. TextWrapping = false;
  16. }
  17. public override string? DeserializeValue(DFLoadStorageEntry entry)
  18. {
  19. return entry.GetValue<string>();
  20. }
  21. public override void SerializeValue(DFSaveStorageEntry entry, string? value)
  22. {
  23. entry.SetValue(value);
  24. }
  25. public override string GetValue(string? value)
  26. {
  27. return value ?? Default;
  28. }
  29. public override string FormatValue(string? value)
  30. {
  31. return value ?? "";
  32. }
  33. protected override void LoadProperties()
  34. {
  35. base.LoadProperties();
  36. PopupEditor = GetProperty(nameof(PopupEditor), false);
  37. TextWrapping = GetProperty(nameof(TextWrapping), false);
  38. }
  39. protected override void SaveProperties()
  40. {
  41. base.SaveProperties();
  42. SetProperty(nameof(PopupEditor), PopupEditor);
  43. SetProperty(nameof(TextWrapping), TextWrapping);
  44. }
  45. }
  46. }