Example #1
0
        public static void LoadSetFileWindowOk(Window callingWindow)
        {
            string fileName = ((FileWindow)callingWindow).Results[0];

            #region Load the file to the mInstructionSetSaveList field - it may be stored off until the .scnx is found
            LastLoadInformation.LastInstructionSetLoaded = fileName;
            mInstructionSetSaveList = InstructionSetSaveList.FromFile(LastLoadInformation.LastInstructionSetLoaded);
            #endregion

            #region Load the properties file (.iepsx) if it exists

            string iepsxFileName = FileManager.RemoveExtension(fileName) + ".iepsx";

            if (FileManager.FileExists(iepsxFileName))
            {
                InstructionEditorPropertiesSave iepsx = InstructionEditorPropertiesSave.FromFile(iepsxFileName);
                iepsx.ApplyToEditor();
            }


            #endregion

            // See if there is already a Blocking scene loaded
            if (EditorData.BlockingScene == null || string.IsNullOrEmpty(EditorData.BlockingScene.Name))
            {
                OkCancelWindow okCancelWindow =
                    GuiManager.ShowOkCancelWindow("There is no blocking scene currently loaded.  Attempt to load the scene " +
                                                  "referenced by the loaded Instruction Set?", "No Scene Loaded");
                okCancelWindow.OkClick += LoadBlockingFromLoadedInstructionSet;
            }
            else
            {
                AddCurrentlyLoadedInstructionSet();
            }

            /*
             *
             #region blueprint Sprites already loaded
             *          if(GuiData.ListBoxWindow.BlueprintSpriteListBox.Count != 0)
             *          {
             *                  CreateActiveSpritesFromIss();
             *                  TimeLineMessages.ToStartPushed(null);
             *
             *          }
             #endregion
             *
             #region blueprint Sprites not already loaded
             *          else
             *          {
             *                  MultiButtonMessageBox mbmb = GuiManager.AddMultiButtonMessageBox();
             *                  mbmb.Name = "No Blueprints Loaded";
             *                  mbmb.Text = ((FileWindow)callingWindow).result[0] + " instruction set requires active Sprites to be loaded.  What would you like to do?";
             *
             *                  mbmb.AddButton("Manually search for .scnx file.", new GuiMessage(LoadActiveSceneClick));
             *
             * //				mbmb.AddButton("Automatically search for .scn with Sprites matching instructions.", new GuiMessage(AutoSearchScn));
             *          }
             #endregion
             */
        }
Example #2
0
        void WarnAboutSavingScene(Window callingWindow)
        {
            string message = "You are attempting to save a Scene (.scnx).  Scenes do not include any node network information.  If you are trying to save a node network, select the Save Node Network menu item";

            OkCancelWindow ocw = GuiManager.ShowOkCancelWindow(message, "Warning");

            ocw.OkClick += OpenFileWindowSaveScene;
        }
        void RemoveAllAnimationButtonClick(Window callingWindow)
        {
            OkCancelWindow window = GuiManager.ShowOkCancelWindow("Are you sure you want to remove all animation information from this model?" +
                                                                  "All objects attached to any joints will be detached.", "Remove anim info");

            window.OkText     = "Yes";
            window.CancelText = "No";

            window.OkClick += new GuiMessage(OnRemoveAllAnimationOk);
        }
Example #4
0
        public static void LoadSpriteRigClick(Window callingWindow)
        {
            OkCancelWindow tempWindow = GuiManager.AddOkCancelWindow();

            tempWindow.ScaleX     = 22f;
            tempWindow.ScaleY     = 19f;
            tempWindow.Message    = "The SpriteEditor does not fully support SpriteRig editing.  Currently, the SpriteEditor can only remember animations for one SpriteRig at a time.  Therefore, you should not load more than one SpriteRig per SpriteEditor session unless you do not plan on saving the SpriteRigs.  \n\nAlso, do not add or remove any Sprites from the SpriteRig as the animation data depends on having the same number of joints and body sprites when saving the SpriteRig.\n\nIf you attempt to save a SpriteRig which does not match the animation information, the SpriteEditor will warn you.\n\nLoad SpriteRig?";
            tempWindow.OkText     = "Yes";
            tempWindow.CancelText = "No";
            tempWindow.OkClick   += new GuiMessage(OpenFileWindowLoadSpriteRig);
        }
Example #5
0
        public static void PromptNew(Window callingWindow)
        {
            OkCancelWindow toNew = GuiManager.AddOkCancelWindow();

            toNew.Name       = "New";
            toNew.Message    = "Any unsaved data will be lost. Continue?";
            toNew.ScaleX     = 9.4f;
            toNew.ScaleY     = 5;
            toNew.OkClick   += new GuiMessage(NewScene);
            toNew.HasMoveBar = true;
            GuiManager.AddDominantWindow(toNew);
        }
Example #6
0
        public static void NewSceneClick(Window callingWindow)
        {
            OkCancelWindow tempWindow = GuiManager.AddOkCancelWindow();

            tempWindow.Name       = "New Scene";
            tempWindow.ScaleX     = 12f;
            tempWindow.ScaleY     = 6f;
            tempWindow.Message    = "Creating a new scene will delete the current scene.  Continue?";
            tempWindow.OkClick   += new GuiMessage(newSceneOk);
            tempWindow.HasMoveBar = true;
            GuiManager.AddDominantWindow(tempWindow);
        }
Example #7
0
        public static void AskIfChangesShouldBeApplied(GuiMessage extraMessage)
        {
            OkCancelWindow tempBox = GuiManager.ShowOkCancelWindow("Apply changes to grid?", "Grid Update");

            tempBox.OkClick     += new GuiMessage(SpriteGridGuiMessages.updateSpriteGridOk);
            tempBox.CancelClick += new GuiMessage(SpriteGridGuiMessages.updateSpriteGridCancel);

            if (extraMessage != null)
            {
                tempBox.OkClick += extraMessage;
            }
        }
Example #8
0
        private void KeyboardControl()
        {
            if (InputManager.ReceivingInput != null)
            {
                return;
            }

            #region Escape for exit
            if (InputManager.Keyboard.KeyPushed(Keys.Escape))
            {
                OkCancelWindow ocw = GuiManager.ShowOkCancelWindow("Exit ParticleEditor?  Unsaved data will be lost", "Exit?");
                ocw.OkClick += new GuiMessage(GuiData.Messages.ExitOk);
            }
            #endregion

            #region press space to emit current emitter
            if (InputManager.Keyboard.KeyPushed(Keys.Space) && AppState.Self.CurrentEmitter != null)
            {
                AppState.Self.CurrentEmitter.Emit(null);
            }
            #endregion

            #region Ctrl + C for copying emitter
            if ((InputManager.Keyboard.KeyDown(Keys.LeftControl) || InputManager.Keyboard.KeyDown(Keys.RightControl)) && InputManager.Keyboard.KeyPushed(Keys.C))
            {
                EditorData.CopyCurrentEmitter();
            }
            #endregion

            #region pressing C to clear all particles
            else if (InputManager.Keyboard.KeyPushed(Keys.C))
            {
                GuiData.ActivityWindow.ClearAllParticles();
            }
            #endregion

            #region pressing delete to delete the current emitter
            if (InputManager.Keyboard.KeyPushed(Keys.Delete))
            {
                DeleteCurrentEmitter();
            }
            #endregion

            if (InputManager.Keyboard.KeyPushed(Keys.A))
            {
                GuiData.ToolsWindow.attachObject.Press();
            }
            if (InputManager.Keyboard.KeyPushed(Keys.M))
            {
                GuiData.ToolsWindow.moveObject.Press();
            }
        }
Example #9
0
 public static void SaveSpriteRigClick(Window callingWindow)
 {
     if (GuiData.srSaveOptions.poseChains != null)
     {
         OkCancelWindow okCancel = GuiManager.ShowOkCancelWindow("The SpriteEditor has a SpriteRig in memory.  Save this SpriteRig?", "SpriteRig in memory");
         okCancel.OkClick     += new GuiMessage(SaveStoredSpriteRig);
         okCancel.CancelClick += new GuiMessage(SaveStoredSpriteRigCancel);
     }
     else
     {
         GuiData.srSaveOptions.Visible = true;
         GuiData.srSaveOptions.FillComboBoxes();
     }
 }
        private void SetPixelPerfectClick(Window callingWindow)
        {
            if (SelectedObject.GridPlane != SpriteGrid.Plane.XY)
            {
                GuiManager.ShowMessageBox("Can't set pixel perfect because this SpriteGrid doesn't use the X/Y Plane", "Invalid Operation");
            }
            else if (SelectedObject != null && SelectedObject.Blueprint.Texture != null)
            {
                Texture2D texture = SelectedObject.Blueprint.Texture;

                float gridZ = SelectedObject.Blueprint.Z;


                float pixelsPerUnit = SpriteManager.Camera.PixelsPerUnitAt(gridZ);

                float desiredScaleX  = .5f * texture.Width / pixelsPerUnit;
                float desiredSpacing = 2 * desiredScaleX;


                // this could potentially make a LOT of Sprites, so we should run a test to make sure the SE isn't going
                // to make too many Sprites.
                float leftBound  = Math.Max(SpriteManager.Camera.AbsoluteLeftXEdgeAt(gridZ), SelectedObject.XLeftBound);
                float rightBound = Math.Min(SpriteManager.Camera.AbsoluteRightXEdgeAt(gridZ), SelectedObject.XRightBound);

                float topBound    = Math.Min(SpriteManager.Camera.AbsoluteTopYEdgeAt(gridZ), SelectedObject.YTopBound);
                float bottomBound = Math.Max(SpriteManager.Camera.AbsoluteBottomYEdgeAt(gridZ), SelectedObject.YBottomBound);

                float numberX = (rightBound - leftBound) / desiredSpacing;
                float numberY = (topBound - bottomBound) / desiredSpacing;

                int totalNumber = FlatRedBall.Math.MathFunctions.RoundToInt(numberX * numberY);

                if (totalNumber > 10000)
                {
                    OkCancelWindow okCancelWindow = GuiManager.ShowOkCancelWindow("This operation will result in approximately " + totalNumber + " Sprites in view. " +
                                                                                  "This could make the SpriteEditor run very slowly or even appear to completely freeze.  Are you sure you want " +
                                                                                  "to perform this action?", "Are you sure?");

                    okCancelWindow.OkClick   += new GuiMessage(ForceSetToPixelPerfect);
                    okCancelWindow.OkText     = "Yes";
                    okCancelWindow.CancelText = "No";
                }
                else
                {
                    ForceSetToPixelPerfect(null);
                }
            }
        }
        private void FlipVerticallyClick(Window callingWindow)
        {
            if (SelectedObject == null)
            {
                return;
            }
            foreach (AnimationFrame animationFrame in SelectedObject)
            {
                animationFrame.FlipVertical = !animationFrame.FlipVertical;
            }

            OkCancelWindow okCancelWindow = GuiManager.ShowOkCancelWindow(
                "Invert RelativeY values?", "Invert RelativeY?");

            okCancelWindow.HasMoveBar = true;
            okCancelWindow.OkClick   += new GuiMessage(InvertRelativeYValues);
        }
Example #12
0
 void SaveSceneClick(Window callingWindow)
 {
     // See if the shape collection is empty.  If it's not, the user
     // might be trying to save a .scnx file which will include the shapes.
     // Just to amek sure they don't make that mistake, give them a warning.
     if (!EditorData.ShapeCollection.IsEmpty)
     {
         OkCancelWindow ocw = GuiManager.ShowOkCancelWindow(
             "You are attempting to save a Scene.  Scenes cannot save any shape information (polygons, circles, etc)." +
             "  If you are trying to save shape information, save either a Polygon List (plylstx) or Shape Collection (shcx).", "Warning");
         ocw.HasMoveBar = true;
         ocw.OkClick   += ShowFileWindowToSaveScene;
     }
     else
     {
         ShowFileWindowToSaveScene(null);
     }
 }
Example #13
0
 public void AskToReplaceOrInsertNewScene(string fileName)
 {
     if (FileManager.FileExists(fileName))
     {
         OkCancelWindow tempWindow = GuiManager.AddOkCancelWindow();
         tempWindow.Message      = "Would you like to replace the current scene or insert " + fileName + " into the current scene?";
         tempWindow.ScaleX       = 16f;
         tempWindow.ScaleY       = 10f;
         tempWindow.Name         = fileName;
         tempWindow.OkText       = "Replace";
         tempWindow.OkClick     += new GuiMessage(LoadSceneReplaceClick);
         tempWindow.CancelText   = "Insert";
         tempWindow.CancelClick += new GuiMessage(LoadSceneInsertClick);
     }
     else
     {
         MessageBox messageBox = GuiManager.ShowMessageBox("Could not find the file " + fileName, "Error loading .scnx");
     }
 }
Example #14
0
        private void GameForm_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            try
            {
                EditorObjects.Gui.LayoutManager.SaveWindowLayout();
            }
            catch (Exception saveException)
            {
                System.Windows.Forms.MessageBox.Show("Error saving the screen layout. " +
                                                     "A file has been saved containing error information.  You can help solve this problem " +
                                                     "by posting the error contained in this file on the FlatRedBall forums.  The file can be " +
                                                     "found in My Documents");

                StringBuilder errorInformation = new StringBuilder();

                errorInformation.AppendLine("Error saving window layout.  Error information: ");
                errorInformation.AppendLine(e.ToString());

                errorInformation.AppendLine("The following windows are contained in the GuiManager");

                foreach (Window w in GuiManager.Windows)
                {
                    errorInformation.AppendLine(w.GetType() + " " + w.Name + " " + w.ToString());
                }

                FileManager.SaveText(errorInformation.ToString(),
                                     FileManager.MyDocuments + "WindowLayoutError.txt");
            }

            OkCancelWindow toExit = GuiManager.AddOkCancelWindow();

            toExit.Message  = "Any unsaved changes will be lost. Are you sure you want to exit?";
            toExit.ScaleX   = 9.4f;
            toExit.ScaleY   = 7;
            toExit.OkClick += new GuiMessage(ExitMessage);
            InputManager.ReceivingInput = toExit;
            GuiManager.AddDominantWindow(toExit);

            e.Cancel = true;
        }
Example #15
0
 public static void loadGridAnimationTextureOk(Window callingWindow)
 {
     if (FileManager.GetExtension(((FileWindow)callingWindow).Results[0]) == "ach")
     {
         OkCancelWindow tempWindow = GuiManager.AddOkCancelWindow();
         tempWindow.ScaleX       = 10f;
         tempWindow.ScaleY       = 7f;
         tempWindow.OkText       = "Embed";
         tempWindow.OkClick     += new GuiMessage(SpriteGridGuiMessages.blueprintEmbedClick);
         tempWindow.CancelText   = "Reference";
         tempWindow.CancelClick += new GuiMessage(SpriteGridGuiMessages.blueprintReferenceClick);
         tempWindow.Message      = "Would you like to embed or reference the animation chain?";
         tempWindow.Name         = ((FileWindow)callingWindow).Results[0];
     }
     else
     {
         SESpriteGridManager.CurrentSpriteGrid.Blueprint.Texture =
             FlatRedBallServices.Load <Texture2D>(((FileWindow)callingWindow).Results[0], GameData.SceneContentManager);
         SESpriteGridManager.CurrentSpriteGrid.SetBaseTexture(SESpriteGridManager.CurrentSpriteGrid.Blueprint.Texture);
         SESpriteGridManager.CurrentSpriteGrid.RefreshPaint();
         GuiData.ListWindow.Add(SESpriteGridManager.CurrentSpriteGrid.Blueprint.Texture);
     }
 }
Example #16
0
        public void spriteGridOkClick(Window callingWindow)
        {
            if (SelectedObject.GridSpacing <= 0f)
            {
                GuiManager.ShowMessageBox("GridSpacing must be greater than 0.", "SpriteGrid error");
            }
            else if ((SelectedObject.Plane == SpriteGrid.Plane.XZ &&
                      (10000f < (SelectedObject.XRightBound - SelectedObject.XLeftBound) * (SelectedObject.ZFarBound - SelectedObject.ZCloseBound))) && (callingWindow.GetType() != typeof(OkCancelWindow)))
            {
                OkCancelWindow tempWindow = GuiManager.ShowOkCancelWindow("The grid you are creating is large and may result in sluggish performance or freezing of the SE.  What would you like to do?", "Large Grid");
                tempWindow.ScaleX     = 15f;
                tempWindow.OkText     = "Create anyway";
                tempWindow.CancelText = "Cancel conversion";
                tempWindow.OkClick   += new GuiMessage(this.spriteGridOkClick);
            }
            else if (mCreatingNewSpriteGrid)
            {
                SpriteGrid tempGrid = null;
                if (SelectedObject.Plane == SpriteGrid.Plane.XY)
                {
                    tempGrid = new SpriteGrid(this.camera, SpriteGrid.Plane.XY, mBlueprintSprite, null);
                }
                else
                {
                    tempGrid = new SpriteGrid(this.camera, SpriteGrid.Plane.XZ, mBlueprintSprite, null);
                }

                if (string.IsNullOrEmpty(mBlueprintSprite.Name))
                {
                    tempGrid.Name =
                        FileManager.RemovePath(mBlueprintSprite.Texture.Name);
                }
                else
                {
                    tempGrid.Name = mBlueprintSprite.Name;
                }

                tempGrid.XLeftBound   = SelectedObject.XLeftBound;
                tempGrid.XRightBound  = SelectedObject.XRightBound;
                tempGrid.YTopBound    = SelectedObject.YTopBound;
                tempGrid.YBottomBound = SelectedObject.YBottomBound;
                tempGrid.ZCloseBound  = SelectedObject.ZCloseBound;
                tempGrid.ZFarBound    = SelectedObject.ZFarBound;
                tempGrid.GridSpacing  = SelectedObject.GridSpacing;

                this.sesgMan.PopulateAndAddGridToEngine(tempGrid, mBlueprintSprite);

                StringFunctions.MakeNameUnique <SpriteGrid>(tempGrid, GameData.Scene.SpriteGrids);

                //tempGrid.InitializeTextureGrid();
                tempGrid.RefreshPaint();
                this.Visible = false;
                SpriteEditorSettings.EditingSpriteGrids  = true;
                GuiData.ToolsWindow.attachSprite.Enabled = false;
            }
            else
            {
                GameData.Cursor.ClickSprite(null);
                SESpriteGridManager.CurrentSpriteGrid.XLeftBound   = SelectedObject.XLeftBound;
                SESpriteGridManager.CurrentSpriteGrid.XRightBound  = SelectedObject.XRightBound;
                SESpriteGridManager.CurrentSpriteGrid.YTopBound    = SelectedObject.YTopBound;
                SESpriteGridManager.CurrentSpriteGrid.YBottomBound = SelectedObject.YBottomBound;
                SESpriteGridManager.CurrentSpriteGrid.ZCloseBound  = SelectedObject.ZCloseBound;
                SESpriteGridManager.CurrentSpriteGrid.ZFarBound    = SelectedObject.ZFarBound;
                if (SESpriteGridManager.CurrentSpriteGrid.GridSpacing != SelectedObject.GridSpacing)
                {
                    SESpriteGridManager.CurrentSpriteGrid.GridSpacing = SelectedObject.GridSpacing;
                    SESpriteGridManager.CurrentSpriteGrid.ResetTextures();
                    SESpriteGridManager.CurrentSpriteGrid.PopulateGrid(this.camera.X, this.camera.Y, 0f);
                }
                SESpriteGridManager.CurrentSpriteGrid.Manage();
                SESpriteGridManager.CurrentSpriteGrid.RefreshPaint();
                this.Visible = false;
            }
        }