Пример #1
0
    /*************************************************************************//**
    * @}
    * @defgroup SC_NDiaPubFunc Public Functions
    * @ingroup DocSC_NDia
    * These are functions that allow for interaction between the SC_NoteDialog and other classes.
    * @{
    *****************************************************************************/

    /**
     * @brief Loads a @link Music::CombinedNote note@endlink into the SC_NoteDialog
     * @param[in] aNote The @link Music::CombinedNote note@endlink to load.
     */
    public void LoadNoteIntoDialog(Music.CombinedNote aNote)
    {
        Music.MelodyNote     melody     = aNote.MusicalNote;
        Music.PercussionNote percussion = aNote.Drums;

        // Add display panels.
        if (melody.NumPitches > 0)
        {
            // Add each pitch in the note.
            int index = 0;
            foreach (Music.PITCH pitch in melody.Pitches)
            {
                GameObject clone = Instantiate(Resources.Load <GameObject>(PDDP_PREFAB_PATH));
                clone.transform.SetParent(mMelodyDisplay);

                SC_PitchDrumDisplayPanel panel = clone.AddComponent <SC_PitchDrumDisplayPanel>();
                panel.InitializeAsPitchDisplay(melody.Pitches[index], melody.Lengths[index], melody.Velocities[index]);
                panel.SetParentContainer(this);
                mPitches.Add(panel);
                index++;
                clone = null;
            }
        }

        // Add each drum in the note.
        if (percussion.NumHits > 0)
        {
            int index = 0;
            foreach (Music.DRUM drum in percussion.Hits)
            {
                GameObject clone = Instantiate(Resources.Load <GameObject>(PDDP_PREFAB_PATH));
                clone.transform.SetParent(mPercussionDisplay);

                SC_PitchDrumDisplayPanel panel = clone.AddComponent <SC_PitchDrumDisplayPanel>();
                panel.InitializeAsDrumDisplay(percussion.Hits[index], percussion.Velocities[index]);
                panel.SetParentContainer(this);
                mDrums.Add(panel);
                index++;
                clone = null;
            }
        }

        // Set the offset panel.
        mOffsetPanel.SetSelected(aNote.OffsetFromPrevNote);

        // Set the Done button
        UpdateDoneButton();
    }
Пример #2
0
    /**
     * @brief Handles @link Music::DRUM drums@endlink being added.
     * @param[in] aDrums The selected @link Music::DRUM drums@endlink.
     * @param[in] aVelocity The selected @link DefVel velocity@endlink.
     */
    private void OnDrumsAdded(Music.DRUM[] aDrums, int aVelocity)
    {
        // Add the pitches to the display container and the melody note.
        foreach (Music.DRUM drum in aDrums)
        {
            // Create a pitch/drum display panel and get its script.
            GameObject clone = Instantiate(Resources.Load <GameObject>(PDDP_PREFAB_PATH));
            SC_PitchDrumDisplayPanel newPanel = clone.AddComponent <SC_PitchDrumDisplayPanel>();

            // Initialize the panel's values and add it to the list.
            newPanel.InitializeAsDrumDisplay(drum, aVelocity);
            newPanel.SetParentContainer(this);
            mDrums.Add(newPanel);

            // Put the new panel in the melody display.
            clone.transform.SetParent(mPercussionDisplay, false);
        }
        UpdateDoneButton();
    }