private static void TryDisplayVariableSave(List <InstanceSavePropertyDescriptor> pdc, ElementSave elementSave, InstanceSave instanceSave, AmountToDisplay amountToDisplay, VariableSave defaultVariable) { ElementSave container = elementSave; if (instanceSave != null) { container = instanceSave.ParentContainer; } // Not sure why we were passing elementSave to this function: // I added a container object //bool shouldInclude = GetIfShouldInclude(defaultVariable, elementSave, instanceSave, ses); bool shouldInclude = Gum.Logic.VariableSaveLogic.GetIfVariableIsActive(defaultVariable, container, instanceSave); shouldInclude &= ( string.IsNullOrEmpty(defaultVariable.SourceObject) || amountToDisplay == AmountToDisplay.AllVariables || !string.IsNullOrEmpty(defaultVariable.ExposedAsName)); if (shouldInclude) { TypeConverter typeConverter = defaultVariable.GetTypeConverter(elementSave); Attribute[] customAttributes = GetAttributesForVariable(defaultVariable); string category = null; if (!string.IsNullOrEmpty(defaultVariable.Category)) { category = defaultVariable.Category; } else if (!string.IsNullOrEmpty(defaultVariable.ExposedAsName)) { category = "Exposed"; } //Type type = typeof(string); Type type = Gum.Reflection.TypeManager.Self.GetTypeFromString(defaultVariable.Type); string name = defaultVariable.Name; if (!string.IsNullOrEmpty(defaultVariable.ExposedAsName)) { name = defaultVariable.ExposedAsName; } var property = mHelper.AddProperty(pdc, name, type, typeConverter, //, customAttributes ); property.Category = category; } }
private static PropertyDescriptorCollection TryDisplayVariableSave(PropertyDescriptorCollection pdc, ElementSave elementSave, InstanceSave instanceSave, AmountToDisplay amountToDisplay, StandardElementSave ses, VariableSave defaultVariable) { ElementSave container = elementSave; if (instanceSave != null) { container = instanceSave.ParentContainer; } // Not sure why we were passing elementSave to this function: // I added a container object //bool shouldInclude = GetIfShouldInclude(defaultVariable, elementSave, instanceSave, ses); bool shouldInclude = GetIfShouldInclude(defaultVariable, container, instanceSave, ses); shouldInclude &= ( string.IsNullOrEmpty(defaultVariable.SourceObject) || amountToDisplay == AmountToDisplay.AllVariables || !string.IsNullOrEmpty(defaultVariable.ExposedAsName)); if (shouldInclude) { TypeConverter typeConverter = defaultVariable.GetTypeConverter(elementSave); Attribute[] customAttributes = GetAttributesForVariable(defaultVariable); //Type type = typeof(string); Type type = Gum.Reflection.TypeManager.Self.GetTypeFromString(defaultVariable.Type); string name = defaultVariable.Name; if (!string.IsNullOrEmpty(defaultVariable.ExposedAsName)) { name = defaultVariable.ExposedAsName; } pdc = mHelper.AddProperty(pdc, name, type, typeConverter, //, customAttributes ); } return(pdc); }
public static TypeConverter GetTypeConverter(this VariableSave variableSave, ElementSave container = null) { ElementSave categoryContainer; StateSaveCategory category; if (variableSave.CustomTypeConverter != null) { return(variableSave.CustomTypeConverter); } else if (variableSave.IsFont) { return(new FontTypeConverter()); } else if (variableSave.Name == "Guide") { AvailableGuidesTypeConverter availableGuidesTypeConverter = new AvailableGuidesTypeConverter(); availableGuidesTypeConverter.GumProjectSave = ObjectFinder.Self.GumProjectSave; availableGuidesTypeConverter.ShowNewGuide = false; return(availableGuidesTypeConverter); } else if (variableSave.IsState(container, out categoryContainer, out category)) { string categoryName = null; if (category != null) { categoryName = category.Name; } AvailableStatesConverter converter = new AvailableStatesConverter(categoryName); converter.ElementSave = categoryContainer; return(converter); } else { // We should see if it's an exposed variable, and if so, let's look to the source object's type converters bool foundInRoot = false; if (!string.IsNullOrEmpty(variableSave.SourceObject) && container != null) { InstanceSave instance = container.GetInstance(variableSave.SourceObject); if (instance != null) { // see if the instance has a variable var foundElementSave = ObjectFinder.Self.GetRootStandardElementSave(instance); if (foundElementSave != null) { VariableSave rootVariableSave = foundElementSave.DefaultState.GetVariableSave(variableSave.GetRootName()); if (rootVariableSave != null) { return(rootVariableSave.GetTypeConverter((ElementSave)null)); } } } } } Type type = variableSave.GetRuntimeType(); return(variableSave.GetTypeConverter(type)); }