public void SetSelectedInstrument(int index)
    {
        if (index >= instruments.presets.Length)
        {
            return;
        }

        if (m_SelectedInstrument != null)
        {
            m_SelectedInstrument.SetSelected(false);
        }

        m_SelectedInstrument = m_Instruments [index];
        m_SelectedInstrument.SetSelected(true);

        keyboard.currentInstrument = index;

        absoluteNotes.onValueChanged.RemoveAllListeners( );
        absoluteNotes.isOn = instruments.presets [index].arpAbsolute;
        UpdateAbsNotes(false);
        absoluteNotes.onValueChanged.AddListener((bool val) => { instruments.presets [index].arpAbsolute = val; UpdateAbsNotes( ); });

        UpdateEnvelopes( );

        volumeEnvelope.SetLoopPoint(instruments.presets[index].volumeLoopPoint, x => instruments.presets[index].volumeLoopPoint        = (int)x);
        arpeggioEnvelope.SetLoopPoint(instruments.presets[index].arpLoopPoint, x => instruments.presets[index].arpLoopPoint            = (int)x);
        noiseEnvelope.SetLoopPoint(instruments.presets [index].noiseModeLoopPoint, x => instruments.presets [index].noiseModeLoopPoint = ( int )x);
        waveOptions.SetData(index);
    }
    public void UpdateInstruments()
    {
        int currCount = m_Instruments.Count;
        int presets   = instruments.presets.Length;

        if (currCount == presets)
        {
            return;
        }

        if (currCount < presets)
        {
            int add = presets - currCount;
            for (int i = 0; i < add; i++)
            {
                GameObject       obj         = Instantiate(instrumentPrefab, transform);
                InstrumentButton btnInstance = obj.GetComponent <InstrumentButton> ( );
                btnInstance.editor = this;
                m_Instruments.Add(btnInstance);
            }
        }
        else
        {
            int remove = currCount - presets;
            for (int i = 0; i < remove; i++)
            {
                DestroyImmediate(m_Instruments [i].gameObject);
            }

            m_Instruments.RemoveRange(0, remove);
        }

        UpdateInstrumentInfo( );

        if (m_SelectedInstrument == null)
        {
            SetSelectedInstrument(0);
        }

        SetEditorState(m_EditorState);
    }
示例#3
0
 //Caputure KeyStrokes
 private void MainForm_KeyDown(object sender, KeyEventArgs e)
 {
     if (MainScore != null)
     {
         //Escape
         if (!e.Control && e.KeyCode == Keys.Escape)
         {
             MainScore.ClearSelectedNoteArrays();
         }
         //Copy
         if (e.Control && e.KeyCode == Keys.C)
         {
             Copy();
         }
         //Cut
         if (e.Control && e.KeyCode == Keys.X)
         {
             Cut();
         }
         //Paste
         if (e.Control && e.KeyCode == Keys.V)
         {
             Paste();
         }
         //Delete
         if (!e.Control && e.KeyCode == Keys.Delete)
         {
             Delete();
         }
         if (e.Control && e.KeyCode == Keys.A)
         {
             SelectAll();
         }
         //Delete Tool Shortcut
         if (!e.Control && e.KeyCode == Keys.D)
         {
             DeleteButton.PerformClick();
         }
         //Select Tool Shortcut
         if (!e.Control && e.KeyCode == Keys.S)
         {
             SelectButton.PerformClick();
         }
         //Note Tool Shortcut
         if (!e.Control && e.KeyCode == Keys.N)
         {
             NoteLengthComboBox.Focus();
         }
         //Tempo Tool Shortcut
         if (!e.Control && e.KeyCode == Keys.T)
         {
             TempoButton.PerformClick();
         }
         //Instrument Tool Shortcut
         if (!e.Control && e.KeyCode == Keys.I)
         {
             InstrumentButton.PerformClick();
         }
         //Snapper Tool Shortcut
         if (e.Control && e.KeyCode == Keys.S)
         {
             SnapButton.PerformClick();
         }
         //Zoom Tool Shortcut : Out
         if (e.Control && e.KeyCode == Keys.OemMinus)
         {//http://stackoverflow.com/questions/3968423/what-is-the-enum-for-minus-underscore-and-equal-plus-key-in-keys-enumera
             ZoomMinusButton.PerformClick();
         }
         //Zoom Tool Shortcut : In
         if (e.Control && e.KeyCode == Keys.Oemplus)
         {
             ZoomPlusButton.PerformClick();
         }
         //Play Shortcut
         if (!e.Control && e.KeyCode == Keys.Space)
         {
             PlayButton.PerformClick();
         }
         MainScore.ScorePictureBox.Refresh();
     }
 }