Example #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);
            }
        }
    }
    private string GetKeyboardBasedNoteManipulationControlHint()
    {
        EKeyboardModifier currentKeyboardModifier = InputUtils.GetCurrentKeyboardModifier();

        return(currentKeyboardModifier switch
        {
            EKeyboardModifier.Shift => "Arrow keys to move notes",
            EKeyboardModifier.Ctrl => "Arrow keys to move left side of notes | Space to play notes",
            EKeyboardModifier.Alt => "Arrow keys to move right side of notes",
            EKeyboardModifier.CtrlShift => "Arrow keys to move notes one octave",
            _ => ""
        });
    void Update()
    {
        EKeyboardModifier modifier = InputUtils.GetCurrentKeyboardModifier();

        if (modifier == EKeyboardModifier.Ctrl)
        {
            if (Input.GetKeyUp(KeyCode.C) && !InputFieldHasFocus())
            {
                CopySelectedNotes();
            }
            else if (Input.GetKeyUp(KeyCode.V) && !InputFieldHasFocus())
            {
                PasteCopiedNotes();
            }
        }
    }
    void Update()
    {
        if (GameObjectUtils.InputFieldHasFocus(eventSystem))
        {
            return;
        }

        EKeyboardModifier modifier = InputUtils.GetCurrentKeyboardModifier();

        if (modifier == EKeyboardModifier.Ctrl)
        {
            if (Input.GetKeyUp(KeyCode.C))
            {
                CopySelectedNotes();
            }
            else if (Input.GetKeyUp(KeyCode.V))
            {
                PasteCopiedNotes();
            }
        }
    }
    public void Update()
    {
        // Detect isAnyKeyUp
        isAnyKeyUp = false;
        if (Input.anyKey)
        {
            isAnyKey = true;
        }
        else if (isAnyKey)
        {
            isAnyKey   = false;
            isAnyKeyUp = true;
        }

        bool inputFieldHasFocus = GameObjectUtils.InputFieldHasFocus(eventSystem);

        if (inputFieldHasFocus)
        {
            inputFieldHasFocusOld = true;
            return;
        }

        EKeyboardModifier modifier = InputUtils.GetCurrentKeyboardModifier();

        // Jump to start / end of song, via Home (Pos1 on German keyboard) / End
        if (Input.GetKeyUp(KeyCode.Home))
        {
            songAudioPlayer.PositionInSongInMillis = 0;
        }
        if (Input.GetKeyUp(KeyCode.End))
        {
            songAudioPlayer.PositionInSongInMillis = songAudioPlayer.DurationOfSongInMillis - 1;
        }

        // Play / pause via Space or P
        bool isPlayPauseButtonUp = Input.GetKeyUp(KeyCode.Space) || Input.GetKeyUp(KeyCode.P);

        if (isPlayPauseButtonUp && modifier == EKeyboardModifier.None)
        {
            ToggleAudioPlayPause();
        }

        // Play only the selected notes via Ctrl+Space or Ctrl+P
        if (isPlayPauseButtonUp && modifier == EKeyboardModifier.Ctrl)
        {
            List <Note> selectedNotes = selectionController.GetSelectedNotes();
            PlayAudioInRangeOfNotes(selectedNotes);
        }

        // Stop playback or return to SingScene via Escape
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            if (songAudioPlayer.IsPlaying)
            {
                songAudioPlayer.PauseAudio();
            }
            else if (!inputFieldHasFocusOld)
            {
                // Special case: the Escape key in an InputField removes its focus on key down.
                // Thus also check that in the previous frame no InputField was focused.
                songEditorSceneController.ContinueToSingScene();
            }
        }

        // Select all notes via Ctrl+A
        if (Input.GetKeyUp(KeyCode.A) && modifier == EKeyboardModifier.Ctrl)
        {
            selectionController.SelectAll();
        }

        // Delete notes
        if (Input.GetKeyUp(KeyCode.Delete))
        {
            List <Note> selectedNotes = selectionController.GetSelectedNotes();
            deleteNotesAction.ExecuteAndNotify(selectedNotes);
        }

        // Undo via Ctrl+Z
        if (Input.GetKeyUp(KeyCode.Z) && modifier == EKeyboardModifier.Ctrl)
        {
            historyManager.Undo();
        }

        // Redo via Ctrl+Y
        if (Input.GetKeyUp(KeyCode.Y) && modifier == EKeyboardModifier.Ctrl)
        {
            historyManager.Redo();
        }

        // Save via Ctrl+S
        if (Input.GetKeyUp(KeyCode.S) && modifier == EKeyboardModifier.Ctrl)
        {
            songEditorSceneController.SaveSong();
        }

        // Tab to select next note, Shift+Tab to select previous note
        if (Input.GetKeyUp(KeyCode.Tab))
        {
            if (modifier == EKeyboardModifier.None)
            {
                selectionController.SelectNextNote();
            }
            else if (modifier == EKeyboardModifier.Shift)
            {
                selectionController.SelectPreviousNote();
            }
        }

        // Start editing of lyrics with F2
        if (Input.GetKeyUp(KeyCode.F2))
        {
            List <Note> selectedNotes = selectionController.GetSelectedNotes();
            if (selectedNotes.Count == 1)
            {
                Note         selectedNote = selectedNotes.FirstOrDefault();
                EditorUiNote uiNote       = editorNoteDisplayer.GetUiNoteForNote(selectedNote);
                if (uiNote != null)
                {
                    uiNote.StartEditingNoteText();
                }
            }
        }

        // Change position in song with Ctrl+ArrowKey
        if (!songAudioPlayer.IsPlaying)
        {
            if (Input.GetKey(KeyCode.LeftArrow) && modifier == EKeyboardModifier.Ctrl)
            {
                songAudioPlayer.PositionInSongInMillis -= 1;
            }
            if (Input.GetKey(KeyCode.RightArrow) && modifier == EKeyboardModifier.Ctrl)
            {
                songAudioPlayer.PositionInSongInMillis += 1;
            }
        }

        // Make golden / freestyle / normal
        UpdateInputToChangeNoteType(modifier);

        // Move and stretch notes
        UpdateInputToMoveAndStretchNotes(modifier);

        // Scroll and zoom in NoteArea
        UpdateInputToScrollAndZoom(modifier);

        // Use the shortcuts that are also used in the YASS song editor.
        UpdateInputForYassShortcuts(modifier);

        inputFieldHasFocusOld = inputFieldHasFocus;
    }
Example #6
0
    void Update()
    {
        EKeyboardModifier modifier = InputUtils.GetCurrentKeyboardModifier();

        // Open / close search via Ctrl
        if (Input.GetKeyDown(KeyCode.LeftControl))
        {
            if (songSelectSceneController.IsSearchEnabled())
            {
                songSelectSceneController.DisableSearch();
            }
            else
            {
                songSelectSceneController.EnableSearch(SearchInputField.ESearchMode.ByTitleOrArtist);
            }
        }

        // Fuzzy search. Do not handle other input in this case.
        if (IsFuzzySearchActive())
        {
            UpdateFuzzySearchInput();
            return;
        }

        if (modifier != EKeyboardModifier.None)
        {
            return;
        }

        if (songSelectSceneController.IsSearchEnabled())
        {
            // Close search via Escape or Return / Enter
            if (Input.GetKeyUp(KeyCode.Escape) ||
                (Input.GetKeyUp(KeyCode.Return) && songSelectSceneController.IsSearchTextInputHasFocus()))
            {
                songSelectSceneController.DisableSearch();
            }
        }
        else
        {
            // Open the main menu via Escape or Backspace
            if (Input.GetKeyUp(KeyCode.Escape) || Input.GetKeyUp(KeyCode.Backspace))
            {
                SceneNavigator.Instance.LoadScene(EScene.MainScene);
            }

            // Random song select via R
            if (Input.GetKeyUp(KeyCode.R) && IsNoControlOrSongButtonFocused())
            {
                songSelectSceneController.OnRandomSong();
            }

            // Open the song editor via E
            if (Input.GetKeyUp(KeyCode.E) && IsNoControlOrSongButtonFocused())
            {
                songSelectSceneController.StartSongEditorScene();
            }
        }

        // Select next / previous song with arrow keys or mouse wheel
        if (Input.GetKeyUp(KeyCode.RightArrow) || Input.mouseScrollDelta.y > 0)
        {
            songSelectSceneController.OnNextSong();
        }

        if (Input.GetKeyUp(KeyCode.LeftArrow) || Input.mouseScrollDelta.y < 0)
        {
            songSelectSceneController.OnPreviousSong();
        }

        // Open the sing scene via Return / Enter
        if (Input.GetKeyUp(KeyCode.Return) && IsNoControlOrSongButtonFocused())
        {
            songSelectSceneController.StartSingScene();
        }

        // Toggle active players with Tab
        if (Input.GetKeyUp(KeyCode.Tab))
        {
            songSelectSceneController.ToggleSelectedPlayers();
        }
    }
Example #7
0
    public void Update()
    {
        EKeyboardModifier modifier = InputUtils.GetCurrentKeyboardModifier();

        // Play / pause via Space
        if (Input.GetKeyUp(KeyCode.Space) && !InputFieldHasFocus())
        {
            ToggleAudioPlayPause();
        }

        // Stop via Escape
        if (Input.GetKeyUp(KeyCode.Escape))
        {
            songAudioPlayer.PauseAudio();
        }

        // Delete notes
        if (Input.GetKeyUp(KeyCode.Delete))
        {
            List <Note> selectedNotes = selectionController.GetSelectedNotes();
            deleteNotesAction.ExecuteAndNotify(selectedNotes);
        }

        // Undo via Ctrl+Z
        if (Input.GetKeyUp(KeyCode.Z) && modifier == EKeyboardModifier.Ctrl)
        {
            historyManager.Undo();
        }

        // Redo via Ctrl+Y
        if (Input.GetKeyUp(KeyCode.Y) && modifier == EKeyboardModifier.Ctrl)
        {
            historyManager.Redo();
        }

        // Save via Ctrl+S
        if (Input.GetKeyUp(KeyCode.S) && modifier == EKeyboardModifier.Ctrl)
        {
            songEditorSceneController.SaveSong();
        }

        // Tab to select next note, Shift+Tab to select previous note
        if (Input.GetKeyUp(KeyCode.Tab))
        {
            if (modifier == EKeyboardModifier.None)
            {
                selectionController.SelectNextNote();
            }
            else if (modifier == EKeyboardModifier.Shift)
            {
                selectionController.SelectPreviousNote();
            }
        }

        // Start editing of lyrics with F2
        if (Input.GetKeyUp(KeyCode.F2))
        {
            List <Note> selectedNotes = selectionController.GetSelectedNotes();
            if (selectedNotes.Count == 1)
            {
                Note         selectedNote = selectedNotes.FirstOrDefault();
                EditorUiNote uiNote       = editorNoteDisplayer.GetUiNoteForNote(selectedNote);
                if (uiNote != null)
                {
                    uiNote.StartEditingNoteText();
                }
            }
        }

        // Change position in song with Ctrl+ArrowKey
        if (!songAudioPlayer.IsPlaying)
        {
            if (Input.GetKey(KeyCode.LeftArrow) && modifier == EKeyboardModifier.Ctrl && !InputFieldHasFocus())
            {
                songAudioPlayer.PositionInSongInMillis -= 1;
            }
            if (Input.GetKey(KeyCode.RightArrow) && modifier == EKeyboardModifier.Ctrl && !InputFieldHasFocus())
            {
                songAudioPlayer.PositionInSongInMillis += 1;
            }
        }

        // Move and stretch notes
        UpdateInputToMoveAndStretchNotes(modifier);

        // Scroll and zoom in NoteArea
        UpdateInputToScrollAndZoom(modifier);
    }
    public void Update()
    {
        // Detect isAnyKeyUp
        isAnyKeyUp = false;
        if (Input.anyKey)
        {
            isAnyKey = true;
        }
        else if (isAnyKey)
        {
            isAnyKey   = false;
            isAnyKeyUp = true;
        }

        if (GameObjectUtils.InputFieldHasFocus(eventSystem))
        {
            return;
        }

        EKeyboardModifier modifier = InputUtils.GetCurrentKeyboardModifier();

        // Play / pause via Space or P
        bool isPlayPauseButtonUp = Input.GetKeyUp(KeyCode.Space) || Input.GetKeyUp(KeyCode.P);

        if (isPlayPauseButtonUp && modifier == EKeyboardModifier.None)
        {
            ToggleAudioPlayPause();
        }

        // Play only the selected notes via Ctrl+Space or Ctrl+P
        if (isPlayPauseButtonUp && modifier == EKeyboardModifier.Ctrl)
        {
            List <Note> selectedNotes = selectionController.GetSelectedNotes();
            PlayAudioInRangeOfNotes(selectedNotes);
        }

        // Stop via Escape
        if (Input.GetKeyUp(KeyCode.Escape))
        {
            songAudioPlayer.PauseAudio();
        }

        // Select all notes via Ctrl+A
        if (Input.GetKeyUp(KeyCode.A) && modifier == EKeyboardModifier.Ctrl)
        {
            selectionController.SelectAll();
        }

        // Delete notes
        if (Input.GetKeyUp(KeyCode.Delete))
        {
            List <Note> selectedNotes = selectionController.GetSelectedNotes();
            deleteNotesAction.ExecuteAndNotify(selectedNotes);
        }

        // Undo via Ctrl+Z
        if (Input.GetKeyUp(KeyCode.Z) && modifier == EKeyboardModifier.Ctrl)
        {
            historyManager.Undo();
        }

        // Redo via Ctrl+Y
        if (Input.GetKeyUp(KeyCode.Y) && modifier == EKeyboardModifier.Ctrl)
        {
            historyManager.Redo();
        }

        // Save via Ctrl+S
        if (Input.GetKeyUp(KeyCode.S) && modifier == EKeyboardModifier.Ctrl)
        {
            songEditorSceneController.SaveSong();
        }

        // Tab to select next note, Shift+Tab to select previous note
        if (Input.GetKeyUp(KeyCode.Tab))
        {
            if (modifier == EKeyboardModifier.None)
            {
                selectionController.SelectNextNote();
            }
            else if (modifier == EKeyboardModifier.Shift)
            {
                selectionController.SelectPreviousNote();
            }
        }

        // Start editing of lyrics with F2
        if (Input.GetKeyUp(KeyCode.F2))
        {
            List <Note> selectedNotes = selectionController.GetSelectedNotes();
            if (selectedNotes.Count == 1)
            {
                Note         selectedNote = selectedNotes.FirstOrDefault();
                EditorUiNote uiNote       = editorNoteDisplayer.GetUiNoteForNote(selectedNote);
                if (uiNote != null)
                {
                    uiNote.StartEditingNoteText();
                }
            }
        }

        // Change position in song with Ctrl+ArrowKey
        if (!songAudioPlayer.IsPlaying)
        {
            if (Input.GetKey(KeyCode.LeftArrow) && modifier == EKeyboardModifier.Ctrl)
            {
                songAudioPlayer.PositionInSongInMillis -= 1;
            }
            if (Input.GetKey(KeyCode.RightArrow) && modifier == EKeyboardModifier.Ctrl)
            {
                songAudioPlayer.PositionInSongInMillis += 1;
            }
        }

        // Move and stretch notes
        UpdateInputToMoveAndStretchNotes(modifier);

        // Scroll and zoom in NoteArea
        UpdateInputToScrollAndZoom(modifier);

        // Use the shortcuts that are also used in the YASS song editor.
        UpdateInputForYassShortcuts(modifier);
    }
Example #9
0
    // Implements keyboard shortcuts similar to Yass.
    // See: https://github.com/UltraStar-Deluxe/Play/issues/111
    private void UpdateInputForYassShortcuts()
    {
        EKeyboardModifier modifier = InputUtils.GetCurrentKeyboardModifier();

        if (modifier != EKeyboardModifier.None
            // Yass shortcuts only work with a keyboard.
            || Keyboard.current == null ||
            AnyInputFieldHasFocus())
        {
            return;
        }

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

        if (Keyboard.current.numpad4Key.wasReleasedThisFrame)
        {
            selectionControl.SelectPreviousNote();
        }
        if (Keyboard.current.numpad6Key.wasReleasedThisFrame)
        {
            selectionControl.SelectNextNote();
        }

        // 1 and 3 moves the note left and right (by one beat, length unchanged)
        if (Keyboard.current.numpad1Key.wasReleasedThisFrame)
        {
            moveNotesAction.MoveNotesHorizontalAndNotify(-1, selectedNotes, followingNotes);
        }
        if (Keyboard.current.numpad3Key.wasReleasedThisFrame)
        {
            moveNotesAction.MoveNotesHorizontalAndNotify(1, selectedNotes, followingNotes);
        }

        // 7 and 9 (and 8 to be more similar to division and multiply for left side) shortens/lengthens the note (by one beat, on the right side)
        if (Keyboard.current.numpad7Key.wasReleasedThisFrame ||
            Keyboard.current.numpad8Key.wasReleasedThisFrame)
        {
            extendNotesAction.ExtendNotesRightAndNotify(-1, selectedNotes, followingNotes);
        }
        if (Keyboard.current.numpad9Key.wasReleasedThisFrame)
        {
            extendNotesAction.ExtendNotesRightAndNotify(1, selectedNotes, followingNotes);
        }

        // division and multiplication shortens/lengthens the note (by one beat, on the left side)
        if (Keyboard.current.numpadDivideKey.wasReleasedThisFrame)
        {
            extendNotesAction.ExtendNotesLeftAndNotify(-1, selectedNotes);
        }
        if (Keyboard.current.numpadMultiplyKey.wasReleasedThisFrame)
        {
            extendNotesAction.ExtendNotesLeftAndNotify(1, selectedNotes);
        }

        // 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 (Keyboard.current.numpadMinusKey.wasReleasedThisFrame)
        {
            moveNotesAction.MoveNotesVerticalAndNotify(1, selectedNotes, followingNotes);
        }
        if (Keyboard.current.numpadPlusKey.wasReleasedThisFrame)
        {
            moveNotesAction.MoveNotesVerticalAndNotify(-1, selectedNotes, followingNotes);
        }

        // 5 plays the current selected notes (if any)
        if (Keyboard.current.numpad5Key.wasReleasedThisFrame)
        {
            if (selectedNotes.IsNullOrEmpty())
            {
                songEditorSceneControl.ToggleAudioPlayPause();
            }
            else
            {
                PlayAudioInRangeOfNotes(selectedNotes);
            }
        }

        // scroll left with h, scroll right with j
        if (Keyboard.current.hKey.wasReleasedThisFrame)
        {
            noteAreaControl.ScrollHorizontal(-1);
        }
        if (Keyboard.current.jKey.wasReleasedThisFrame)
        {
            noteAreaControl.ScrollHorizontal(1);
        }
    }
Example #10
0
    private void OnNavigate(InputAction.CallbackContext context)
    {
        if (!songAudioPlayer.IsPlaying)
        {
            Vector2           direction = context.ReadValue <Vector2>();
            EKeyboardModifier modifier  = InputUtils.GetCurrentKeyboardModifier();

            // Scroll
            if (modifier == EKeyboardModifier.None)
            {
                if (direction.x < 0)
                {
                    noteAreaControl.ScrollHorizontal(-1);
                }
                if (direction.x > 0)
                {
                    noteAreaControl.ScrollHorizontal(1);
                }
            }

            List <Note> selectedNotes = selectionControl.GetSelectedNotes();
            if (selectedNotes.IsNullOrEmpty())
            {
                return;
            }

            // Move and stretch notes
            List <Note> followingNotes = GetFollowingNotesOrEmptyListIfDeactivated(selectedNotes);

            // Move with Shift
            if (modifier == EKeyboardModifier.Shift)
            {
                if (direction.x != 0)
                {
                    moveNotesAction.MoveNotesHorizontalAndNotify((int)direction.x, selectedNotes, followingNotes);
                }
                if (direction.y != 0)
                {
                    moveNotesAction.MoveNotesVerticalAndNotify((int)direction.y, selectedNotes, followingNotes);
                }
            }

            // Move notes one octave up / down via Ctrl+Shift
            if (modifier == EKeyboardModifier.CtrlShift)
            {
                moveNotesAction.MoveNotesVerticalAndNotify((int)direction.y * 12, selectedNotes, followingNotes);
            }

            // Extend right side with Alt
            if (modifier == EKeyboardModifier.Alt)
            {
                extendNotesAction.ExtendNotesRightAndNotify((int)direction.x, selectedNotes, followingNotes);
            }

            // Extend left side with Ctrl
            if (modifier == EKeyboardModifier.Ctrl)
            {
                extendNotesAction.ExtendNotesLeftAndNotify((int)direction.x, selectedNotes);
            }
        }
    }