Ejemplo n.º 1
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
        }
Ejemplo n.º 2
0
        public PositionedObjectList <Polygon> LoadPolygonList(string name, bool addToShapeManager, bool makeVisible)
        {
            PolygonSaveList psl = PolygonSaveList.FromFile(name);

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

            if (addToShapeManager)
            {
                foreach (Polygon polygon in loadedPolygons)
                {
                    ShapeManager.AddPolygon(polygon);
                }
            }

            foreach (Polygon polygon in loadedPolygons)
            {
                polygon.Visible = makeVisible;
            }

            mPolygons.AddRange(loadedPolygons);

            return(loadedPolygons);
        }