Пример #1
0
        void SaveShapeListOk(Window callingWindow)
        {
            string fileName = ((FileWindow)callingWindow).Results[0];

            ShapeCollectionSave shapeSaveList = new ShapeCollectionSave();

            shapeSaveList.AddPolygonList(EditorData.Polygons);
            shapeSaveList.AddAxisAlignedRectangleList(EditorData.AxisAlignedRectangles);
            shapeSaveList.AddCircleList(EditorData.Circles);
            shapeSaveList.AddAxisAlignedCubeList(EditorData.AxisAlignedCubes);
            shapeSaveList.AddSphereList(EditorData.Spheres);
            shapeSaveList.Save(fileName);

#if FRB_MDX
            GameForm.TitleText = "PolygonEditor - Editing " + fileName;
#else
            FlatRedBallServices.Game.Window.Title = "PolygonEditor Editing - " + fileName;
#endif

            fileName  = FileManager.RemoveExtension(fileName);
            fileName += ".pesix";
            PolygonEditorSettings savedInformation = new PolygonEditorSettings(EditorData.LineGrid);
            savedInformation.BoundsCameraSave    = CameraSave.FromCamera(EditorData.BoundsCamera);
            savedInformation.UsePixelCoordinates = SpriteManager.Camera.Orthogonal;
            savedInformation.Save(fileName);
        }
Пример #2
0
        public static void LoadPolygonList(string fileName)
        {
            FlatRedBall.Content.Polygon.PolygonSaveList psl = FlatRedBall.Content.Polygon.PolygonSaveList.FromFile(fileName);

            PositionedObjectList <Polygon> polygonList = psl.ToPolygonList();

            // At a later time may want to support Insert and Replace.  For now, do Replace
            while (Polygons.Count != 0)
            {
                ShapeManager.Remove(Polygons[0]);
            }

            foreach (Polygon polygon in polygonList)
            {
                ShapeManager.AddPolygon(polygon);
                ShapeCollection.Polygons.Add(polygon);
                polygon.Color = EditorProperties.PolygonColor;
            }

#if FRB_MDX
            GameForm.TitleText = "PolygonEditor - Editing " + fileName;
#else
            FlatRedBallServices.Game.Window.Title = "PolygonEditor Editing - " + fileName;
#endif

            LastLoadedShapeCollection = null;
            LastLoadedPolygonList     = fileName;

            #region Load the SavedInformation if available

            fileName = FileManager.RemoveExtension(fileName) + ".pesix";
            if (System.IO.File.Exists(fileName))
            {
                try
                {
                    PolygonEditorSettings savedInformation = PolygonEditorSettings.FromFile(fileName);

                    if (savedInformation.LineGridSave != null)
                    {
                        savedInformation.LineGridSave.ToLineGrid(EditorData.LineGrid);
                    }

                    if (savedInformation.UsePixelCoordinates)
                    {
                        SpriteManager.Camera.UsePixelCoordinates(false);
                    }
                }
                catch
                {
                    GuiManager.ShowMessageBox(
                        "Could not load the settings file " + fileName + ".  \nThe data file was loaded with no problems",
                        "Error");
                }
            }
            #endregion
        }
Пример #3
0
        void SavePolygonListOk(Window callingWindow)
        {
            string fileName = ((FileWindow)callingWindow).Results[0];

            PolygonSaveList polygonSaveList = new PolygonSaveList();

            polygonSaveList.AddPolygonList(EditorData.Polygons);
            polygonSaveList.Save(fileName);

#if FRB_MDX
            GameForm.TitleText = "PolygonEditor - Editing " + fileName;
#else
            FlatRedBallServices.Game.Window.Title = "PolygonEditor Editing - " + fileName;
#endif

            fileName  = FileManager.RemoveExtension(fileName);
            fileName += ".pesix";
            PolygonEditorSettings savedInformation = new PolygonEditorSettings(EditorData.LineGrid);
            savedInformation.Save(fileName);
        }
Пример #4
0
        public static void LoadShapeCollection(string fileName, ReplaceOrInsert replaceOrInsert)
        {
            #region Load and set the ShapeCollection

            FlatRedBall.Content.Math.Geometry.ShapeCollectionSave ssl = FlatRedBall.Content.Math.Geometry.ShapeCollectionSave.FromFile(fileName);
            ssl.Shift(mOffset);
            mOffset = new Vector3();
            // Remove the current shapes

            if (mTypesToLoad != null)
            {
                if (!mTypesToLoad.LoadCubes)
                {
                    ssl.AxisAlignedCubeSaves.Clear();
                }

                if (!mTypesToLoad.LoadRectangles)
                {
                    ssl.AxisAlignedRectangleSaves.Clear();
                }

                if (!mTypesToLoad.LoadCircles)
                {
                    ssl.CircleSaves.Clear();
                }

                if (!mTypesToLoad.LoadPolygons)
                {
                    ssl.PolygonSaves.Clear();
                }

                if (!mTypesToLoad.LoadSpheres)
                {
                    ssl.SphereSaves.Clear();
                }


                mTypesToLoad = null;
            }

            if (replaceOrInsert == ReplaceOrInsert.Replace)
            {
                EditorData.ShapeCollection.RemoveFromManagers(true);

                ssl.SetShapeCollection(EditorData.ShapeCollection);
                EditorData.ShapeCollection.AddToManagers();
            }
            else
            {
                string nameToPreserve = EditorData.ShapeCollection.Name;

                // Easiest way to get everything in the ShapeManager is to remove the shapes from the managers
                // then re-add them once the newly-loaded shapes have been put in the ShapeCollection
                EditorData.ShapeCollection.RemoveFromManagers(false);

                ssl.SetShapeCollection(EditorData.ShapeCollection); // this will just add to the ShapeCollection

                EditorData.ShapeCollection.AddToManagers();
                EditorData.ShapeCollection.Name = nameToPreserve;
            }
            #endregion

            #region Set the title of the window

            if (replaceOrInsert == ReplaceOrInsert.Replace)
            {
#if FRB_MDX
                // Do this before loading the SavedInformation
                GameForm.TitleText = "PolygonEditor - Editing " + fileName;
#else
                FlatRedBallServices.Game.Window.Title = "PolygonEditor Editing - " + fileName;
#endif
            }

            #endregion

            if (replaceOrInsert == ReplaceOrInsert.Replace)
            {
                EditorData.LastLoadedPolygonList     = null;
                EditorData.LastLoadedShapeCollection = fileName;
            }

            #region Load the SavedInformation if available

            if (replaceOrInsert == ReplaceOrInsert.Replace)
            {
                fileName = FileManager.RemoveExtension(fileName) + ".pesix";
                if (System.IO.File.Exists(fileName))
                {
                    try
                    {
                        PolygonEditorSettings savedInformation = PolygonEditorSettings.FromFile(fileName);
                        if (savedInformation.LineGridSave != null)
                        {
                            savedInformation.LineGridSave.ToLineGrid(EditorData.LineGrid);
                        }

                        if (savedInformation.BoundsCameraSave != null)
                        {
                            savedInformation.BoundsCameraSave.SetCamera(EditorData.BoundsCamera);
                        }

                        if (savedInformation.UsePixelCoordinates)
                        {
                            SpriteManager.Camera.UsePixelCoordinates(false);
                        }
                    }
                    catch
                    {
                        GuiManager.ShowMessageBox(
                            "Could not load the settings file " + fileName + ".  \nThe data file was loaded with no problems",
                            "Error");
                    }
                }
            }
            #endregion
        }