DFLayoutStringFieldProperties.cs 1.5 KB

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