Esempio n. 1
0
 /// <summary>
 /// Create the event used when a bone has been linked by an item.
 /// </summary>
 /// <param name="bone">The linked bone.</param>
 public BoneEventArgs(Bone bone)
 {
     //Pass along the data.
     _Bone = bone;
 }
Esempio n. 2
0
 /// <summary>
 /// Create the event used when a bone has been created by an item.
 /// </summary>
 /// <param name="bone">The created bone.</param>
 public BoneCreatedEventArgs(Bone bone)
 {
     //Pass along the data.
     _Bone = bone;
     _SpriteName = null;
     _SpriteOrigin = Vector2.Zero;
     _SpriteRotationOffset = 0;
 }
Esempio n. 3
0
        /// <summary>
        /// Initialize the bone dialog.
        /// </summary>
        /// <param name="gui">The GUI that this dialog will be a part of.</param>
        /// <param name="position">The position of this dialog.</param>
        /// <param name="height">The height of this dialog.</param>
        /// <param name="width">The width of this dialog.</param>
        protected override void Initialize(GraphicalUserInterface gui, Vector2 position, float width, float height)
        {
            //The inherited method.
            base.Initialize(gui, position, width, height);

            //Intialize some variables.
            _Layout.IsEnabled = false;
            _Bone = new Bone();
            _BoneSprite = null;
            _Border = 5;
            _Ratio = .4f;
            _StartPosition = Vector2.Zero;
            _EndPosition = Vector2.Zero;

            //Create the necessary components.
            _Picturebox = new Picturebox(GUI, new Vector2((position.X + _Border + (Width * _Ratio)), (position.Y + _Border)),
                ((Width * (1 - _Ratio)) - (2 * _Border) - 15), (Height - 35 - (2 * _Border)));
            _Slider = new Slider(GUI, new Vector2((position.X + Width - _Border - 10), (position.Y + (Height - 85 - _Border))), SliderType.Vertical, 50);
            _NameLabel = new Label(GUI, Vector2.Add(Position, new Vector2(_Border, _Border)), 50, 15);
            _NameTextbox = new Textbox(GUI, Vector2.Add(_NameLabel.Position, new Vector2(_NameLabel.Width, 0)),
                ((Width * _Ratio) - (2 * _Border) - _NameLabel.Width), 15);
            _ParentLabel = new Label(GUI, Vector2.Add(_NameLabel.Position, new Vector2(0, 15)), 50, 15);
            _ParentTextbox = new Textbox(GUI, Vector2.Add(_ParentLabel.Position, new Vector2(_ParentLabel.Width, 0)),
                ((Width * _Ratio) - (2 * _Border) - _ParentLabel.Width), 15);
            _AddSpriteButton = new Button(GUI, Vector2.Add(_NameLabel.Position, new Vector2(10, 40)), 75, 30);
            _CloseButton = new Button(GUI, new Vector2((Position.X + ((Width / 2) - 25)), (Position.Y + (Height - 30 - _Border))), 50, 30);

            //Modify the components.
            _Picturebox.Origin = new Vector2((_Picturebox.Width / 2), (_Picturebox.Height / 2));
            _NameLabel.Text = "Name:";
            _ParentLabel.Text = "Parent ID:";
            _AddSpriteButton.Text = "Sprite";
            _Slider.Value = 1;
            _Slider.Maximum = 3;
            _CloseButton.Text = "Done";

            //Add the controls.
            AddItem(_Picturebox);
            AddItem(_Slider);
            AddItem(_NameLabel);
            AddItem(_NameTextbox);
            AddItem(_ParentLabel);
            AddItem(_ParentTextbox);
            AddItem(_AddSpriteButton);
            AddItem(_CloseButton);

            //Hook up to some events.
            _AddSpriteButton.MouseClick += OnAddSpriteButtonClick;
            _CloseButton.MouseClick += OnCloseButtonClick;
            _Picturebox.MouseClick += OnPictureboxClick;
            _Slider.ValueChange += OnSliderChange;
        }
Esempio n. 4
0
 /// <summary>
 /// Create the event used when a bone has been created by an item.
 /// </summary>
 /// <param name="bone">The created bone.</param>
 /// <param name="spriteName">The name of the bone's sprite.</param>
 /// <param name="origin">The origin of the bone's sprite.</param>
 public BoneCreatedEventArgs(Bone bone, string spriteName, Vector2 origin, float rotationOffset)
 {
     //Pass along the data.
     _Bone = bone;
     _SpriteName = spriteName;
     _SpriteOrigin = origin;
     _SpriteRotationOffset = rotationOffset;
 }
Esempio n. 5
0
        /// <summary>
        /// Display a form that lets the user edit an already existing bone.
        /// </summary>
        /// <param name="bone">The bone to edit.</param>
        private void DisplayEditBoneDialog(Bone bone)
        {
            //The dialog.
            EditBoneDialog dialog = new EditBoneDialog(_GUI, new Vector2(350, 150), 500, 400);

            //Display the dialog.
            _GUI.AddForegroundItem(dialog);
            dialog.Bone = bone;
            //Subscribe to some of the bone dialog's events.
            //(_GUI.LastItem as EditBoneDialog).BoneEdited += OnBoneCreated;
        }
Esempio n. 6
0
        /// <summary>
        /// A new bone has been selected.
        /// </summary>
        /// <param name="bone">The bone to select.</param>
        protected virtual void BoneSelectedInvoke(Bone bone)
        {
            //Select the bone.
            _Bone = bone;
            _BoneSprite = _Bone.Skeleton.Sprites.Find(_Bone.Index.ToString());
            //Update all components to reflect this change.
            UpdateComponents();

            //If someone has hooked up a delegate to the event, fire it.
            if (BoneSelected != null) { BoneSelected(this, new BoneEventArgs(bone)); }
        }
Esempio n. 7
0
 /// <summary>
 /// Swap a bone with another bone.
 /// </summary>
 /// <param name="bone">The bone to swap.</param>
 public void SwapBone(Bone bone)
 {
     //Swap the bones.
     if (ExistsBone(bone.Index)) { _BonesToBe[GetBonePosition(bone.Index)] = bone; }
 }
Esempio n. 8
0
 /// <summary>
 /// Add a bone to the keyframe, thus enabling an animation to occur with that bone.
 /// </summary>
 /// <param name="bone">A copy of a bone modified to act as an animation goal for the source bone.</param>
 public void AddBone(Bone bone)
 {
     //If the bone has been added before, swap that bone with this one.
     if (ExistsBone(bone.Index)) { SwapBone(bone); }
     //Otherwise just add a bone to be into the list and create a default blend factor.
     else { _BonesToBe.Add(bone); _BlendFactors.Add(1f); }
 }
Esempio n. 9
0
        /// <summary>
        /// Get the blend factor for a certain bone.
        /// </summary>
        /// <param name="bone">The bone.</param>
        /// <returns>The blend factor.</returns>
        public float GetBlendFactor(Bone bone)
        {
            //If the bone exists in the keyframe, return its blend factor.
            if (ExistsBone(bone.Index)) { return _BlendFactors[GetBonePosition(bone.Index)]; }

            //If no bone was found, return zero.
            return 0;
        }
Esempio n. 10
0
 /// <summary>
 /// Remove a bone from the keyframe.
 /// </summary>
 /// <param name="bone">The bone to remove from the keyframe.</param>
 public void RemoveBone(Bone bone)
 {
     //Try and remove a bone to be from the list.
     try { _BonesToBe.Remove(bone); }
     catch { }
 }
Esempio n. 11
0
 /// <summary>
 /// Find a bone's index in the skeleton's list.
 /// </summary>
 /// <param name="bone">The bone to find.</param>
 /// <returns>The index of the bone.</returns>
 public int FindBone(Bone bone)
 {
     return (_Bones.FindIndex(b => (b.Equals(bone))));
 }
Esempio n. 12
0
 /// <summary>
 /// Add a bone to a keyframe, thus enabling that bone to be animated.
 /// </summary>
 /// <param name="animationIndex">The index of the particular animation.</param>
 /// <param name="keyframeIndex">The index of the particular keyframe.</param>
 /// <param name="bone">A copy of the bone to animate, only modified to portray the final composition of that bone. This is what the bone will animate into.</param>
 public void AddBoneToBe(int animationIndex, int keyframeIndex, Bone bone)
 {
     _Animations[animationIndex].Keyframes[keyframeIndex].AddBone(bone);
 }
Esempio n. 13
0
 /// <summary>
 /// Add a bone to the skeleton.
 /// </summary>
 /// <param name="bone">The bone to add.</param>
 public void AddBone(Bone bone)
 {
     //Add a bone to the skeleton.
     _Bones.Add(bone);
     //Make sure the bone is aware of this skeleton.
     _Bones[_Bones.Count - 1].Skeleton = this;
     //Set the index of this bone if it has not been already set.
     if (_Bones[_Bones.Count - 1].Index == -1) { _Bones[_Bones.Count - 1].Index = (_Bones.Count - 1); }
 }
Esempio n. 14
0
        /// <summary>
        /// Initialize the bone dialog.
        /// </summary>
        /// <param name="gui">The GUI that this dialog will be a part of.</param>
        /// <param name="position">The position of this dialog.</param>
        /// <param name="height">The height of this dialog.</param>
        /// <param name="width">The width of this dialog.</param>
        protected override void Initialize(GraphicalUserInterface gui, Vector2 position, float width, float height)
        {
            //The inherited method.
            base.Initialize(gui, position, width, height);

            //Intialize some variables.
            _Bone = new Bone();
            _Border = 5;
            _SpriteName = null;
            _SpriteOrigin = Vector2.Zero;
            _SpriteRotationOffset = 0;
            _NameLabel = new Label(GUI, Vector2.Add(Position, new Vector2(_Border, _Border)), 50, 15);
            _NameLabel.Text = "Name:";
            _NameTextbox = new Textbox(GUI, Vector2.Add(_NameLabel.Position, new Vector2(_NameLabel.Width, 0)), (Width - (2 * _Border) - _NameLabel.Width), 15);
            _AddSpriteButton = new Button(GUI, Vector2.Add(_NameLabel.Position, new Vector2(10, 40)), 75, 30);
            _AddSpriteButton.Text = "Sprite";
            _CloseButton = new Button(GUI, new Vector2((Position.X + ((Width / 2) - 25)), (Position.Y + (Height - 30 - _Border))), 50, 30);
            _CloseButton.Text = "Done";

            //Add the controls.
            AddItem(_NameLabel);
            AddItem(_NameTextbox);
            AddItem(_AddSpriteButton);
            AddItem(_CloseButton);

            //Hook up to some events.
            _AddSpriteButton.MouseClick += OnAddSpriteButtonClick;
            _CloseButton.MouseClick += OnCloseButtonClick;
        }
Esempio n. 15
0
        /// <summary>
        /// Deep clone this bone.
        /// </summary>
        public Bone DeepClone()
        {
            //Create a blank bone.
            Bone bone = new Bone();

            //Add all the data to it.
            bone.Skeleton = _Skeleton;
            bone.Name = _Name;
            bone.Index = _Index;
            bone.ParentIndex = _ParentIndex;
            bone.StartPosition = _StartPosition;
            bone.EndPosition = _EndPosition;

            //Return the deep cloned bone.
            return bone;
        }