示例#1
0
    private void Start()
    {
        // Make all Buttons focusable
        uiDoc.rootVisualElement.Query <Button>().ForEach(button => button.focusable = true);

        startButton.RegisterCallbackButtonTriggered(() => SceneNavigator.Instance.LoadScene(EScene.SongSelectScene));
        startButton.Focus();
        settingsButton.RegisterCallbackButtonTriggered(() => SceneNavigator.Instance.LoadScene(EScene.OptionsScene));
        aboutButton.RegisterCallbackButtonTriggered(() => SceneNavigator.Instance.LoadScene(EScene.AboutScene));
        quitButton.RegisterCallbackButtonTriggered(() => OpenQuitGameDialog());

        InitButtonDescription(startButton, R.String.mainScene_button_sing_description);
        InitButtonDescription(settingsButton, R.String.mainScene_button_settings_description);
        InitButtonDescription(aboutButton, R.String.mainScene_button_about_description);
        InitButtonDescription(quitButton, R.String.mainScene_button_quit_description);
        InitButtonDescription(jukeboxButton, R.String.mainScene_button_description_noImplementation);
        InitButtonDescription(partyButton, R.String.mainScene_button_description_noImplementation);

        UpdateVersionInfoText();

        UpdateTranslation();

        sceneSubtitle.text = I18NManager.GetTranslation(R.String.mainScene_button_sing_description);

        InputManager.GetInputAction(R.InputActions.usplay_back).PerformedAsObservable(5)
        .Subscribe(_ => ToggleCloseGameDialog());
    }
示例#2
0
    private void ShowHighscores(SongMeta songMeta, EDifficulty difficulty)
    {
        currentDifficulty       = difficulty;
        difficultyText.text     = i18nManager.GetTranslation(I18NKeys.difficulty) + ": " + difficulty.GetTranslatedName();
        titleAndArtistText.text = $"{songMeta.Title} - {songMeta.Artist}";

        LocalStatistic       localStatistic = statistics.GetLocalStats(songMeta);
        List <SongStatistic> songStatistics = localStatistic?.StatsEntries?.SongStatistics?
                                              .Where(it => it.Difficulty == difficulty).ToList();

        if (songStatistics.IsNullOrEmpty())
        {
            songStatistics = new List <SongStatistic>();
        }
        songStatistics.Sort(new CompareBySongScoreDescending());
        List <SongStatistic> topSongStatistics = songStatistics.Take(topEntries.Length).ToList();

        for (int i = 0; i < topEntries.Length; i++)
        {
            if (i < topSongStatistics.Count)
            {
                ShowHighscore(topEntries[i], topSongStatistics[i], i);
                topEntries[i].gameObject.SetActive(true);
            }
            else
            {
                topEntries[i].gameObject.SetActive(false);
            }
        }
    }
示例#3
0
 void Start()
 {
     if (!i18nKey.IsNullOrEmpty() &&
         tooltipText.IsNullOrEmpty())
     {
         tooltipText = I18NManager.GetTranslation(i18nKey);
     }
 }
示例#4
0
    public void UpdateTranslation()
    {
        string displayName = releaseName.IsNullOrEmpty() ? remoteRelease : releaseName;

        dialogMessage.text                 = I18NManager.GetTranslation(R.String.newVersionAvailableDialog_message, "remoteRelease", displayName, "websiteLink", websiteLink);
        dialogTitle.text                   = I18NManager.GetTranslation(R.String.newVersionAvailableDialog_title);
        ignoreThisVersionButton.text       = I18NManager.GetTranslation(R.String.newVersionAvailableDialog_ignoreThisVersion);
        ignoreAllFutureVersionsButton.text = I18NManager.GetTranslation(R.String.newVersionAvailableDialog_ignoreAllFutureVersions);
    }
示例#5
0
 public void UpdateTranslation()
 {
     if (!Application.isPlaying && startButton == null)
     {
         SceneInjectionManager.Instance.DoInjection();
     }
     startButton.text    = I18NManager.GetTranslation(R.String.mainScene_button_sing_label);
     settingsButton.text = I18NManager.GetTranslation(R.String.mainScene_button_settings_label);
     aboutButton.text    = I18NManager.GetTranslation(R.String.mainScene_button_about_label);
     quitButton.text     = I18NManager.GetTranslation(R.String.mainScene_button_quit_label);
 }
示例#6
0
 protected override string GetDisplayString(UltraStarPlaylist playlist)
 {
     if (playlist == null ||
         playlist is UltraStarAllSongsPlaylist)
     {
         return(I18NManager.GetTranslation(R.String.filter_allSongs));
     }
     else
     {
         return(playlistManager.GetPlaylistName(playlist));
     }
 }
示例#7
0
    public void OnSelect(BaseEventData eventData)
    {
        if (uiButtonDescriptionText == null)
        {
            return;
        }

        string description = buttonDescriptionI18nKey.IsNullOrEmpty()
            ? ""
            : I18NManager.GetTranslation(buttonDescriptionI18nKey);

        uiButtonDescriptionText.SetText(description);
    }
 protected override void FillContextMenu(ContextMenu contextMenu)
 {
     contextMenu.AddItem(I18NManager.GetTranslation(R.String.action_togglePause),
                         () => singSceneController.TogglePlayPause());
     contextMenu.AddItem(I18NManager.GetTranslation(R.String.action_restart),
                         () => singSceneController.Restart());
     contextMenu.AddItem(I18NManager.GetTranslation(R.String.action_skipToNextLyrics),
                         () => singSceneController.SkipToNextSingableNote());
     contextMenu.AddItem(I18NManager.GetTranslation(R.String.action_exitSong),
                         () => singSceneController.FinishScene(false));
     contextMenu.AddItem(I18NManager.GetTranslation(R.String.action_openSongEditor),
                         () => singSceneController.OpenSongInEditor());
 }
示例#9
0
    private void OpenQuitGameDialog()
    {
        if (closeGameDialog != null)
        {
            return;
        }

        closeGameDialog = new SimpleUxmlDialog(
            quitGameDialogUxml,
            uiDoc.rootVisualElement,
            I18NManager.GetTranslation(R.String.mainScene_quitDialog_title),
            I18NManager.GetTranslation(R.String.mainScene_quitDialog_message));
        Button yesButton = closeGameDialog.AddButton(I18NManager.GetTranslation(R.String.yes), () => ApplicationUtils.QuitOrStopPlayMode());

        yesButton.Focus();
        closeGameDialog.AddButton(I18NManager.GetTranslation(R.String.no), () => CloseQuitGameDialog());
    }
    protected override void FillContextMenu(ContextMenu contextMenu)
    {
        contextMenu.AddItem(I18NManager.GetTranslation(R.String.action_reloadSong),
                            () => SongMeta.Reload());

        contextMenu.AddItem(I18NManager.GetTranslation(R.String.action_openSongEditor),
                            () => songSelectSceneController.StartSongEditorScene());

        if (PlatformUtils.IsStandalone)
        {
            contextMenu.AddItem(I18NManager.GetTranslation(R.String.action_openSongFolder),
                                () => SongMetaUtils.OpenDirectory(SongMeta));
            AddPlaylistContextMenuItems(contextMenu);
        }

        contextMenu.AddSeparator();
    }
 private void AddPlaylistContextMenuItems(ContextMenu contextMenu)
 {
     foreach (UltraStarPlaylist playlist in playlistManager.Playlists)
     {
         string playlistName = playlistManager.GetPlaylistName(playlist);
         Dictionary <string, string> placeholders = new Dictionary <string, string> {
             ["playlist"] = playlistName
         };
         if (playlist.HasSongEntry(SongMeta.Artist, SongMeta.Title))
         {
             contextMenu.AddItem(I18NManager.GetTranslation(R.String.action_removeFromPlaylist, placeholders),
                                 () => playlistManager.RemoveSongFromPlaylist(playlist, SongMeta));
         }
         else
         {
             contextMenu.AddItem(I18NManager.GetTranslation(R.String.action_addToPlaylist, placeholders),
                                 () => playlistManager.AddSongToPlaylist(playlist, SongMeta));
         }
     }
 }
示例#12
0
    public void UpdateTranslation()
    {
        if (key == null)
        {
            Debug.LogWarning($"Missing translation key for object '{gameObject.name}'", gameObject);
            return;
        }

        string timmedKey = key.Trim();

        if (string.IsNullOrEmpty(timmedKey))
        {
            Debug.LogWarning($"Missing translation key for object '{gameObject.name}'", gameObject);
            return;
        }

        Dictionary <string, string> translationArguments = GetTranslationArguments();
        string translation = I18NManager.GetTranslation(timmedKey, translationArguments);
        Text   uiText      = GetComponent <Text>();

        uiText.text = translation;
    }
示例#13
0
    private SingSceneData CreateSingSceneData(SongMeta songMeta)
    {
        SingSceneData singSceneData = new SingSceneData();

        singSceneData.SelectedSongMeta = songMeta;

        List <PlayerProfile> selectedPlayerProfiles = playerProfileListController.GetSelectedPlayerProfiles();

        if (selectedPlayerProfiles.IsNullOrEmpty())
        {
            UiManager.Instance.CreateWarningDialog(
                I18NManager.GetTranslation(R.String.songSelectScene_noPlayerSelected_title),
                I18NManager.GetTranslation(R.String.songSelectScene_noPlayerSelected_message));
            return(null);
        }
        singSceneData.SelectedPlayerProfiles = selectedPlayerProfiles;

        PlayerProfileToMicProfileMap playerProfileToMicProfileMap = playerProfileListController.GetSelectedPlayerProfileToMicProfileMap();

        singSceneData.PlayerProfileToMicProfileMap = playerProfileToMicProfileMap;
        return(singSceneData);
    }
示例#14
0
    void Start()
    {
        string playerProfilesCsv = SceneData.SelectedPlayerProfiles.Select(it => it.Name).ToCsv();

        Debug.Log($"{playerProfilesCsv} start (or continue) singing of {SongMeta.Title} at {SceneData.PositionInSongInMillis} ms.");

        // Prepare columns and rows for player UI
        PlayerUiArea.SetupPlayerUiGrid(SceneData.SelectedPlayerProfiles.Count, playerUiArea.GetComponent <GridLayoutGroupCellSizer>());

        // Handle players
        List <PlayerProfile> playerProfilesWithoutMic = new List <PlayerProfile>();

        foreach (PlayerProfile playerProfile in SceneData.SelectedPlayerProfiles)
        {
            SceneData.PlayerProfileToMicProfileMap.TryGetValue(playerProfile, out MicProfile micProfile);
            if (micProfile == null)
            {
                playerProfilesWithoutMic.Add(playerProfile);
            }
            PlayerController playerController = CreatePlayerController(playerProfile, micProfile);

            if (SceneData.PlayerProfileToScoreDataMap.TryGetValue(playerProfile, out PlayerScoreControllerData scoreData))
            {
                playerController.PlayerScoreController.ScoreData = scoreData;
            }

            // Handle crown display
            if (SceneData.SelectedPlayerProfiles.Count > 1)
            {
                playerController.PlayerScoreController.NoteScoreEventStream.Subscribe(noteScoreEvent => { RecomputeCrowns(); });
                playerController.PlayerScoreController.SentenceScoreEventStream.Subscribe(sentenceScoreEvent => { RecomputeCrowns(); });
            }
            playerController.PlayerUiController.PlayerCrownDisplayer.ShowCrown(false);
        }

        // Handle dummy singers
        if (Application.isEditor)
        {
            DummySingers = FindObjectsOfType <AbstractDummySinger>().ToList();
            foreach (AbstractDummySinger dummySinger in DummySingers)
            {
                if (dummySinger.playerIndexToSimulate < PlayerControllers.Count)
                {
                    dummySinger.SetPlayerController(PlayerControllers[dummySinger.playerIndexToSimulate]);
                }
                else
                {
                    Debug.LogWarning("DummySinger cannot simulate player with index " + dummySinger.playerIndexToSimulate);
                    dummySinger.gameObject.SetActive(false);
                }
            }
        }

        // Create warning about missing microphones
        string playerNameCsv = string.Join(",", playerProfilesWithoutMic.Select(it => it.Name).ToList());

        if (!playerProfilesWithoutMic.IsNullOrEmpty())
        {
            UiManager.Instance.CreateWarningDialog(
                I18NManager.GetTranslation(R.String.singScene_missingMicrophones_title),
                I18NManager.GetTranslation(R.String.singScene_missingMicrophones_message, "playerNameCsv", playerNameCsv));
        }

        // Associate LyricsDisplayer with one of the (duett) players
        InitLyricsDisplayers();

        //Save information about the song being started into stats
        Statistics stats = StatsManager.Instance.Statistics;

        stats.RecordSongStarted(SongMeta);

        songVideoPlayer.Init(SongMeta, songAudioPlayer);

        StartCoroutine(StartMusicAndVideo());

        // Rebuild whole UI
        LayoutRebuilder.ForceRebuildLayoutImmediate(CanvasUtils.FindCanvas().GetComponent <RectTransform>());
    }
示例#15
0
 protected override string GetDisplayString(bool item)
 {
     return(I18NManager.GetTranslation(item ? i18nCodeTrue : i18nCodeFalse));
 }
示例#16
0
    public static string GetTranslatedName(this EDifficulty difficulty)
    {
        string i18nCode = difficulty.GetI18NCode();

        return(I18NManager.GetTranslation(i18nCode));
    }
示例#17
0
 protected override string GetDisplayString(ESongOrder value)
 {
     return($"{I18NManager.GetTranslation(R.String.order)}: {I18NManager.GetTranslation("order_" + value.ToString())}");
 }
示例#18
0
 private void InitButtonDescription(Button button, string i18nCode)
 {
     button.RegisterCallback <PointerEnterEvent>(_ => sceneSubtitle.text = I18NManager.GetTranslation(i18nCode));
     button.RegisterCallback <FocusEvent>(_ => sceneSubtitle.text        = I18NManager.GetTranslation(i18nCode));
 }