namespace InABox.Core
{
    public class DFLayoutOptionFieldProperties : DFLayoutFieldProperties<string, string?>
    {
        
        [EditorSequence(-995)]
        [TextBoxEditor]
        public override string Default { get; set; }
        
        public DFLayoutOptionFieldProperties()
        {
            Options = "";
            OptionType = DFLayoutOptionType.Combo;
        }

        [MemoEditor]
        [EditorSequence(1)]
        public string Options { get; set; }

        [EnumLookupEditor(typeof(DFLayoutOptionType))]
        [EditorSequence(2)]
        public DFLayoutOptionType OptionType { get; set; }

        protected override void LoadProperties()
        {
            base.LoadProperties();
            Options = GetProperty("Options", "");
            OptionType = GetProperty("OptionType", DFLayoutOptionType.Combo);
        }

        protected override void SaveProperties()
        {
            base.SaveProperties();
            SetProperty("Options", Options);
            SetProperty("OptionType", OptionType);
        }

        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;
        }
    }
}