Exemplo n.º 1
0
        public bool IsAssetLoadedByName <T>(string assetName)
        {
            if (FileManager.IsRelative(assetName))
            {
                assetName = FileManager.MakeAbsolute(assetName);
            }

            assetName = FileManager.Standardize(assetName);

            string combinedName = assetName + typeof(T).Name;

            if (mDisposableDictionary.ContainsKey(combinedName))
            {
                return(true);
            }
            else if (mNonDisposableDictionary.ContainsKey(combinedName))
            {
                return(true);
            }

            else if (mAssets.ContainsKey(combinedName))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 2
0
        public void AddNonDisposable(string objectName, object objectToAdd)
        {
            if (FileManager.IsRelative(objectName))
            {
                objectName = FileManager.MakeAbsolute(objectName);
            }

            string modifiedName = objectName + objectToAdd.GetType().Name;

            bool shouldAdd = true;

            if (mNonDisposableDictionary.ContainsKey(modifiedName))
            {
                var existing = objectToAdd;
                if (existing != objectToAdd)
                {
                    throw new InvalidOperationException($"The name {objectName} is already taken by {objectToAdd}");
                }
                else
                {
                    shouldAdd = false;
                }
            }

            if (shouldAdd)
            {
                mNonDisposableDictionary.Add(modifiedName, objectToAdd);
            }
        }
Exemplo n.º 3
0
        public List <SourceReferencingFile> GetSourceReferencingReferencedFiles(RelativeType relativeType)
        {
            List <SourceReferencingFile> referencedFiles = new List <SourceReferencingFile>();

            if (relativeType == RelativeType.Absolute)
            {
                string directory = this.ScenePath;

                string oldRelativeDirectory = FileManager.RelativeDirectory;
                FileManager.RelativeDirectory = directory;

                for (int i = 0; i < referencedFiles.Count; i++)
                {
                    referencedFiles[i].SourceFile =
                        FileManager.MakeAbsolute(referencedFiles[i].SourceFile);

                    referencedFiles[i].DestinationFile =
                        FileManager.MakeAbsolute(referencedFiles[i].DestinationFile);
                }

                FileManager.RelativeDirectory = oldRelativeDirectory;
            }

            return(referencedFiles);
        }
Exemplo n.º 4
0
        // This used to be internal - making it public since users use this
        public T GetNonDisposable <T>(string objectName)
        {
            if (FileManager.IsRelative(objectName))
            {
                objectName = FileManager.MakeAbsolute(objectName);
            }

            objectName += typeof(T).Name;

            return((T)mNonDisposableDictionary[objectName]);
        }
Exemplo n.º 5
0
        public void AddNonDisposable(string objectName, object objectToAdd)
        {
            if (FileManager.IsRelative(objectName))
            {
                objectName = FileManager.MakeAbsolute(objectName);
            }

            string modifiedName = objectName + objectToAdd.GetType().Name;

            mNonDisposableDictionary.Add(modifiedName, objectToAdd);
        }
Exemplo n.º 6
0
        public void AddDisposable(string disposableName, IDisposable disposable)
        {
            if (FileManager.IsRelative(disposableName))
            {
                disposableName = FileManager.MakeAbsolute(disposableName);
            }

            disposableName = FileManager.Standardize(disposableName);

            string modifiedName = disposableName + disposable.GetType().Name;



            lock (mDisposableDictionary)
            {
                mDisposableDictionary.Add(modifiedName, disposable);
            }
        }
Exemplo n.º 7
0
        public static AnimationChainListSave FromFile(string fileName)
        {
            AnimationChainListSave toReturn = null;

            if (ManualDeserialization)
            {
                toReturn = DeserializeManually(fileName);
            }
            else
            {
                toReturn =
                    FileManager.XmlDeserialize <AnimationChainListSave>(fileName);
            }

            if (FileManager.IsRelative(fileName))
            {
                fileName = FileManager.MakeAbsolute(fileName);
            }

            toReturn.mFileName = fileName;

            return(toReturn);
        }
Exemplo n.º 8
0
        private void MakeAssetsRelative(string fileName)
        {
            string oldRelativeDirectory = FileManager.RelativeDirectory;

            if (FileManager.IsRelative(fileName))
            {
                fileName = FileManager.MakeAbsolute(fileName);
            }
            FileManager.RelativeDirectory = FileManager.GetDirectory(fileName);


            #region SpriteSave - Make textures relative
            foreach (SpriteSave ss in SpriteList)
            {
                ss.MakeRelative();
            }
            #endregion


            #region SpriteFrameSave - Make the textures relative

            foreach (SpriteFrameSave sfs in SpriteFrameSaveList)
            {
                sfs.ParentSprite.Texture = FileManager.MakeRelative(sfs.ParentSprite.Texture);

                if (string.IsNullOrEmpty(sfs.ParentSprite.AnimationChainsFile) == false)
                {
                    sfs.ParentSprite.AnimationChainsFile =
                        FileManager.MakeRelative(sfs.ParentSprite.AnimationChainsFile);
                }
            }

            #endregion


            #region SpriteGridSave - Make textures realtive
            foreach (SpriteGridSave sgs in SpriteGridList)
            {
                sgs.BaseTexture       = FileManager.MakeRelative(sgs.BaseTexture);
                sgs.Blueprint.Texture = FileManager.MakeRelative(sgs.Blueprint.Texture);
                foreach (string[] row in sgs.GridTexturesArray)
                {
                    for (int i = 0; i < row.Length; i++)
                    {
                        row[i] = FileManager.MakeRelative(row[i]);
                    }
                }

                if (sgs.AnimationChainGridSave != null)
                {
                    sgs.AnimationChainGridSave.MakeRelative();
                }
            }
            #endregion

            #region TextSaves - Make textures and .fnt files relative

            foreach (TextSave textSave in TextSaveList)
            {
                textSave.FontTexture = FileManager.MakeRelative(textSave.FontTexture);
                textSave.FontFile    = FileManager.MakeRelative(textSave.FontFile);
            }

            #endregion

            FileManager.RelativeDirectory = oldRelativeDirectory;
        }