private void FillTunnelingObjects()
        {
            List <string> availableObjects = AvailableNamedObjectsAndFiles.GetAvailableObjects(false, true, GlueState.Self.CurrentElement, null);

            foreach (string availableObject in availableObjects)
            {
                this.TunnelingObjectComboBox.Items.Add(availableObject);
            }
        }
        private void UpdateIncludedAndExcluded(EventResponseSave instance)
        {
            ////////////////////Early Out/////////////////////////
            if (instance == null)
            {
                return;
            }
            ///////////////////End Early Out///////////////////////
            ResetToDefault();

            ExcludeMember("ToStringDelegate");
            ExcludeMember("Contents");

            AvailableCustomVariables typeConverter = new AvailableCustomVariables(CurrentElement);

            typeConverter.IncludeNone = false;

            typeConverter.InclusionPredicate = DoesCustomVariableCreateEvent;
            IncludeMember(typeof(EventResponseSave).GetProperty("SourceVariable").Name,
                          typeof(EventResponseSave), typeConverter);


            if (string.IsNullOrEmpty(instance.SourceVariable))
            {
                ExcludeMember(typeof(EventResponseSave).GetProperty("BeforeOrAfter").Name);
            }



            AvailableNamedObjectsAndFiles availableNamedObjects = new AvailableNamedObjectsAndFiles(
                CurrentElement);

            availableNamedObjects.IncludeReferencedFiles = false;
            IncludeMember(typeof(EventResponseSave).GetProperty("SourceObject").Name,
                          typeof(EventResponseSave),
                          availableNamedObjects);

            AvailableEvents availableEvents = new AvailableEvents();

            availableEvents.Element         = CurrentElement;
            availableEvents.NamedObjectSave = CurrentElement.GetNamedObjectRecursively(instance.SourceObject);
            IncludeMember(typeof(EventResponseSave).GetProperty("SourceObjectEvent").Name,
                          typeof(EventResponseSave),
                          availableEvents);
        }
Esempio n. 3
0
        private TypeConverter HandleGetTypeConverter(IElement container, NamedObjectSave instance, TypedMemberBase typedMember)
        {
            Type   memberType = typedMember.MemberType;
            string memberName = typedMember.MemberName;

            TypeConverter typeConverter = null;

            // If the NOS references a FRB type, we need to adjust the type appropriately

            bool wasTypeModified = false;
            Type oldType         = memberType;

            bool handled = false;



            if (instance.SourceType == SourceType.FlatRedBallType)
            {
                Type type = TypeManager.GetTypeFromString(instance.SourceClassType);

                if (type == typeof(Sprite) && memberName == "CurrentChainName")
                {
                    // special case handling for CurrentChainName
                    typeConverter = new AvailableAnimationChainsStringConverter(container, instance);

                    handled = true;
                }
                else if (typedMember.MemberType?.Name == "Sprite")
                {
                    var nosTypeConverter = new AvailableNamedObjectsAndFiles(container);
                    nosTypeConverter.NamedObjectTypeRestriction = "FlatRedBall.Sprite";
                    typeConverter = nosTypeConverter;
                    handled       = true;
                }
            }
            else if (instance.SourceType == SourceType.File)
            {
                if (instance.ClassType == "Sprite" && memberName == "CurrentChainName")
                {
                    // special case handling for CurrentChainName
                    typeConverter = new AvailableAnimationChainsStringConverter(container, instance);

                    handled = true;
                }
            }

            if (!handled)
            {
                if (instance.DoesMemberNeedToBeSetByContainer(memberName))
                {
                    var availableNamedObjectsAndFiles = new AvailableNamedObjectsAndFiles(container);
                    availableNamedObjectsAndFiles.NamedObjectTypeRestriction = typedMember.MemberType.FullName;
                    typeConverter = availableNamedObjectsAndFiles;
                }
                else if (memberType.IsEnum)
                {
                    typeConverter = new EnumConverter(memberType);
                }
                else if (memberType == typeof(Microsoft.Xna.Framework.Color))
                {
                    typeConverter = new AvailableColorTypeConverter();
                    memberType    = typeof(string);
                }
                else if (IsTypeFile(typedMember))
                {
                    AvailableFileStringConverter availableFileStringConverter = new AvailableFileStringConverter(container);
                    availableFileStringConverter.QualifiedRuntimeTypeName = memberType.FullName;
                    if (!string.IsNullOrEmpty(typedMember.CustomTypeName))
                    {
                        availableFileStringConverter.QualifiedRuntimeTypeName = typedMember.CustomTypeName;
                    }
                    availableFileStringConverter.RemovePathAndExtension = true;
                    typeConverter = availableFileStringConverter;

                    memberType = typeof(string);
                }
                else if (instance.SourceType == SourceType.Entity && !string.IsNullOrEmpty(instance.SourceClassType))
                {
                    EntitySave entity = ObjectFinder.Self.GetEntitySave(instance.SourceClassType);

                    if (entity != null)
                    {
                        CustomVariable customVariable = entity.GetCustomVariable(memberName);

                        if (customVariable != null)
                        {
                            typeConverter = customVariable.GetTypeConverter(entity);
                        }
                    }
                }
            }
            //else if (this.SourceType == SaveClasses.SourceType.FlatRedBallType &&
            //    typedMember != null && typedMember.MemberType != null)
            //{

            //}

            if (wasTypeModified)
            {
                memberType = oldType;
            }

            return(typeConverter);
        }
Esempio n. 4
0
        private TypeConverter HandleGetTypeConverter(IElement container, NamedObjectSave instance, TypedMemberBase typedMember)
        {
            Type   memberType = typedMember.MemberType;
            string memberName = typedMember.MemberName;

            TypeConverter typeConverter = null;

            // If the NOS references a FRB type, we need to adjust the type appropriately

            bool wasTypeModified = false;
            Type oldType         = memberType;

            bool handled = false;



            if (instance.SourceType == SourceType.FlatRedBallType)
            {
                Type type = TypeManager.GetTypeFromString(instance.SourceClassType);

                if (type == typeof(Sprite) && memberName == "CurrentChainName")
                {
                    // special case handling for CurrentChainName
                    typeConverter = new AvailableAnimationChainsStringConverter(container, instance);

                    handled = true;
                }

                // Victor Chelaru
                // October 26, 2015:
                // I don't think we need this anymore - we should just let the CSVs do their job
                // defining variables and not rely on reflection. That way plugins will be able to
                // handle everything without relying on reflection
                //if (!handled && type != null)
                //{
                //    FieldInfo fieldInfo = type.GetField(memberName);
                //    if (fieldInfo != null)
                //    {
                //        memberType = fieldInfo.FieldType;
                //        wasTypeModified = true;
                //    }

                //    if (wasTypeModified == false)
                //    {
                //        PropertyInfo propertyInfo = type.GetProperty(memberName);
                //        if (propertyInfo != null)
                //        {
                //            memberType = propertyInfo.PropertyType;
                //            wasTypeModified = true;
                //        }

                //    }
                //}
            }
            else if (instance.SourceType == SourceType.File)
            {
                if (instance.ClassType == "Sprite" && memberName == "CurrentChainName")
                {
                    // special case handling for CurrentChainName
                    typeConverter = new AvailableAnimationChainsStringConverter(container, instance);

                    handled = true;
                }
            }

            if (!handled)
            {
                if (instance.DoesMemberNeedToBeSetByContainer(memberName))
                {
                    var availableNamedObjectsAndFiles = new AvailableNamedObjectsAndFiles(container);
                    availableNamedObjectsAndFiles.NamedObjectTypeRestriction = typedMember.MemberType.FullName;
                    typeConverter = availableNamedObjectsAndFiles;
                }
                else if (memberType.IsEnum)
                {
                    typeConverter = new EnumConverter(memberType);
                }
                else if (memberType == typeof(Microsoft.Xna.Framework.Color))
                {
                    typeConverter = new AvailableColorTypeConverter();
                    memberType    = typeof(string);
                }
                else if (IsTypeFile(typedMember))
                {
                    AvailableFileStringConverter availableFileStringConverter = new AvailableFileStringConverter(container);
                    availableFileStringConverter.QualifiedRuntimeTypeName = memberType.FullName;
                    if (!string.IsNullOrEmpty(typedMember.CustomTypeName))
                    {
                        availableFileStringConverter.QualifiedRuntimeTypeName = typedMember.CustomTypeName;
                    }
                    availableFileStringConverter.RemovePathAndExtension = true;
                    typeConverter = availableFileStringConverter;

                    memberType = typeof(string);
                }
                else if (instance.SourceType == SourceType.Entity && !string.IsNullOrEmpty(instance.SourceClassType))
                {
                    EntitySave entity = ObjectFinder.Self.GetEntitySave(instance.SourceClassType);

                    if (entity != null)
                    {
                        CustomVariable customVariable = entity.GetCustomVariable(memberName);

                        if (customVariable != null)
                        {
                            typeConverter = customVariable.GetTypeConverter(entity);
                        }
                    }
                }
            }
            //else if (this.SourceType == SaveClasses.SourceType.FlatRedBallType &&
            //    typedMember != null && typedMember.MemberType != null)
            //{

            //}

            if (wasTypeModified)
            {
                memberType = oldType;
            }

            return(typeConverter);
        }