Пример #1
0
    /**
     * @brief Handles when a note panel is selected for editing.
     * @param[in] aPanel The panel representing the note that we're editing.
     *
     * @see SongCreationManager::OnModifyNote
     */
    public void HandleEditNote(SC_NoteDisplayPanel aPanel)
    {
        // Create a new note dialog.
        GameObject dialogObj = Instantiate(Resources.Load <GameObject>(NOTE_DIALOG_PATH));

        dialogObj.transform.SetParent(transform);

        // Get the dialog's script and add the listener for when it's finished.
        SC_NoteDialog dialog = dialogObj.transform.GetChild(0).GetComponent <SC_NoteDialog>();

        dialog.LoadNoteIntoDialog(aPanel.GetNote());
        mEditIndex = aPanel.GetNoteIndex();
        dialog.NoteDialogFinished.AddListener(OnModifyNote);
    }
Пример #2
0
    /**
     * @brief Handles the Add Note button being clicked by loading a @link DocSC_NDia Note Dialog@endlink.
     */
    public void OnNewNoteButtonClicked()
    {
        // Load the dialog.
        GameObject dialogObj = Instantiate(Resources.Load <GameObject>(NOTE_DIALOG_PATH));

        dialogObj.transform.SetParent(transform, true);
        SC_NoteDialog dialog = dialogObj.transform.GetChild(0).GetComponent <SC_NoteDialog>();

        // Get the initial offset for the note dialog.
        Music.NoteLength dialogOffset = new Music.NoteLength(Music.NOTE_LENGTH_BASE.NONE);
        if (mSong.GetNumNotes() > 0)
        {
            // Get the last note to find the initial offset.
            int lastNoteIndex           = mSong.GetNumNotes() - 1;
            Music.CombinedNote lastNote = mSong.GetNote(lastNoteIndex);

            // If there are pitches in the last note, then set the dialog's offset to
            // be the shortest length of all of the pitches in the last note.
            if (lastNote.NumPitches > 0)
            {
                Music.NoteLength shortestLength = lastNote.MusicalNote.Lengths[0];
                for (int i = 1; i < lastNote.NumPitches; i++)
                {
                    if (lastNote.MusicalNote.Lengths[i] < shortestLength)
                    {
                        shortestLength = lastNote.MusicalNote.Lengths[i];
                    }
                }
                dialogOffset = shortestLength;
            }
            // If there are not pitches in the last note, then set it to
            // the last note's offset.
            else
            {
                dialogOffset = lastNote.OffsetFromPrevNote;
            }
        }

        dialog.SetDefaultOffset(dialogOffset);
        dialog.NoteDialogFinished.AddListener(OnCreateNote);
    }
 /**
  * @brief Sets the todocparent
  * @param[in] aParent The todocparent
  */
 public void SetParentContainer(SC_NoteDialog aParent)
 {
     mParent = aParent;
 }