Esempio n. 1
0
        private bool HandleTryAddContainedObjects(string absoluteFile, List <string> availableObjects)
        {
            bool toReturn = ContentParser.GetNamedObjectsIn(absoluteFile, availableObjects);

            return(toReturn);
        }
Esempio n. 2
0
        private static void CheckForBrokenReferencesToObjectsInFile(string changedFile)
        {
            bool shouldSave = false;

            string relativeToContent = FileManager.MakeRelative(changedFile, FileManager.RelativeDirectory);


            for (int i = 0; i < ProjectManager.GlueProjectSave.Entities.Count; i++)
            {
                bool shouldGenerateEntityCode = false;

                EntitySave entity = ProjectManager.GlueProjectSave.Entities[i];

                for (int j = 0; j < entity.NamedObjects.Count; j++)
                {
                    NamedObjectSave namedObjectSave = entity.NamedObjects[j];

                    if (namedObjectSave.SourceType == SourceType.File &&
                        namedObjectSave.SourceFile == relativeToContent)
                    {
                        // verify that the referenced object still exists
                        string objectToFind = namedObjectSave.SourceName;



                        if (!string.IsNullOrEmpty(objectToFind) && objectToFind != "<NONE>")
                        {
                            List <string> namedObjects = new List <string>();

                            ContentParser.GetNamedObjectsIn(namedObjectSave.SourceFile, namedObjects);
                            // FINISH THIS!!!!
                            if (!namedObjects.Contains(objectToFind))
                            {
                                System.Windows.Forms.MessageBox.Show(
                                    string.Format(
                                        "The object {0} references an object {1} in the file {2}.  This object no longer exists, so the object {0} will have its reference set to NONE.",
                                        namedObjectSave.FieldName, objectToFind, namedObjectSave.SourceFile));

                                namedObjectSave.SourceName = "<NONE>";
                                shouldGenerateEntityCode   = true;
                                shouldSave = true;

                                if (entity == EditorLogic.CurrentEntitySave)
                                {
                                    MainGlueWindow.Self.PropertyGrid.Refresh();
                                }
                            }
                        }
                    }
                }

                if (shouldGenerateEntityCode)
                {
                    CodeWriter.GenerateCode(entity);
                }
            }

            if (shouldSave)
            {
                GluxCommands.Self.SaveGlux();
                ProjectManager.SaveProjects();
            }
        }