namespace InABox.Core
{
    
    public class DFLayoutStringFieldProperties : DFLayoutFieldProperties<string, string?>
    {
        
        [EditorSequence(-995)]
        [TextBoxEditor]
        public override string Default { get; set; }
        
        [EditorSequence(3)]
        [CheckBoxEditor(Caption = "Allow Wrap?")]
        public bool TextWrapping { get; set; } = false;

        [EditorSequence(4)]
        [CheckBoxEditor(Caption = "Popup Editor?")]
        public bool PopupEditor { get; set; } = false;

        public override string? DeserializeValue(DFLoadStorageEntry entry)
        {
            return entry.GetValue<string>();
        }

        public override void SerializeValue(DFSaveStorageEntry entry, string? value)
        {
            entry.SetValue(value);
        }

        public override string GetValue(string? value)
        {
            return value ?? Default;
        }

        public override string FormatValue(string? value)
        {
            return value ?? string.Empty;
        }

        protected override void LoadProperties()
        {
            base.LoadProperties();
            PopupEditor = GetProperty(nameof(PopupEditor), false);
            TextWrapping = GetProperty(nameof(TextWrapping), false);
        }

        protected override void SaveProperties()
        {
            base.SaveProperties();
            SetProperty(nameof(PopupEditor), PopupEditor);
            SetProperty(nameof(TextWrapping), TextWrapping);
        }
    }
}