Exemplo n.º 1
0
        public IEnumerator GetFFZChannelEmotes() //{TwitchLoginConfig.Instance.TwitchChannelName}
        {
            UnityWebRequest www = UnityWebRequest.Get($"https://api.frankerfacez.com/v1/room/{TwitchLoginConfig.Instance.TwitchChannelName}");

            yield return(www.SendWebRequest());

            if (www.isNetworkError || www.isHttpError)
            {
            }
            else
            {
                JSONNode json = JSON.Parse(www.downloadHandler.text);
                if (json["sets"].IsObject)
                {
                    JSONArray emotes = json["sets"][json["room"]["set"].ToString()]["emoticons"].AsArray;
                    foreach (JSONObject o in emotes)
                    {
                        JSONObject urls  = o["urls"].AsObject;
                        string     url   = urls[urls.Count - 1];
                        string     index = url.Substring(url.IndexOf(".com/") + 5);
                        SharedCoroutineStarter.instance.StartCoroutine(LoadScripts.LoadSpriteCoroutine(url, (image) =>
                        {
                            BTTVEmotePool.Add(o["name"], image); //i think this works? lmao
                        }));
                    }
                }
            }
        }
Exemplo n.º 2
0
        public void SetContent(ChannelInfo channelInfo)
        {
            _container.SetActive(true);

            currentChannel = channelInfo;

            if (!string.IsNullOrEmpty(channelInfo.iconUrl))
            {
                _loadingIndicator.SetActive(true);
                StartCoroutine(LoadScripts.LoadSpriteCoroutine(channelInfo.iconUrl, (image) =>
                {
                    _loadingIndicator.SetActive(false);
                    _channelCover.sprite = image;
                }));
                Misc.Logger.Info("Loading icon from URL: \"" + channelInfo.iconUrl + "\"");
            }
            else
            {
                Misc.Logger.Info("Icon URL is empty!");
                _channelCover.sprite = Sprites.radioIcon;
            }

            _channelNameText.text = channelInfo.name;
            _playerCountText.text = "Players: " + channelInfo.playerCount;
            _nowPlayingText.text  = "Now playing: " + channelInfo.currentSong.songName;
        }
        public void Init(Song _song)
        {
            Destroy(GetComponent <LevelListTableCell>());

            reuseIdentifier = "DownloadCell";

            song = _song;

            _authorText     = GetComponentsInChildren <TextMeshProUGUI>().First(x => x.name == "Author");
            _songNameText   = GetComponentsInChildren <TextMeshProUGUI>().First(x => x.name == "SongName");
            _coverRawImage  = GetComponentsInChildren <UnityEngine.UI.RawImage>().First(x => x.name == "CoverImage");
            _bgImage        = GetComponentsInChildren <UnityEngine.UI.Image>().First(x => x.name == "BG");
            _highlightImage = GetComponentsInChildren <UnityEngine.UI.Image>().First(x => x.name == "Highlight");
            _beatmapCharacteristicAlphas = new float[0];
            _beatmapCharacteristicImages = new UnityEngine.UI.Image[0];
            _bought = true;

            foreach (var icon in GetComponentsInChildren <UnityEngine.UI.Image>().Where(x => x.name.StartsWith("LevelTypeIcon")))
            {
                Destroy(icon.gameObject);
            }

            _songNameText.text = string.Format("{0}\n<size=80%>{1}</size>", song.songName, song.songSubName);
            _authorText.text   = song.levelAuthorName;
            StartCoroutine(LoadScripts.LoadSpriteCoroutine(song.coverURL, (cover) => { if (cover != null)
                                                                                       {
                                                                                           _coverRawImage.texture = cover.texture;
                                                                                       }
                                                           }));

            _bgImage.enabled    = true;
            _bgImage.sprite     = Sprite.Create((new Texture2D(1, 1)), new Rect(0, 0, 1, 1), Vector2.one / 2f);
            _bgImage.type       = UnityEngine.UI.Image.Type.Filled;
            _bgImage.fillMethod = UnityEngine.UI.Image.FillMethod.Horizontal;

            switch (song.songQueueState)
            {
            case SongQueueState.Queued:
            case SongQueueState.Downloading:
            {
                _bgImage.color      = new Color(1f, 1f, 1f, 0.35f);
                _bgImage.fillAmount = song.downloadingProgress;
            }
            break;

            case SongQueueState.Downloaded:
            {
                _bgImage.color      = new Color(1f, 1f, 1f, 0.35f);
                _bgImage.fillAmount = 1f;
            }
            break;

            case SongQueueState.Error:
            {
                _bgImage.color      = new Color(1f, 0f, 0f, 0.35f);
                _bgImage.fillAmount = 1f;
            }
            break;
            }
        }
Exemplo n.º 4
0
        public void SetSongInfo(SongInfo songInfo)
        {
            _currentSongInfo = songInfo;

            if (_currentSongCell != null)
            {
                BeatmapLevelSO level = SongLoader.CustomBeatmapLevelPackCollectionSO.beatmapLevelPacks.SelectMany(x => x.beatmapLevelCollection.beatmapLevels).FirstOrDefault(x => x.levelID.StartsWith(songInfo.levelId)) as BeatmapLevelSO;

                if (level == null)
                {
                    _currentSongCell.SetText(_currentSongInfo.songName);
                    _currentSongCell.SetSubText("Loading info...");
                    SongDownloader.Instance.RequestSongByLevelID(_currentSongInfo.levelId, (song) =>
                    {
                        _currentSongCell.SetText($"{song.songName} <size=80%>{song.songSubName}</size>");
                        _currentSongCell.SetSubText(song.authorName);
                        StartCoroutine(LoadScripts.LoadSpriteCoroutine(song.coverUrl, (cover) => { _currentSongCell.SetIcon(cover); }));
                    }
                                                                 );
                }
                else
                {
                    _currentSongCell.SetText($"{level.songName} <size=80%>{level.songSubName}</size>");
                    _currentSongCell.SetSubText(level.songAuthorName);
                    _currentSongCell.SetIcon(level.coverImage);
                }
            }
        }
        public void SetSong(SongInfo info)
        {
            if (_songTableCell == null)
            {
                return;
            }

            _selectedSong = SongLoader.CustomBeatmapLevelPackCollectionSO.beatmapLevelPacks.SelectMany(x => x.beatmapLevelCollection.beatmapLevels).FirstOrDefault(x => x.levelID.StartsWith(info.levelId)) as BeatmapLevelSO;

            if (_selectedSong != null)
            {
                _songTableCell.SetText(_selectedSong.songName + " <size=80%>" + _selectedSong.songSubName + "</size>");
                _songTableCell.SetSubText(_selectedSong.songAuthorName);
                _songTableCell.SetIcon(_selectedSong.coverImage);
            }
            else
            {
                _songTableCell.SetText(info.songName);
                _songTableCell.SetSubText("Loading info...");
                SongDownloader.Instance.RequestSongByLevelID(info.levelId, (song) =>
                {
                    _songTableCell.SetText($"{song.songName} <size=80%>{song.songSubName}</size>");
                    _songTableCell.SetSubText(song.authorName);
                    StartCoroutine(LoadScripts.LoadSpriteCoroutine(song.coverUrl, (cover) => { _songTableCell.SetIcon(cover); }));
                });
            }
        }
        public TableCell CellForIdx(int row)
        {
            LevelListTableCell _tableCell = Instantiate(_songListTableCellInstance);

            _tableCell.reuseIdentifier = "MoreSongsTableCell";
            _tableCell.GetPrivateField <TextMeshProUGUI>("_songNameText").text = string.Format("{0} <size=80%>{1}</size>", songsList[row].songName, songsList[row].songSubName);
            _tableCell.GetPrivateField <TextMeshProUGUI>("_authorText").text   = songsList[row].authorName;
            _tableCell.SetPrivateField("_beatmapCharacteristicAlphas", new float[0]);
            _tableCell.SetPrivateField("_beatmapCharacteristicImages", new UnityEngine.UI.Image[0]);
            _tableCell.SetPrivateField("_bought", true);

            foreach (var icon in _tableCell.GetComponentsInChildren <UnityEngine.UI.Image>().Where(x => x.name.StartsWith("LevelTypeIcon")))
            {
                Destroy(icon.gameObject);
            }

            StartCoroutine(LoadScripts.LoadSpriteCoroutine(songsList[row].coverUrl, (cover) => { _tableCell.GetPrivateField <UnityEngine.UI.Image>("_coverImage").sprite = cover; }));
            bool alreadyDownloaded = SongDownloader.Instance.IsSongDownloaded(songsList[row]);

            if (alreadyDownloaded)
            {
                foreach (UnityEngine.UI.Image img in _tableCell.GetComponentsInChildren <UnityEngine.UI.Image>())
                {
                    img.color = new Color(1f, 1f, 1f, 0.2f);
                }
                foreach (TextMeshProUGUI text in _tableCell.GetComponentsInChildren <TextMeshProUGUI>())
                {
                    text.faceColor = new Color(1f, 1f, 1f, 0.2f);
                }
            }

            return(_tableCell);
        }
Exemplo n.º 7
0
        public void SetSelectedSong(SongInfo info)
        {
            _selectedSong = SongLoader.CustomBeatmapLevelPackCollectionSO.beatmapLevelPacks.SelectMany(x => x.beatmapLevelCollection.beatmapLevels).FirstOrDefault(x => x.levelID.StartsWith(info.levelId)) as BeatmapLevelSO;

            if (_selectedSong != null)
            {
                _selectedSongCell.SetText(_selectedSong.songName + " <size=80%>" + _selectedSong.songSubName + "</size>");
                _selectedSongCell.SetSubText(_selectedSong.songAuthorName);
                _selectedSongCell.SetIcon(_selectedSong.coverImage);

                _characteristicControl.SetTexts(_selectedSong.beatmapCharacteristics.Select(x => x.characteristicName).ToArray());

                int standardCharacteristicIndex = Array.FindIndex(_selectedSong.beatmapCharacteristics, x => x.serializedName == "Standard");

                _characteristicControl.SelectCellWithNumber((standardCharacteristicIndex == -1 ? 0 : standardCharacteristicIndex));
                _characteristicControl_didSelectCellEvent(null, (standardCharacteristicIndex == -1 ? 0 : standardCharacteristicIndex));
            }
            else
            {
                _selectedSongCell.SetText(info.songName);
                _selectedSongCell.SetSubText("Loading info...");
                SongDownloader.Instance.RequestSongByLevelID(info.levelId, (song) =>
                {
                    _selectedSongCell.SetText($"{song.songName} <size=80%>{song.songSubName}</size>");
                    _selectedSongCell.SetSubText(song.authorName);
                    StartCoroutine(LoadScripts.LoadSpriteCoroutine(song.coverUrl, (cover) => { _selectedSongCell.SetIcon(cover); }));
                });
            }
        }
Exemplo n.º 8
0
        public void SetSongInfo(SongInfo songInfo)
        {
            _currentSongInfo = songInfo;

            if (_currentSongCell != null)
            {
                IPreviewBeatmapLevel level = SongCore.Loader.CustomBeatmapLevelPackCollectionSO.beatmapLevelPacks.SelectMany(x => x.beatmapLevelCollection.beatmapLevels).FirstOrDefault(x => x.levelID.StartsWith(songInfo.levelId));
                if (level == null)
                {
                    _currentSongCell.SetText(_currentSongInfo.songName);
                    _currentSongCell.SetSubText("Loading info...");
                    SongDownloader.Instance.RequestSongByLevelID(_currentSongInfo.hash, (song) =>
                    {
                        _currentSongCell.SetText($"{song.songName} <size=80%>{song.songSubName}</size>");
                        _currentSongCell.SetSubText(song.songAuthorName + " <size=80%>[" + song.levelAuthorName + "]</size>");
                        StartCoroutine(LoadScripts.LoadSpriteCoroutine(song.coverURL, (cover) => { _currentSongCell.SetIcon(cover); }));
                    }
                                                                 );
                }
                else
                {
                    _currentSongCell.SetText($"{level.songName} <size=80%>{level.songSubName}</size>");
                    _currentSongCell.SetSubText(level.songAuthorName + " <size=80%>[" + level.levelAuthorName + "]</size>");

                    level.GetCoverImageTexture2DAsync(new CancellationTokenSource().Token).ContinueWith((tex) =>
                    {
                        if (!tex.IsFaulted)
                        {
                            _currentSongCell.SetIcon(tex.Result);
                        }
                    }).ConfigureAwait(false);
                }
            }
        }
Exemplo n.º 9
0
        public override TableCell CellForIdx(int row)
        {
            LevelListTableCell _tableCell = GetTableCell(false);

            _tableCell.reuseIdentifier = "MoreSongsTableCell";
            _tableCell.GetPrivateField <TextMeshProUGUI>("_songNameText").text = string.Format("{0} <size=80%>{1}</size>", songsList[row].songName, songsList[row].songSubName);
            _tableCell.GetPrivateField <TextMeshProUGUI>("_authorText").text   = songsList[row].songAuthorName + " <size=80%>[" + songsList[row].levelAuthorName + "]</size>";
            _tableCell.SetPrivateField("_beatmapCharacteristicAlphas", new float[0]);
            _tableCell.SetPrivateField("_beatmapCharacteristicImages", new UnityEngine.UI.Image[0]);
            _tableCell.SetPrivateField("_bought", true);

            StartCoroutine(LoadScripts.LoadSpriteCoroutine(songsList[row].coverURL, (cover) => { _tableCell.GetPrivateField <UnityEngine.UI.RawImage>("_coverRawImage").texture = cover.texture; }));
            bool alreadyDownloaded = SongDownloader.Instance.IsSongDownloaded(songsList[row]);

            if (alreadyDownloaded)
            {
                foreach (UnityEngine.UI.Image img in _tableCell.GetComponentsInChildren <UnityEngine.UI.Image>())
                {
                    img.color = new Color(1f, 1f, 1f, 0.2f);
                }
                foreach (TextMeshProUGUI text in _tableCell.GetComponentsInChildren <TextMeshProUGUI>())
                {
                    text.faceColor = new Color(1f, 1f, 1f, 0.2f);
                }
            }

            return(_tableCell);
        }
Exemplo n.º 10
0
        public void SetSelectedSong(SongInfo info)
        {
            SetLoadingState(false);

            _selectedSong = null;

            _selectedSongCell.SetText(info.songName);
            _selectedSongCell.SetSubText("Loading info...");

            _playButton.SetButtonText("PLAY");
            _playBtnGlow.color = new Color(0f, 0.7058824f, 1f, 0.7843137f);

            SongDownloader.Instance.RequestSongByLevelID(info.hash, (song) =>
            {
                _selectedSongCell.SetText($"{song.songName} <size=80%>{song.songSubName}</size>");
                _selectedSongCell.SetSubText(song.songAuthorName + " <size=80%>[" + song.levelAuthorName + "]</size>");
                StartCoroutine(LoadScripts.LoadSpriteCoroutine(song.coverURL, (cover) => { _selectedSongCell.SetIcon(cover); }));
            });

            _timeParamText.transform.parent.gameObject.SetActive(false);
            _bpmParamText.transform.parent.gameObject.SetActive(false);
            _blocksParamText.transform.parent.gameObject.SetActive(false);
            _obstaclesParamText.transform.parent.gameObject.SetActive(false);
            _starsParamText.transform.parent.gameObject.SetActive(false);
            _ratingParamText.transform.parent.gameObject.SetActive(false);

            _rankedText.gameObject.SetActive(false);

            _characteristicControl.SetTexts(new string[] { "None" });
            _characteristicControl.SelectCellWithNumber(0);
            _difficultyControl.SetTexts(new string[] { "None" });
            _difficultyControl.SelectCellWithNumber(0);
        }
        public void SetSelectedSong(SongInfo info)
        {
            _selectedSong = SongLoader.CustomLevelCollectionSO.levels.FirstOrDefault(x => x.levelID.StartsWith(info.levelId));

            if (_selectedSong != null)
            {
                _selectedDifficulty = _selectedSong.difficultyBeatmaps.OrderByDescending(x => x.difficulty).First().difficulty;

                _selectedSongCell.songName   = _selectedSong.songName + "\n<size=80%>" + _selectedSong.songSubName + "</size>";
                _selectedSongCell.author     = _selectedSong.songAuthorName;
                _selectedSongCell.coverImage = _selectedSong.coverImage;
            }
            else
            {
                _selectedSongCell.songName = info.songName;
                _selectedSongCell.author   = "Loading info...";
                SongDownloader.Instance.RequestSongByLevelID(info.levelId, (song) =>
                {
                    _selectedSongCell.songName = $"{song.songName}\n<size=80%>{song.songSubName}</size>";
                    _selectedSongCell.author   = song.authorName;
                    StartCoroutine(LoadScripts.LoadSpriteCoroutine(song.coverUrl, (cover) => { _selectedSongCell.coverImage = cover; }));
                });
            }
            UpdateButtons();
        }
        public void SetSong(SongInfo info)
        {
            if (_songTableCell == null)
            {
                return;
            }

            _selectedSong = SongLoader.CustomLevelCollectionSO.levels.FirstOrDefault(x => x.levelID.StartsWith(info.levelId));

            if (_selectedSong != null)
            {
                _songTableCell.songName   = _selectedSong.songName + "\n<size=80%>" + _selectedSong.songSubName + "</size>";
                _songTableCell.author     = _selectedSong.songAuthorName;
                _songTableCell.coverImage = _selectedSong.coverImage;
            }
            else
            {
                _songTableCell.songName = info.songName;
                _songTableCell.author   = "Loading info...";
                SongDownloader.Instance.RequestSongByLevelID(info.levelId, (song) =>
                {
                    _songTableCell.songName = $"{song.songName}\n<size=80%>{song.songSubName}</size>";
                    _songTableCell.author   = song.authorName;
                    StartCoroutine(LoadScripts.LoadSpriteCoroutine(song.coverUrl, (cover) => { _songTableCell.coverImage = cover; }));
                });
            }
        }
Exemplo n.º 13
0
        public void SetSongInfo(SongInfo songInfo)
        {
            _currentSongInfo = songInfo;

            if (_currentSongCell != null)
            {
                LevelSO level = SongLoader.CustomLevelCollectionSO.levels.FirstOrDefault(x => x.levelID.StartsWith(songInfo.levelId));
                if (level == null)
                {
                    _currentSongCell.songName = _currentSongInfo.songName;
                    _currentSongCell.author   = "Loading info...";
                    SongDownloader.Instance.RequestSongByLevelID(_currentSongInfo.levelId, (song) =>
                    {
                        _currentSongCell.songName = $"{song.songName}\n<size=80%>{song.songSubName}</size>";
                        _currentSongCell.author   = song.authorName;
                        StartCoroutine(LoadScripts.LoadSpriteCoroutine(song.coverUrl, (cover) => { _currentSongCell.coverImage = cover; }));
                    }
                                                                 );
                }
                else
                {
                    _currentSongCell.songName   = $"{level.songName}\n<size=80%>{level.songSubName}</size>";
                    _currentSongCell.author     = level.songAuthorName;
                    _currentSongCell.coverImage = level.coverImage;
                }
            }
        }
Exemplo n.º 14
0
 public void SetImage(string url)
 {
     SharedCoroutineStarter.instance.StartCoroutine(LoadScripts.LoadSpriteCoroutine(url, (profileImage) =>
     {
         image.texture = profileImage;
         image.color   = Color.white;
     }));
 }
Exemplo n.º 15
0
        public TableCell CellForIdx(TableView tableView, int idx)
        {
            LevelListTableCell tableCell = (LevelListTableCell)tableView.DequeueReusableCellForIdentifier(_songsTableView.reuseIdentifier);

            if (!tableCell)
            {
                if (songListTableCellInstance == null)
                {
                    songListTableCellInstance = Resources.FindObjectsOfTypeAll <LevelListTableCell>().First(x => (x.name == "LevelListTableCell"));
                }

                tableCell = Instantiate(songListTableCellInstance);
            }

            var level = _allBeatmaps.FirstOrDefault(x => x.levelID == requestedSongs[idx].levelId);

            if (level != null)
            {
                tableCell.SetDataFromLevelAsync(level, false);
                tableCell.RefreshAvailabilityAsync(_additionalContentModel, level.levelID);
            }
            else
            {
                TextMeshProUGUI songNameText   = LevelListTableCell_SongNameText(ref tableCell);
                TextMeshProUGUI authorNameText = LevelListTableCell_AuthorText(ref tableCell);
                songNameText.text   = string.Format("{0} <size=80%>{1}</size>", requestedSongs[idx].songName, requestedSongs[idx].songSubName);
                authorNameText.text = "Loading info...";

                RawImage coverImage = LevelListTableCell_CoverImage(ref tableCell);
                coverImage.texture = null;
                coverImage.color   = Color.clear;

                LevelListTableCell_BadgeImage(ref tableCell).enabled = false;

                Image[] chars = LevelListTableCell_CharImages(ref tableCell);

                foreach (Image img in chars)
                {
                    img.enabled = false;
                }

                SongDownloader.Instance.RequestSongByLevelID(requestedSongs[idx].hash, (info) =>
                {
                    songNameText.text   = string.Format("{0} <size=80%>{1}</size>", info.songName, info.songSubName);
                    authorNameText.text = info.songAuthorName;

                    StartCoroutine(LoadScripts.LoadSpriteCoroutine(info.coverURL, (cover) =>
                    {
                        coverImage.texture = cover;
                        coverImage.color   = Color.white;
                    }));
                });
            }

            tableCell.reuseIdentifier = _songsTableView.reuseIdentifier;
            return(tableCell);
        }
Exemplo n.º 16
0
        public void SetSong(SongInfo info, Boolean finished)
        {
            if (_songTableCell == null)
            {
                return;
            }

            if (finished)
            {
                var highscore = PluginUI.instance.roomFlowCoordinator.lastHighScore;
                if (highscore == 0)
                {
                    _lastHighscoreText.SetText("No previous highscore");
                }
                else
                {
                    _lastHighscoreText.SetText($"Previous highscore: {highscore}");
                }
                _lastHighscoreText.gameObject.SetActive(true);
            }
            else
            {
                _lastHighscoreText.gameObject.SetActive(false);
            }

            _selectedSong = SongCore.Loader.CustomBeatmapLevelPackCollectionSO.beatmapLevelPacks.SelectMany(x => x.beatmapLevelCollection.beatmapLevels).FirstOrDefault(x => x.levelID.StartsWith(info.levelId));

            if (_selectedSong != null)
            {
                _songTableCell.SetText(_selectedSong.songName + " <size=80%>" + _selectedSong.songSubName + "</size>");
                _songTableCell.SetSubText(_selectedSong.songAuthorName + " <size=80%>[" + _selectedSong.levelAuthorName + "]</size>");

                _selectedSong.GetCoverImageTexture2DAsync(new CancellationTokenSource().Token).ContinueWith((tex) =>
                {
                    if (!tex.IsFaulted)
                    {
                        _songTableCell.SetIcon(tex.Result);
                    }
                }).ConfigureAwait(false);
            }
            else
            {
                _songTableCell.SetText(info.songName);
                _songTableCell.SetSubText("Loading info...");
                SongDownloader.Instance.RequestSongByLevelID(info.hash, (song) =>
                {
                    _songTableCell.SetText($"{song.songName} <size=80%>{song.songSubName}</size>");
                    _songTableCell.SetSubText(song.songAuthorName + " <size=80%>[" + song.levelAuthorName + "]</size>");
                    StartCoroutine(LoadScripts.LoadSpriteCoroutine(song.coverURL, (cover) => { _songTableCell.SetIcon(cover); }));
                });
            }
        }
Exemplo n.º 17
0
        private void MessageReceived(TwitchMessage msg)
        {
            //User Fetch and Cache
            PersistentSingleton <HMMainThreadDispatcher> .instance.Enqueue(GetTwitchViewerInfo(msg));


            //Emote Cache
            if (msg.emotes != "")
            {
                string[] emotes = msg.emotes.Split('/');

                if (!Settings.EmotePopups.Enable)
                {
                    return;
                }

                int count = 0;
                foreach (var emote in emotes)
                {
                    if (count > 3)
                    {
                        break;
                    }

                    string invemote = emote;
                    int    index    = invemote.IndexOf(":");
                    if (index > 0)
                    {
                        invemote = invemote.Substring(0, index);
                    }

                    if (!TwitchEmotePool.ContainsKey(invemote))
                    {
                        SharedCoroutineStarter.instance.StartCoroutine(LoadScripts.LoadSpriteCoroutine($"https://static-cdn.jtvnw.net/emoticons/v1/{invemote}/3.0", (image) =>
                        {
                            if (!TwitchEmotePool.ContainsKey(invemote))
                            {
                                TwitchEmotePool.Add(invemote, image);
                                EmoteProcessed.Invoke(invemote);
                            }
                        }));
                    }
                    else
                    {
                        EmoteProcessed.Invoke(invemote);
                    }
                    count++;
                }
            }
        }
        public TableCell CellForIdx(TableView tableView, int idx)
        {
            LevelListTableCell tableCell = (LevelListTableCell)tableView.DequeueReusableCellForIdentifier(_songsTableView.reuseIdentifier);

            if (!tableCell)
            {
                if (songListTableCellInstance == null)
                {
                    songListTableCellInstance = Resources.FindObjectsOfTypeAll <LevelListTableCell>().First(x => (x.name == "LevelListTableCell"));
                }

                tableCell = Instantiate(songListTableCellInstance);
            }

            var level = _beatmapLevelsModel.allLoadedBeatmapLevelPackCollection.beatmapLevelPacks.SelectMany(x => x.beatmapLevelCollection.beatmapLevels).FirstOrDefault(x => x.levelID == requestedSongs[idx].levelId);

            if (level != null)
            {
                tableCell.SetDataFromLevelAsync(level, false);
                tableCell.RefreshAvailabilityAsync(_additionalContentModel, level.levelID);
            }
            else
            {
                tableCell.GetPrivateField <TextMeshProUGUI>("_songNameText").text = string.Format("{0} <size=80%>{1}</size>", level.songName, level.songSubName);
                tableCell.GetPrivateField <TextMeshProUGUI>("_authorText").text   = level.songAuthorName;

                var coverImage = tableCell.GetPrivateField <RawImage>("_coverRawImage");
                coverImage.texture = null;
                coverImage.color   = Color.clear;

                Image[] chars = tableCell.GetPrivateField <Image[]>("_beatmapCharacteristicImages");

                foreach (var img in chars)
                {
                    img.enabled = false;
                }

                SongDownloader.Instance.RequestSongByLevelID(requestedSongs[idx].hash, (info) =>
                {
                    tableCell.GetPrivateField <TextMeshProUGUI>("_songNameText").text = string.Format("{0} <size=80%>{1}</size>", info.songName, info.songSubName);
                    tableCell.GetPrivateField <TextMeshProUGUI>("_authorText").text   = info.songAuthorName;

                    StartCoroutine(LoadScripts.LoadSpriteCoroutine(info.coverURL, (cover) => { coverImage.texture = cover; }));
                });
            }

            tableCell.reuseIdentifier = _songsTableView.reuseIdentifier;
            return(tableCell);
        }
Exemplo n.º 19
0
        public void SetSelectedSong(SongInfo song)
        {
            Plugin.log.Debug("Downloading song info!");

            controlsRect.gameObject.SetActive(false);
            buttonsRect.gameObject.SetActive(false);
            loadingRect.gameObject.SetActive(true);

            songNameText.text = song.songName;

            durationText.text       = "--";
            bpmText.text            = "--";
            npsText.text            = "--";
            notesCountText.text     = "--";
            obstaclesCountText.text = "--";
            bombsCountText.text     = "--";

            maxComboValue.text  = "--";
            highscoreValue.text = "--";
            maxRankValue.text   = "--";

            rankingValue.text = "--";
            starsText.text    = "--";
            ratingText.text   = "--";

            levelCoverImage.texture = _defaultArtworkTexture;

            SetLoadingState(false);

            SongDownloader.Instance.RequestSongByLevelID(song.hash, (info) =>
            {
                songNameText.text = info.songName;
                durationText.text = info.duration.MinSecDurationText();
                bpmText.text      = info.bpm.ToString();

                long votes      = info.upVotes - info.downVotes;
                ratingText.text = (votes < 0 ? votes.ToString() : $"+{votes}");

                StartCoroutine(LoadScripts.LoadSpriteCoroutine(info.coverURL, (cover) => { levelCoverImage.texture = cover; }));
            });
        }
Exemplo n.º 20
0
        public void SetContent(MoreSongsFlowCoordinator sender, Song newSongInfo)
        {
            _currentSong = newSongInfo;

            songNameText.text = _currentSong.songName;

            downloadsText.text          = _currentSong.downloads;
            _levelParams.bpm            = float.Parse(_currentSong.plays);
            _levelParams.notesCount     = int.Parse(_currentSong.beatsPerMinute);
            _levelParams.obstaclesCount = int.Parse(_currentSong.upvotes);
            _levelParams.bombsCount     = int.Parse(_currentSong.downvotes);

            difficulty1Text.text = (_currentSong.difficultyLevels.Where(x => (x.difficulty == "Expert" || x.difficulty == "ExpertPlus")).Count() > 0) ? "Yes" : "No";
            difficulty2Text.text = (_currentSong.difficultyLevels.Where(x => x.difficulty == "Hard").Count() > 0) ? "Yes" : "No";
            difficulty3Text.text = (_currentSong.difficultyLevels.Where(x => (x.difficulty == "Easy" || x.difficulty == "Normal")).Count() > 0) ? "Yes" : "No";

            StartCoroutine(LoadScripts.LoadSpriteCoroutine(_currentSong.coverUrl, (cover) => { coverImage.sprite = cover; }));

            SetFavoriteState(PluginConfig.favoriteSongs.Any(x => x.Contains(_currentSong.hash)));
            SetDownloadState((SongDownloader.Instance.IsSongDownloaded(_currentSong) ? DownloadState.Downloaded : (sender.IsDownloadingSong(_currentSong) ? DownloadState.Downloading : DownloadState.NotDownloaded)));
        }
Exemplo n.º 21
0
        public void SetSong(SongInfo info)
        {
            selectedLevel = null;

            songNameText.text = info.songName;

            levelCoverImage.texture = _defaultArtworkTexture;

            difficultyControlRect.gameObject.SetActive(false);
            playNowButton.SetButtonText("DOWNLOAD");
            playNowButtonGlow.SetGlow("#5DADE2");

            SongDownloader.Instance.RequestSongByLevelID(info.hash, (song) =>
            {
                songNameText.text = info.songName;

                StartCoroutine(LoadScripts.LoadSpriteCoroutine(song.coverURL, (cover) => { levelCoverImage.texture = cover; }));
            });

            SetProgressBarState(false, 0f);
        }
Exemplo n.º 22
0
        public void CreateImage()
        {
            _image          = new GameObject("CustomUIImage").AddComponent <Image>();
            _image.material = Sprites.NoGlowMat;
            _image.rectTransform.SetParent(pauseCanvas, false);
            _image.rectTransform.anchorMin        = new Vector2(0.5f, 0.5f);
            _image.rectTransform.anchorMax        = new Vector2(0.5f, 0.5f);
            _image.rectTransform.anchoredPosition = new Vector2(0f, 4.5f);
            _image.rectTransform.sizeDelta        = new Vector2(16f, 16f);
            _image.rectTransform.localPosition    = new Vector2(-30f, -5f);
            _image.sprite = UIUtilities.BlankSprite;

            SharedCoroutineStarter.instance.StartCoroutine(LoadScripts.LoadSpriteCoroutine("https://auros.red/persistantfiles/sadtracking1.png", (image) =>
            {
                _image.sprite = image;
                Log.Info("Image Created");
            }
                                                                                           ));

            _image2          = new GameObject("CustomUIImage").AddComponent <Image>();
            _image2.material = Sprites.NoGlowMat;
            _image2.rectTransform.SetParent(pauseCanvas, false);
            _image2.rectTransform.anchorMin        = new Vector2(0.5f, 0.5f);
            _image2.rectTransform.anchorMax        = new Vector2(0.5f, 0.5f);
            _image2.rectTransform.anchoredPosition = new Vector2(0f, 4.5f);
            _image2.rectTransform.sizeDelta        = new Vector2(16f, 16f);
            _image2.rectTransform.localPosition    = new Vector2(30f, -5f);
            _image2.sprite = UIUtilities.BlankSprite;

            SharedCoroutineStarter.instance.StartCoroutine(LoadScripts.LoadSpriteCoroutine("https://auros.red/persistantfiles/sadtracking2.png", (image) =>
            {
                _image2.sprite = image;
                Log.Info("Image Created");
            }
                                                                                           ));

            _image.enabled  = false;
            _image2.enabled = false;
        }
Exemplo n.º 23
0
        public IEnumerator GetBTTVGlobalEmotes()
        {
            UnityWebRequest www = UnityWebRequest.Get($"https://api.betterttv.net/2/emotes");

            yield return(www.SendWebRequest());

            if (www.isNetworkError || www.isHttpError)
            {
            }
            else
            {
                JSONNode json = JSON.Parse(www.downloadHandler.text);
                if (json["status"].AsInt == 200)
                {
                    JSONArray emotes = json["emotes"].AsArray;
                    foreach (JSONObject o in emotes)
                    {
                        if (o["imageType"] != "gif")
                        {
                            var id = (string)o["id"];
                            SharedCoroutineStarter.instance.StartCoroutine(LoadScripts.LoadSpriteCoroutine($"https://cdn.betterttv.net/emote/{id}/3x", (image) =>
                            {
                                BTTVEmotePool.Add(o["code"], image);
                            }));
                        }
                        else
                        {
                            var id  = (string)o["id"];
                            var gif = new GameObject().AddComponent <GIFer>();
                            gif.Create($"https://cdn.betterttv.net/emote/{id}/3x");
                            DontDestroyOnLoad(gif); //Im sorry
                            BTTVAnimatedEmotePool.Add(o["code"], gif);
                        }
                    }
                }
            }
        }
        public void SetSong(SongInfo info)
        {
            selectedLevel = _beatmapLevelsModel.allLoadedBeatmapLevelPackCollection.beatmapLevelPacks.SelectMany(x => x.beatmapLevelCollection.beatmapLevels).FirstOrDefault(x => x.levelID.StartsWith(info.levelId));

            if (selectedLevel != null)
            {
                SetContent(selectedLevel);
            }
            else
            {
                songNameText.text = info.songName;

                levelCoverImage.texture = _defaultArtworkTexture;

                diffValue.text         = "--";
                goodCutsValue.text     = "--";
                maxComboValue.text     = "";
                scoreValue.text        = "--";
                rankValue.text         = "--";
                scoreChangeValue.text  = "--";
                scoreChangeValue.color = Color.white;
                scoreChangeIcon.gameObject.SetActive(false);

                SongDownloader.Instance.RequestSongByLevelID(info.hash, (song) =>
                {
                    songNameText.text = info.songName;

                    StartCoroutine(LoadScripts.LoadSpriteCoroutine(song.coverURL, (cover) => { levelCoverImage.texture = cover; }));
                });

                if (PluginManager.GetPluginFromId("BeatSaverVoting") != null)
                {
                    BeatSaverVotingInterop.Hide();
                }
            }
        }
Exemplo n.º 25
0
        public void SetContent(MoreSongsFlowCoordinator sender, Song newSongInfo)
        {
            selectedCharacteristic = null;
            currentDifficulties    = null;
            _currentSong           = newSongInfo;

            songNameText.text = _currentSong.songName;
            if (_characteristicSegmentedDisplay == null)
            {
                _characteristicSegmentedDisplay = BeatSaberUI.CreateIconSegmentedControl(rectTransform, new Vector2(-40, .2f), new Vector2(70, 9f),
                                                                                         delegate(int value) { SelectedCharacteristic(_currentSong.metadata.characteristics[value]); });
                SetupCharacteristicDisplay(_characteristicSegmentedDisplay, _currentSong);
            }
            else
            {
                SetupCharacteristicDisplay(_characteristicSegmentedDisplay, _currentSong);
            }



            if (_difficultySegmentedDisplay == null)
            {
                _difficultySegmentedDisplay = BeatSaberUI.CreateTextSegmentedControl(rectTransform, new Vector2(-40, -9f), new Vector2(85, 8f),
                                                                                     delegate(int value) { SelectedDifficulty(currentDifficulties[value]); });
                _difficultySegmentedDisplay.transform.localScale = new Vector3(.8f,
                                                                               _difficultySegmentedDisplay.transform.localScale.y, _difficultySegmentedDisplay.transform.localScale.z);
                SetupDifficultyDisplay(_difficultySegmentedDisplay, _currentSong);
            }
            else
            {
                SetupDifficultyDisplay(_difficultySegmentedDisplay, _currentSong);
            }

            downloadsText.text          = _currentSong.downloads.ToString();
            _levelParams.bpm            = (float)(_currentSong.plays);
            _levelParams.notesCount     = (int)_currentSong.bpm;
            _levelParams.obstaclesCount = _currentSong.upVotes;
            _levelParams.bombsCount     = _currentSong.downVotes;

            Polyglot.LocalizedTextMeshProUGUI localizer1 = difficulty1Title.GetComponentInChildren <Polyglot.LocalizedTextMeshProUGUI>();
            if (localizer1 != null)
            {
                GameObject.Destroy(localizer1);
            }
            Polyglot.LocalizedTextMeshProUGUI localizer2 = difficulty2Title.GetComponentInChildren <Polyglot.LocalizedTextMeshProUGUI>();
            if (localizer2 != null)
            {
                GameObject.Destroy(localizer2);
            }
            Polyglot.LocalizedTextMeshProUGUI localizer3 = difficulty3Title.GetComponentInChildren <Polyglot.LocalizedTextMeshProUGUI>();
            if (localizer3 != null)
            {
                GameObject.Destroy(localizer3);
            }
            difficulty1Title.text = "";
            difficulty2Title.text = "";
            difficulty3Title.text = "";
            difficulty1Text.text  = "";
            difficulty2Text.text  = "";
            difficulty3Text.text  = "";



            //       difficulty1Text.text = (_currentSong.metadata.difficulties.expert || _currentSong.metadata.difficulties.expertPlus) ? "Yes" : "No";
            //       difficulty2Text.text = (_currentSong.metadata.difficulties.hard) ? "Yes" : "No";
            //       difficulty3Text.text = (_currentSong.metadata.difficulties.easy || _currentSong.metadata.difficulties.normal) ? "Yes" : "No";

            StartCoroutine(LoadScripts.LoadSpriteCoroutine(_currentSong.coverURL, (cover) => { coverImage.texture = cover.texture; }));

            SetFavoriteState(PluginConfig.favoriteSongs.Any(x => x.Contains(_currentSong.hash)));
            SetDownloadState((SongDownloader.Instance.IsSongDownloaded(_currentSong) ? DownloadState.Downloaded : (sender.IsDownloadingSong(_currentSong) ? DownloadState.Downloading : DownloadState.NotDownloaded)));
            SetLoadingState(false);


            SelectedCharacteristic(_currentSong.metadata.characteristics[0]);
        }
Exemplo n.º 26
0
        private IEnumerator GetTwitchViewerInfo(TwitchMessage msg)
        {
            yield return(new WaitForSecondsRealtime(.025f));

            using (UnityWebRequest www = UnityWebRequest.Get($"https://api.twitch.tv/helix/users?login={msg.user.displayName}"))
            {
                www.SetRequestHeader("Client-ID", "gbrndadd5hgnm9inrdsw8xpx5w9xa9");
                yield return(www.SendWebRequest());

                JSONNode response = JSON.Parse(www.downloadHandler.text);
                if (response["data"].AsArray.Count > 0)
                {
                    var userdata = response["data"][0];
                    var profile  = (string)userdata["profile_image_url"];
                    var type     = (string)userdata["type"];
                    var btype    = (string)userdata["broadcaster_type"];

                    bool userCached = Viewers.TryGetValue(msg.user.displayName, out Viewer vi);

                    if (!userCached)
                    {
                        Viewer newViewer = new Viewer
                        {
                            Name = msg.user.displayName,
                            ID   = msg.user.id,
                        };

                        Logger.log.Info("Color: " + msg.user.color);
                        if (msg.user.color != "")
                        {
                            newViewer.Color = msg.user.color;
                        }
                        else
                        {
                            newViewer.Color = "#ffffff";
                        }

                        if (type == "")
                        {
                            if (btype == "partner")
                            {
                                newViewer.Type = Type.Partner;
                            }
                            else if (btype == "affiliate")
                            {
                                newViewer.Type = Type.Affiliate;
                            }
                            else
                            {
                                newViewer.Type = Type.None;
                            }
                        }
                        else if (type == "staff")
                        {
                            newViewer.Type = Type.Staff;
                        }
                        else if (type == "admin")
                        {
                            newViewer.Type = Type.Admin;
                        }
                        else
                        {
                            newViewer.Type = Type.None;
                        }

                        if (msg.user.id == "152734662")
                        {
                            newViewer.Role = Role.Other;
                        }
                        else if (msg.user.isBroadcaster)
                        {
                            newViewer.Role = Role.Broadcaster;
                        }
                        else if (msg.user.isMod)
                        {
                            newViewer.Role = Role.Mod;
                        }
                        else if (msg.user.isVip)
                        {
                            newViewer.Role = Role.Vip;
                        }
                        else if (msg.user.isSub)
                        {
                            newViewer.Role = Role.Sub;
                        }
                        else
                        {
                            newViewer.Role = Role.None;
                        }

                        SharedCoroutineStarter.instance.StartCoroutine(LoadScripts.LoadSpriteCoroutine(profile, (image) => {
                            newViewer.Profile = image.texture;
                            Viewers.TryAdd(msg.user.displayName.ToLower(), newViewer);
                        }));
                    }
                }
            }
        }