示例#1
0
        protected override void OnDoubleClick(System.EventArgs e)
        {
            if (MessageBox.Show(@"Are you sure you want to add this to the Scene?", @"Confirmation", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                // Add our sprite
                EditorSprite sprite = new EditorSprite(Game);

                // Open a Memory Stream
                MemoryStream stream = new MemoryStream();

                // Save the current sprite image to a stream
                SpriteImage.Save(stream, ImageFormat.Png);

                // Load the stream into a texture2D object
                sprite.Texture = Texture2D.FromStream(Game.GraphicsDevice, stream);

                // Close the Stream
                stream.Close();

                sprite.AssetName = FileName;
                sprite.Position  = new Vector2(-Globals.CurrentCameraOffsetX, 0);
                sprite.Name      = Name;

                // Add it to our key frame container
                Globals.ObjectAdded.Invoke(sprite);

                // Select it out the gate
                Globals.ObjectSelected.Invoke(sprite);
            }
        }
示例#2
0
        public void LoadImgFiles(EditorSprite eSprite, Panel brushPanel)
        {
            Image ret = null;

            sprite_space.TryGetValue(eSprite, out ret);
            if (ret != null)
            {
                brushPanel.BackgroundImage = ret;
                //brushPanel.BackgroundImageLayout = ImageLayout.Center;
            }
        }
示例#3
0
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            Globals.IsDialogWindowOpen = false;

            if (Globals.RenderWindow.CurrentSelectedObject is EditorSprite)
            {
                EditorSprite s = Globals.RenderWindow.CurrentSelectedObject as EditorSprite;
                {
                    s.ObjectTypeName = lsTypes.Text;
                    s.ObjectType     = lsTypes.SelectedItem.GetType();
                }

                Service.CloseDropDown();
            }

            if (Globals.RenderWindow.CurrentSelectedObject is EditorActor)
            {
                EditorActor s = Globals.RenderWindow.CurrentSelectedObject as EditorActor;
                {
                    s.ObjectTypeName = lsTypes.Text;
                    s.ObjectType     = lsTypes.SelectedItem.GetType();
                }

                Service.CloseDropDown();
            }

            if (Globals.RenderWindow.CurrentSelectedObject is EditorEmitter)
            {
                EditorEmitter s = Globals.RenderWindow.CurrentSelectedObject as EditorEmitter;
                {
                    s.ObjectTypeName = lsTypes.Text;
                    s.ObjectType     = lsTypes.SelectedItem.GetType();
                }

                Service.CloseDropDown();
            }

            if (Globals.RenderWindow.CurrentSelectedObject is EditorGroup)
            {
                EditorGroup s = Globals.RenderWindow.CurrentSelectedObject as EditorGroup;
                {
                    s.ObjectTypeName = lsTypes.Text;
                    s.ObjectType     = lsTypes.SelectedItem.GetType();
                }

                Service.CloseDropDown();
            }
        }
        private void tsDuplicate_Click(object sender, EventArgs e)
        {
            // Grab our currently selected frame
            var old = pnKeyFrameContainer.Controls[Globals.CurrentSelectedObject.Index] as conKeyFrame;

            if (old == null)
            {
                MessageBox.Show("Could not grab the current frame for duplication!", "Error", MessageBoxButtons.OK);
                return;
            }

            // Create Frame and add it to our container
            conKeyFrame con = new conKeyFrame();

            pnKeyFrameContainer.Controls.Add(con);

            // Display the Frame number on the frame we just added (indexof returns 0 based array so add 1)
            con.Tag         = Globals.FrameSelectedEvent;
            con.FrameNumber = pnKeyFrameContainer.Controls.IndexOf(con);

            for (int i = 0; i < con.VisualObjects.Count; i++)
            {
                if (con.VisualObjects[i] is Sprite)
                {
                    Sprite original = con.VisualObjects[i] as Sprite;

                    if (original != null)
                    {
                        EditorSprite s = new EditorSprite(Game);

                        s.Name         = original.Name;
                        s.AssetName    = original.AssetName;
                        s.Texture      = original.Texture;
                        s.Position     = original.Position;
                        s.Scale        = original.Scale;
                        s.Rotation     = original.Rotation;
                        s.BlendMode    = original.BlendMode;
                        s.Camera       = original.Camera;
                        s.CustomEffect = original.CustomEffect;
                        s.Color        = original.Color;
                        s.DrawOrder    = original.DrawOrder;
                        s.UpdateOrder  = original.UpdateOrder;
                        s.Visible      = original.Visible;
                        s.Effects      = original.Effects;
                        s.Origin       = original.Origin;
                        s.LayerDepth   = original.LayerDepth;
                        s.Enabled      = original.Enabled;
                        s.Index        = original.Index;

                        s.Initialize();

                        // Add it to our visual objects
                        con.VisualObjects.Add(s);
                    }
                }

                if (con.VisualObjects[i] is ParticleEmitter)
                {
                    ParticleEmitter original = con.VisualObjects[i] as ParticleEmitter;

                    if (original != null)
                    {
                        EditorEmitter emitter = new EditorEmitter(Game);
                        emitter.Name             = original.Name;
                        emitter.Position         = original.Position;
                        emitter.Texture          = original.Texture;
                        emitter.ParticleColor    = original.ParticleColor;
                        emitter.AssetName        = original.AssetName;
                        emitter.Camera           = original.Camera;
                        emitter.DrawOrder        = original.DrawOrder;
                        emitter.UpdateOrder      = original.UpdateOrder;
                        emitter.Index            = original.Index;
                        emitter.MaxAcceleration  = original.MaxAcceleration;
                        emitter.MinAcceleration  = original.MinAcceleration;
                        emitter.MinLifeSpan      = original.MinLifeSpan;
                        emitter.MaxLifeSpan      = original.MaxLifeSpan;
                        emitter.MinParticles     = original.MinParticles;
                        emitter.MaxParticles     = original.MaxParticles;
                        emitter.MinRotationSpeed = original.MinRotationSpeed;
                        emitter.MaxRotationSpeed = original.MaxRotationSpeed;
                        emitter.MinScale         = original.MinScale;
                        emitter.MaxScale         = original.MaxScale;
                        emitter.ForceObjects     = original.ForceObjects;
                        emitter.Visible          = original.Visible;
                        emitter.Index            = original.Index;

                        emitter.Initialize();

                        // Add it to our visual objects
                        con.VisualObjects.Add(emitter);
                    }
                }
            }

            // Init all the sprites
//			for (int i = 0; i < con.VisualObjects.Count; i++)
//				con.VisualObjects[i].Initialize();

            con.IsLocked   = old.IsLocked;
            con.IsSelected = true;
            con.FrameSpeed = old.FrameSpeed;

            Globals.FrameSelectedEvent.Invoke(con.FrameNumber);
        }
示例#5
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]);
        }
示例#6
0
        private void btnDuplicate_Click(object sender, EventArgs e)
        {
            int counts  = Convert.ToInt16(tbQTY.Text);
            int offsetX = Convert.ToInt16(tbXOffset.Text);
            int offsetY = Convert.ToInt16(tbYOffset.Text);

            float totalWidth  = 0;
            float totalHeight = 0;

            #region Groups

            if (SceneObjects[rlSceneObjects.SelectedIndex] is EditorGroup)
            {
                EditorGroup original = SceneObjects[rlSceneObjects.SelectedIndex] as EditorGroup;

                if (original != null)
                {
                    for (int i = 0; i < counts; i++)
                    {
                        EditorGroup group = new EditorGroup(Globals.Game, RenderWindow)
                        {
                            AssetName       = original.AssetName,
                            DrawOrder       = original.DrawOrder,
                            UpdateOrder     = original.UpdateOrder,
                            Enabled         = original.Enabled,
                            Name            = original.Name,
                            Scale           = original.Scale,
                            Visible         = original.Visible,
                            ShowBoundingBox = true,
                            Position        = original.Position
                        };

                        foreach (VisualObject o in original.Objects)
                        {
                            if (o is EditorSprite)
                            {
                                EditorSprite sOriginal = o as EditorSprite;

                                // Init our new Sprite
                                EditorSprite sprite = new EditorSprite(sOriginal.Game)
                                {
                                    Name            = sOriginal.Name,
                                    Texture         = sOriginal.Texture,
                                    AssetName       = sOriginal.AssetName,
                                    Position        = sOriginal.Position,
                                    Scale           = sOriginal.Scale,
                                    LayerDepth      = sOriginal.LayerDepth,
                                    Origin          = sOriginal.Origin,
                                    Rotation        = sOriginal.Rotation,
                                    StartPosition   = sOriginal.StartPosition,
                                    UpdateOrder     = sOriginal.UpdateOrder,
                                    CustomEffect    = sOriginal.CustomEffect,
                                    ShowBoundingBox = false,
                                    BlendMode       = sOriginal.BlendMode,
                                    DrawOrder       = sOriginal.DrawOrder,
                                    ScrollSpeed     = sOriginal.ScrollSpeed,
                                };

                                // Init this texture
                                sprite.Initialize();

                                // Add it to our groups objects
                                group.Objects.Add(sprite);
                            }

                            if (o is EditorEmitter)
                            {
                                EditorEmitter eOriginal = o as EditorEmitter;

                                EditorEmitter emitter = new EditorEmitter(eOriginal.Game, RenderWindow)
                                {
                                    Name                = eOriginal.Name,
                                    AssetName           = eOriginal.AssetName,
                                    Camera              = eOriginal.Camera,
                                    ParticleColor       = eOriginal.ParticleColor,
                                    DrawOrder           = eOriginal.DrawOrder,
                                    EnableAlphaBlending = eOriginal.EnableAlphaBlending,
                                    Enabled             = eOriginal.Enabled,
                                    ForceObjects        = eOriginal.ForceObjects,
                                    MinAcceleration     = eOriginal.MinAcceleration,
                                    MaxAcceleration     = eOriginal.MaxAcceleration,
                                    MinInitialSpeed     = eOriginal.MinInitialSpeed,
                                    MaxInitialSpeed     = eOriginal.MaxInitialSpeed,
                                    MinLifeSpan         = eOriginal.MinLifeSpan,
                                    MaxLifeSpan         = eOriginal.MaxLifeSpan,
                                    MinParticles        = eOriginal.MinParticles,
                                    MaxParticles        = eOriginal.MaxParticles,
                                    MinRotationSpeed    = eOriginal.MinRotationSpeed,
                                    MaxRotationSpeed    = eOriginal.MaxRotationSpeed,
                                    MinScale            = eOriginal.MinScale,
                                    MaxScale            = eOriginal.MaxScale,
                                    ShowBoundingBox     = false,
                                    Texture             = eOriginal.Texture,
                                    Position            = eOriginal.Position
                                };

                                emitter.Initialize();

                                // Add it to our group
                                group.Objects.Add(emitter);
                            }
                        }

                        // Initialize our group
                        group.Initialize();

                        float width  = 0;
                        float height = 0;

                        foreach (VisualObject o in group.Objects)
                        {
                            if (o is EditorSprite)
                            {
                                EditorSprite s = o as EditorSprite;
                                if ((s.Texture.Width * s.Scale.X) > width)
                                {
                                    width = s.Texture.Width * s.Scale.X;
                                }

                                if ((s.Texture.Height * s.Scale.Y) > height)
                                {
                                    height = s.Texture.Height * s.Scale.Y;
                                }
                            }
                            if (o is EditorEmitter)
                            {
                                EditorEmitter emitter = o as EditorEmitter;
                                if ((emitter.Texture.Width * emitter.Scale.X) > width)
                                {
                                    width = emitter.Texture.Width * emitter.Scale.X;
                                }

                                if ((emitter.Texture.Height * emitter.Scale.Y) > height)
                                {
                                    height = emitter.Texture.Height * emitter.Scale.Y;
                                }
                            }
                        }

                        totalWidth  += width + offsetX * (i + 1);
                        totalHeight += height + offsetY * (i + 1);

                        // Move the individual objects in the group
                        // TODO: Make this later automatically done in the CTBaseGroup class!
                        foreach (VisualObject vo in group.Objects)
                        {
                            switch (cbDirection.Text)
                            {
                            case "X":
                                vo.Position += new Vector2(totalWidth, 0);
                                break;

                            case "Y":
                                vo.Position += new Vector2(0, totalHeight);
                                break;

                            case "Both":
                                vo.Position += new Vector2(totalWidth, totalHeight);
                                break;
                            }
                        }

                        // Move the Complete groups position too
                        switch (cbDirection.Text)
                        {
                        case "X":
                            group.Position += new Vector2(totalWidth, 0);
                            break;

                        case "Y":
                            group.Position += new Vector2(0, totalHeight);
                            break;

                        case "Both":
                            group.Position += new Vector2(totalWidth, totalHeight);
                            break;
                        }

                        group.Name = original.Name + (i + 1);

                        // Add it to current our Key Frame
                        Globals.ObjectAdded.Invoke(group);
                    }
                }
            }

            #endregion

            #region Sprites

            if (SceneObjects[rlSceneObjects.SelectedIndex] is EditorSprite)
            {
                EditorSprite sprite = SceneObjects[rlSceneObjects.SelectedIndex] as EditorSprite;

                if (sprite != null)
                {
                    for (int i = 0; i < counts; i++)
                    {
                        totalWidth  += (sprite.Texture.Width * sprite.Scale.X) + offsetX * (i + 1);
                        totalHeight += (sprite.Texture.Height * sprite.Scale.Y) + offsetY * (i + 1);

                        EditorSprite s = new EditorSprite(sprite.Game)
                        {
                            Name                     = sprite.Name,
                            AssetName                = sprite.AssetName,
                            BlendMode                = sprite.BlendMode,
                            Color                    = sprite.Color,
                            CameraOffsetX            = sprite.CameraOffsetX,
                            CameraOffsetY            = sprite.CameraOffsetY,
                            CameraZoomOffset         = sprite.CameraZoomOffset,
                            CustomEffect             = sprite.CustomEffect,
                            DrawOrder                = sprite.DrawOrder,
                            Effects                  = sprite.Effects,
                            Enabled                  = sprite.Enabled,
                            IsLocked                 = sprite.IsLocked,
                            ShowBoundingBox          = sprite.ShowBoundingBox,
                            LayerDepth               = sprite.LayerDepth,
                            Origin                   = sprite.Origin,
                            Position                 = sprite.Position,
                            Rotation                 = sprite.Rotation,
                            Scale                    = sprite.Scale,
                            UpdateOrder              = sprite.UpdateOrder,
                            Visible                  = sprite.Visible,
                            Texture                  = sprite.Texture,
                            ScrollSpeed              = sprite.ScrollSpeed,
                            AttachedPathingNode      = sprite.AttachedPathingNode,
                            AttachedPathingNodeName  = sprite.AttachedPathingNodeName,
                            CurrentPathLerpPosition  = sprite.CurrentPathLerpPosition,
                            CurrentPathNodeIndex     = sprite.CurrentPathNodeIndex,
                            StartPathingLerpPosition = sprite.StartPathingLerpPosition,
                            StartPathNodeIndex       = sprite.StartPathNodeIndex,
                        };

                        s.Initialize();

                        switch (cbDirection.Text)
                        {
                        case "X":
                            s.Position += new Vector2(totalWidth, 0);
                            break;

                        case "Y":
                            s.Position += new Vector2(0, totalHeight);
                            break;

                        case "Both":
                            s.Position += new Vector2(totalWidth, totalHeight);
                            break;
                        }

                        // Add it to our scene
                        Globals.ObjectAdded.Invoke(s);
                    }
                }
            }

            #endregion

            #region Emitters

            if (SceneObjects[rlSceneObjects.SelectedIndex] is EditorEmitter)
            {
                EditorEmitter original = SceneObjects[rlSceneObjects.SelectedIndex] as EditorEmitter;

                if (original != null)
                {
                    for (int i = 1; i < counts; i++)
                    {
                        totalWidth  += (original.Texture.Width * original.Scale.X) + offsetX * (i + 1);
                        totalHeight += (original.Texture.Height * original.Scale.Y) + offsetY * (i + 1);

                        EditorEmitter emitter = new EditorEmitter(original.Game, RenderWindow)
                        {
                            Name                     = original.Name,
                            AssetName                = original.AssetName,
                            Camera                   = original.Camera,
                            ParticleColor            = original.ParticleColor,
                            DrawOrder                = original.DrawOrder,
                            EnableAlphaBlending      = original.EnableAlphaBlending,
                            Enabled                  = original.Enabled,
                            ForceObjects             = original.ForceObjects,
                            MinAcceleration          = original.MinAcceleration,
                            MaxAcceleration          = original.MaxAcceleration,
                            MinInitialSpeed          = original.MinInitialSpeed,
                            MaxInitialSpeed          = original.MaxInitialSpeed,
                            MinLifeSpan              = original.MinLifeSpan,
                            MaxLifeSpan              = original.MaxLifeSpan,
                            MinParticles             = original.MinParticles,
                            MaxParticles             = original.MaxParticles,
                            MinRotationSpeed         = original.MinRotationSpeed,
                            MaxRotationSpeed         = original.MaxRotationSpeed,
                            MinScale                 = original.MinScale,
                            MaxScale                 = original.MaxScale,
                            ShowBoundingBox          = true,
                            Texture                  = original.Texture,
                            Position                 = original.Position,
                            AttachedPathingNode      = original.AttachedPathingNode,
                            AttachedPathingNodeName  = original.AttachedPathingNodeName,
                            CurrentPathLerpPosition  = original.CurrentPathLerpPosition,
                            CurrentPathNodeIndex     = original.CurrentPathNodeIndex,
                            StartPathingLerpPosition = original.StartPathingLerpPosition,
                            StartPathNodeIndex       = original.StartPathNodeIndex
                        };

                        emitter.Initialize();

                        switch (cbDirection.Text)
                        {
                        case "X":
                            emitter.Position += new Vector2(totalWidth, 0);
                            break;

                        case "Y":
                            emitter.Position += new Vector2(0, totalHeight);
                            break;

                        case "Both":
                            emitter.Position += new Vector2(totalWidth, totalHeight);
                            break;
                        }

                        // Add it to current our Key Frame
                        Globals.ObjectAdded.Invoke(emitter);
                    }
                }
            }

            #endregion

            #region Custom Sprite Boxes

            if (SceneObjects[rlSceneObjects.SelectedIndex] is EditorSpriteBox)
            {
                EditorSpriteBox sprite = SceneObjects[rlSceneObjects.SelectedIndex] as EditorSpriteBox;

                if (sprite != null)
                {
                    for (int i = 0; i < counts; i++)
                    {
                        totalWidth  += (sprite.Texture.Width * sprite.Scale.X) + offsetX * (i + 1);
                        totalHeight += (sprite.Texture.Height * sprite.Scale.Y) + offsetY * (i + 1);

                        EditorSpriteBox s = new EditorSpriteBox(sprite.Game, RenderWindow)
                        {
                            Name                     = sprite.Name,
                            AssetName                = sprite.AssetName,
                            BlendMode                = sprite.BlendMode,
                            Width                    = sprite.Width,
                            Height                   = sprite.Height,
                            Color                    = sprite.Color,
                            CameraOffsetX            = sprite.CameraOffsetX,
                            CameraOffsetY            = sprite.CameraOffsetY,
                            CameraZoomOffset         = sprite.CameraZoomOffset,
                            CustomEffect             = sprite.CustomEffect,
                            DrawOrder                = sprite.DrawOrder,
                            Effects                  = sprite.Effects,
                            Enabled                  = sprite.Enabled,
                            IsLocked                 = sprite.IsLocked,
                            ShowBoundingBox          = sprite.ShowBoundingBox,
                            LayerDepth               = sprite.LayerDepth,
                            Origin                   = sprite.Origin,
                            Position                 = sprite.Position,
                            Rotation                 = sprite.Rotation,
                            Scale                    = sprite.Scale,
                            UpdateOrder              = sprite.UpdateOrder,
                            Visible                  = sprite.Visible,
                            Texture                  = sprite.Texture,
                            ScrollSpeed              = sprite.ScrollSpeed,
                            AttachedPathingNode      = sprite.AttachedPathingNode,
                            AttachedPathingNodeName  = sprite.AttachedPathingNodeName,
                            CurrentPathLerpPosition  = sprite.CurrentPathLerpPosition,
                            CurrentPathNodeIndex     = sprite.CurrentPathNodeIndex,
                            StartPathingLerpPosition = sprite.StartPathingLerpPosition,
                            StartPathNodeIndex       = sprite.StartPathNodeIndex
                        };

                        s.Initialize();

                        switch (cbDirection.Text)
                        {
                        case "X":
                            s.Position += new Vector2(totalWidth, 0);
                            break;

                        case "Y":
                            s.Position += new Vector2(0, totalHeight);
                            break;

                        case "Both":
                            s.Position += new Vector2(totalWidth, totalHeight);
                            break;
                        }

                        // Add it to our scene
                        Globals.ObjectAdded.Invoke(s);
                    }
                }
            }

            #endregion

            Globals.IsDialogWindowOpen = false;

            Dispose();
        }
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            if (lsSceneObjects.SelectedItem != null && lsAvailablePaths.SelectedItem != null)
            {
                if (lsSceneObjects.SelectedItem is EditorGroup)
                {
                    EditorGroup  vo = lsSceneObjects.SelectedItem as EditorGroup;
                    LedgeBuilder bo = lsAvailablePaths.SelectedItem as LedgeBuilder;

                    if (bo != null)
                    {
                        vo.AttachedPathingNode     = bo;
                        vo.CurrentPathNodeIndex    = Convert.ToInt16(tbNodeIndex.Text);
                        vo.AttachedPathingNodeName = bo.Name;

                        foreach (LedgeNodeDisplay node in bo.Nodes)
                        {
                            node.Scale = vo.Scale;
                        }

                        Globals.IsDialogWindowOpen = false;

                        Dispose();
                    }
                }

                if (lsSceneObjects.SelectedItem is EditorSprite)
                {
                    EditorSprite vo = lsSceneObjects.SelectedItem as EditorSprite;
                    LedgeBuilder bo = lsAvailablePaths.SelectedItem as LedgeBuilder;

                    if (bo != null)
                    {
                        vo.AttachedPathingNode     = bo;
                        vo.CurrentPathNodeIndex    = Convert.ToInt16(tbNodeIndex.Text);
                        vo.AttachedPathingNodeName = bo.Name;

                        foreach (LedgeNodeDisplay node in bo.Nodes)
                        {
                            node.Scale = vo.Scale;
                        }

                        Globals.IsDialogWindowOpen = false;

                        Dispose();
                    }
                }

                if (lsSceneObjects.SelectedItem is EditorEmitter)
                {
                    EditorEmitter vo = lsSceneObjects.SelectedItem as EditorEmitter;
                    LedgeBuilder  bo = lsAvailablePaths.SelectedItem as LedgeBuilder;

                    if (bo != null)
                    {
                        vo.AttachedPathingNode     = bo;
                        vo.CurrentPathNodeIndex    = Convert.ToInt16(tbNodeIndex.Text);
                        vo.AttachedPathingNodeName = bo.Name;

                        foreach (LedgeNodeDisplay node in bo.Nodes)
                        {
                            node.Scale = vo.Scale;
                        }

                        Globals.IsDialogWindowOpen = false;

                        Dispose();
                    }
                }

                if (lsSceneObjects.SelectedItem is EditorActor)
                {
                    EditorActor  vo = lsSceneObjects.SelectedItem as EditorActor;
                    LedgeBuilder bo = lsAvailablePaths.SelectedItem as LedgeBuilder;

                    if (bo != null)
                    {
                        vo.AttachedPathingNode     = bo;
                        vo.CurrentPathNodeIndex    = Convert.ToInt16(tbNodeIndex.Text);
                        vo.AttachedPathingNodeName = bo.Name;

                        // Store these in the pathing node
                        bo.Sequences = vo.Sequences;

                        foreach (LedgeNodeDisplay node in bo.Nodes)
                        {
                            node.AnimationSequence = vo.ClipPlayer.CurrentSequence;
                            node.Scale             = vo.Scale;
                        }

                        Globals.IsDialogWindowOpen = false;

                        Dispose();
                    }
                }
            }
            else
            {
                MessageBox.Show(@"Please select a scene object and an available pathing node to attach it to.");
            }
        }
示例#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]);
        }