Exemplo n.º 1
0
 public override bool CanConvert(Type objectType) => SettingsUtils.IsDropdown(objectType);
        public SettingsPropertyDefinition(IEnumerable <IPropertyDefinitionBase> propertyDefinitions, IPropertyGroupDefinition propertyGroupDefinition, IRef propertyReference)
        {
            GroupName    = propertyGroupDefinition.GroupName;
            IsMainToggle = propertyGroupDefinition.IsMainToggle;
            GroupOrder   = propertyGroupDefinition.GroupOrder;

            PropertyReference = propertyReference;

            if (PropertyReference.Type == typeof(bool))
            {
                SettingType = SettingType.Bool;
            }
            else if (PropertyReference.Type == typeof(int))
            {
                SettingType = SettingType.Int;
            }
            else if (PropertyReference.Type == typeof(float))
            {
                SettingType = SettingType.Float;
            }
            else if (PropertyReference.Type == typeof(string))
            {
                SettingType = SettingType.String;
            }
            else if (SettingsUtils.IsDropdown(PropertyReference.Type))
            {
                SettingType = SettingType.Dropdown;
            }

            foreach (var propertyDefinition in propertyDefinitions)
            {
                if (propertyDefinition is IPropertyDefinitionBase propertyBase)
                {
                    DisplayName    = new TextObject(propertyBase.DisplayName, null).ToString();
                    Order          = propertyBase.Order;
                    RequireRestart = propertyBase.RequireRestart;
                    HintText       = new TextObject(propertyBase.HintText, null).ToString();
                }
                if (propertyDefinition is SettingPropertyAttribute settingPropertyAttribute) // v1
                {
                    MinValue         = settingPropertyAttribute.MinValue;
                    MaxValue         = settingPropertyAttribute.MaxValue;
                    EditableMinValue = settingPropertyAttribute.MinValue;
                    EditableMaxValue = settingPropertyAttribute.MaxValue;
                }
                if (propertyDefinition is IPropertyDefinitionBool propertyDefinitionBool) // v2
                {
                }
                if (propertyDefinition is IPropertyDefinitionWithMinMax propertyDefinitionWithMinMax)
                {
                    MinValue         = propertyDefinitionWithMinMax.MinValue;
                    MaxValue         = propertyDefinitionWithMinMax.MaxValue;
                    EditableMinValue = propertyDefinitionWithMinMax.MinValue;
                    EditableMaxValue = propertyDefinitionWithMinMax.MaxValue;
                }
                if (propertyDefinition is IPropertyDefinitionWithEditableMinMax propertyDefinitionWithEditableMinMax)
                {
                    EditableMinValue = propertyDefinitionWithEditableMinMax.EditableMinValue;
                    EditableMaxValue = propertyDefinitionWithEditableMinMax.EditableMaxValue;
                }
                if (propertyDefinition is IPropertyDefinitionWithFormat propertyDefinitionWithFormat)
                {
                    ValueFormat = propertyDefinitionWithFormat.ValueFormat;
                }
                if (propertyDefinition is IPropertyDefinitionText propertyDefinitionText)
                {
                }
                if (propertyDefinition is IPropertyDefinitionDropdown propertyDefinitionDropdown)
                {
                    SelectedIndex = propertyDefinitionDropdown.SelectedIndex;
                }
            }
        }