Esempio n. 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();
    }
Esempio n. 2
0
    private SongCreationManager.SC_InputFieldAndSlider mGlobalPitchVelocityHandler = null; //!< The handler for setting the @link DefVel Note Velocity@endlink for all of the @link Music::PITCH pitches@endlink in the @link Music::CombinedNote note@endlink being represented.

    private void Awake()
    {
        // Initialize the lists.
        mPitches = new List <SC_PitchDrumDisplayPanel>();
        mDrums   = new List <SC_PitchDrumDisplayPanel>();

        // Get the display panels.
        mMelodyDisplay     = transform.GetChild(1).GetChild(0).GetChild(0);
        mPercussionDisplay = transform.GetChild(3).GetChild(0).GetChild(0);

        // Set up the global pitch velocity.
        mGlobalPitchVelocityHandler = transform.GetChild(6).gameObject.AddComponent <SongCreationManager.SC_InputFieldAndSlider>();
        mGlobalPitchVelocityHandler.SetReferenceToInputField(transform.GetChild(5).GetComponent <InputField>());
        mGlobalPitchVelocityHandler.SetAsInt(true);
        mGlobalPitchVelocityHandler.SetValue(70f);
        mGlobalPitchVelocityHandler.ValueChanged.AddListener(OnGlobalPitchVelocityChanged);

        // Set up the global drum velocity.
        mGlobalDrumVelocityHandler = transform.GetChild(9).gameObject.AddComponent <SongCreationManager.SC_InputFieldAndSlider>();
        mGlobalDrumVelocityHandler.SetReferenceToInputField(transform.GetChild(8).GetComponent <InputField>());
        mGlobalDrumVelocityHandler.SetAsInt(true);
        mGlobalDrumVelocityHandler.SetValue(70f);
        mGlobalDrumVelocityHandler.ValueChanged.AddListener(OnGlobalDrumVelocityChanged);

        // Set up the offset panel
        mOffsetPanel = transform.GetChild(11).gameObject.AddComponent <SC_LengthOffsetSelectionPanel>();
        mOffsetPanel.SetSelected(new Music.NoteLength(Music.NOTE_LENGTH_BASE.NONE));

        // Get the done button and add its listener.
        mDoneButton = transform.GetChild(12).GetChild(0).GetComponent <Button>();
        mDoneButton.onClick.AddListener(OnDoneButtonClicked);
        mDoneButton.gameObject.SetActive(false);

        // Get the Add Pitch Button and set its listener
        mAddPitchButton = transform.GetChild(12).GetChild(1).GetComponent <Button>();
        mAddPitchButton.onClick.AddListener(OnAddPitchButtonClicked);

        // Get the Add Drum Button and set its listener.
        mAddDrumButton = transform.GetChild(12).GetChild(2).GetComponent <Button>();
        mAddDrumButton.onClick.AddListener(OnAddDrumButtonClicked);

        // Get the cancel button and set its listener.
        mCancelButton = transform.GetChild(12).GetChild(3).GetComponent <Button>();
        mCancelButton.onClick.AddListener(OnCancelButtonClicked);

        NoteDialogFinished = new NoteDialogFinishedEvent();
    }
    private Text mSelectedPitchDisplay = null;                                  //!< The text that displays the selected @link Music::PITCH pitches@endlink.

    /*************************************************************************//**
    * @}
    * @defgroup SC_APDUnity Unity Functions
    * @ingroup DocSC_APD
    * These are functions automatically called by Unity.
    * @{
    *****************************************************************************/

    /**
     * @brief Initializes the dialog.
     */
    private void Awake()
    {
        // Get the display for showing selected pitches.
        mSelectedPitchDisplay      = transform.GetChild(0).GetChild(0).GetComponent <Text>();
        mSelectedPitchDisplay.text = "Added Pitches: ";

        // Get the display for showing the toggle switches
        mPitchToggleDisplay = transform.GetChild(1).GetChild(0).GetChild(0).gameObject;

        // Get the velocity handler.
        mVelocityHandler = transform.GetChild(4).gameObject.AddComponent <SongCreationManager.SC_InputFieldAndSlider>();
        mVelocityHandler.SetReferenceToInputField(transform.GetChild(3).gameObject.GetComponent <InputField>());
        mVelocityHandler.SetValue(70);

        // Get the length selector.
        mLengthSelector = transform.GetChild(6).gameObject.AddComponent <SC_LengthOffsetSelectionPanel>();
        mLengthSelector.SetSelected(new Music.NoteLength(Music.NOTE_LENGTH_BASE.Q));

        // Get the buttons.
        mCancelButton = transform.GetChild(7).GetChild(1).GetComponent <Button>();
        mCancelButton.onClick.AddListener(OnCancelButtonClicked);
        mDoneButton = transform.GetChild(7).GetChild(0).GetComponent <Button>();
        mDoneButton.onClick.AddListener(OnDoneButtonClicked);
        mDoneButton.gameObject.SetActive(false);

        // Set up the toggle switches.
        mPitchToggles = new List <Toggle>();
        for (int i = 0; i < Music.MAX_SUPPORTED_NOTES + 1; i++)
        {
            // Create the toggle switch.
            GameObject newToggleObj = Instantiate(Resources.Load <GameObject>(TOGGLE_PREFAB_PATH));
            Toggle     tog          = newToggleObj.GetComponent <Toggle>();
            tog.isOn = false;
            tog.transform.SetParent(mPitchToggleDisplay.transform, false);
            tog.onValueChanged.AddListener(OnPitchSelected);
            tog.transform.GetChild(1).GetComponent <Text>().text = Music.NoteToString(i);

            // Add the toggle switch to the list.
            mPitchToggles.Add(tog);
        }

        // Set up the selected pitches.
        mSelectedPitches = new List <Music.PITCH>();

        // Set up the event.
        AddPitchDialogFinished = new AddPitchDialogFinishedEvent();
    }
    /*************************************************************************//**
    * @}
    * @defgroup SC_APDHandlers Event Handlers
    * @ingroup DocSC_APD
    * These are functions called by the SC_AddPitchDialog in order to handle events.
    * @{
    *****************************************************************************/

    /**
     * @brief Sets the default length
     * @param[in] aLength The default length
     */
    public void SetDefaultLength(Music.NoteLength aLength)
    {
        mLengthSelector.SetSelected(aLength);
    }