/*************************************************************************//** * @} * @defgroup SC_MDPPubFunc Public Functions * @ingroup DocSC_MDP * Functions for other classes to interact with the SC_MeasureDisplayPanel. * @{ *****************************************************************************/ /** * @brief Adds a @link Music::CombinedNote note@endlink to the @link SC_MeasureDisplayPanel::mNotes list of notes managed by this panel@endlink. * @param[in] aNote The todoc note to add to the measure. * @param[in] aNoteIndex The index of the @link Music::CombinedNote note@endlink in the overall Song. * * This function also creates the @link DocSC_NDP SC_NoteDisplayPanel object@endlink for the @link Music::CombinedNote note@endlink. */ public void AddNote(Music.CombinedNote aNote, int aNoteIndex) { // Calculate the percentage used up in the measure. float newPercentage = mPercentageUsed + Music.GetNoteLengthRelativeToMeasure(aNote.OffsetFromPrevNote, Music.TIME_SIGNATURE_4_4()); // If there is no more room in the measure for this note, then send it back to the parent. if (newPercentage >= 1f) { mParent.HandleFullMeasure(newPercentage - mPercentageUsed, aNote); } // If there is more room, then create the new panel and add it to this measure. else { // Update the percentage used. mPercentageUsed = newPercentage; // Create a SC_NoteDisplayPanel GameObject clone = null; clone = Instantiate(Resources.Load <GameObject>(NOTE_DISPLAY_PANEL_PATH)); Assert.IsNotNull(clone, "Could not load SC_NoteDisplayPanel prefab!"); // Set the values for the note's transform. clone.transform.SetParent(transform.parent); // Initialize the cloned panel. SC_NoteDisplayPanel newPanel = clone.AddComponent <SC_NoteDisplayPanel>(); newPanel.LoadNote(aNote, aNoteIndex); // Add the panel to the list. mNotes.Add(newPanel); } }
/** * @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); }
/** * @brief Moves a todocnote earlier in the Song. * @param[in] aNotePanel The panel that triggered the event. */ public void HandleMoveNoteRight(SC_NoteDisplayPanel aNotePanel) { // Get the note to move and the note that was previously to the left. Music.CombinedNote noteToMove = aNotePanel.GetNote(); int noteToMoveIndex = aNotePanel.GetNoteIndex(); Music.CombinedNote noteToRight = mSong.GetNote(noteToMoveIndex + 1); // Swap the notes. mSong.ReplaceNote(noteToMove, noteToMoveIndex + 1); mSong.ReplaceNote(noteToRight, noteToMoveIndex); // Reload the song. OnLoadSong(mSong); }
/** * @brief Handles a todocnote being removed. * @param[in] aPanel The todocpanel representing the todocnote being removed. */ public void HandleRemoveNote(SC_NoteDisplayPanel aPanel) { mSong.RemoveNote(aPanel.GetNoteIndex()); OnLoadSong(mSong); }