FlatRedBall.Glue.GuiDisplay.NamedObjectPropertyGridDisplayer.ExcludeAndIncludeGlueVariables C# (CSharp) Method

ExcludeAndIncludeGlueVariables() private method

private ExcludeAndIncludeGlueVariables ( NamedObjectSave instance ) : void
instance FlatRedBall.Glue.SaveClasses.NamedObjectSave
return void
        private void ExcludeAndIncludeGlueVariables(NamedObjectSave instance)
        {

            bool shouldIncludeSourceClassType = true;
            bool shouldIncludeSourceFile = true;
            bool shouldIncludeSourceName = true;
            bool shouldIncludeSourceClassGenericType = true;
            bool shouldShowCurrentState = true;
            bool shouldIncludeIncludeInIVisible = true;
            bool shouldIncludeIncludeInIClickable = true;
            bool shouldIncludeIsContainer = true;
            bool shouldShowIsZBuffered = false;
            bool shouldIncludeSetByContainer = true;
            bool shouldShowGenerateTimedEmit = false;

            ExcludeMember("InstructionSaves");
            ExcludeMember("Properties");
            ExcludeMember("FileCreatedBy");
            ExcludeMember("FulfillsRequirement");
            ExcludeMember("IsNodeHidden");


            if (DisplayMode == DisplayModes.VariablesOnly)
            {
                ExcludeAllMembers();
            }
            else
            {

                if (DisplayMode != DisplayModes.Debug)
                {
                    ExcludeMember("InstantiatedByBase");
                }

                var containerType = instance.GetContainerType();

                // Screens can't be IVisible/IClickable so no need to show these properties
                // in screens
                shouldIncludeIncludeInIVisible = containerType == ContainerType.Entity;
                shouldIncludeIncludeInIClickable = containerType == ContainerType.Entity;

                bool shouldShowAttachToContainer = containerType == ContainerType.Entity &&
                    instance.IsList == false;
                // Not sure if we want to keep this or not, but currently objects in Entities can't be attached to the Camera
                bool shouldShowAttachToCamera = instance.GetContainerType() == ContainerType.Screen;

                if (!shouldShowAttachToContainer)
                {
                    this.ExcludeMember("AttachToContainer");
                }


                if (!shouldShowAttachToCamera)
                {
                    ExcludeMember("AttachToCamera");
                }

                if (instance.SourceType == SaveClasses.SourceType.FlatRedBallType && instance.SourceClassType == "Layer")
                {

                }

                // We used to not show the AddToManagers property for objects inside Entities, but as I worked on SteamBirds
                // I found myself needing it.
                //else if (ContainerType == ContainerType.Entity)
                //{
                //    ExcludeMember("AddToManagers");
                //}

                if (instance.SetByDerived)
                {
                    ExcludeMember("AttachToContainer");
                }
                if (instance.InstantiatedByBase)
                {
                    ExcludeMember("SourceType");
                    shouldIncludeSourceClassType = false;
                    shouldIncludeSourceClassGenericType = false;

                    ExcludeMember("InstanceName");
                    ExcludeMember("CallActivity");
                    ExcludeMember("IgnoresPausing");
                    ExcludeMember("HasPublicProperty");
                    ExcludeMember("ExposedInDerived");

                    ExcludeMember("SetByDerived");
                    ExcludeMember("SetByContainer");
                }

                bool shouldIncludeAddToManagers = !instance.InstantiatedByBase && !instance.IsList;
                if (!shouldIncludeAddToManagers)
                {
                    ExcludeMember("AddToManagers");
                }

                UpdateLayerIncludeAndExclude(instance);

                if (containerType != ContainerType.Entity)
                {
                    shouldIncludeIsContainer = false;
                    shouldIncludeSetByContainer = false;
                }

                #region Camera-related properties

                if (instance.SourceType != SaveClasses.SourceType.FlatRedBallType || instance.SourceClassType != "Camera")
                {
                    ExcludeMember("IsNewCamera");
                }

                #endregion

                #region Text-related properties

                if (instance.SourceType != SaveClasses.SourceType.FlatRedBallType || instance.SourceClassType != "Text")
                {
                    ExcludeMember("IsPixelPerfect");
                }

                #endregion

                
                                        // we don't show this on files because Sprites from file will be put on the z buffer according to the
                                        // file.
                shouldShowIsZBuffered = instance.SourceType == SourceType.FlatRedBallType &&
                    (instance.SourceClassType != "Sprite" || instance.SourceClassType != "SpriteFrame");

                shouldShowGenerateTimedEmit = 
                    (instance.SourceType == SourceType.FlatRedBallType && instance.SourceClassType == "Emitter") ||
                    (instance.SourceType == SourceType.File && instance.ClassType == "Emitter");

                #region Remove based off of SourceType

                if (instance.SourceType == SourceType.FlatRedBallType)
                {
                    shouldShowCurrentState = false;
                    shouldIncludeSourceFile = false;
                    shouldIncludeSourceName = false;

                    if (!instance.IsGenericType)
                    {
                        shouldIncludeSourceClassGenericType = false;
                    }
                }
                else if (instance.SourceType == SourceType.File)
                {
                    shouldShowCurrentState = false;
                    shouldIncludeSourceClassType = false;
                    shouldIncludeSourceClassGenericType = false;

                }
                else if (instance.SourceType == SourceType.Entity)
                {
                    shouldIncludeSourceFile = false;
                    shouldIncludeSourceName = false;
                    shouldIncludeSourceClassGenericType = false;



                    shouldShowCurrentState = DetermineIfShouldShowStates(instance);
                }

                #endregion


                if (shouldIncludeSourceClassType)
                {
                    IncludeMember("SourceClassType", typeof(NamedObjectSave), new AvailableClassTypeConverter(instance));
                }
                else
                {
                    ExcludeMember("SourceClassType");
                }

                if (shouldIncludeSourceFile)
                {
                    IncludeMember("SourceFile", typeof(NamedObjectSave), new AvailableFileStringConverter(CurrentElement));
                }
                else
                {
                    ExcludeMember("SourceFile");
                }

                if(shouldShowGenerateTimedEmit)
                {
                    IncludeMember(nameof(instance.GenerateTimedEmit), typeof(NamedObjectSave));
                }
                else
                {
                    ExcludeMember(nameof(instance.GenerateTimedEmit));
                }

                if (shouldIncludeSourceName)
                {
                    IncludeMember("SourceName", typeof(NamedObjectSave), new AvailableNameablesStringConverter(instance));
                }
                else
                {
                    ExcludeMember("SourceName");
                }

                if (shouldIncludeSourceClassGenericType)
                {
                    IncludeMember("SourceClassGenericType", typeof(NamedObjectSave), new AvailableClassGenericTypeConverter());
                }
                else
                {
                    ExcludeMember("SourceClassGenericType");
                }

                if (shouldShowCurrentState)
                {
                    IncludeMember("CurrentState", typeof(NamedObjectSave),
                        new AvailableStates(CurrentNamedObject, CurrentElement, CurrentCustomVariable, CurrentStateSave));
                }
                else
                {
                    ExcludeMember("CurrentState");
                }

                if (!shouldIncludeIncludeInIClickable)
                {
                    ExcludeMember("IncludeInIClickable");
                }
                if (!shouldIncludeIncludeInIVisible)
                {
                    ExcludeMember("IncludeInIVisible");
                }

                if (!shouldShowIsZBuffered)
                {
                    ExcludeMember("IsZBuffered");
                }
                if (!shouldIncludeSetByContainer)
                {
                    ExcludeMember("SetByContainer");
                }
                //else if (this.SourceType == SourceType.SetByParentContainer)
                //{
                //    ExcludeMember("SourceFile");
                //    ExcludeMember("SourceName");
                //    ExcludeMember("SourceClassGenericType");
                //    ExcludeMember("AddToManagers");
                //}
            }
        }