Example #1
0
        public static List <string> GetFilesReferencedByAsset(string file, bool readRecursively)
        {
            string fileExtension = FileManager.GetExtension(file);

            List <string> referencedFiles = null;           // = new List<string>();

            switch (fileExtension)
            {
                #region Scene (.scnx)

            case "scnx":

                SpriteEditorScene ses = SpriteEditorScene.FromFile(file);
                referencedFiles = ses.GetReferencedFiles(RelativeType.Absolute);
                break;

                #endregion

                #region Emitter List (.emix)

            case "emix":
                EmitterSaveList esl = EmitterSaveList.FromFile(file);
                referencedFiles = esl.GetReferencedFiles(RelativeType.Absolute);
                break;

                #endregion

                #region SpriteRig (.srgx)

            case "srgx":
                SpriteRigSave srs = SpriteRigSave.FromFile(file);
                referencedFiles = srs.GetReferencedFiles(RelativeType.Absolute);
                break;

                #endregion

                #region AnimationChain List

            case "achx":
                AnimationChainListSave acls = AnimationChainListSave.FromFile(file);
                referencedFiles = acls.GetReferencedFiles(RelativeType.Absolute);
                break;

                #endregion

                #region Bitmap Font Generator Config File (.bmfc)

            case "bmfc":

                referencedFiles = new List <string>();

                // These are only referenced IF they actually exist
                string referencedFileToAdd = FileManager.RemoveExtension(file) + ".png";
                if (FileManager.FileExists(referencedFileToAdd))
                {
                    referencedFiles.Add(referencedFileToAdd);
                }

                referencedFileToAdd = FileManager.RemoveExtension(file) + ".fnt";
                if (FileManager.FileExists(referencedFileToAdd))
                {
                    referencedFiles.Add(referencedFileToAdd);
                }
                break;

                #endregion

                #region X File (.x)

            case "x":
                referencedFiles = GetTextureReferencesInX(file);
                break;

                #endregion

                #region WME File (.wme)
            case "wme":
                referencedFiles = new List <string>();
                WMELoader.GetReferencedFiles(file, referencedFiles, RelativeType.Absolute);

                break;

                #endregion

                #region Spline List (.slpx) - falls to default

            case "splx":

                #endregion
            default:
                referencedFiles = new List <string>();
                break;
            }

            if (readRecursively)
            {
                for (int i = referencedFiles.Count - 1; i > -1; i--)
                {
                    referencedFiles.AddRange(GetFilesReferencedByAsset(referencedFiles[i], true));
                }
            }

            // Files may include "../", so let's get rid of that stuff
            for (int i = 0; i < referencedFiles.Count; i++)
            {
                referencedFiles[i] = FileManager.Standardize(referencedFiles[i], "", false);
            }


            return(referencedFiles);
        }