コード例 #1
0
        public void SetKeyframe(int index, float value)
        {
            bool          exists = Keyframes.GetKeyframe(index) != null;
            KeyframeEntry k      = Keyframes.SetFrameValue(index, value);

            if (!exists && !_generateTangents)
            {
                k.GenerateTangent();
            }

            if (_generateTangents)
            {
                k.GenerateTangent();
                k._prev.GenerateTangent();
                k._next.GenerateTangent();
            }

            SignalPropertyChange();
        }
コード例 #2
0
ファイル: CHR0Node.cs プロジェクト: soopercool101/brawltools1
        public void SetKeyframe(KeyFrameMode mode, int index, float value)
        {
            KeyframeEntry k = Keyframes.SetFrameValue(mode, index, value);

            k.GenerateTangent();
            k._prev.GenerateTangent();
            k._next.GenerateTangent();

            SignalPropertyChange();
        }
コード例 #3
0
        internal void SetKeyframe(int keyFrameMode, int index, float value)
        {
            KeyframeArray keys   = GetKeys(keyFrameMode);
            bool          exists = keys.GetKeyframe(index) != null;
            KeyframeEntry k      = keys.SetFrameValue(index, value);

            if (!exists && !_generateTangents)
            {
                k.GenerateTangent();
            }

            if (_generateTangents)
            {
                k.GenerateTangent();
                k._prev.GenerateTangent();
                k._next.GenerateTangent();
            }

            SignalPropertyChange();
        }
コード例 #4
0
ファイル: SRT0Node.cs プロジェクト: 0000duck/brawltools
        public void RemoveKeyframe(KeyFrameMode mode, int index)
        {
            KeyframeEntry k = Keyframes.Remove(mode, index);

            if (k != null && _generateTangents)
            {
                k.GenerateTangent();
                k._prev.GenerateTangent();
                k._next.GenerateTangent();
            }
        }
コード例 #5
0
        public void RemoveKeyframe(int arrayIndex, int index)
        {
            KeyframeEntry k = Keyframes.Remove(arrayIndex, index);

            if (k != null && _generateTangents)
            {
                k.GenerateTangent();
                k._prev.GenerateTangent();
                k._next.GenerateTangent();
            }
        }
コード例 #6
0
ファイル: CHR0Node.cs プロジェクト: 0000duck/brawltools
        public KeyframeEntry SetKeyframe(KeyFrameMode mode, int index, float value, bool forceNoGenTans)
        {
            KeyframeEntry k = Keyframes.SetFrameValue(mode, index, value);

            if (_generateTangents && !forceNoGenTans)
            {
                k.GenerateTangent();
                k._prev.GenerateTangent();
                k._next.GenerateTangent();
            }

            SignalPropertyChange();
            return(k);
        }
コード例 #7
0
ファイル: CHR0Node.cs プロジェクト: PeterHatch/brawltools
        public KeyframeEntry SetKeyframe(int arrayIndex, int index, float value)
        {
            bool          exists = Keyframes.GetKeyframe(arrayIndex, index) != null;
            KeyframeEntry k      = Keyframes.SetFrameValue(arrayIndex, index, value);

            if (!exists && !_generateTangents)
            {
                k.GenerateTangent();
            }

            if (_generateTangents)
            {
                k.GenerateTangent();

                if (_alterAdjTangents && _alterAdjTangents_KeyFrame_Set)
                {
                    k._prev.GenerateTangent();
                    k._next.GenerateTangent();
                }
            }

            SignalPropertyChange();
            return(k);
        }
コード例 #8
0
ファイル: CHR0Node.cs プロジェクト: PeterHatch/brawltools
        public KeyframeEntry SetKeyframe(int arrayIndex, int index, float value, bool forceNoGenTans)
        {
            KeyframeEntry k = Keyframes.SetFrameValue(arrayIndex, index, value);

            if (_generateTangents && !forceNoGenTans)
            {
                k.GenerateTangent();

                if (_alterAdjTangents && _alterAdjTangents_KeyFrame_Set)
                {
                    k._prev.GenerateTangent();
                    k._next.GenerateTangent();
                }
            }

            SignalPropertyChange();
            return(k);
        }
コード例 #9
0
        public KeyframeEntry SetKeyframe(int arrayIndex, int index, float value, bool forceNoGenTans = false, bool parsing = false)
        {
            KeyframeEntry k = Keyframes.SetFrameValue(arrayIndex, index, value, parsing);

            if (!forceNoGenTans)
            {
                bool exists = Keyframes.GetKeyframe(arrayIndex, index) != null;
                if (_generateTangents || !exists)
                {
                    k.GenerateTangent();
                }
                if (_generateTangents && _alterAdjTangents && _alterAdjTangents_KeyFrame_Set)
                {
                    k._prev.GenerateTangent();
                    k._next.GenerateTangent();
                }
            }

            SignalPropertyChange();
            return(k);
        }
コード例 #10
0
        protected override void OnMouseMove(MouseEventArgs e)
        {
            if (_keyRoot == null)
            {
                return;
            }

            float xVal     = e.X / _xScale;
            float y        = (Height - e.Y);
            int   frameVal = (int)(xVal + 1.5f);
            int   min      = GetKeyframeMinIndex();

            if (!_dragging)
            {
                _hiKey = null;

                Cursor = Cursors.Default;

                if (AllKeyframes)
                {
                    for (KeyframeEntry entry = _keyRoot._next; (entry != _keyRoot); entry = entry._next)
                    {
                        float frame = (float)entry._index;
                        if (Math.Abs(e.X - (frame * _xScale)) <= _pointWidth)
                        {
                            if (Math.Abs(y - (entry._value - _minVal) * _yScale) <= _pointWidth)
                            {
                                _hiKey = entry;
                                Cursor = Cursors.Hand;
                                return;
                            }
                        }
                    }
                }

                if (/*_drawTans && */ _selKey != null)
                {
                    if (!AllKeyframes)
                    {
                        if (SelectedKeyframe._prev._index != -1)
                        {
                            float frame = (float)SelectedKeyframe._prev._index;
                            if (Math.Abs(e.X - ((frame - min) * _xScale)) <= _pointWidth)
                            {
                                if (Math.Abs(y - ((SelectedKeyframe._prev._value - _minVal) * _yScale)) <= _pointWidth)
                                {
                                    _hiKey = SelectedKeyframe._prev;
                                    Cursor = Cursors.Hand;
                                    return;
                                }
                            }
                        }

                        float frame1 = (float)SelectedKeyframe._index;
                        if (Math.Abs(e.X - ((frame1 - min) * _xScale)) <= _pointWidth)
                        {
                            if (Math.Abs(y - ((SelectedKeyframe._value - _minVal) * _yScale)) <= _pointWidth)
                            {
                                _hiKey = SelectedKeyframe;
                                Cursor = Cursors.Hand;
                                return;
                            }
                        }

                        if (SelectedKeyframe._next._index != -1)
                        {
                            float frame = (float)SelectedKeyframe._next._index;
                            if (Math.Abs(e.X - ((frame - min) * _xScale)) <= _pointWidth)
                            {
                                if (Math.Abs(y - ((SelectedKeyframe._next._value - _minVal) * _yScale)) <= _pointWidth)
                                {
                                    _hiKey = SelectedKeyframe._next;
                                    Cursor = Cursors.Hand;
                                    return;
                                }
                            }
                        }
                    }

                    float i1 = -(_tanLen / 2);
                    float i2 = (_tanLen / 2);

                    int   xVal2 = _selKey._index;
                    float yVal  = _selKey._value;
                    float tan   = _selKey._tangent;

                    float   p   = (float)Math.Sqrt(_precision / 4.0f);
                    Vector2 one = new Vector2((xVal2 + i1 * p - min) * _xScale, (yVal - _minVal + tan * i1 * p) * _yScale);
                    Vector2 two = new Vector2((xVal2 + i2 * p - min) * _xScale, (yVal - _minVal + tan * i2 * p) * _yScale);

                    _slopePoint = null;
                    if (Math.Abs(e.X - one._x) <= _pointWidth)
                    {
                        if (Math.Abs(y - one._y) <= _pointWidth)
                        {
                            Cursor      = Cursors.Hand;
                            _slopePoint = new Vector2(e.X, y);
                            _origPos    = new Vector2((float)(xVal2 - min) * _xScale, (yVal - _minVal) * _yScale);
                            _hiKey      = _selKey;
                            return;
                        }
                    }

                    if (Math.Abs(e.X - two._x) <= _pointWidth)
                    {
                        if (Math.Abs(y - two._y) <= _pointWidth)
                        {
                            Cursor      = Cursors.Hand;
                            _slopePoint = new Vector2(e.X, y);
                            _origPos    = new Vector2((float)(xVal2 - min) * _xScale, (yVal - _minVal) * _yScale);
                            _hiKey      = _selKey;
                            return;
                        }
                    }
                }
                if (AllKeyframes)
                {
                    if (Math.Abs(e.X - (_frame * _xScale)) <= _pointWidth)
                    {
                        Cursor = Cursors.VSplit;
                    }
                }
            }
            else if (_selKey != null && (_keyDraggingAllowed || _slopePoint != null))
            {
                if (_slopePoint != null)
                {
                    int   xVal2 = _selKey._index;
                    float yVal  = _selKey._value;

                    float xDiff = e.X - ((Vector2)_slopePoint)._x;
                    float yDiff = y - ((Vector2)_slopePoint)._y;

                    float x2 = ((Vector2)_slopePoint)._x + xDiff;
                    float y2 = ((Vector2)_slopePoint)._y + yDiff;

                    _slopePoint = new Vector2(x2 == _origPos._x ? ((Vector2)_slopePoint)._x : x2, y2);

                    Vector2 x = (Vector2)_slopePoint - _origPos;
                    _selKey._tangent = (float)Math.Round((x._y / _yScale) / (x._x / _xScale), 5);

                    if (_genTans)
                    {
                        _selKey._prev.GenerateTangent();
                        _selKey._next.GenerateTangent();
                    }

                    if (_syncStartEnd)
                    {
                        if (SelectedKeyframe._prev._index == -1 && SelectedKeyframe._prev._prev != SelectedKeyframe)
                        {
                            SelectedKeyframe._prev._prev._tangent = SelectedKeyframe._tangent;
                            SelectedKeyframe._prev._prev._value   = SelectedKeyframe._value;
                        }

                        if (SelectedKeyframe._next._index == -1 && SelectedKeyframe._next._next != SelectedKeyframe)
                        {
                            SelectedKeyframe._next._next._tangent = SelectedKeyframe._tangent;
                            SelectedKeyframe._next._next._value   = SelectedKeyframe._value;
                        }
                    }

                    Invalidate();

                    if (SelectedKeyframeChanged != null)
                    {
                        SelectedKeyframeChanged(this, null);
                    }

                    if (SignalChange != null)
                    {
                        SignalChange(this, null);
                    }
                }
                else if (_keyDraggingAllowed)
                {
                    float yVal  = y / _yScale + _minVal;
                    int   xv    = frameVal - 1;
                    int   xDiff = xv - (int)_prevX;
                    float yDiff = (yVal - _prevY);

                    if (_selKey._prev._index < _selKey._index + xDiff && _selKey._next._index > _selKey._index + xDiff && _selKey._next._index != -1 && _selKey._prev._index != -1)
                    {
                        _selKey._index += xDiff;
                    }

                    _selKey._value = (float)Math.Round(_selKey._value + yDiff, 3);
                    _prevX         = xv;
                    _prevY         = yVal;

                    if (_genTans)
                    {
                        _selKey.GenerateTangent();
                        _selKey._prev.GenerateTangent();
                        _selKey._next.GenerateTangent();
                    }

                    if (_syncStartEnd)
                    {
                        if (SelectedKeyframe._prev._index == -1 && SelectedKeyframe._prev._prev != SelectedKeyframe)
                        {
                            SelectedKeyframe._prev._prev._tangent = SelectedKeyframe._tangent;
                            SelectedKeyframe._prev._prev._value   = SelectedKeyframe._value;
                        }
                        if (SelectedKeyframe._next._index == -1 && SelectedKeyframe._next._next != SelectedKeyframe)
                        {
                            SelectedKeyframe._next._next._tangent = SelectedKeyframe._tangent;
                            SelectedKeyframe._next._next._value   = SelectedKeyframe._value;
                        }
                    }

                    Invalidate();

                    if (SelectedKeyframeChanged != null)
                    {
                        SelectedKeyframeChanged(this, null);
                    }

                    if (SignalChange != null)
                    {
                        SignalChange(this, null);
                    }
                }
            }
            else if (frameVal > 0 && _selKey == null)
            {
                FrameIndex = frameVal;
            }
        }
コード例 #11
0
        protected override void OnMouseDown(MouseEventArgs e)
        {
            bool keyChanged = _selKey != _hiKey;

            _selKey = _hiKey;

            if (DisplayAllKeyframes)
            {
                _dragging = _selKey != null || Cursor == Cursors.VSplit || _slopePoint != null;
            }
            else
            {
                _dragging = _selKey != null && (_slopePoint != null || Cursor == Cursors.Hand);
            }

            if (_selKey != null)
            {
                if (_slopePoint == null)
                {
                    int min = GetKeyframeMinIndex();
                    _prevX = _selKey._index - min;
                    _prevY = _selKey._value;
                }
                _frame = _selKey._index;

                if ((_dragging && !Has3PlusVals()) || _slopePoint != null)
                {
                    _lockIncs = true;
                }
            }
            else if (!_dragging && ModifierKeys == Keys.Control)
            {
                int           frameVal = (int)(e.X / _xScale + 0.5f);
                KeyframeEntry entry;
                for (entry = _keyRoot._next;
                     entry != _keyRoot && entry._index >= 0 && entry._index <= FrameLimit;
                     entry = entry._next)
                {
                    if (entry._index < frameVal)
                    {
                        if (entry.Second != null)
                        {
                            entry = entry.Second;
                        }

                        if (entry._next._index > frameVal || entry._next == _keyRoot)
                        {
                            break;
                        }
                    }
                }
                if (entry != _keyRoot)
                {
                    int           min = GetKeyframeMinIndex();
                    KeyframeEntry r   = new KeyframeEntry(frameVal + min, ((float)Height - e.Y) / _yScale + _minVal);
                    entry.InsertAfter(r);
                    r.GenerateTangent();
                    _selKey   = r;
                    _dragging = true;
                    _prevX    = _selKey._index - min;
                    _prevY    = _selKey._value;
                    _frame    = _selKey._index;
                    Invalidate();
                }

                if (SignalChange != null)
                {
                    SignalChange(this, null);
                }
            }

            if (keyChanged)
            {
                Invalidate();
                if (SelectedKeyframeChanged != null)
                {
                    SelectedKeyframeChanged(this, null);
                }
            }
        }
コード例 #12
0
        protected override void OnMouseMove(MouseEventArgs e)
        {
            if (_keyRoot == null)
            {
                return;
            }

            float mouseY = (float)Height - e.Y;
            float mouseX = e.X;

            //Get nearest frame value
            int frameVal = (int)(mouseX / _xScale + 0.5f);

            int min = GetKeyframeMinIndex();

            if (!_dragging)
            {
                if (_hiKey != null)
                {
                    _hiKey = null;
                    Invalidate();
                }

                Cursor = Cursors.Default;

                if (DisplayAllKeyframes)
                {
                    for (KeyframeEntry entry = _keyRoot._next; (entry != _keyRoot); entry = entry._next)
                    {
                        float frame = (float)entry._index;
                        if (Math.Abs(mouseX - (frame * _xScale)) <= _pointWidth)
                        {
                            if (Math.Abs(mouseY - ((entry._value - _minVal) * _yScale)) <= _pointWidth)
                            {
                                _hiKey = entry;
                                Cursor = Cursors.Hand;
                                Invalidate();
                                return;
                            }
                        }
                    }
                }

                if (/*_drawTans && */ _selKey != null)
                {
                    if (!DisplayAllKeyframes)
                    {
                        if (SelectedKeyframe._prev._index != -1)
                        {
                            float frame = (float)SelectedKeyframe._prev._index;
                            if (Math.Abs(mouseX - ((frame - min) * _xScale)) <= _pointWidth)
                            {
                                if (Math.Abs(mouseY - ((SelectedKeyframe._prev._value - _minVal) * _yScale)) <= _pointWidth)
                                {
                                    _hiKey = SelectedKeyframe._prev;
                                    Cursor = Cursors.Hand;
                                    Invalidate();
                                    return;
                                }
                            }
                        }

                        float frame1 = (float)SelectedKeyframe._index;
                        if (Math.Abs(mouseX - ((frame1 - min) * _xScale)) <= _pointWidth)
                        {
                            if (Math.Abs(mouseY - ((SelectedKeyframe._value - _minVal) * _yScale)) <= _pointWidth)
                            {
                                _hiKey = SelectedKeyframe;
                                Cursor = Cursors.Hand;
                                Invalidate();
                                return;
                            }
                        }

                        if (SelectedKeyframe._next._index != -1)
                        {
                            float frame = (float)SelectedKeyframe._next._index;
                            if (Math.Abs(mouseX - ((frame - min) * _xScale)) <= _pointWidth)
                            {
                                if (Math.Abs(mouseY - ((SelectedKeyframe._next._value - _minVal) * _yScale)) <= _pointWidth)
                                {
                                    _hiKey = SelectedKeyframe._next;
                                    Cursor = Cursors.Hand;
                                    Invalidate();
                                    return;
                                }
                            }
                        }
                    }

                    float i1 = -(_tanLen / 2);
                    float i2 = -i1;

                    int   xVal2 = _selKey._index;
                    float yVal  = _selKey._value;
                    float tan   = _selKey._tangent;

                    float   p   = (float)Math.Sqrt(_precision / 4.0f);
                    Vector2 one = new Vector2((xVal2 + i1 * p - min) * _xScale, (yVal - _minVal + tan * i1 * p) * _yScale);
                    Vector2 two = new Vector2((xVal2 + i2 * p - min) * _xScale, (yVal - _minVal + tan * i2 * p) * _yScale);

                    _slopePoint = null;
                    if (Math.Abs(mouseX - one._x) <= _pointWidth && Math.Abs(mouseY - one._y) <= _pointWidth)
                    {
                        _slopePoint = new Vector2(mouseX, mouseY);
                        _origPos    = new Vector2((float)(xVal2 - min) * _xScale, (yVal - _minVal) * _yScale);
                        _hiKey      = _selKey;
                        Cursor      = Cursors.Hand;
                        Invalidate();
                        return;
                    }

                    if (Math.Abs(mouseX - two._x) <= _pointWidth)
                    {
                        if (Math.Abs(mouseY - two._y) <= _pointWidth)
                        {
                            _slopePoint = new Vector2(mouseX, mouseY);
                            _origPos    = new Vector2((float)(xVal2 - min) * _xScale, (yVal - _minVal) * _yScale);
                            _hiKey      = _selKey;
                            Cursor      = Cursors.Hand;
                            Invalidate();
                            return;
                        }
                    }
                }
                if (DisplayAllKeyframes)
                {
                    if (Math.Abs(mouseX - (_frame * _xScale)) <= _pointWidth)
                    {
                        Cursor = Cursors.VSplit;
                    }
                }
            }
            else if (_selKey != null && (_keyDraggingAllowed || _slopePoint != null))
            {
                if (_slopePoint != null)
                {
                    int   xVal2 = _selKey._index;
                    float yVal  = _selKey._value;

                    float xDiff = mouseX - ((Vector2)_slopePoint)._x;
                    float yDiff = mouseY - ((Vector2)_slopePoint)._y;

                    float x2 = ((Vector2)_slopePoint)._x + xDiff;
                    float y2 = ((Vector2)_slopePoint)._y + yDiff;

                    _slopePoint = new Vector2(x2 == _origPos._x ? ((Vector2)_slopePoint)._x : x2, y2);

                    Vector2 x = (Vector2)_slopePoint - _origPos;
                    _selKey._tangent = (float)Math.Round((x._y / _yScale) / (x._x / _xScale), 5);

                    if (_genTans)
                    {
                        _selKey._prev.GenerateTangent();
                        _selKey._next.GenerateTangent();
                    }

                    if (_syncStartEnd)
                    {
                        if (SelectedKeyframe._prev._index == -1 && SelectedKeyframe._prev._prev != SelectedKeyframe)
                        {
                            SelectedKeyframe._prev._prev._tangent = SelectedKeyframe._tangent;
                            SelectedKeyframe._prev._prev._value   = SelectedKeyframe._value;
                        }

                        if (SelectedKeyframe._next._index == -1 && SelectedKeyframe._next._next != SelectedKeyframe)
                        {
                            SelectedKeyframe._next._next._tangent = SelectedKeyframe._tangent;
                            SelectedKeyframe._next._next._value   = SelectedKeyframe._value;
                        }
                    }

                    Invalidate();

                    if (SelectedKeyframeChanged != null)
                    {
                        SelectedKeyframeChanged(this, null);
                    }

                    if (SignalChange != null)
                    {
                        SignalChange(this, null);
                    }
                }
                else if (_keyDraggingAllowed)
                {
                    float yVal  = mouseY / _yScale + _minVal;
                    int   xv    = frameVal;
                    int   xDiff = xv - (int)(_prevX + 0.5f);
                    float yDiff = (yVal - _prevY);

                    int  newFrameIndex = _selKey._index + xDiff;
                    bool frameSet      =
                        newFrameIndex >= 0 &&
                        newFrameIndex < FrameLimit &&
                        (newFrameIndex >= _selKey._prev._index || _selKey._prev._index < 0) &&
                        (newFrameIndex <= _selKey._next._index || _selKey._next._index < 0);

                    if (newFrameIndex == _selKey._prev._index)
                    {
                        if (_selKey._prev._prev._index == _selKey._prev._index)
                        {
                            frameSet = false;
                        }
                    }
                    else if (newFrameIndex == _selKey._next._index)
                    {
                        if (_selKey._next._next._index == _selKey._next._index)
                        {
                            frameSet = false;
                        }
                    }

                    _selKey._value = (float)Math.Round(_selKey._value + yDiff, 3);

                    if (frameSet)
                    {
                        FrameIndex = _selKey._index = newFrameIndex;
                    }

                    _prevX = xv;
                    _prevY = yVal;

                    if (_genTans)
                    {
                        if (_alterSelTangent_Drag)
                        {
                            _selKey.GenerateTangent();
                        }

                        if (_alterAdjTangents_KeyFrame_Drag)
                        {
                            _selKey._prev.GenerateTangent();
                            _selKey._next.GenerateTangent();
                        }
                    }

                    if (_syncStartEnd)
                    {
                        if (SelectedKeyframe._prev._index == -1 && SelectedKeyframe._prev._prev != SelectedKeyframe)
                        {
                            SelectedKeyframe._prev._prev._tangent = SelectedKeyframe._tangent;
                            SelectedKeyframe._prev._prev._value   = SelectedKeyframe._value;
                        }
                        if (SelectedKeyframe._next._index == -1 && SelectedKeyframe._next._next != SelectedKeyframe)
                        {
                            SelectedKeyframe._next._next._tangent = SelectedKeyframe._tangent;
                            SelectedKeyframe._next._next._value   = SelectedKeyframe._value;
                        }
                    }

                    Invalidate();

                    if (SelectedKeyframeChanged != null)
                    {
                        SelectedKeyframeChanged(this, null);
                    }

                    if (SignalChange != null)
                    {
                        SignalChange(this, null);
                    }
                }
            }
            else if (frameVal >= 0 && frameVal < _frameLimit && _selKey == null)
            {
                FrameIndex = frameVal;
            }
        }