protected override void OnEffectTick(PatternRow playPattern)
        {
            if (_keyboard == null)
            {
                return; //something probably went wrong during initialization, ignore this device effect playback
            }
            var columnSize       = _keyboard.DeviceRectangle.Width / playPattern.TotalColumns;
            var columnStartIndex = 0;

            for (var patternColumn = 0; patternColumn < playPattern.TotalColumns; patternColumn++)
            {
                var columnEndIndex = columnStartIndex + (int)Math.Round(columnSize);
                var maxWidth       = (int)Math.Round(_keyboard.DeviceRectangle.Width);

                if (IsLastPatternColumn(playPattern, patternColumn))
                {
                    columnEndIndex = maxWidth + 100;
                }

                var drawArea     = new RectangleF(columnStartIndex, 0, columnEndIndex, _keyboard.DeviceRectangle.Height + 100);
                var columnColor  = GetPlaybackColumnColor(playPattern, patternColumn);
                var corsairColor = new CorsairColor(columnColor.R, columnColor.G, columnColor.B);

                foreach (var led in _keyboard[drawArea])
                {
                    led.Color = corsairColor;
                }

                columnStartIndex = columnEndIndex;
            }
        }
Exemplo n.º 2
0
        private int CalculateDelay(PatternRow patternRow)
        {
            var calculatedDelay = (int)(100 * SettingsManager.Settings.PlaybackSettings.SpeedModifier * patternRow.Speed);

            //The animation effect speed cannot be lower than 24 millis as it will cause issues in the device playbacks
            return(calculatedDelay < DelayFloorLimit ? DelayFloorLimit : calculatedDelay);
        }
Exemplo n.º 3
0
    void SelectAll()
    {
        int  col          = patternView.position.dataColumn;
        int  chn          = patternView.position.channel;
        bool hasSelection = boxSelection.hasSelection;
        bool oneChannel   = boxSelection.selection.startCol == boxSelection.selection.endCol;

        if (!hasSelection || oneChannel)
        {
            PatternRow top    = patternView.GetRowAt(chn, 0);
            PatternRow bottom = patternView.GetRowAt(chn, songData.patternLength - 1);

            if (hasSelection)
            {
                boxSelection.SetSelection(top.GetSelectable(0), bottom.GetSelectable(SongData.SONG_DATA_COUNT - 1));
            }
            else
            {
                boxSelection.SetSelection(top.GetSelectable(col), bottom.GetSelectable(col));
            }
        }
        else
        {
            PatternRow top    = patternView.GetRowAt(0, 0);
            PatternRow bottom = patternView.GetRowAt(patternView.channels.Length - 1, songData.patternLength - 1);
            boxSelection.SetSelection(top.GetSelectable(0), bottom.GetSelectable(SongData.SONG_DATA_COUNT - 1));
        }
    }
Exemplo n.º 4
0
        protected override void OnEffectTick(PatternRow playPattern)
        {
            if (_chromaMouse == null)
            {
                return; //something probably went wrong during initialization, ignore this device effect playback
            }
            var columnSize = Constants.MaxColumns / playPattern.TotalColumns;
            var startIndex = 0;

            for (var patternColumn = 0; patternColumn < playPattern.TotalColumns; patternColumn++)
            {
                var columnEndIndex = startIndex + columnSize;
                var rowEndIndex    = startIndex + columnSize;

                if (IsMismatchingLastEndIndex(playPattern, Constants.MaxColumns, patternColumn, columnEndIndex))
                {
                    columnEndIndex = Constants.MaxColumns;
                }
                if (IsMismatchingLastEndIndex(playPattern, Constants.MaxRows, patternColumn, columnEndIndex))
                {
                    rowEndIndex = Constants.MaxRows;
                }

                if (IsAnimateVerticallyEnabled)
                {
                    AnimateVertical(playPattern, startIndex, rowEndIndex, patternColumn);
                    startIndex = rowEndIndex;
                }
                else
                {
                    AnimateHorizontal(playPattern, startIndex, columnEndIndex, patternColumn);
                    startIndex = columnEndIndex;
                }
            }
        }
Exemplo n.º 5
0
 protected bool IsMismatchingLastEndIndex(
     PatternRow patternRow,
     int maxColumns,
     int patternColumn,
     int columnEndIndex)
 {
     return(IsLastPatternColumn(patternRow, patternColumn) && columnEndIndex != maxColumns);
 }
Exemplo n.º 6
0
        private void AnimateVertical(PatternRow playPattern, int startIndex, int endIndex, int patternColumn)
        {
            var maxWidth     = (int)Math.Round(_mouse.DeviceRectangle.Width);
            var drawArea     = new RectangleF(0, startIndex, maxWidth, endIndex);
            var columnColor  = GetPlaybackColumnColor(playPattern, patternColumn);
            var corsairColor = new CorsairColor(columnColor.R, columnColor.G, columnColor.B);

            foreach (var led in _mouse[drawArea])
            {
                led.Color = corsairColor;
            }
        }
Exemplo n.º 7
0
        private void AnimateHorizontal(PatternRow playPattern, int startIndex, int endIndex, int patternColumn)
        {
            var maxHeight    = (int)Math.Round(_mouse.DeviceRectangle.Height);
            var drawArea     = new RectangleF(startIndex, 0, endIndex, maxHeight);
            var columnColor  = GetPlaybackColumnColor(playPattern, patternColumn);
            var corsairColor = new CorsairColor(columnColor.R, columnColor.G, columnColor.B);

            foreach (var led in _mouse[drawArea])
            {
                led.Color = corsairColor;
            }
        }
Exemplo n.º 8
0
        /*
         * private bool _Selected;
         * public bool Selected
         * {
         *      get { return this._Selected; }
         *      set
         *      {
         *              this._Selected = value;
         *              foreach (var note in this.Channels)
         *                      note.RowSelected = value;
         *              RaisePropertyChanged(() => this.Selected);
         *      }
         * }
         * */

        public PatternRowViewModel(PatternRow row, int rowNum)
        {
            this.Row      = row;
            this.RowNum   = rowNum;
            this.Channels = new ObservableCollection <NoteViewModel>(row.Channels.Select((note, index) =>
                                                                                         Injector.Get <NoteViewModel>(
                                                                                             new ConstructorArgument("note", note),
                                                                                             new ConstructorArgument("row", this),
                                                                                             new ConstructorArgument("channelNum", index)
                                                                                             )
                                                                                         ));
        }
Exemplo n.º 9
0
 private void AnimateHorizontal(PatternRow playPattern, int startIndex, int endIndex, int patternColumn)
 {
     for (var row = 0; row < Constants.MaxRows; row++)
     {
         for (var column = startIndex; column < endIndex; column++)
         {
             try
             {
                 _chromaMouse[row, column] =
                     GetPlaybackColumnColor(playPattern, patternColumn);
             }
             catch (ColoreException ex)
             {
                 Logger.Warn("Chroma SDK has raised an issue the mouse: " + ex.Message, ex);
             }
         }
     }
 }
Exemplo n.º 10
0
        protected override void OnEffectTick(PatternRow playPattern)
        {
            if (_mouse == null)
            {
                return; //something probably went wrong during initialization, ignore this device effect playback
            }
            var maxWidth   = (int)Math.Round(_mouse.DeviceRectangle.Width);
            var maxHeight  = (int)Math.Round(_mouse.DeviceRectangle.Height);
            var columnSize = maxWidth / playPattern.TotalColumns;
            var startIndex = 0;

            for (var patternColumn = 0; patternColumn < playPattern.TotalColumns; patternColumn++)
            {
                var columnEndIndex = startIndex + columnSize;
                var rowEndIndex    = startIndex + columnSize;

                if (IsMismatchingLastEndIndex(playPattern, maxWidth, patternColumn, columnEndIndex))
                {
                    columnEndIndex = maxWidth;
                }
                if (IsMismatchingLastEndIndex(playPattern, maxHeight, patternColumn, columnEndIndex))
                {
                    rowEndIndex = maxHeight;
                }

                if (IsAnimateVerticallyEnabled)
                {
                    AnimateVertical(playPattern, startIndex, rowEndIndex, patternColumn);
                    startIndex = rowEndIndex;
                }
                else
                {
                    AnimateHorizontal(playPattern, startIndex, columnEndIndex, patternColumn);
                    startIndex = columnEndIndex;
                }
            }

            _mouse.Update();
        }
Exemplo n.º 11
0
        protected override void OnEffectTick(PatternRow playPattern)
        {
            if (_chromaKeyboard == null)
            {
                return; //something probably went wrong during initialization, ignore this device effect playback
            }
            var columnSize       = Constants.MaxColumns / playPattern.TotalColumns;
            var columnStartIndex = 0;

            for (var patternColumn = 0; patternColumn < playPattern.TotalColumns; patternColumn++)
            {
                var columnEndIndex = columnStartIndex + columnSize;

                if (IsMismatchingLastEndIndex(playPattern, Constants.MaxColumns, patternColumn, columnEndIndex))
                {
                    columnEndIndex = Constants.MaxColumns;
                }

                for (var row = 0; row < Constants.MaxRows; row++)
                {
                    for (var column = columnStartIndex; column < columnEndIndex; column++)
                    {
                        try
                        {
                            _chromaKeyboard[row, column] =
                                GetPlaybackColumnColor(playPattern, patternColumn);
                        }
                        catch (ColoreException ex)
                        {
                            Logger.Warn("Chroma SDK has raised an issue for the keyboard: " + ex.Message, ex);
                        }
                    }
                }

                columnStartIndex = columnEndIndex;
            }
        }
Exemplo n.º 12
0
 /// <summary>
 /// Is invoked on each effect tick.
 /// An effect tick is triggered each 100 milliseconds of the system time clock as the effect is running in a
 /// background thread and isn't aware of the game ticks.
 /// </summary>
 /// <param name="playPattern">Set the pattern the effect tick needs to process.</param>
 protected abstract void OnEffectTick(PatternRow playPattern);
Exemplo n.º 13
0
 protected bool IsLastPatternColumn(PatternRow patternRow, int patternColumn)
 {
     return(patternColumn == patternRow.TotalColumns - 1);
 }
Exemplo n.º 14
0
        protected Color GetPlaybackColumnColor(PatternRow playPattern, int index)
        {
            var colorType = playPattern.ColorColumns.ElementAt(index);

            return(colorType == ColorType.OFF ? Color.Black : _colorManager[index, playPattern.TotalColumns]);
        }
Exemplo n.º 15
0
    public void UpdatePatternLength()
    {
        if (m_CurrentLength == data.patternLength)
        {
            return;
        }

        if (m_CurrentLength > 0)
        {
            SetSelection(0, 0, 0, false);
        }

        if (m_PatternRows == null)
        {
            m_PatternRows = new List <PatternRow> [channels.Length];
            for (int i = 0; i < channels.Length; i++)
            {
                m_PatternRows [i] = new List <PatternRow> ( );
            }
        }

        if (m_CurrentLength < data.patternLength)
        {
            for (int i = 0; i < data.patternLength - m_CurrentLength; i++)
            {
                GameObject lineNum = Instantiate(lineNumberPrefab, lineNumbers);
                m_LineNumbers.Add(lineNum.GetComponentInChildren <Text> ( ));

                for (int p = 0; p < channels.Length; p++)
                {
                    GameObject rowObj = Instantiate(patternRowPrefab, channels [p].transform);
                    PatternRow row    = rowObj.GetComponent <PatternRow> ( );
                    row.view    = this;
                    row.channel = p;
                    row.UpdateData( );
                    m_PatternRows[p].Add(row);
                }
            }
        }
        else
        {
            int removeCount = m_CurrentLength - data.patternLength;
            Debug.Log("Remove " + removeCount + " entries");

            for (int i = 0; i < removeCount; i++)
            {
                Destroy(m_LineNumbers [data.patternLength + i].transform.parent.gameObject);
            }

            m_LineNumbers.RemoveRange(data.patternLength, removeCount);

            for (int i = 0; i < channels.Length; i++)
            {
                for (int p = 0; p < removeCount; p++)
                {
                    Destroy(m_PatternRows [i] [data.patternLength + p].gameObject);
                }

                m_PatternRows[i].RemoveRange(data.patternLength, removeCount);

                UpdatePatternChannel(i);
            }
        }

        m_CurrentLength = data.patternLength;
        UpdateLineNumbers( );
    }