예제 #1
0
        static void AdvancedClick(Window callingWindow)
        {
            mTypesToLoad = new TypesToLoad();
            mLastAsclw   = new AdvancedShapeCollectionLoadingWindow(
                GuiManager.Cursor, CreateMbmb(mFileNameToLoad), mTypesToLoad);

            GuiManager.AddWindow(mLastAsclw);
        }
예제 #2
0
        static void AdvancedClick(Window callingWindow)
        {
            mTypesToLoad = new TypesToLoad();
            mLastAsclw = new AdvancedShapeCollectionLoadingWindow(
                GuiManager.Cursor, CreateMbmb(mFileNameToLoad), mTypesToLoad);

            GuiManager.AddWindow(mLastAsclw);
        }
        public AdvancedShapeCollectionLoadingWindow(Cursor cursor, MultiButtonMessageBox mbmb, TypesToLoad typesToLoad) : base(cursor)
        {
            this.AddWindow(mbmb);

            this.ScaleX = mbmb.ScaleX + 12.5f;
            mbmb.DrawBorders = false;
            mbmb.X = mbmb.ScaleX;

            mbmb.RemoveButton(mbmb.GetButton("Advanced >>"));
            // Maybe one day we want to allow the user to go back to the 
            // basic view?  It's a pain, so I won't do that now

            mbmb.Y = mbmb.ScaleY;
            this.ScaleY = mbmb.ScaleY + 1;


            //Button cancelButton = mbmb.GetButton("Cancel");
            //mbmb.RemoveButton(cancelButton);
            mbmb.HasMoveBar = false;
            mbmb.HasCloseButton = false;
            this.HasMoveBar = true;

            //mbmb.AddButton(cancelButton);

            TextDisplay textDisplay = new TextDisplay(cursor);
            textDisplay.Text = "Offset";
            this.AddWindow(textDisplay);
            textDisplay.X = mbmb.ScaleX * 2;
            textDisplay.Y = 1;

            offsetWindow = new Vector3Display(cursor);
            this.AddWindow(offsetWindow);
            offsetWindow.X = mbmb.ScaleX * 2 + offsetWindow.ScaleX ;
            offsetWindow.Y = offsetWindow.ScaleY + 2;

            mbmb.Closing += new GuiMessage(CloseThis);
            this.Name = "";

            PropertyGrid<TypesToLoad> propertyGrid = new PropertyGrid<TypesToLoad>(cursor);
            propertyGrid.ObjectDisplaying = typesToLoad;
            propertyGrid.HasMoveBar = false;
            propertyGrid.HasCloseButton = false;

            this.AddWindow(propertyGrid);
            propertyGrid.X = mbmb.ScaleX * 2 + propertyGrid.ScaleX - 1; // subtract 1 because we're not going to show the frames
            propertyGrid.Y = propertyGrid.ScaleY + 2 + offsetWindow.ScaleY * 2 + .5f;

            propertyGrid.DrawBorders = false;

        }
예제 #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
        }
예제 #5
0
        public AdvancedShapeCollectionLoadingWindow(Cursor cursor, MultiButtonMessageBox mbmb, TypesToLoad typesToLoad) : base(cursor)
        {
            this.AddWindow(mbmb);

            this.ScaleX      = mbmb.ScaleX + 12.5f;
            mbmb.DrawBorders = false;
            mbmb.X           = mbmb.ScaleX;

            mbmb.RemoveButton(mbmb.GetButton("Advanced >>"));
            // Maybe one day we want to allow the user to go back to the
            // basic view?  It's a pain, so I won't do that now

            mbmb.Y      = mbmb.ScaleY;
            this.ScaleY = mbmb.ScaleY + 1;


            //Button cancelButton = mbmb.GetButton("Cancel");
            //mbmb.RemoveButton(cancelButton);
            mbmb.HasMoveBar     = false;
            mbmb.HasCloseButton = false;
            this.HasMoveBar     = true;

            //mbmb.AddButton(cancelButton);

            TextDisplay textDisplay = new TextDisplay(cursor);

            textDisplay.Text = "Offset";
            this.AddWindow(textDisplay);
            textDisplay.X = mbmb.ScaleX * 2;
            textDisplay.Y = 1;

            offsetWindow = new Vector3Display(cursor);
            this.AddWindow(offsetWindow);
            offsetWindow.X = mbmb.ScaleX * 2 + offsetWindow.ScaleX;
            offsetWindow.Y = offsetWindow.ScaleY + 2;

            mbmb.Closing += new GuiMessage(CloseThis);
            this.Name     = "";

            PropertyGrid <TypesToLoad> propertyGrid = new PropertyGrid <TypesToLoad>(cursor);

            propertyGrid.ObjectDisplaying = typesToLoad;
            propertyGrid.HasMoveBar       = false;
            propertyGrid.HasCloseButton   = false;

            this.AddWindow(propertyGrid);
            propertyGrid.X = mbmb.ScaleX * 2 + propertyGrid.ScaleX - 1; // subtract 1 because we're not going to show the frames
            propertyGrid.Y = propertyGrid.ScaleY + 2 + offsetWindow.ScaleY * 2 + .5f;

            propertyGrid.DrawBorders = false;
        }
예제 #6
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

        }