示例#1
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);
                }
            }
        }
示例#2
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
                        }));
                    }
                }
            }
        }
        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;
            }
        }
        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();
        }
示例#5
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); }));
                });
            }
        }
 public void SetImage(string url)
 {
     SharedCoroutineStarter.instance.StartCoroutine(LoadScripts.LoadSpriteCoroutine(url, (profileImage) =>
     {
         image.texture = profileImage;
         image.color   = Color.white;
     }));
 }
示例#7
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); }));
                });
            }
        }
示例#8
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++;
                }
            }
        }
示例#9
0
        public TableCell CellForRow(int row)
        {
            LevelListTableCell _tableCell = Instantiate(_videoListTableCellInstance);

            // fix aspect ratio
            (_tableCell.transform.Find("CoverImage") as RectTransform).sizeDelta         = new Vector2(160f / 9f, 10);
            (_tableCell.transform.Find("CoverImage") as RectTransform).anchoredPosition += new Vector2(160f / 9f / 2f, 0f);
            (_tableCell.transform.Find("CoverImage") as RectTransform).GetComponent <UnityEngine.UI.Image>().preserveAspect = false;

            (_tableCell.transform.Find("SongName") as RectTransform).anchoredPosition += new Vector2(160f / 9f, 0f);
            (_tableCell.transform.Find("Author") as RectTransform).anchoredPosition   += new Vector2(160f / 9f, 0f);

            _tableCell.reuseIdentifier = "VideosTableCell";
            _tableCell.songName        = string.Format("{0}\n<size=80%>{1}</size>", resultsList[row].title, resultsList[row].author);
            _tableCell.author          = "[" + resultsList[row].duration + "]" + resultsList[row].description;
            StartCoroutine(LoadScripts.LoadSprite(resultsList[row].thumbnailURL, _tableCell));

            return(_tableCell);
        }
示例#10
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; }));
            });
        }
示例#11
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);
        }
示例#12
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;
        }
示例#13
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);
                        }
                    }
                }
            }
        }