Beispiel #1
0
        public static void AddNamedObjectToCurrentNamedObjectList(NamedObjectSave namedObject)
        {
            namedObject.AddToManagers = true;

            NamedObjectSave parentNamedObject = EditorLogic.CurrentNamedObject;

            parentNamedObject.ContainedObjects.Add(namedObject);

            EditorLogic.CurrentElementTreeNode.UpdateReferencedTreeNodes();

            // Since it's part of a list we know its type
            string typeOfNewObject = parentNamedObject.SourceClassGenericType;

            if (ObjectFinder.Self.GetEntitySave(typeOfNewObject) != null)
            {
                namedObject.SourceType = SourceType.Entity;

                namedObject.SourceClassType = typeOfNewObject;
                namedObject.UpdateCustomProperties();
            }
            else if (AvailableClassTypeConverter.IsFlatRedBallType(typeOfNewObject))
            {
                namedObject.SourceType      = SourceType.FlatRedBallType;
                namedObject.SourceClassType = typeOfNewObject;
                namedObject.UpdateCustomProperties();
            }

            // Highlight the newly created object
            TreeNode newNode = GlueState.Self.Find.NamedObjectTreeNode(namedObject);

            if (newNode != null)
            {
                MainGlueWindow.Self.ElementTreeView.SelectedNode = newNode;
            }
        }
 public void Show(ElementRuntime elementRuntime, NamedObjectSave nosToShow)
 {
     mCurrentElementRuntime = elementRuntime;
     if (nosToShow != null)
     {
         nosToShow.UpdateCustomProperties();
     }
     mCurrentNos = nosToShow;
     mNosDisplayer.CurrentElement = GlueViewState.Self.CurrentElement;
     mNosDisplayer.Instance = mCurrentNos;
     mNosDisplayer.PropertyGrid = mPropertyGrid;
 }
        public void TestRelativeAbsoluteConversion()
        {
            NamedObjectSave nos = new NamedObjectSave();
            nos.SourceType = SourceType.FlatRedBallType;
            nos.SourceClassType = "Sprite";
            nos.UpdateCustomProperties();
            nos.InstanceName = "SpriteObject";
            nos.SetPropertyValue("ScaleX", 2.0f);
            nos.SetPropertyValue("X", 4.0f);
            nos.SetPropertyValue("RotationZ", 4.0f);
            nos.SetPropertyValue("RotationZVelocity", 4.0f);

            mEntitySave.NamedObjects.Add(nos);

            CustomVariable customVariable = new CustomVariable();
            customVariable.SourceObject = nos.InstanceName;
            customVariable.SourceObjectProperty = "ScaleY";
            customVariable.DefaultValue = 8.0f;

            mEntitySave.CustomVariables.Add(customVariable);

            ElementRuntime elementRuntime = new ElementRuntime(mEntitySave, null, null, null, null);

            Sprite sprite = elementRuntime.ContainedElements[0].DirectObjectReference as Sprite;
            sprite.ForceUpdateDependencies();

            if (elementRuntime.X != 0)
            {
                throw new Exception("NOS variables are being applied to the container instead of just to the NOS");
            }

            if (sprite.X != 4.0f)
            {
                throw new Exception("Absolute values should get set when setting X on objects even though they're attached");
            }

            if (sprite.RotationZ != 4.0f)
            {
                throw new Exception("Absolute values should get set when setting RotationZ on objects even though they're attached");
            }
            if (sprite.RelativeRotationZVelocity != 4.0f)
            {
                throw new Exception("Setting RotationZVelocity should set RelativeRotationZVelocity");
            }
            if (sprite.ScaleX != 2.0f)
            {
                throw new Exception("Scale values aren't properly showing up on Sprites");
            }
            if (sprite.ScaleY != 8.0f)
            {
                throw new Exception("Scale values aren't properly showing up on Sprites");
            }
        }
        public static void UpdateShownVariables(DataUiGrid grid, NamedObjectSave instance, IElement container)
        {
            grid.Categories.Clear();

            List<MemberCategory> categories = new List<MemberCategory>();
            var defaultCategory = new MemberCategory("Variables");
            defaultCategory.FontSize = 14;
            categories.Add(defaultCategory);

            AssetTypeInfo ati = instance.GetAssetTypeInfo();

            // not sure if this is needed:
            if (instance.TypedMembers.Count == 0)
            {
                instance.UpdateCustomProperties();
            }

            CreateCategoriesAndVariables(instance, container, categories, ati);

            if (ati != null)
            {
                SortCategoriesAndMembers(ref categories, ati);
            }


            if (defaultCategory.Members.Count == 0)
            {
                categories.Remove(defaultCategory);
            }
            else if (categories.Count != 1)
            {
                defaultCategory.Name = "Other Variables";
            }

            if (categories.Count != 0)
            {
                // "Name" should be the very first property:
                var nameCategory = CreateNameInstanceMember(instance);
                categories.Insert(0, nameCategory);
            }

            SetAlternatingColors(grid, categories);

            foreach(var category in categories)
            {
                grid.Categories.Add(category);
            }

            grid.Refresh();
        }
        private void CreateScreenSave()
        {
            mScreenSave = new ScreenSave();
            mScreenSave.Name = "ScreenSaveInVariableSettingTest";
            ObjectFinder.Self.GlueProject.Screens.Add(mScreenSave);

            NamedObjectSave nos = new NamedObjectSave();
            nos.SourceType = SourceType.Entity;
            nos.SourceClassType = mEntitySave.Name;
            nos.UpdateCustomProperties();
            nos.InstanceName = "TestObject1";
            nos.SetPropertyValue("X", 150);

            mScreenSave.NamedObjects.Add(nos);
        }
Beispiel #6
0
        public static NamedObjectSave Clone(this NamedObjectSave instance)
        {
            NamedObjectSave newNamedObjectSave = FileManager.CloneObject(instance);

            newNamedObjectSave.TypedMembers.Clear();

            newNamedObjectSave.UpdateCustomProperties();
            // March 6, 2012
            // UpdateCustomProperties
            // creates the InstructionSaves
            // for the NamedObjectSave according
            // to the variables for this object; however,
            // an object may have InstructionSaves for variables
            // that aren't part of its type - they may exist because
            // the user has switched from an old type and Glue is holding
            // on to those old values in case the user wants to switch back.
            // Therefore, we shouldn't fill the instruction saves this way, intstead
            // let's just have the instruction saves bee Added.
            newNamedObjectSave.InstructionSaves = new List <CustomVariableInNamedObject>();

            newNamedObjectSave.ContainedObjects = new List <NamedObjectSave>(instance.ContainedObjects.Count);

            for (int i = 0; i < instance.InstructionSaves.Count; i++)
            {
                //var duplicateInstruction =
                //    instance.InstructionSaves[i].Clone<CustomVariableInNamedObject>();

                var duplicateInstruction =
                    FileManager.CloneObject(instance.InstructionSaves[i]);

                // Events are instance-specific so we prob don't want to copy those
                duplicateInstruction.EventOnSet = null;

                newNamedObjectSave.InstructionSaves.Add(duplicateInstruction);
            }

            foreach (NamedObjectSave containedNamedObject in instance.ContainedObjects)
            {
                newNamedObjectSave.ContainedObjects.Add(containedNamedObject.Clone());
            }

            return(newNamedObjectSave);
        }
        private void ShowPopupsForMissingVariablesInNewType(NamedObjectSave namedObjectSave, object oldValue)
        {
            if (namedObjectSave.SourceType == SourceType.Entity)
            {
                string oldType = (string)oldValue;
                string message = namedObjectSave.GetMessageWhySwitchMightCauseProblems(oldType);

                if (message != null)
                {
                    message += "\nDo you want to change to " + namedObjectSave.SourceClassType + " anyway?";

                    DialogResult result = MessageBox.Show(message, "Change anyway?", MessageBoxButtons.YesNo);

                    if (result == DialogResult.No)
                    {
                        namedObjectSave.SourceClassType = (string)oldValue;
                        namedObjectSave.UpdateCustomProperties();

                    }
                }
            }
        }
        private void ReactToChangedSourceClassType(NamedObjectSave namedObjectSave, object oldValue)
        {
            if (namedObjectSave.SourceClassType == "<NONE>" ||
                namedObjectSave.SourceClassType == null)
            {
                namedObjectSave.SourceClassType = (string)oldValue;
                namedObjectSave.UpdateCustomProperties();

            }
            else
            {



                if (namedObjectSave.SourceType == SourceType.Entity)
                {
                    EntitySave entitySave = ObjectFinder.Self.GetEntitySave(namedObjectSave.SourceClassType);

#if GLUE
                    // If the EntitySave is null then that probably means that the Entity has been renamed and this hasn't
                    // been pushed to the project yet.
                    if (entitySave != null && ProjectManager.VerifyReferenceGraph(entitySave) == ProjectManager.CheckResult.Failed)
                    {
                        namedObjectSave.SourceClassType = (string)oldValue;
                    }
                    else
#endif
                    {
                        namedObjectSave.UpdateCustomProperties();
                    }
                }
                else if (namedObjectSave.SourceType == SaveClasses.SourceType.FlatRedBallType)
                {
                    namedObjectSave.UpdateCustomProperties();

                }
            }

            if (namedObjectSave.SourceClassType != (string)oldValue)
            {
                ShowPopupsForMissingVariablesInNewType( namedObjectSave, oldValue);

                if (namedObjectSave.SourceClassType == "Layer")
                {
                    namedObjectSave.AddToManagers = true;
                }
            }
            // else, we should probably do something here to revert to defaults.  What a pain

        }
        private void ReactToSourceClassGenericType(NamedObjectSave namedObjectSave, object oldValue)
        {
            namedObjectSave.UpdateCustomProperties();

            if (ObjectFinder.Self.GetEntitySave(namedObjectSave.SourceClassGenericType) != null)
            {
                namedObjectSave.AddToManagers = true;
            }

            var baseNos = namedObjectSave;
            var element = EditorLogic.CurrentElement;

            if (baseNos.SetByDerived)
            {
                List<IElement> derivedElements = new List<IElement>();
                if (element is EntitySave)
                {
                    derivedElements.AddRange(ObjectFinder.Self.GetAllEntitiesThatInheritFrom(element as EntitySave));
                }
                else
                {
                    derivedElements.AddRange(ObjectFinder.Self.GetAllScreensThatInheritFrom(element as ScreenSave));
                }

                foreach (IElement derivedElement in derivedElements)
                {
                    NamedObjectSave derivedNos = derivedElement.GetNamedObjectRecursively(baseNos.InstanceName);

                    if (derivedNos != baseNos)
                    {
                        UpdateDerivedNosFromBase(baseNos, derivedNos);
                    }
                }
            }

            ProjectManager.UpdateAllDerivedElementFromBaseValues(false, true);
        }
Beispiel #10
0
        private void CreateNamedObjectWithSetVariable()
        {
            mNamedObjectWithSetVariable = new NamedObjectSave();
            mNamedObjectWithSetVariable.InstanceName = "SpriteObject";
            // This will be complicated because it requires FRB to be instantiated!
            //mNamedObjectWithSetVariable.SourceType = SourceType.File;
            //mNamedObjectWithSetVariable.SourceFile = "Entities/StateTestEntity/SceneFile.scnx";
            //mNamedObjectWithSetVariable.SourceName = "Untextured (Sprite)";

            mNamedObjectWithSetVariable.SourceType = SourceType.FlatRedBallType;
            mNamedObjectWithSetVariable.SourceClassType = "Sprite";

            mNamedObjectWithSetVariable.UpdateCustomProperties();
            mNamedObjectWithSetVariable.SetPropertyValue("Y", 10.0f);

            mEntitySave.NamedObjects.Add(mNamedObjectWithSetVariable);
            
        }
        public void TestSetPropertyValue()
        {
            NamedObjectSave nos = new NamedObjectSave();
            nos.SourceType = SourceType.FlatRedBallType;
            nos.SourceClassType = "Sprite";

            nos.UpdateCustomProperties();
            nos.SetPropertyValue("Texture", "redball");

            if (nos.InstructionSaves.Count == 0)
            {
                throw new Exception("There should be a Texture instruction save");
            }

            if (nos.InstructionSaves.First(instruction => instruction.Member == "Texture").Type != "Texture2D")
            {
                throw new Exception("The instruction should be of type Texture2D, but it's not");
            }

        }
        private void CreateContainerEntitySave()
        {
            mContainerEntitySave = new EntitySave();
            mContainerEntitySave.Name = "ContainerCustomVariableEntity";

            mBaseNosInContainer = new NamedObjectSave();
            mBaseNosInContainer.InstanceName = mEntitySave.Name + "Instance";
            mBaseNosInContainer.SourceType = SourceType.Entity;
            mBaseNosInContainer.SourceClassType = mEntitySave.Name;
            mContainerEntitySave.NamedObjects.Add(mBaseNosInContainer);

            CustomVariable customVariable = new CustomVariable();
            customVariable.Name = "TunneledCategorizedStateVariable";
            customVariable.SourceObject = mBaseNosInContainer.InstanceName;
            customVariable.SourceObjectProperty = "CurrentStateCategoryState";
            customVariable.Type = "StateCategory";
            mContainerEntitySave.CustomVariables.Add(customVariable);

            mDerivedNosInContainer = new NamedObjectSave();
            mDerivedNosInContainer.InstanceName = "DerivedNosInContainer";
            mDerivedNosInContainer.SourceType = SourceType.Entity;
            mDerivedNosInContainer.SourceClassType = mDerivedEntitySave.Name;
            mDerivedNosInContainer.UpdateCustomProperties();
            mContainerEntitySave.NamedObjects.Add(mDerivedNosInContainer);


            ObjectFinder.Self.GlueProject.Entities.Add(mContainerEntitySave);
        }
        void CreateElementRuntime(string name)
        {
            var entitySave = new EntitySave {Name = name};

            ObjectFinder.Self.GlueProject.Entities.Add(entitySave);

            #region Create CustomVariables
            var xVariable = new CustomVariable
                                {
                                    Name = "X", 
                                    Type = "float", 
                                    DefaultValue = 3.0f
                                };
            entitySave.CustomVariables.Add(xVariable);

            var yVariable = new CustomVariable
                                {
                                    Name = "Y", 
                                    Type = "float", 
                                    DefaultValue = 4.0f
                                };
            entitySave.CustomVariables.Add(yVariable);


            var customVariable = new CustomVariable
                                {
                                    Name = "SomeNewVar",
                                    Type = "double",
                                    DefaultValue = 3.333
                                };
            entitySave.CustomVariables.Add(customVariable);

            var csvTypeVAriable = new CustomVariable
                                {
                                    Name = "CsvTypeVariable",
                                    Type = "CsvType.csv",
                                    DefaultValue = null

                                };
            entitySave.CustomVariables.Add(csvTypeVAriable);

            var csvTypeVariable2 = new CustomVariable
                                {
                                    Name = "EnemyInfoVariable",
                                    Type = "EnemyInfo.csv",
                                    DefaultValue = "Imp"

                                };
            entitySave.CustomVariables.Add(csvTypeVariable2);

            var scaleXVariable = new CustomVariable
            {
                Name = "ScaleX",
                Type = "float",
                DefaultValue = 10.0f
            };
            entitySave.CustomVariables.Add(scaleXVariable);


            #endregion

            #region Create the NamedObjectsSave

            NamedObjectSave nos = new NamedObjectSave();
            nos.SourceType = SourceType.FlatRedBallType;
            nos.SourceClassType = "Sprite";
            nos.InstanceName = "SpriteObject";
            nos.UpdateCustomProperties();
            nos.SetPropertyValue("ScaleX", 3.0f);
            entitySave.NamedObjects.Add(nos);


            #endregion

            #region Create the ReferencedFileSaves

            ReferencedFileSave rfs = new ReferencedFileSave();
            rfs.Name = "Content/Entities/ReferencedFileSaveTestsBaseEntity/SceneFile.scnx";
            entitySave.ReferencedFiles.Add(rfs);

            rfs = new ReferencedFileSave();
            rfs.Name = "Content/EnemyInfo.csv";
            rfs.CreatesDictionary = true;

            entitySave.ReferencedFiles.Add(rfs);


            #endregion

            mElementRuntime = new ElementRuntime(entitySave, null, null, null, null)
                                  {
                                      X = (float) xVariable.DefaultValue, 
                                      Y = (float) yVariable.DefaultValue
                                  };


            #region Create the uncategorized states

            var leftX = new InstructionSave
            {
                Member = "X",
                Value = -10,
                Type = "float"
            };




            var rightX = new InstructionSave
            {
                Member = "X",
                Value = 10,
                Type = "float"
            };

            var someNewVarSetLeft = new InstructionSave
            {
                Member = "SomeNewVar",
                Value = -10.0,
                Type = "double"

            };


            var someNewVarSetRight = new InstructionSave
            {
                Member = "SomeNewVar",
                Value = 10.0,
                Type = "double"

            };

            var leftState = new StateSave {Name = "Left"};
            leftState.InstructionSaves.Add(leftX);
            leftState.InstructionSaves.Add(someNewVarSetLeft);

            var rightState = new StateSave {Name = "Right"};
            rightState.InstructionSaves.Add(rightX);
            rightState.InstructionSaves.Add(someNewVarSetRight);


            entitySave.States.Add(leftState);
            entitySave.States.Add(rightState);

            #endregion

            #region Create the categorized states

            StateSaveCategory category = new StateSaveCategory();
            category.SharesVariablesWithOtherCategories = false;

            category.Name = "StateCategory";

            var topY = new InstructionSave
            {
                Member = "Y",
                Value = 10,
                Type = "float"
            };

            var bottomY = new InstructionSave
            {
                Member = "Y",
                Value = 10,
                Type = "float"
            };

            var topState = new StateSave { Name = "Top" };
            topState.InstructionSaves.Add(topY);
            var bottomState = new StateSave { Name = "Bottom" };
            bottomState.InstructionSaves.Add(rightX);

            category.States.Add(topState);
            category.States.Add(bottomState);

            entitySave.StateCategoryList.Add(category);

            #endregion
        }
        private void UpdateDerivedNosFromBase(NamedObjectSave baseNos, NamedObjectSave derivedNos)
        {
            if (baseNos.IsList && !string.IsNullOrEmpty(baseNos.SourceClassGenericType))
            {
                derivedNos.SourceType = baseNos.SourceType;
                derivedNos.SourceClassType = baseNos.SourceClassType;
                derivedNos.SourceClassGenericType = baseNos.SourceClassGenericType;
                derivedNos.UpdateCustomProperties();

            }

        }
Beispiel #15
0
        void CreateContainerElementRuntime()
        {

            EntitySave containerEntitySave = new EntitySave { Name = "ContainerVariableSetting" };
            ObjectFinder.Self.GlueProject.Entities.Add(containerEntitySave);
            NamedObjectSave nos = new NamedObjectSave();
            nos.SourceType = SourceType.Entity;
            nos.InstanceName = mEntitySave.Name + "Instance";
            nos.SourceClassType = mEntitySave.Name;
            containerEntitySave.NamedObjects.Add(nos);

            nos.UpdateCustomProperties();
            nos.SetPropertyValue("CurrentStateSaveCategoryState", "SecondState");

            mContainedElementRuntime = new ElementRuntime(containerEntitySave, null, null, null, null);

            // This thing is attached - we need to check its relativeX
            //if (mContainedElementRuntime.ContainedElements[0].X != -10.0f)
            if (mContainedElementRuntime.ContainedElements[0].RelativeX != -10.0f)
            {
                throw new Exception("Categorized states on contained NamedObjectSave Elements aren't setting values properly");
            }
        }
        internal static NamedObjectSave CreateNewNamedObjectInElement(IElement elementToCreateIn, EntitySave blueprintEntity, bool createList = false)
        {
            if (elementToCreateIn is EntitySave && ((EntitySave)elementToCreateIn).ImplementsIVisible && !blueprintEntity.ImplementsIVisible)
            {
                MultiButtonMessageBox mbmb = new MultiButtonMessageBox();
                mbmb.MessageText = "The Entity\n\n" + blueprintEntity + "\n\nDoes not Implement IVisible, but the Entity it is being dropped in does.  " +
                    "What would you like to do?";

                mbmb.AddButton("Make " + blueprintEntity.Name + " implement IVisible", DialogResult.OK);
                mbmb.AddButton("Nothing (your code will not compile until this problem is resolved manually)", DialogResult.Cancel);

                DialogResult result = mbmb.ShowDialog(MainGlueWindow.Self);
                if (result == DialogResult.OK)
                {
                    blueprintEntity.ImplementsIVisible = true;
                    CodeGeneratorIElement.GenerateElementDerivedAndReferenced(blueprintEntity);
                }

            }

            BaseElementTreeNode elementTreeNode = GlueState.Self.Find.ElementTreeNode(elementToCreateIn);

            //EntityTreeNode entityTreeNode =
            //    ElementViewWindow.GetEntityTreeNode(entityToCreateIn); 

            NamedObjectSave newNamedObject = new NamedObjectSave();

            // We'll add "List" or "Instance" below
            string newName = FileManager.RemovePath(blueprintEntity.Name);

            #region Set the source type properties for the new NamedObject

            if (createList)
            {
                newName += "List";
                newNamedObject.SourceType = SourceType.FlatRedBallType;
                newNamedObject.SourceClassType = "PositionedObjectList<T>";
                newNamedObject.SourceClassGenericType = blueprintEntity.Name;
                newNamedObject.UpdateCustomProperties();
            }
            else
            {
                newName += "Instance";
                newNamedObject.SourceType = SourceType.Entity;
                newNamedObject.SourceClassType = blueprintEntity.Name;
                newNamedObject.UpdateCustomProperties();
            }

            #endregion

            #region Set the name for the new NamedObject

            // get an acceptable name for the new object
            if (elementToCreateIn.GetNamedObjectRecursively(newName) != null)
            {
                newName += "2";
            }

            while (elementToCreateIn.GetNamedObjectRecursively(newName) != null)
            {
                newName = StringFunctions.IncrementNumberAtEnd(newName);
            }

            newNamedObject.InstanceName = newName;


            #endregion

            // We need to add to managers here.  Why?  Because normally when the type of a NamedObject is changed, 
            // the PropertyGrid handles setting whether it should be added or not. But in this case, we're not changing
            // the type of the new NamedObject through the PropertyGrid - instead it's being set programatically to be an
            // Entity.  So, we should add to managers programatically since the PropertyGrid won't do it for us.
            // Update December 11, 2011
            // AddToManagers defaults to
            // true on new NamedObjectSaves
            // so there's no need to explicitly
            // set it to true here.
            //newNamedObject.AddToManagers = true;


            NamedObjectSaveExtensionMethodsGlue.AddNewNamedObjectToElementTreeNode(elementTreeNode, newNamedObject, true);

            return newNamedObject;
        }
        public static void UpdateShownVariables(DataUiGrid grid, NamedObjectSave instance, IElement container)
        {
            grid.Categories.Clear();

            List<MemberCategory> categories = new List<MemberCategory>();
            var defaultCategory = new MemberCategory("Variables");
            defaultCategory.FontSize = 14;
            categories.Add(defaultCategory);

            AssetTypeInfo ati = instance.GetAssetTypeInfo();

            // not sure if this is needed:
            if (instance.TypedMembers.Count == 0)
            {
                instance.UpdateCustomProperties();
            }

            for (int i = 0; i < instance.TypedMembers.Count; i++)
            {

                TypedMemberBase typedMember = instance.TypedMembers[i];
                InstanceMember instanceMember = CreateInstanceMember(instance, container, typedMember, ati);

                var categoryToAddTo = GetOrCreateCategoryToAddTo(categories, ati, typedMember);

                if (instanceMember != null)
                {
                    categoryToAddTo.Members.Add(instanceMember);
                }
            }

            if (ati != null)
            {
                SortCategoriesAndMembers(ref categories, ati);
            }

            if (defaultCategory.Members.Count == 0)
            {
                categories.Remove(defaultCategory);
            }
            else if(categories.Count != 1)
            {
                defaultCategory.Name = "Other Variables";
            }

            if (categories.Count != 0)
            {
                // "Name" shoul be the very first property:
                var nameCategory = CreateNameInstanceMember(instance);
                //categories.Add(nameCategory);
                categories.Insert(0, nameCategory);
                //categories.First().Members.Insert(0, nameInstanceMember);
            }

            // skip the first category in putting the alternating colors:
            for (int i = 0; i < categories.Count; i++)
            {
                var category = categories[i];
                if (i != 0)
                {
                    const byte brightness = 227;
                    category.SetAlternatingColors(new SolidColorBrush(Color.FromRgb(brightness, brightness, brightness)), Brushes.Transparent);
                }
                grid.Categories.Add(category);
            }
            grid.Refresh();
        }
        public static void AddNamedObjectToCurrentNamedObjectList(NamedObjectSave namedObject)
        {
            namedObject.AddToManagers = true;

            NamedObjectSave parentNamedObject = EditorLogic.CurrentNamedObject;

            parentNamedObject.ContainedObjects.Add(namedObject);

            EditorLogic.CurrentElementTreeNode.UpdateReferencedTreeNodes();

            // Since it's part of a list we know its type
            string typeOfNewObject = parentNamedObject.SourceClassGenericType;

            if (ObjectFinder.Self.GetEntitySave(typeOfNewObject) != null)
            {
                namedObject.SourceType = SourceType.Entity;

                namedObject.SourceClassType = typeOfNewObject;
                namedObject.UpdateCustomProperties();
            }
            else if (AvailableClassTypeConverter.IsFlatRedBallType(typeOfNewObject))
            {
                namedObject.SourceType = SourceType.FlatRedBallType;
                namedObject.SourceClassType = typeOfNewObject;
                namedObject.UpdateCustomProperties();
            }

            // Highlight the newly created object
            TreeNode newNode = GlueState.Self.Find.NamedObjectTreeNode(namedObject);

            if (newNode != null)
            {
                MainGlueWindow.Self.ElementTreeView.SelectedNode = newNode;
            }
        }
        void CreateParentElementRuntime()
        {
            EntitySave containerEntity = new EntitySave();
            ObjectFinder.Self.GlueProject.Entities.Add(containerEntity);

            containerEntity.Name = "ContainerEntity";

            NamedObjectSave first = new NamedObjectSave();
            first.SourceType = SourceType.Entity;
            first.SourceClassType = "ExpressionParserTestEntity";
            first.InstanceName = "FirstObject";
            first.UpdateCustomProperties();
            first.SetPropertyValue("CsvTypeVariable", "CsvValue1");

            containerEntity.NamedObjects.Add(first);

            mParentElementRuntime = new ElementRuntime(
                containerEntity, null, null, null, null);
        }