Beispiel #1
0
        public void Add(LoadedFile loadedFile)
        {
            if (loadedFile.RuntimeObject is NodeNetwork)
            {
                LoadedNodeNetworks.Add(loadedFile.RuntimeObject as NodeNetwork);
            }
            else if (loadedFile.RuntimeObject is EmitterList)
            {
                LoadedEmitterLists.Add(loadedFile.RuntimeObject as EmitterList);
            }
            else if (loadedFile.RuntimeObject is ShapeCollection)
            {
                LoadedShapeCollections.Add(loadedFile.RuntimeObject as ShapeCollection);
            }

            mAddedRfses.Add(loadedFile);
        }
 public void Add(object objectToAdd)
 {
     if (objectToAdd is NodeNetwork)
     {
         LoadedNodeNetworks.Add(objectToAdd as NodeNetwork);
     }
     else if (objectToAdd is Scene)
     {
         LoadedScenes.Add(objectToAdd as Scene);
     }
     else if (objectToAdd is EmitterList)
     {
         LoadedEmitterLists.Add(objectToAdd as EmitterList);
     }
     else if (objectToAdd is ShapeCollection)
     {
         LoadedShapeCollections.Add(objectToAdd as ShapeCollection);
     }
 }
        private object LoadRfsAndAddToLists(ReferencedFileSave r, bool isBeingAccessed, IElement container)
        {
            string extension = FileManager.GetExtension(r.Name).ToLower();

            object runtimeObject = null;

            if (!r.LoadedOnlyWhenReferenced || isBeingAccessed)
            {
                switch (extension)
                {
                case "scnx":
                    runtimeObject = LoadScnx(r, container);
                    if ((!r.IsSharedStatic || container is ScreenSave) && runtimeObject != null)
                    {
                        LoadedScenes.Add(runtimeObject as Scene);
                    }
                    break;

                case "shcx":
                    runtimeObject = LoadShcx(r, container);
                    if ((!r.IsSharedStatic || container is ScreenSave) && runtimeObject != null)
                    {
                        LoadedShapeCollections.Add(runtimeObject as ShapeCollection);
                    }
                    break;

                case "nntx":
                    runtimeObject = LoadNntx(r, container);
                    if ((!r.IsSharedStatic || container is ScreenSave) && runtimeObject != null)
                    {
                        LoadedNodeNetworks.Add(runtimeObject as NodeNetwork);
                    }
                    break;

                case "emix":
                    runtimeObject = LoadEmix(r);
                    if ((!r.IsSharedStatic || container is ScreenSave) && runtimeObject != null)
                    {
                        LoadedEmitterLists.Add(runtimeObject as EmitterList);
                    }
                    break;

                case "achx":
                    runtimeObject = LoadAchx(r);
                    break;

                case "png":
                case "bmp":
                case "dds":
                case "tga":
                    runtimeObject = LoadTexture2D(r);
                    break;

                case "csv":
                    runtimeObject = LoadCsv(r);
                    break;

                case "fnt":
                    runtimeObject = LoadFnt(r);
                    break;

                case "splx":
                    runtimeObject = LoadSplx(r);
                    break;
                }
            }


            return(runtimeObject);
        }
Beispiel #4
0
        private LoadedFile LoadRfsAndAddToLists(ReferencedFileSave r, IElement container)
        {
            LoadedFile loadedFile     = null;
            bool       isAlreadyAdded = false;

            FilePath filePath =
                ElementRuntime.ContentDirectory + r.Name;

            loadedFile = mLoadedRfses.FirstOrDefault(item => item.FilePath == filePath);
            if (loadedFile != null)
            {
                if (mAddedRfses.Any(item => item.FilePath == filePath) == false &&
                    (r.IsSharedStatic == false || container is ScreenSave))
                {
                    foreach (var manager in FileManagers)
                    {
                        if (manager.AddToManagers(loadedFile))
                        {
                            mAddedRfses.Add(loadedFile);
                            break;
                        }
                    }
                }
            }
            else
            {
                foreach (var manager in FileManagers)
                {
                    loadedFile = manager.TryCreateFile(r, container);
                    if (loadedFile != null)
                    {
                        if ((!r.IsSharedStatic || container is ScreenSave) && loadedFile != null)
                        {
                            LoadedRfses.Add(loadedFile);

                            if (r.AddToManagers)
                            {
                                manager.AddToManagers(loadedFile);
                                mAddedRfses.Add(loadedFile);
                            }
                        }
                        break;
                    }
                }
            }



            if (loadedFile == null)
            {
                string extension     = FileManager.GetExtension(r.Name).ToLower();
                object runtimeObject = null;

                switch (extension)
                {
                case "shcx":
                    runtimeObject = LoadShcx(r, container);
                    if ((!r.IsSharedStatic || container is ScreenSave) && runtimeObject != null)
                    {
                        LoadedShapeCollections.Add(runtimeObject as ShapeCollection);
                    }
                    break;

                case "nntx":
                    runtimeObject = LoadNntx(r, container);
                    if ((!r.IsSharedStatic || container is ScreenSave) && runtimeObject != null)
                    {
                        LoadedNodeNetworks.Add(runtimeObject as NodeNetwork);
                    }
                    break;

                case "emix":
                    runtimeObject = LoadEmix(r);
                    if ((!r.IsSharedStatic || container is ScreenSave) && runtimeObject != null)
                    {
                        LoadedEmitterLists.Add(runtimeObject as EmitterList);
                    }
                    break;

                case "achx":
                    runtimeObject = LoadAchx(r);
                    break;

                case "png":
                case "bmp":
                case "dds":
                case "tga":
                    runtimeObject = LoadTexture2D(r);
                    break;

                case "csv":
                    runtimeObject = LoadCsv(r);
                    break;

                case "fnt":
                    runtimeObject = LoadFnt(r);
                    break;

                case "splx":
                    runtimeObject = LoadSplx(r);
                    break;
                }

                if (runtimeObject != null)
                {
                    loadedFile = new LoadedFile();
                    loadedFile.RuntimeObject      = runtimeObject;
                    loadedFile.ReferencedFileSave = r;
                    loadedFile.FilePath           = ElementRuntime.ContentDirectory + r.Name;

                    LoadedRfses.Add(loadedFile);
                }
            }


            return(loadedFile);
        }