Exemple #1
0
    private void OnScrollWheel(InputAction.CallbackContext context)
    {
        EKeyboardModifier modifier = InputUtils.GetCurrentKeyboardModifier();

        int scrollDirection = Math.Sign(context.ReadValue <Vector2>().y);

        if (scrollDirection != 0 && noteArea.IsPointerOver)
        {
            // Scroll horizontal in NoteArea with no modifier
            if (modifier == EKeyboardModifier.None)
            {
                noteArea.ScrollHorizontal(scrollDirection);
            }

            // Zoom horizontal in NoteArea with Ctrl
            if (modifier == EKeyboardModifier.Ctrl)
            {
                noteArea.ZoomHorizontal(scrollDirection);
            }

            // Scroll vertical in NoteArea with Shift
            if (modifier == EKeyboardModifier.Shift)
            {
                noteArea.ScrollVertical(scrollDirection);
            }

            // Zoom vertical in NoteArea with Ctrl + Shift
            if (modifier == EKeyboardModifier.CtrlShift)
            {
                noteArea.ZoomVertical(scrollDirection);
            }
        }
    }
Exemple #2
0
    private void UpdateInputToScrollAndZoom(EKeyboardModifier modifier)
    {
        // Scroll with arroy keys
        if (Input.GetKeyUp(KeyCode.LeftArrow) && modifier == EKeyboardModifier.None && !InputFieldHasFocus())
        {
            noteArea.ScrollHorizontal(-1);
        }
        if (Input.GetKeyUp(KeyCode.RightArrow) && modifier == EKeyboardModifier.None && !InputFieldHasFocus())
        {
            noteArea.ScrollHorizontal(1);
        }

        // Zoom and scroll with mouse wheel
        int scrollDirection = Math.Sign(Input.mouseScrollDelta.y);

        if (scrollDirection != 0 && noteArea.IsPointerOver)
        {
            // Scroll horizontal in NoteArea with mouse wheel
            if (modifier == EKeyboardModifier.None)
            {
                noteArea.ScrollHorizontal(scrollDirection);
            }

            // Zoom horizontal in NoteArea with Ctrl + mouse wheel
            if (modifier == EKeyboardModifier.Ctrl)
            {
                noteArea.ZoomHorizontal(scrollDirection);
            }

            // Scroll vertical in NoteArea with Shift + mouse wheel
            if (modifier == EKeyboardModifier.Shift)
            {
                noteArea.ScrollVertical(scrollDirection);
            }

            // Zoom vertical in NoteArea with Ctrl + Shift + mouse wheel
            if (modifier == EKeyboardModifier.CtrlShift)
            {
                noteArea.ZoomVertical(scrollDirection);
            }
        }
    }
Exemple #3
0
    public void Update()
    {
        bool noModifier     = !Input.GetKey(KeyCode.LeftControl) && !Input.GetKey(KeyCode.LeftShift) && !Input.GetKey(KeyCode.LeftAlt);
        bool ctrlExclusive  = Input.GetKey(KeyCode.LeftControl) && !Input.GetKey(KeyCode.LeftShift) && !Input.GetKey(KeyCode.LeftAlt);
        bool shiftExclusive = !Input.GetKey(KeyCode.LeftControl) && Input.GetKey(KeyCode.LeftShift) && !Input.GetKey(KeyCode.LeftAlt);

        bool ctrlShiftExclusive = Input.GetKey(KeyCode.LeftControl) && Input.GetKey(KeyCode.LeftShift) && !Input.GetKey(KeyCode.LeftAlt);

        int scrollDirection = Math.Sign(Input.mouseScrollDelta.y);

        if (Input.GetKeyUp(KeyCode.Space))
        {
            songEditorSceneController.TogglePlayPause();
        }

        if (scrollDirection != 0 && noteArea.IsPointerOver)
        {
            // Scroll horizontal in NoteArea with mouse wheel
            if (noModifier)
            {
                noteArea.ScrollHorizontal(scrollDirection);
            }

            // Zoom horizontal in NoteArea with Ctrl + mouse wheel
            if (ctrlExclusive)
            {
                noteArea.ZoomHorizontal(scrollDirection);
            }

            // Scroll vertical in NoteArea with Shift + mouse wheel
            if (shiftExclusive)
            {
                noteArea.ScrollVertical(scrollDirection);
            }

            // Zoom vertical in NoteArea with Ctrl + Shift + mouse wheel
            if (ctrlShiftExclusive)
            {
                noteArea.ZoomVertical(scrollDirection);
            }
        }
    }
    // Implements keyboard shortcuts similar to Yass.
    // See: https://github.com/UltraStar-Deluxe/Play/issues/111
    private void UpdateInputForYassShortcuts(EKeyboardModifier modifier)
    {
        if (modifier != EKeyboardModifier.None)
        {
            return;
        }

        if (!isAnyKeyUp)
        {
            return;
        }

        // 4 and 6 on keypad to move to the previous/next note
        List <Note> selectedNotes  = selectionController.GetSelectedNotes();
        List <Note> followingNotes = GetFollowingNotesOrEmptyListIfDeactivated(selectedNotes);

        if (Input.GetKeyUp(KeyCode.Keypad4))
        {
            selectionController.SelectPreviousNote();
        }
        if (Input.GetKeyUp(KeyCode.Keypad6))
        {
            selectionController.SelectNextNote();
        }

        // 1 and 3 moves the note left and right (by one beat, length unchanged)
        if (Input.GetKeyUp(KeyCode.Keypad1))
        {
            moveNotesAction.MoveNotesHorizontalAndNotify(-1, selectedNotes, followingNotes);
        }
        if (Input.GetKeyUp(KeyCode.Keypad3))
        {
            moveNotesAction.MoveNotesHorizontalAndNotify(1, selectedNotes, followingNotes);
        }

        // 7 and 9 shortens/lengthens the note (by one beat, on the right side)
        if (Input.GetKeyUp(KeyCode.Keypad7))
        {
            extendNotesAction.ExtendNotesRightAndNotify(-1, selectedNotes, followingNotes);
        }
        if (Input.GetKeyUp(KeyCode.Keypad9))
        {
            extendNotesAction.ExtendNotesRightAndNotify(1, selectedNotes, followingNotes);
        }

        // Minus sign moves a note up a half-tone (due to the key's physical location, this makes sense)
        // Plus sign moves a note down a half-tone
        if (Input.GetKeyUp(KeyCode.KeypadMinus))
        {
            moveNotesAction.MoveNotesVerticalAndNotify(1, selectedNotes, followingNotes);
        }
        if (Input.GetKeyUp(KeyCode.KeypadPlus))
        {
            moveNotesAction.MoveNotesVerticalAndNotify(-1, selectedNotes, followingNotes);
        }

        // 5 plays the current selected note
        if (Input.GetKeyUp(KeyCode.Keypad5))
        {
            PlayAudioInRangeOfNotes(selectedNotes);
        }

        // scroll left with h, scroll right with j
        if (Input.GetKeyUp(KeyCode.H))
        {
            noteArea.ScrollHorizontal(-1);
        }
        if (Input.GetKeyUp(KeyCode.J))
        {
            noteArea.ScrollHorizontal(1);
        }
    }