示例#1
0
        public OkListWindow(string message, string title)
            : base(GuiManager.Cursor)
        {
            mName          = title;
            ScaleX         = 13;
            ScaleY         = 15;
            HasMoveBar     = true;
            HasCloseButton = true;
            MinimumScaleX  = 9;
            MinimumScaleY  = 10;

            mOkButton = new Button(mCursor);
            AddWindow(mOkButton);
            mOkButton.ScaleX = 1.7f;
            mOkButton.ScaleY = 1.2f;
            mOkButton.Text   = "Ok";
            mOkButton.Click += new GuiMessage(OkButtonClicked);

            mMessageTextDisplay = new TextDisplay(mCursor);
            AddWindow(mMessageTextDisplay);
            mMessageTextDisplay.Text = message;
            mMessageTextDisplay.X    = 1;
            mMessageTextDisplay.Y    = 1.4f;

            mListBox = new ListBox(mCursor);
            AddWindow(mListBox);
            mListBox.StrongSelect += ShowSelectedItemInNewWindow;

            this.Resizable = true;
            Resizing      += WindowResize;

            WindowResize(this);

            GuiManager.AddDominantWindow(this);
        }
示例#2
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);
        }
示例#3
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);
        }
示例#4
0
        public void Show(bool creatingNewSpriteGrid, Sprite spriteToUse)
        {
            mCreatingNewSpriteGrid = creatingNewSpriteGrid;

            if (GameData.Camera.Orthogonal)
            {
                Texture2D texture = spriteToUse.Texture;

                float pixelsPerUnit = camera.PixelsPerUnitAt(spriteToUse.Z);


                spriteToUse.ScaleX = .5f * texture.Width / pixelsPerUnit;
                spriteToUse.ScaleY = .5f * texture.Height / pixelsPerUnit;

                SelectedObject.GridSpacing = 2 * spriteToUse.ScaleX;
            }
            else
            {
                SelectedObject.GridSpacing = 2;
            }

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

            SelectedObject.Plane = SpriteGrid.Plane.XY;
            UpdateDisplayedProperties();

            if (mCreatingNewSpriteGrid)
            {
                mBlueprintSprite = spriteToUse;

                this.Name    = "New SpriteGrid Properties";
                this.Visible = true;
                this.mResizeWarning.Visible = false;
                //this.yOrZTextDisplay.Visible = true;
                //this.yOrZComboBox.Visible = true;
                GuiManager.AddDominantWindow(this);
            }
            else
            {
                this.Visible = true;
                this.mResizeWarning.Visible = true;
                GuiManager.AddDominantWindow(this);
            }
        }
示例#5
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;
        }
示例#6
0
        void SaveNodeNetworkOk(Window callingWindow)
        {
            mNameOfNodeNetwork = ((FileWindow)callingWindow).Results[0];

            PropertyGrid <AxisFlippingSettings> axisFlippingSettings = new PropertyGrid <AxisFlippingSettings>(GuiManager.Cursor);

            axisFlippingSettings.HasCloseButton = false;
            axisFlippingSettings.Name           = "Save Options:";
            GuiManager.AddDominantWindow(axisFlippingSettings);
            axisFlippingSettings.HasCloseButton = true;
            axisFlippingSettings.SelectedObject = new AxisFlippingSettings();

            Button okButton = new Button(GuiManager.Cursor);

            okButton.Text   = "Save";
            okButton.ScaleX = 3f;
            okButton.ScaleY = 2;
            okButton.Click += SaveNodeNetworkSettingsOk;
            okButton.Click += RemoveParentWindow;

            axisFlippingSettings.Closing += GuiManager.RemoveWindow;
            axisFlippingSettings.AddWindow(okButton);
        }
示例#7
0
        public static void MakeSceneRelativeAndSave(Scene scene, string fileName, string contentManager, List <string> filesToMakeDotDotRelative,
                                                    ReplaceTextureDelegate replaceTextureDelegate, SaveSceneDelegate saveDelegate)
        {
            if (replaceTextureDelegate == null)
            {
                replaceTextureDelegate = DefaultReplaceTexture;
            }

            mTexturesNotRelative.Clear();
            mAnimationChainListsNotRelative.Clear();
            mFntFilesNotRelative.Clear();
            mModelsNotRelative.Clear();
            mExtraFilesToCopy.Clear();

            mSaveDelegate   = saveDelegate;
            mLastFileName   = fileName;
            mContentManager = contentManager;

            string pathOfFile = FileManager.GetDirectory(fileName);

            #region Find any not-relative Sprites

            foreach (Sprite s in scene.Sprites)
            {
                if (s.Texture == null)
                {
                    continue;
                }

                string textureFileName = s.Texture.SourceFile();

                if (!FileManager.IsRelativeTo(textureFileName, pathOfFile) &&
                    !mTexturesNotRelative.Contains(s.Texture))
                {
                    mTexturesNotRelative.Add(s.Texture);
                }

                if (s.AnimationChains != null && string.IsNullOrEmpty(s.AnimationChains.Name) == false &&
                    !FileManager.IsRelativeTo(s.AnimationChains.Name, pathOfFile) &&
                    !mAnimationChainListsNotRelative.Contains(s.AnimationChains))
                {
                    mAnimationChainListsNotRelative.Add(s.AnimationChains);
                }
            }

            #endregion

            #region Find any not-relative SpriteGrids

            foreach (SpriteGrid sg in scene.SpriteGrids)
            {
                List <Texture2D> usedTextures = sg.GetUsedTextures();
                foreach (Texture2D texture in usedTextures)
                {
                    if (!FileManager.IsRelativeTo(texture.SourceFile(), pathOfFile) && !mTexturesNotRelative.Contains(texture))
                    {
                        mTexturesNotRelative.Add(texture);
                    }
                }
            }

            #endregion

            #region Find any not-relative SpriteFrames

            foreach (SpriteFrame sf in scene.SpriteFrames)
            {
                if (!FileManager.IsRelativeTo(sf.Texture.SourceFile(), pathOfFile) && !mTexturesNotRelative.Contains(sf.Texture))
                {
                    mTexturesNotRelative.Add(sf.Texture);
                }
            }

            #endregion

            #region Find any not-relative Fonts (Text objects)

            foreach (Text t in scene.Texts)
            {
                BitmapFont bitmapFont = t.Font;

                if (bitmapFont == TextManager.DefaultFont)
                {
                    continue;
                }

                foreach (Texture2D texture in bitmapFont.Textures)
                {
                    if (!FileManager.IsRelativeTo(texture.SourceFile(), pathOfFile) &&
                        !mTexturesNotRelative.Contains(texture))
                    {
                        mTexturesNotRelative.Add(texture);
                    }
                }
                if (!FileManager.IsRelativeTo(bitmapFont.FontFile, pathOfFile) &&
                    !mFntFilesNotRelative.Contains(bitmapFont.FontFile))
                {
                    mFntFilesNotRelative.Add(bitmapFont.FontFile);
                }
            }

            #endregion

            #region Find any non-relative PositionedModels

            foreach (PositionedModel positionedModel in scene.PositionedModels)
            {
                if (!FileManager.IsRelativeTo(positionedModel.ModelFileName, pathOfFile) &&
                    !mModelsNotRelative.Contains(positionedModel.ModelFileName))
                {
                    mModelsNotRelative.Add(positionedModel.ModelFileName);
                }

#if !FRB_MDX
                // Extra files which won't be re-referenced
                foreach (SourceReferencingFile extraFile in positionedModel.ExtraFiles)
                {
                    if (!FileManager.IsRelativeTo(extraFile.DestinationFile, pathOfFile) &&
                        !mExtraFilesToCopy.Contains(extraFile.DestinationFile))
                    {
                        mExtraFilesToCopy.Add(extraFile.DestinationFile);
                    }
                }
#endif
            }

            #endregion

            #region Loop through all AnimationChains and add any missing files

            foreach (AnimationChainList acl in mAnimationChainListsNotRelative)
            {
                foreach (AnimationChain chain in acl)
                {
                    foreach (AnimationFrame frame in chain)
                    {
                        Texture2D texture = frame.Texture;

                        if (!FileManager.IsRelativeTo(texture.SourceFile(), pathOfFile) &&
                            !mTexturesNotRelative.Contains(texture))
                        {
                            mTexturesNotRelative.Add(texture);
                        }
                    }
                }
            }

            #endregion

            mLastFileName   = fileName;
            mContentManager = contentManager;
            mSaveDelegate   = saveDelegate;


            #region If there are files which are not relative, show the multi button message box

            SceneSaving             = scene;
            mReplaceTextureDelegate = replaceTextureDelegate;

            string message = "The file\n\n" + fileName +
                             "\n\nreferences the following which are not relative:";


            CopyTexturesMultiButtonMessageBox mbmb = new CopyTexturesMultiButtonMessageBox();
            mbmb.Text       = message;
            mbmb.SaveClick += CopyAssetsToFileFolder;

            //mbmb.AddButton("Make all references relative using \"..\\\"", MakeSceneRelativeWithDotDots);
            //mbmb.AddButton("Copy textures to relative and reference copies.", new GuiMessage(CopyAssetsToFileFolder));

            foreach (Texture2D texture in mTexturesNotRelative)
            {
                mbmb.AddItem(texture.SourceFile());
            }

            foreach (AnimationChainList animationChainList in mAnimationChainListsNotRelative)
            {
                mbmb.AddItem(animationChainList.Name);
            }
            foreach (string s in mFntFilesNotRelative)
            {
                mbmb.AddItem(s);
            }
            foreach (string s in mModelsNotRelative)
            {
                mbmb.AddItem(s);
            }

            foreach (string s in mExtraFilesToCopy)
            {
                mbmb.AddItem(s);
            }


            //mbmb.FilesToMakeDotDotRelative = filesToMakeDotDotRelative;
            if (filesToMakeDotDotRelative.Count != mbmb.ItemsCount)
            {
                mbmb.FilesMarkedDotDotRelative = filesToMakeDotDotRelative;
                GuiManager.AddDominantWindow(mbmb);
            }
            else
            {
                saveDelegate(fileName, true);
            }

            #endregion
        }
示例#8
0
        private void SaveEmitterOk(FlatRedBall.Gui.Window callingWindow)
        {
            string fileName = "";

            if (callingWindow is FileWindow)
            {
                fileName      = ((FileWindow)callingWindow).Results[0];
                mLastFileName = fileName;
            }
            else
            {
                fileName = mLastFileName;
            }

            #region Get all of the not-relative textures

            mTexturesNotRelative.Clear();
            mAnimationChainListsNotRelative.Clear();

            string pathOfFile = FileManager.GetDirectory(fileName);

            foreach (Emitter emitter in EditorData.Emitters)
            {
                if (emitter.Texture != null &&
                    !FileManager.IsRelativeTo(emitter.Texture.Name, pathOfFile) &&
                    !mTexturesNotRelative.Contains(emitter.Texture))
                {
                    mTexturesNotRelative.Add(emitter.Texture);
                }

                if (emitter.ParticleBlueprint.AnimationChains != null &&
                    string.IsNullOrEmpty(emitter.ParticleBlueprint.AnimationChains.Name) == false &&
                    !FileManager.IsRelativeTo(emitter.ParticleBlueprint.AnimationChains.Name, pathOfFile) &&
                    !mAnimationChainListsNotRelative.Contains(emitter.ParticleBlueprint.AnimationChains))
                {
                    mAnimationChainListsNotRelative.Add(emitter.ParticleBlueprint.AnimationChains);
                }
            }

            #endregion

            mLastFileName = fileName;

            string message = "The following file has the following non-relative references\n" + fileName;


            CopyTexturesMultiButtonMessageBox mbmb = new CopyTexturesMultiButtonMessageBox();
            mbmb.Text = message;


            mbmb.SaveClick += CopyAssetsToFileFolder;
            //mbmb.AddButton("Cancel Save", null);
            //mbmb.AddButton("Copy textures to relative and reference copies.", new GuiMessage(CopyAssetsToFileFolder));

            foreach (Texture2D texture in mTexturesNotRelative)
            {
                mbmb.AddItem(texture.Name);
            }

            foreach (AnimationChainList animationChainList in mAnimationChainListsNotRelative)
            {
                mbmb.AddItem(animationChainList.Name);
            }
            if (EditorData.EditorProperties.FilesToMakeDotDotRelative.Count != mbmb.ItemsCount)
            {
                mbmb.FilesMarkedDotDotRelative = EditorData.EditorProperties.FilesToMakeDotDotRelative;
                GuiManager.AddDominantWindow(mbmb);
            }
            else
            {
                PerformSave(null);
            }
        }