Пример #1
0
    void Start()
    {
        // Toggle Search
        InputManager.GetInputAction(R.InputActions.usplay_toggleSearch).PerformedAsObservable()
        .Subscribe(_ => ToggleSearch());

        // Toggle song is favorite
        InputManager.GetInputAction(R.InputActions.usplay_toggleFavorite).PerformedAsObservable()
        .Subscribe(_ => songSelectSceneController.ToggleSelectedSongIsFavorite());

        // Toggle favorite playlist is active
        InputManager.GetInputAction(R.InputActions.usplay_toggleFavoritePlaylistActive).StartedAsObservable()
        .Subscribe(_ => songSelectSceneController.ToggleFavoritePlaylist());

        // Close search or leave scene with Back
        InputManager.GetInputAction(R.InputActions.usplay_back).PerformedAsObservable()
        .Subscribe(_ => OnBack());

        // Select random song
        InputManager.GetInputAction(R.InputActions.usplay_randomSong).PerformedAsObservable()
        .Subscribe(_ => songSelectSceneController.OnRandomSong());

        // Open the song editor
        InputManager.GetInputAction(R.InputActions.usplay_openSongEditor).PerformedAsObservable()
        .Subscribe(_ => songSelectSceneController.StartSongEditorScene());

        // Toggle selected players
        InputManager.GetInputAction(R.InputActions.usplay_togglePlayers).PerformedAsObservable()
        .Subscribe(_ => songSelectSceneController.ToggleSelectedPlayers());

        // Open the sing scene
        InputManager.GetInputAction(R.InputActions.ui_submit).PerformedAsObservable()
        .Subscribe(OnSubmit);
        InputManager.GetInputAction(R.InputActions.usplay_start).PerformedAsObservable()
        .Subscribe(_ => songSelectSceneController.CheckAudioAndStartSingScene());

        // Select next / previous song with (hold) arrow keys or mouse wheel
        InputManager.GetInputAction(R.InputActions.ui_navigate).PerformedAsObservable()
        .Subscribe(OnNavigate);
        InputManager.GetInputAction(R.InputActions.ui_scrollWheel).PerformedAsObservable()
        .Subscribe(OnScrollWheel);
    }
Пример #2
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();
        }
    }
    void Update()
    {
        SongSelectSceneController songSelectSceneController = SongSelectSceneController.Instance;

        // Open / close search
        if (Input.GetKeyDown(QuickSearchArtist))
        {
            songSelectSceneController.EnableSearch(SearchInputField.ESearchMode.ByArtist);
        }
        if (Input.GetKeyDown(QuickSearchSong))
        {
            songSelectSceneController.EnableSearch(SearchInputField.ESearchMode.BySongTitle);
        }

        if (songSelectSceneController.IsSearchEnabled())
        {
            // When the search is enabled, then close it via Escape
            if (Input.GetKeyUp(KeyCode.Escape))
            {
                songSelectSceneController.DisableSearch();
            }
        }
        else
        {
            // When the search is not enabled, then open the main menu via Escape or Backspace
            if (Input.GetKeyUp(KeyCode.Escape) || Input.GetKeyUp(KeyCode.Backspace))
            {
                SceneNavigator.Instance.LoadScene(EScene.MainScene);
            }

            if (Input.GetKeyUp(RandomSongShortcut))
            {
                songSelectSceneController.OnRandomSong();
            }
        }

        if (Input.GetKeyUp(NextSongShortcut))
        {
            songSelectSceneController.OnNextSong();
        }

        if (Input.GetKeyUp(PreviousSongShortcut))
        {
            songSelectSceneController.OnPreviousSong();
        }

        if (Input.GetKeyUp(StartSingSceneShortcut) ||
            (Input.GetKeyUp(OpenInEditorShortcut) && !songSelectSceneController.IsSearchEnabled()))
        {
            GameObject focusedControl              = GameObjectUtils.GetSelectedGameObject();
            bool       focusedControlIsSongButton  = (focusedControl != null && focusedControl.GetComponent <SongRouletteItem>() != null);
            bool       focusedControlIsSearchField = (focusedControl != null && focusedControl.GetComponent <SearchInputField>() != null);
            if (focusedControl == null || focusedControlIsSongButton || focusedControlIsSearchField)
            {
                if (Input.GetKeyUp(StartSingSceneShortcut))
                {
                    songSelectSceneController.StartSingScene();
                }
                else if (Input.GetKeyUp(OpenInEditorShortcut))
                {
                    songSelectSceneController.StartSongEditorScene();
                }
            }
        }
    }