Пример #1
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            OpenFileDialog openSpline = new OpenFileDialog()
            {
                Multiselect = true,
                Filter      = ".obj files|*.obj"
            };

            if (openSpline.ShowDialog() == DialogResult.OK)
            {
                foreach (string i in openSpline.FileNames)
                {
                    Spline s = SplineFromFile(i);

                    if (s.Points.Length < 2)
                    {
                        MessageBox.Show("Error: file " + i + " has less than two vertices. Skipping...");
                        continue;
                    }
                    SplineList.Add(SplineFromFile(i));
                    listBoxSplines.Items.Add("Spline " + listBoxSplines.Items.Count.ToString());
                }
                listBoxSplines.SelectedIndex = listBoxSplines.Items.Count - 1;
            }
        }
Пример #2
0
		public SplineList ToSplineList()
		{
			SplineList listToReturn = new SplineList();
			listToReturn.Name = mFileName;
			AddToList(listToReturn);

			return listToReturn;
		}
Пример #3
0
        public SplineList ToSplineList()
        {
            SplineList listToReturn = new SplineList();

            listToReturn.Name = mFileName;
            AddToList(listToReturn);

            return(listToReturn);
        }
Пример #4
0
        private void buttonDelete_Click(object sender, EventArgs e)
        {
            if (CurrentlySelectedObject != -1 & CurrentlySelectedObject < SplineList.Count)
            {
                int previous = CurrentlySelectedObject;
                SplineList.RemoveAt(CurrentlySelectedObject);

                listBoxSplines.Items.Clear();
                for (int i = 0; i < SplineList.Count; i++)
                {
                    listBoxSplines.Items.Add("Spline " + i.ToString());
                }
                if (previous < listBoxSplines.Items.Count)
                {
                    listBoxSplines.SelectedIndex = previous;
                }
                else
                {
                    listBoxSplines.SelectedIndex = previous - 1;
                }
            }
        }
Пример #5
0
        public T LoadFromFile <T>(string assetName)
        {
            string extension = FileManager.GetExtension(assetName);

            if (FileManager.IsRelative(assetName))
            {
                // get the absolute path using the current relative directory
                assetName = FileManager.RelativeDirectory + assetName;
            }



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


            // get the dictionary by the contentManagerName.  If it doesn't exist, GetDisposableDictionaryByName
            // will create it.

            if (mDisposableDictionary.ContainsKey(fullNameWithType))
            {
#if PROFILE
                mHistory.Add(new ContentLoadHistory(
                                 TimeManager.CurrentTime, typeof(T).Name, fullNameWithType, ContentLoadDetail.Cached));
#endif

                return((T)mDisposableDictionary[fullNameWithType]);
            }
            else if (mNonDisposableDictionary.ContainsKey(fullNameWithType))
            {
                return((T)mNonDisposableDictionary[fullNameWithType]);
            }
            else
            {
#if PROFILE
                mHistory.Add(new ContentLoadHistory(
                                 TimeManager.CurrentTime,
                                 typeof(T).Name,
                                 fullNameWithType,
                                 ContentLoadDetail.HddFromFile));
#endif
#if DEBUG
                // The ThrowExceptionIfFileDoesntExist
                // call used to be done before the checks
                // in the dictionaries.  But whatever is held
                // in there may not really be a file so let's check
                // if the file exists after we check the dictionaries.
                FileManager.ThrowExceptionIfFileDoesntExist(assetName);
#endif

                IDisposable loadedAsset = null;

                if (typeof(T) == typeof(Texture2D) || typeof(T) == typeof(Microsoft.Xna.Framework.Graphics.Texture2D))
                {
                    // for now we'll create it here, eventually have it in a dictionary:
                    loadedAsset = textureContentLoader.Load(assetName);
                }

                #region Scene

                else if (typeof(T) == typeof(FlatRedBall.Scene))
                {
                    FlatRedBall.Scene scene = FlatRedBall.Content.Scene.SceneSave.FromFile(assetName).ToScene(mName);

                    object sceneAsObject = scene;

                    lock (mNonDisposableDictionary)
                    {
                        if (!mNonDisposableDictionary.ContainsKey(fullNameWithType))
                        {
                            mNonDisposableDictionary.Add(fullNameWithType, scene);
                        }
                    }
                    return((T)sceneAsObject);
                }

                #endregion

                #region EmitterList

                else if (typeof(T) == typeof(EmitterList))
                {
                    EmitterList emitterList = EmitterSaveList.FromFile(assetName).ToEmitterList(mName);


                    mNonDisposableDictionary.Add(fullNameWithType, emitterList);


                    return((T)((object)emitterList));
                }

                #endregion

                #region Image
#if !MONOGAME
                else if (typeof(T) == typeof(Image))
                {
                    switch (extension.ToLowerInvariant())
                    {
                    case "gif":
                        Image image = Image.FromFile(assetName);
                        loadedAsset = image;
                        break;
                    }
                }
#endif
                #endregion

                #region BitmapList
#if !XBOX360 && !SILVERLIGHT && !WINDOWS_PHONE && !MONOGAME
                else if (typeof(T) == typeof(BitmapList))
                {
                    loadedAsset = BitmapList.FromFile(assetName);
                }
#endif

                #endregion

                #region NodeNetwork
                else if (typeof(T) == typeof(NodeNetwork))
                {
                    NodeNetwork nodeNetwork = NodeNetworkSave.FromFile(assetName).ToNodeNetwork();

                    mNonDisposableDictionary.Add(fullNameWithType, nodeNetwork);

                    return((T)((object)nodeNetwork));
                }
                #endregion

                #region ShapeCollection

                else if (typeof(T) == typeof(ShapeCollection))
                {
                    ShapeCollection shapeCollection =
                        ShapeCollectionSave.FromFile(assetName).ToShapeCollection();

                    mNonDisposableDictionary.Add(fullNameWithType, shapeCollection);

                    return((T)((object)shapeCollection));
                }
                #endregion

                #region PositionedObjectList<Polygon>

                else if (typeof(T) == typeof(PositionedObjectList <FlatRedBall.Math.Geometry.Polygon>))
                {
                    PositionedObjectList <FlatRedBall.Math.Geometry.Polygon> polygons =
                        PolygonSaveList.FromFile(assetName).ToPolygonList();
                    mNonDisposableDictionary.Add(fullNameWithType, polygons);
                    return((T)((object)polygons));
                }

                #endregion

                #region AnimationChainList

                else if (typeof(T) == typeof(AnimationChainList))
                {
                    if (assetName.EndsWith("gif"))
                    {
#if WINDOWS_8 || UWP || DESKTOP_GL
                        throw new NotImplementedException();
#else
                        AnimationChainList acl = new AnimationChainList();
                        acl.Add(FlatRedBall.Graphics.Animation.AnimationChain.FromGif(assetName, this.mName));
                        acl[0].ParentGifFileName = assetName;
                        loadedAsset = acl;
#endif
                    }
                    else
                    {
                        loadedAsset =
                            AnimationChainListSave.FromFile(assetName).ToAnimationChainList(mName);
                    }

                    mNonDisposableDictionary.Add(fullNameWithType, loadedAsset);
                }

                #endregion

                else if (typeof(T) == typeof(Song))
                {
                    var loader = new SongLoader();
                    return((T)(object)loader.Load(assetName));
                }
#if MONOGAME
                else if (typeof(T) == typeof(SoundEffect))
                {
                    T soundEffect;

                    if (assetName.StartsWith(@".\") || assetName.StartsWith(@"./"))
                    {
                        soundEffect = base.Load <T>(assetName.Substring(2));
                    }
                    else
                    {
                        soundEffect = base.Load <T>(assetName);
                    }

                    return(soundEffect);
                }
#endif

                #region RuntimeCsvRepresentation

#if !SILVERLIGHT
                else if (typeof(T) == typeof(RuntimeCsvRepresentation))
                {
#if XBOX360
                    throw new NotImplementedException("Can't load CSV from file.  Try instead to use the content pipeline.");
#else
                    return((T)((object)CsvFileManager.CsvDeserializeToRuntime(assetName)));
#endif
                }
#endif


                #endregion

                #region SplineList

                else if (typeof(T) == typeof(List <Spline>))
                {
                    List <Spline> splineList = SplineSaveList.FromFile(assetName).ToSplineList();
                    mNonDisposableDictionary.Add(fullNameWithType, splineList);
                    object asObject = splineList;

                    return((T)asObject);
                }

                else if (typeof(T) == typeof(SplineList))
                {
                    SplineList splineList = SplineSaveList.FromFile(assetName).ToSplineList();
                    mNonDisposableDictionary.Add(fullNameWithType, splineList);
                    object asObject = splineList;

                    return((T)asObject);
                }

                #endregion

                #region BitmapFont

                else if (typeof(T) == typeof(BitmapFont))
                {
                    // We used to assume the texture is named the same as the font file
                    // But now FRB understands the .fnt file and gets the PNG from the font file
                    //string pngFile = FileManager.RemoveExtension(assetName) + ".png";
                    string fntFile = FileManager.RemoveExtension(assetName) + ".fnt";

                    BitmapFont bitmapFont = new BitmapFont(fntFile, this.mName);

                    object bitmapFontAsObject = bitmapFont;

                    return((T)bitmapFontAsObject);
                }

                #endregion


                #region Text

                else if (typeof(T) == typeof(string))
                {
                    return((T)((object)FileManager.FromFileText(assetName)));
                }

                #endregion

                #region Catch mistakes

#if DEBUG
                else if (typeof(T) == typeof(Spline))
                {
                    throw new Exception("Cannot load Splines.  Try using the List<Spline> type instead.");
                }
                else if (typeof(T) == typeof(Emitter))
                {
                    throw new Exception("Cannot load Emitters.  Try using the EmitterList type instead.");
                }
#endif

                #endregion

                #region else, exception!

                else
                {
                    throw new NotImplementedException("Cannot load content of type " +
                                                      typeof(T).AssemblyQualifiedName + " from file.  If you are loading " +
                                                      "through the content pipeline be sure to remove the extension of the file " +
                                                      "name.");
                }

                #endregion

                if (loadedAsset != null)
                {
                    lock (mDisposableDictionary)
                    {
                        // Multiple threads could try to load this content simultaneously
                        if (!mDisposableDictionary.ContainsKey(fullNameWithType))
                        {
                            mDisposableDictionary.Add(fullNameWithType, loadedAsset);
                        }
                    }
                }

                return((T)loadedAsset);
            }
        }
Пример #6
0
        /// <summary>
        ///  Creates a runtime object and adds the LoadedFile to the element.
        /// </summary>
        /// <param name="objectToLoad"></param>
        /// <param name="container"></param>
        /// <param name="elementRuntime"></param>
        /// <param name="objectType"></param>
        /// <param name="objectJustLoaded"></param>
        /// <param name="newElementRuntime"></param>
        /// <param name="toAddTo"></param>
        /// <param name="layerToAddTo"></param>
        /// <param name="rfs"></param>
        /// <param name="pullsFromEntireNamedObject"></param>
        /// <returns></returns>
        private static LoadedFile CreateRuntimeObjectForNamedObject(NamedObjectSave objectToLoad,
                                                                    IElement container, ElementRuntime elementRuntime, string objectType,
                                                                    LoadedFile objectJustLoaded,
                                                                    ElementRuntime newElementRuntime,
                                                                    object toAddTo,
                                                                    Layer layerToAddTo, ReferencedFileSave rfs, bool pullsFromEntireNamedObject)
        {
            var fileName = ElementRuntime.ContentDirectory + objectToLoad.SourceFile;


            bool       shouldClone = rfs != null && (rfs.IsSharedStatic && !(container is ScreenSave)) && !pullsFromEntireNamedObject;
            LoadedFile toReturn    = null;

            // This could have a ( in the name in a file like .scnx, so use the last (
            //int indexOfType = objectToLoad.SourceName.IndexOf("(");
            int indexOfType = objectToLoad.SourceName.LastIndexOf("(");

            string objectName = objectToLoad.SourceName.Substring(0, indexOfType - 1);

            switch (objectType)
            {
            case "Scene":
            {
                Scene scene = objectJustLoaded.RuntimeObject as Scene;

                foreach (Text text in scene.Texts)
                {
                    text.AdjustPositionForPixelPerfectDrawing = true;
                    if (ObjectFinder.Self.GlueProject.UsesTranslation)
                    {
                        text.DisplayText = LocalizationManager.Translate(text.DisplayText);
                    }
                }

                if (shouldClone)
                {
                    scene = scene.Clone();
                    elementRuntime.EntireScenes.Add(objectToLoad.SourceFile, scene);

                    var loadedFile = new LoadedFile();
                    loadedFile.RuntimeObject      = scene;
                    loadedFile.FilePath           = objectToLoad.SourceFile;
                    loadedFile.ReferencedFileSave = rfs;
                    toReturn = loadedFile;

                    newElementRuntime.ReferencedFileRuntimeList.Add(loadedFile);

                    scene.AddToManagers(layerToAddTo);
                }
            }
            break;


            case "Sprite":
            {
                Sprite loadedSprite = null;
                Scene  scene        = objectJustLoaded.RuntimeObject as Scene;
                if (scene != null)
                {
                    loadedSprite = scene.Sprites.FindByName(objectName);
                }

                if (loadedSprite == null)
                {
                    System.Windows.Forms.MessageBox.Show("There is a missing Sprite called\n\n" + objectName + "\n\n" +
                                                         "in the object\n\n" + elementRuntime.Name + "\n\n" +
                                                         "This probably happened if someone changed the name of a Sprite in a .scnx file but didn't update " +
                                                         "the associated object in Glue", "Missing Sprite");
                }
                else
                {
                    if (shouldClone)
                    {
                        loadedSprite = loadedSprite.Clone();
                        (toAddTo as Scene).Sprites.Add(loadedSprite);
                        SpriteManager.AddToLayer(loadedSprite, layerToAddTo);

                        var loadedFile = new LoadedFile();

                        loadedFile.RuntimeObject      = loadedSprite;
                        loadedFile.FilePath           = objectJustLoaded.FilePath;
                        loadedFile.DataModel          = objectJustLoaded.DataModel;
                        loadedFile.ReferencedFileSave = objectJustLoaded.ReferencedFileSave;

                        toReturn = loadedFile;
                    }
                }
            }
            break;


            case "SpriteFrame":
            {
                Scene       scene             = objectJustLoaded.RuntimeObject as Scene;
                SpriteFrame loadedSpriteFrame = scene.SpriteFrames.FindByName(objectName);
                if (loadedSpriteFrame != null)
                {
                    if (shouldClone)
                    {
                        loadedSpriteFrame = loadedSpriteFrame.Clone();
                        (toAddTo as Scene).SpriteFrames.Add(loadedSpriteFrame);
                        SpriteManager.AddToLayer(loadedSpriteFrame, layerToAddTo);

                        var loadedFile = new LoadedFile();

                        loadedFile.RuntimeObject      = loadedSpriteFrame;
                        loadedFile.FilePath           = objectJustLoaded.FilePath;
                        loadedFile.DataModel          = objectJustLoaded.DataModel;
                        loadedFile.ReferencedFileSave = objectJustLoaded.ReferencedFileSave;
                        toReturn = loadedFile;
                    }
                }
            }
            break;

            case "SpriteGrid":
            {
                Scene      scene      = objectJustLoaded.RuntimeObject as Scene;
                SpriteGrid spriteGrid = null;
                for (int i = 0; i < scene.SpriteGrids.Count; i++)
                {
                    if (scene.SpriteGrids[i].Name == objectName)
                    {
                        spriteGrid = scene.SpriteGrids[i];
                        break;
                    }
                }
                if (spriteGrid != null)
                {
                    if (shouldClone)
                    {
                        spriteGrid = spriteGrid.Clone();
                        (toAddTo as Scene).SpriteGrids.Add(spriteGrid);
                        spriteGrid.Layer = layerToAddTo;
                        spriteGrid.PopulateGrid();
                        spriteGrid.RefreshPaint();
                        spriteGrid.Manage();

                        var loadedFile = new LoadedFile();

                        loadedFile.RuntimeObject      = spriteGrid;
                        loadedFile.FilePath           = objectJustLoaded.FilePath;
                        loadedFile.DataModel          = objectJustLoaded.DataModel;
                        loadedFile.ReferencedFileSave = objectJustLoaded.ReferencedFileSave;
                        toReturn = loadedFile;
                    }
                }
            }
            break;

            case "Text":
            {
                Scene scene = objectJustLoaded.RuntimeObject as Scene;

                Text loadedText = scene.Texts.FindByName(objectName);
                if (loadedText != null)
                {
                    if (shouldClone)
                    {
                        loadedText = loadedText.Clone();
                        (toAddTo as Scene).Texts.Add(loadedText);

                        TextManager.AddToLayer(loadedText, layerToAddTo);

                        var loadedFile = new LoadedFile();

                        loadedFile.RuntimeObject      = loadedText;
                        loadedFile.FilePath           = objectJustLoaded.FilePath;
                        loadedFile.DataModel          = objectJustLoaded.DataModel;
                        loadedFile.ReferencedFileSave = objectJustLoaded.ReferencedFileSave;
                        toReturn = loadedFile;
                    }
                    loadedText.AdjustPositionForPixelPerfectDrawing = true;
                    if (LocalizationManager.HasDatabase)
                    {
                        loadedText.DisplayText = LocalizationManager.Translate(loadedText.DisplayText);
                    }
                }
            }
            break;

            case "ShapeCollection":
            {
                ShapeCollection shapeCollection = objectJustLoaded.RuntimeObject as ShapeCollection;

                if (shouldClone)
                {
                    shapeCollection = shapeCollection.Clone();
                    elementRuntime.EntireShapeCollections.Add(objectToLoad.SourceFile, shapeCollection);

                    newElementRuntime.ReferencedFileRuntimeList.LoadedShapeCollections.Add(shapeCollection);

                    shapeCollection.AddToManagers(layerToAddTo);

                    var loadedFile = new LoadedFile();

                    loadedFile.RuntimeObject      = shapeCollection;
                    loadedFile.FilePath           = objectJustLoaded.FilePath;
                    loadedFile.DataModel          = objectJustLoaded.DataModel;
                    loadedFile.ReferencedFileSave = objectJustLoaded.ReferencedFileSave;
                    toReturn = loadedFile;
                }
                // Most cases are handled below in an AttachTo method, but
                // ShapeCollection isn't a PositionedObject so we have to do it manually here
                if (objectToLoad.AttachToContainer)
                {
                    shapeCollection.AttachTo(elementRuntime, true);
                }
            }
            break;

            case "AxisAlignedCube":
            {
                ShapeCollection shapeCollection       = objectJustLoaded.RuntimeObject as ShapeCollection;
                AxisAlignedCube loadedAxisAlignedCube = shapeCollection.AxisAlignedCubes.FindByName(objectName);


                if (shouldClone)
                {
                    loadedAxisAlignedCube = loadedAxisAlignedCube.Clone();
                    (toAddTo as ShapeCollection).AxisAlignedCubes.Add(loadedAxisAlignedCube);
                    ShapeManager.AddToLayer(loadedAxisAlignedCube, layerToAddTo);

                    var loadedFile = new LoadedFile();

                    loadedFile.RuntimeObject      = loadedAxisAlignedCube;
                    loadedFile.FilePath           = objectJustLoaded.FilePath;
                    loadedFile.DataModel          = objectJustLoaded.DataModel;
                    loadedFile.ReferencedFileSave = objectJustLoaded.ReferencedFileSave;
                    toReturn = loadedFile;
                }
            }
            break;


            case "AxisAlignedRectangle":
            {
                ShapeCollection      shapeCollection            = objectJustLoaded.RuntimeObject as ShapeCollection;
                AxisAlignedRectangle loadedAxisAlignedRectangle = shapeCollection.AxisAlignedRectangles.FindByName(objectName);


                if (shouldClone)
                {
                    loadedAxisAlignedRectangle = loadedAxisAlignedRectangle.Clone();
                    (toAddTo as ShapeCollection).AxisAlignedRectangles.Add(loadedAxisAlignedRectangle);
                    ShapeManager.AddToLayer(loadedAxisAlignedRectangle, layerToAddTo);

                    var loadedFile = new LoadedFile();

                    loadedFile.RuntimeObject      = loadedAxisAlignedRectangle;
                    loadedFile.FilePath           = objectJustLoaded.FilePath;
                    loadedFile.DataModel          = objectJustLoaded.DataModel;
                    loadedFile.ReferencedFileSave = objectJustLoaded.ReferencedFileSave;
                    toReturn = loadedFile;
                }
            }
            break;

            case "Circle":
            {
                ShapeCollection shapeCollection = objectJustLoaded.RuntimeObject as ShapeCollection;
                Circle          loadedCircle    = shapeCollection.Circles.FindByName(objectName);


                if (shouldClone)
                {
                    loadedCircle = loadedCircle.Clone();
                    (toAddTo as ShapeCollection).Circles.Add(loadedCircle);
                    ShapeManager.AddToLayer(loadedCircle, layerToAddTo);

                    var loadedFile = new LoadedFile();

                    loadedFile.RuntimeObject      = loadedCircle;
                    loadedFile.FilePath           = objectJustLoaded.FilePath;
                    loadedFile.DataModel          = objectJustLoaded.DataModel;
                    loadedFile.ReferencedFileSave = objectJustLoaded.ReferencedFileSave;
                    toReturn = loadedFile;
                }
            }
            break;

            case "Polygon":
            {
                ShapeCollection shapeCollection = objectJustLoaded.RuntimeObject as ShapeCollection;
                Polygon         loadedPolygon   = shapeCollection.Polygons.FindByName(objectName);


                if (shouldClone)
                {
                    loadedPolygon = loadedPolygon.Clone();
                    (toAddTo as ShapeCollection).Polygons.Add(loadedPolygon);
                    ShapeManager.AddToLayer(loadedPolygon, layerToAddTo);

                    var loadedFile = new LoadedFile();

                    loadedFile.RuntimeObject      = loadedPolygon;
                    loadedFile.FilePath           = objectJustLoaded.FilePath;
                    loadedFile.DataModel          = objectJustLoaded.DataModel;
                    loadedFile.ReferencedFileSave = objectJustLoaded.ReferencedFileSave;
                    toReturn = loadedFile;
                }
            }
            break;

            case "Sphere":
            {
                ShapeCollection shapeCollection = objectJustLoaded.RuntimeObject as ShapeCollection;
                Sphere          loadedSphere    = shapeCollection.Spheres.FindByName(objectName);


                if (shouldClone)
                {
                    loadedSphere = loadedSphere.Clone();
                    (toAddTo as ShapeCollection).Spheres.Add(loadedSphere);
                    ShapeManager.AddToLayer(loadedSphere, layerToAddTo);

                    var loadedFile = new LoadedFile();

                    loadedFile.RuntimeObject      = loadedSphere;
                    loadedFile.FilePath           = objectJustLoaded.FilePath;
                    loadedFile.DataModel          = objectJustLoaded.DataModel;
                    loadedFile.ReferencedFileSave = objectJustLoaded.ReferencedFileSave;
                    toReturn = loadedFile;
                }
            }
            break;

            case "Capsule2D":
            {
                ShapeCollection shapeCollection = objectJustLoaded.RuntimeObject as ShapeCollection;
                Capsule2D       loadedCapsule2D = shapeCollection.Capsule2Ds.FindByName(objectName);


                if (shouldClone)
                {
                    loadedCapsule2D = loadedCapsule2D.Clone();
                    (toAddTo as ShapeCollection).Capsule2Ds.Add(loadedCapsule2D);
                    ShapeManager.AddToLayer(loadedCapsule2D, layerToAddTo);

                    var loadedFile = new LoadedFile();

                    loadedFile.RuntimeObject      = loadedCapsule2D;
                    loadedFile.FilePath           = objectJustLoaded.FilePath;
                    loadedFile.DataModel          = objectJustLoaded.DataModel;
                    loadedFile.ReferencedFileSave = objectJustLoaded.ReferencedFileSave;
                    toReturn = loadedFile;
                }
            }
            break;

            case "Emitter":
            {
                EmitterList emitterList   = objectJustLoaded.RuntimeObject as EmitterList;
                Emitter     loadedEmitter = emitterList.FindByName(objectName);

                if (shouldClone && loadedEmitter != null)
                {
                    loadedEmitter = loadedEmitter.Clone();
                    (toAddTo as EmitterList).Add(loadedEmitter);
                    SpriteManager.AddEmitter(loadedEmitter, layerToAddTo);

                    var loadedFile = new LoadedFile();

                    loadedFile.RuntimeObject      = loadedEmitter;
                    loadedFile.FilePath           = objectJustLoaded.FilePath;
                    loadedFile.DataModel          = objectJustLoaded.DataModel;
                    loadedFile.ReferencedFileSave = objectJustLoaded.ReferencedFileSave;
                    toReturn = loadedFile;
                }
            }
            break;

            case "EmitterList":
            {
                EmitterList emitterList = objectJustLoaded.RuntimeObject as EmitterList;

                if (shouldClone && emitterList != null)
                {
                    emitterList = emitterList.Clone();

                    foreach (var item in emitterList)
                    {
                        SpriteManager.AddEmitter(item);
                    }

                    var loadedFile = new LoadedFile();

                    loadedFile.RuntimeObject      = emitterList;
                    loadedFile.FilePath           = objectJustLoaded.FilePath;
                    loadedFile.DataModel          = objectJustLoaded.DataModel;
                    loadedFile.ReferencedFileSave = objectJustLoaded.ReferencedFileSave;
                    toReturn = loadedFile;
                }
            }
            break;

            case "NodeNetwork":
            {
                NodeNetwork nodeNetwork = objectJustLoaded.RuntimeObject as NodeNetwork;

                if (shouldClone)
                {
                    nodeNetwork = nodeNetwork.Clone();

                    elementRuntime.EntireNodeNetworks.Add(objectToLoad.SourceFile, nodeNetwork);

                    newElementRuntime.ReferencedFileRuntimeList.LoadedNodeNetworks.Add(nodeNetwork);

                    var loadedFile = new LoadedFile();

                    loadedFile.RuntimeObject      = nodeNetwork;
                    loadedFile.FilePath           = objectJustLoaded.FilePath;
                    loadedFile.DataModel          = objectJustLoaded.DataModel;
                    loadedFile.ReferencedFileSave = objectJustLoaded.ReferencedFileSave;
                    toReturn = loadedFile;
                }
            }
            break;

            case "SplineList":
            {
                SplineList splineList = objectJustLoaded.RuntimeObject as SplineList;

                if (shouldClone)
                {
                    splineList = splineList.Clone();

                    elementRuntime.EntireSplineLists.Add(splineList.Name, splineList);

                    foreach (var spline in splineList)
                    {
                        spline.CalculateVelocities();
                        spline.CalculateAccelerations();
                    }

                    splineList.AddToManagers();


                    splineList[0].UpdateShapes();

                    var loadedFile = new LoadedFile();

                    loadedFile.RuntimeObject      = splineList;
                    loadedFile.FilePath           = objectJustLoaded.FilePath;
                    loadedFile.DataModel          = objectJustLoaded.DataModel;
                    loadedFile.ReferencedFileSave = objectJustLoaded.ReferencedFileSave;
                    toReturn = loadedFile;
                }
            }
            break;

            case "Spline":
            {
                SplineList splineList = objectJustLoaded.RuntimeObject as SplineList;
                Spline     spline     = splineList.FirstOrDefault(item => item.Name == objectName);


                if (shouldClone && spline != null)
                {
                    spline = spline.Clone();
                    (toAddTo as SplineList).Add(spline);

                    // Eventually support layers?
                    //ShapeManager.AddToLayer(spline, layerToAddTo);

                    var loadedFile = new LoadedFile();

                    loadedFile.RuntimeObject      = spline;
                    loadedFile.FilePath           = objectJustLoaded.FilePath;
                    loadedFile.DataModel          = objectJustLoaded.DataModel;
                    loadedFile.ReferencedFileSave = objectJustLoaded.ReferencedFileSave;
                    toReturn = loadedFile;
                }
                spline.CalculateVelocities();
                spline.CalculateAccelerations();
            }
            break;
            }

            if (toReturn == null)
            {
                foreach (var manager in ReferencedFileRuntimeList.FileManagers)
                {
                    var objectFromFile = manager.TryGetObjectFromFile(elementRuntime.ReferencedFileRuntimeList.LoadedRfses, rfs, objectType, objectName);

                    if (objectFromFile != null)
                    {
                        var runtimeObject = objectFromFile;

                        var loadedFile = new LoadedFile();

                        loadedFile.RuntimeObject      = runtimeObject;
                        loadedFile.FilePath           = objectJustLoaded.FilePath;
                        loadedFile.DataModel          = objectJustLoaded.DataModel;
                        loadedFile.ReferencedFileSave = objectJustLoaded.ReferencedFileSave;
                        toReturn = loadedFile;


                        break;
                    }
                }
            }


            if (toReturn != null && objectToLoad.AttachToContainer)
            {
                if (toReturn.RuntimeObject is PositionedObject)
                {
                    // If the object is already attached to something, that means it
                    // came from a file, so we don't want to re-attach it.
                    PositionedObject asPositionedObject = toReturn.RuntimeObject as PositionedObject;
                    if (asPositionedObject.Parent == null)
                    {
                        asPositionedObject.AttachTo(elementRuntime, true);
                    }
                }
                else if (toReturn.RuntimeObject is Scene)
                {
                    ((Scene)toReturn.RuntimeObject).AttachAllDetachedTo(elementRuntime, true);
                }
                else if (toReturn.RuntimeObject is ShapeCollection)
                {
                    ((ShapeCollection)toReturn.RuntimeObject).AttachAllDetachedTo(elementRuntime, true);
                }
            }


            return(toReturn);
        }