Ejemplo n.º 1
0
        public static void ValidateDependencies(List<SpriteSave> spriteSaves,
            SpriteList spritesToValidate)
        {
            foreach (SpriteSave ss in spriteSaves)
                if (ss.Parent != string.Empty)
                    spritesToValidate.FindByName(ss.Name).AttachTo(
                        spritesToValidate.FindByName(ss.Parent), false);

        }
Ejemplo n.º 2
0
 public static void ValidateDependencies(List <SpriteSave> spriteSaves,
                                         SpriteList spritesToValidate)
 {
     foreach (SpriteSave ss in spriteSaves)
     {
         if (ss.Parent != string.Empty)
         {
             spritesToValidate.FindByName(ss.Name).AttachTo(
                 spritesToValidate.FindByName(ss.Parent), false);
         }
     }
 }
        public void FillComboBoxes()
        {
            SpriteList possibleSprites = new SpriteList();

            if (this.sceneOrGroup.Text == "Entire Scene")
            {
                possibleSprites = GameData.Scene.Sprites;
            }
            else if (GameData.EditorLogic.CurrentSprites.Count != 0)
            {
                ((Sprite)GameData.EditorLogic.CurrentSprites[0].TopParent).GetAllDescendantsOneWay(possibleSprites);
            }
            this.rootSpriteComboBox.AddItem("<No Root>");
            foreach (Sprite s in possibleSprites)
            {
                this.rootSpriteComboBox.AddItem(s.Name);
            }
            Sprite defaultRoot = possibleSprites.FindByName("root1");

            if (defaultRoot == null)
            {
                defaultRoot = possibleSprites.FindByName("root");
            }
            if (defaultRoot == null)
            {
                defaultRoot = possibleSprites.FindByName("Root");
            }
            if (defaultRoot == null)
            {
                defaultRoot = possibleSprites.FindByName("Root1");
            }
            if (defaultRoot == null)
            {
                defaultRoot = possibleSprites.FindWithNameContaining("root");
            }
            if (defaultRoot == null)
            {
                defaultRoot = possibleSprites.FindWithNameContaining("Root");
            }
            if (defaultRoot != null)
            {
                this.rootSpriteComboBox.Text = defaultRoot.Name;
            }
            else
            {
                this.rootSpriteComboBox.Text = "<No Root>";
            }
        }
Ejemplo n.º 4
0
        private void saveButtonClick(Window callingWindow)
        {
            // If a user thinks he's funny and selects AllNotJoint for BodySprites
            // and AllNotBodySprites for Joints, let the user know he has to
            // specify some criteria.
            if (this.bodySpriteSelectionMethod.Text == "All Not Joint" &&
                this.jointSpriteSelectionMethod.Text == "All Not Body")
            {
                GuiManager.ShowMessageBox(
                    "Cannot select All Not Body for Joint Selection when " +
                    "All Not Joint is selected for Body Sprite Selection.  " +
                    "Change one of the criteria and try to save again.", "Selection Error");
                return;

            }



            double error = 0;
            SpriteList possibleSprites = new SpriteList();

            if (this.sceneOrGroup.Text == "Entire Scene")
            {
                possibleSprites = GameData.Scene.Sprites;
            }
            else if (GameData.EditorLogic.CurrentSprites.Count != 0)
            {
                ((Sprite)GameData.EditorLogic.CurrentSprites[0].TopParent).GetAllDescendantsOneWay(possibleSprites);
            }

            #region Get rid of the Axes from the possibleSprites

            if (possibleSprites.Contains(GameData.EditorLogic.EditAxes.xAxis))
            {
                possibleSprites.Remove(GameData.EditorLogic.EditAxes.xAxis);
            }
            if (possibleSprites.Contains(GameData.EditorLogic.EditAxes.yAxis))
            {
                possibleSprites.Remove(GameData.EditorLogic.EditAxes.yAxis);
            }
            if (possibleSprites.Contains(GameData.EditorLogic.EditAxes.zAxis))
            {
                possibleSprites.Remove(GameData.EditorLogic.EditAxes.zAxis);
            }
            if (possibleSprites.Contains(GameData.EditorLogic.EditAxes.xRot))
            {
                possibleSprites.Remove(GameData.EditorLogic.EditAxes.xRot);
            }
            if (possibleSprites.Contains(GameData.EditorLogic.EditAxes.yRot))
            {
                possibleSprites.Remove(GameData.EditorLogic.EditAxes.yRot);
            }
            if (possibleSprites.Contains(GameData.EditorLogic.EditAxes.xScale))
            {
                possibleSprites.Remove(GameData.EditorLogic.EditAxes.xScale);
            }
            if (possibleSprites.Contains(GameData.EditorLogic.EditAxes.yScale))
            {
                possibleSprites.Remove(GameData.EditorLogic.EditAxes.yScale);
            }
            if (possibleSprites.Contains(GameData.EditorLogic.EditAxes.origin))
            {
                possibleSprites.Remove(GameData.EditorLogic.EditAxes.origin);
            }
            #endregion

            if (this.bodySpriteSelectionMethod.Text == "Name Includes")
            {
                this.bodySprites = possibleSprites.FindSpritesWithNameContaining(this.bodyNameToInclude.Text);
            }
            else if (this.bodySpriteSelectionMethod.Text == "By Texture")
            {
                this.bodySprites = possibleSprites.FindSpritesWithTexture(
                    FlatRedBallServices.Load<Texture2D>(this.bodyAvailableTextures.Text, GameData.SceneContentManager));
            }
            else if (this.bodySpriteSelectionMethod.Text == "All")
            {
                this.bodySprites = possibleSprites;
            }

            if (this.jointSpriteSelectionMethod.Text == "Name Includes")
            {
                this.joints = possibleSprites.FindSpritesWithNameContaining(this.jointNameToInclude.Text);
            }
            else if (this.jointSpriteSelectionMethod.Text == "By Texture")
            {
                this.joints = possibleSprites.FindSpritesWithTexture(
                    FlatRedBallServices.Load<Texture2D>(this.jointAvailableTextures.Text, GameData.SceneContentManager));
            }
            else if (this.jointSpriteSelectionMethod.Text == "All")
            {
                this.joints = possibleSprites;
            }

            try
            {
                if (bodySpriteSelectionMethod == null) System.Windows.Forms.MessageBox.Show("a");

                if (this.bodySpriteSelectionMethod.Text == "All Not Joint")
                {
                    this.bodySprites = new SpriteList();

                    if (possibleSprites == null) System.Windows.Forms.MessageBox.Show("b");


                    foreach (Sprite s in possibleSprites)
                    {
                        if (this == null) System.Windows.Forms.MessageBox.Show("c");
                        if (this.joints == null) System.Windows.Forms.MessageBox.Show("d");
                        if (this.bodySprites == null) System.Windows.Forms.MessageBox.Show("e");



                        if (!this.joints.Contains(s))
                        {
                            this.bodySprites.Add(s);
                        }
                    }
                }
            }
            catch { error = 3.3; }
                if (this.jointSpriteSelectionMethod.Text == "All Not Body")
                {
                    this.joints = new SpriteList();
                    foreach (Sprite s in possibleSprites)
                    {
                        if (!this.bodySprites.Contains(s))
                        {
                            this.joints.Add(s);
                        }
                    }
                }

                if (this.rootSpriteComboBox.Text != "<No Root>")
                {
                    this.root = possibleSprites.FindByName(this.rootSpriteComboBox.Text);
                }
                else
                {
                    this.root = null;
                }




            FileButtonWindow.spriteRigOptionsOK(this);
            this.Visible = false;

        }
Ejemplo n.º 5
0
 public void FillComboBoxes()
 {
     SpriteList possibleSprites = new SpriteList();
     if (this.sceneOrGroup.Text == "Entire Scene")
     {
         possibleSprites = GameData.Scene.Sprites;
     }
     else if (GameData.EditorLogic.CurrentSprites.Count != 0)
     {
         ((Sprite)GameData.EditorLogic.CurrentSprites[0].TopParent).GetAllDescendantsOneWay(possibleSprites);
     }
     this.rootSpriteComboBox.AddItem("<No Root>");
     foreach (Sprite s in possibleSprites)
     {
         this.rootSpriteComboBox.AddItem(s.Name);
     }
     Sprite defaultRoot = possibleSprites.FindByName("root1");
     if (defaultRoot == null)
     {
         defaultRoot = possibleSprites.FindByName("root");
     }
     if (defaultRoot == null)
     {
         defaultRoot = possibleSprites.FindByName("Root");
     }
     if (defaultRoot == null)
     {
         defaultRoot = possibleSprites.FindByName("Root1");
     }
     if (defaultRoot == null)
     {
         defaultRoot = possibleSprites.FindWithNameContaining("root");
     }
     if (defaultRoot == null)
     {
         defaultRoot = possibleSprites.FindWithNameContaining("Root");
     }
     if (defaultRoot != null)
     {
         this.rootSpriteComboBox.Text = defaultRoot.Name;
     }
     else
     {
         this.rootSpriteComboBox.Text = "<No Root>";
     }
 }
        private void saveButtonClick(Window callingWindow)
        {
            // If a user thinks he's funny and selects AllNotJoint for BodySprites
            // and AllNotBodySprites for Joints, let the user know he has to
            // specify some criteria.
            if (this.bodySpriteSelectionMethod.Text == "All Not Joint" &&
                this.jointSpriteSelectionMethod.Text == "All Not Body")
            {
                GuiManager.ShowMessageBox(
                    "Cannot select All Not Body for Joint Selection when " +
                    "All Not Joint is selected for Body Sprite Selection.  " +
                    "Change one of the criteria and try to save again.", "Selection Error");
                return;
            }



            double     error           = 0;
            SpriteList possibleSprites = new SpriteList();

            if (this.sceneOrGroup.Text == "Entire Scene")
            {
                possibleSprites = GameData.Scene.Sprites;
            }
            else if (GameData.EditorLogic.CurrentSprites.Count != 0)
            {
                ((Sprite)GameData.EditorLogic.CurrentSprites[0].TopParent).GetAllDescendantsOneWay(possibleSprites);
            }

            #region Get rid of the Axes from the possibleSprites

            if (possibleSprites.Contains(GameData.EditorLogic.EditAxes.xAxis))
            {
                possibleSprites.Remove(GameData.EditorLogic.EditAxes.xAxis);
            }
            if (possibleSprites.Contains(GameData.EditorLogic.EditAxes.yAxis))
            {
                possibleSprites.Remove(GameData.EditorLogic.EditAxes.yAxis);
            }
            if (possibleSprites.Contains(GameData.EditorLogic.EditAxes.zAxis))
            {
                possibleSprites.Remove(GameData.EditorLogic.EditAxes.zAxis);
            }
            if (possibleSprites.Contains(GameData.EditorLogic.EditAxes.xRot))
            {
                possibleSprites.Remove(GameData.EditorLogic.EditAxes.xRot);
            }
            if (possibleSprites.Contains(GameData.EditorLogic.EditAxes.yRot))
            {
                possibleSprites.Remove(GameData.EditorLogic.EditAxes.yRot);
            }
            if (possibleSprites.Contains(GameData.EditorLogic.EditAxes.xScale))
            {
                possibleSprites.Remove(GameData.EditorLogic.EditAxes.xScale);
            }
            if (possibleSprites.Contains(GameData.EditorLogic.EditAxes.yScale))
            {
                possibleSprites.Remove(GameData.EditorLogic.EditAxes.yScale);
            }
            if (possibleSprites.Contains(GameData.EditorLogic.EditAxes.origin))
            {
                possibleSprites.Remove(GameData.EditorLogic.EditAxes.origin);
            }
            #endregion

            if (this.bodySpriteSelectionMethod.Text == "Name Includes")
            {
                this.bodySprites = possibleSprites.FindSpritesWithNameContaining(this.bodyNameToInclude.Text);
            }
            else if (this.bodySpriteSelectionMethod.Text == "By Texture")
            {
                this.bodySprites = possibleSprites.FindSpritesWithTexture(
                    FlatRedBallServices.Load <Texture2D>(this.bodyAvailableTextures.Text, GameData.SceneContentManager));
            }
            else if (this.bodySpriteSelectionMethod.Text == "All")
            {
                this.bodySprites = possibleSprites;
            }

            if (this.jointSpriteSelectionMethod.Text == "Name Includes")
            {
                this.joints = possibleSprites.FindSpritesWithNameContaining(this.jointNameToInclude.Text);
            }
            else if (this.jointSpriteSelectionMethod.Text == "By Texture")
            {
                this.joints = possibleSprites.FindSpritesWithTexture(
                    FlatRedBallServices.Load <Texture2D>(this.jointAvailableTextures.Text, GameData.SceneContentManager));
            }
            else if (this.jointSpriteSelectionMethod.Text == "All")
            {
                this.joints = possibleSprites;
            }

            try
            {
                if (bodySpriteSelectionMethod == null)
                {
                    System.Windows.Forms.MessageBox.Show("a");
                }

                if (this.bodySpriteSelectionMethod.Text == "All Not Joint")
                {
                    this.bodySprites = new SpriteList();

                    if (possibleSprites == null)
                    {
                        System.Windows.Forms.MessageBox.Show("b");
                    }


                    foreach (Sprite s in possibleSprites)
                    {
                        if (this == null)
                        {
                            System.Windows.Forms.MessageBox.Show("c");
                        }
                        if (this.joints == null)
                        {
                            System.Windows.Forms.MessageBox.Show("d");
                        }
                        if (this.bodySprites == null)
                        {
                            System.Windows.Forms.MessageBox.Show("e");
                        }



                        if (!this.joints.Contains(s))
                        {
                            this.bodySprites.Add(s);
                        }
                    }
                }
            }
            catch { error = 3.3; }
            if (this.jointSpriteSelectionMethod.Text == "All Not Body")
            {
                this.joints = new SpriteList();
                foreach (Sprite s in possibleSprites)
                {
                    if (!this.bodySprites.Contains(s))
                    {
                        this.joints.Add(s);
                    }
                }
            }

            if (this.rootSpriteComboBox.Text != "<No Root>")
            {
                this.root = possibleSprites.FindByName(this.rootSpriteComboBox.Text);
            }
            else
            {
                this.root = null;
            }



            FileButtonWindow.spriteRigOptionsOK(this);
            this.Visible = false;
        }
Ejemplo n.º 7
0
        public static void LoadSpriteRigOk(Window callingWindow)
        {
            #region Load the SpriteRig

            EditorSprite es;
            string fileName = ((FileWindow)callingWindow).Results[0];

            SpriteRigSave srs = SpriteRigSave.FromFile(fileName);
            SpriteList loadedSprites = new SpriteList();

            SpriteRig spriteRig = srs.ToSpriteRig(GameData.SceneContentManager);

            #endregion

            #region Play some Pose so that the SpriteRig has a proper pose and texture coordinates

            // Play and stop an animation to get the texture coordinates set up in case
            // the SpriteRig has texture coords defined in its AnimationChains
            if (spriteRig.PoseChains.Count != 0)
            {
                spriteRig.SetPoseChain(spriteRig.PoseChains[0]);
                spriteRig.Animate = true;
                spriteRig.SetPositionAtTimeFromAnimationStart(0);
                spriteRig.Animate = false;

            }
            #endregion

            GuiData.srSaveOptions.joints = new SpriteList();
            GuiData.srSaveOptions.bodySprites = new SpriteList();
            GuiData.srSaveOptions.joints.Clear();
            GuiData.srSaveOptions.bodySprites.Clear();

            string oldRelativeDirectory = FileManager.RelativeDirectory;
            FileManager.RelativeDirectory = FileManager.GetDirectory(fileName);


            foreach (Sprite regularSprite in spriteRig.Joints)
            {
                es = new EditorSprite();

                es.SetFromRegularSprite(regularSprite);
                GameData.Scene.Sprites.Add(es);
                SpriteManager.AddSprite(es);
                loadedSprites.AddOneWay(es);
                GuiData.srSaveOptions.joints.Add(es);
            }
            foreach (Sprite regularSprite in spriteRig.BodySprites)
            {
                es = new EditorSprite();
                es.SetFromRegularSprite(regularSprite);
                GameData.Scene.Sprites.Add(es);
                SpriteManager.AddSprite(es);
                loadedSprites.AddOneWay(es);
                GuiData.srSaveOptions.bodySprites.Add(es);
            }

            // The root is not part of the body Sprites, but it should be
            if (spriteRig.Root != null && GameData.Scene.Sprites.Contains(spriteRig.Root) == false)
            {
                es = new EditorSprite();
                es.SetFromRegularSprite(spriteRig.Root);
                GameData.Scene.Sprites.Add(es);
                SpriteManager.AddSprite(es);
                loadedSprites.AddOneWay(es);
                GuiData.srSaveOptions.bodySprites.Add(es);

            }

            if (spriteRig.Root != null)
            {
                GuiData.srSaveOptions.root = GuiData.srSaveOptions.bodySprites.FindByName(spriteRig.Root.Name);
                GuiData.srSaveOptions.bodySprites.Remove(GuiData.srSaveOptions.root);
            }
            GuiData.srSaveOptions.poseChains = spriteRig.PoseChains;
            if (srs.JointsVisible)
            {
                GuiData.srSaveOptions.jointsVisible.Press();
            }
            else
            {
                GuiData.srSaveOptions.jointsVisible.Unpress();
            }
            if (srs.RootVisible)
            {
                GuiData.srSaveOptions.rootVisible.Press();
            }
            else
            {
                GuiData.srSaveOptions.rootVisible.Unpress();
            }

            FileManager.RelativeDirectory = oldRelativeDirectory;

            string oldRelative = FileManager.RelativeDirectory;
            if (srs.AssetsRelativeToFile)
            {
                FileManager.RelativeDirectory = FileManager.GetDirectory(fileName);
            }

            FileManager.RelativeDirectory = oldRelative;
            foreach (SpriteSave ss in srs.Joints)
            {
                srs.BodySprites.Add(ss);
            }


            for (int i = 0; i < loadedSprites.Count; i++)
            {

                if (loadedSprites[i].PixelSize > 0f)
                {
                    ((EditorSprite)loadedSprites[i]).ConstantPixelSizeExempt = false;
                }
                else
                {
                    ((EditorSprite)loadedSprites[i]).ConstantPixelSizeExempt = true;
                }

                if (loadedSprites[i].Texture.texture != null)
                {
                    GuiData.ListWindow.Add(loadedSprites[i].Texture);
                }

                string parentName = "";

                Sprite matchingSprite = spriteRig.BodySprites.FindByName(loadedSprites[i].Name);

                if (matchingSprite == null)
                {
                    matchingSprite = spriteRig.Joints.FindByName(loadedSprites[i].Name);
                }
                // parent may be null if there is no root
                if (matchingSprite != null && matchingSprite.Parent != null)
                {
                    parentName = matchingSprite.Parent.Name;

                    loadedSprites[i].AttachTo(loadedSprites.FindByName(parentName), false);
                }
            }
            GameData.Scene.Sprites.SortZInsertionDescending();




            AskToSearchForReplacements(((FileWindow)callingWindow).Results[0]);
        }
Ejemplo n.º 8
0
        public static void LoadSpriteRigOk(Window callingWindow)
        {
            #region Load the SpriteRig

            EditorSprite es;
            string       fileName = ((FileWindow)callingWindow).Results[0];

            SpriteRigSave srs           = SpriteRigSave.FromFile(fileName);
            SpriteList    loadedSprites = new SpriteList();

            SpriteRig spriteRig = srs.ToSpriteRig(GameData.SceneContentManager);

            #endregion

            #region Play some Pose so that the SpriteRig has a proper pose and texture coordinates

            // Play and stop an animation to get the texture coordinates set up in case
            // the SpriteRig has texture coords defined in its AnimationChains
            if (spriteRig.PoseChains.Count != 0)
            {
                spriteRig.SetPoseChain(spriteRig.PoseChains[0]);
                spriteRig.Animate = true;
                spriteRig.SetPositionAtTimeFromAnimationStart(0);
                spriteRig.Animate = false;
            }
            #endregion

            GuiData.srSaveOptions.joints      = new SpriteList();
            GuiData.srSaveOptions.bodySprites = new SpriteList();
            GuiData.srSaveOptions.joints.Clear();
            GuiData.srSaveOptions.bodySprites.Clear();

            string oldRelativeDirectory = FileManager.RelativeDirectory;
            FileManager.RelativeDirectory = FileManager.GetDirectory(fileName);


            foreach (Sprite regularSprite in spriteRig.Joints)
            {
                es = new EditorSprite();

                es.SetFromRegularSprite(regularSprite);
                GameData.Scene.Sprites.Add(es);
                SpriteManager.AddSprite(es);
                loadedSprites.AddOneWay(es);
                GuiData.srSaveOptions.joints.Add(es);
            }
            foreach (Sprite regularSprite in spriteRig.BodySprites)
            {
                es = new EditorSprite();
                es.SetFromRegularSprite(regularSprite);
                GameData.Scene.Sprites.Add(es);
                SpriteManager.AddSprite(es);
                loadedSprites.AddOneWay(es);
                GuiData.srSaveOptions.bodySprites.Add(es);
            }

            // The root is not part of the body Sprites, but it should be
            if (spriteRig.Root != null && GameData.Scene.Sprites.Contains(spriteRig.Root) == false)
            {
                es = new EditorSprite();
                es.SetFromRegularSprite(spriteRig.Root);
                GameData.Scene.Sprites.Add(es);
                SpriteManager.AddSprite(es);
                loadedSprites.AddOneWay(es);
                GuiData.srSaveOptions.bodySprites.Add(es);
            }

            if (spriteRig.Root != null)
            {
                GuiData.srSaveOptions.root = GuiData.srSaveOptions.bodySprites.FindByName(spriteRig.Root.Name);
                GuiData.srSaveOptions.bodySprites.Remove(GuiData.srSaveOptions.root);
            }
            GuiData.srSaveOptions.poseChains = spriteRig.PoseChains;
            if (srs.JointsVisible)
            {
                GuiData.srSaveOptions.jointsVisible.Press();
            }
            else
            {
                GuiData.srSaveOptions.jointsVisible.Unpress();
            }
            if (srs.RootVisible)
            {
                GuiData.srSaveOptions.rootVisible.Press();
            }
            else
            {
                GuiData.srSaveOptions.rootVisible.Unpress();
            }

            FileManager.RelativeDirectory = oldRelativeDirectory;

            string oldRelative = FileManager.RelativeDirectory;
            if (srs.AssetsRelativeToFile)
            {
                FileManager.RelativeDirectory = FileManager.GetDirectory(fileName);
            }

            FileManager.RelativeDirectory = oldRelative;
            foreach (SpriteSave ss in srs.Joints)
            {
                srs.BodySprites.Add(ss);
            }


            for (int i = 0; i < loadedSprites.Count; i++)
            {
                if (loadedSprites[i].PixelSize > 0f)
                {
                    ((EditorSprite)loadedSprites[i]).ConstantPixelSizeExempt = false;
                }
                else
                {
                    ((EditorSprite)loadedSprites[i]).ConstantPixelSizeExempt = true;
                }

                if (loadedSprites[i].Texture.texture != null)
                {
                    GuiData.ListWindow.Add(loadedSprites[i].Texture);
                }

                string parentName = "";

                Sprite matchingSprite = spriteRig.BodySprites.FindByName(loadedSprites[i].Name);

                if (matchingSprite == null)
                {
                    matchingSprite = spriteRig.Joints.FindByName(loadedSprites[i].Name);
                }
                // parent may be null if there is no root
                if (matchingSprite != null && matchingSprite.Parent != null)
                {
                    parentName = matchingSprite.Parent.Name;

                    loadedSprites[i].AttachTo(loadedSprites.FindByName(parentName), false);
                }
            }
            GameData.Scene.Sprites.SortZInsertionDescending();



            AskToSearchForReplacements(((FileWindow)callingWindow).Results[0]);
        }