示例#1
0
        public void Init(Song _song)
        {
            LevelListTableCell cell = GetComponent <LevelListTableCell>();

            foreach (FieldInfo info in cell.GetType().GetFields(BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic))
            {
                info.SetValue(this, info.GetValue(cell));
            }

            Destroy(cell);

            reuseIdentifier = "DownloadCell";

            song = _song;

            songName = string.Format("{0}\n<size=80%>{1}</size>", song.songName, song.songSubName);
            author   = song.authorName;
            StartCoroutine(LoadScripts.LoadSprite(song.coverUrl, this));

            _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;
            }
        }
示例#2
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);
        }
        public override TableCell CellForIdx(TableView tableView, int row)
        {
            LevelListTableCell _tableCell  = GetTableCell(false);
            RawImage           coverImage  = _tableCell.GetPrivateField <RawImage>("_coverRawImage");
            TextMeshProUGUI    songName    = _tableCell.GetPrivateField <TextMeshProUGUI>("_songNameText");
            TextMeshProUGUI    description = _tableCell.GetPrivateField <TextMeshProUGUI>("_authorText");

            coverImage.rectTransform.sizeDelta          = new Vector2(160f / 9f, coverImage.rectTransform.sizeDelta.y);
            songName.rectTransform.anchoredPosition    += new Vector2(160f / 9f, 0f);
            description.rectTransform.anchoredPosition += new Vector2(160f / 9f, 0f);

            songName.text     = string.Format("{0}\n<size=80%>{1}</size>", resultsList[row].title, resultsList[row].author);
            songName.color    = Color.white;
            description.text  = "[" + resultsList[row].duration + "]" + resultsList[row].description;
            description.color = Color.white;

            StartCoroutine(LoadScripts.LoadSprite(resultsList[row].thumbnailURL, coverImage.GetComponent <UnityEngine.UI.RawImage>(), 16f / 9f));
            _tableCell.reuseIdentifier = "VideosTableCell";

            return(_tableCell);
        }
示例#4
0
        public override TableCell CellForIdx(int row)
        {
            LevelListTableCell _tableCell = GetTableCell(false);

            // fix aspect ratios
            (_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 = true;

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

            // Fill in data
            _tableCell.GetPrivateField <TextMeshProUGUI>("_songNameText").text  = string.Format("{0}\n<size=80%>{1}</size>", resultsList[row].title, resultsList[row].author);
            _tableCell.GetPrivateField <TextMeshProUGUI>("_songNameText").color = Color.white;
            _tableCell.GetPrivateField <TextMeshProUGUI>("_authorText").text    = "[" + resultsList[row].duration + "]" + resultsList[row].description;
            _tableCell.GetPrivateField <TextMeshProUGUI>("_authorText").color   = Color.white;
            StartCoroutine(LoadScripts.LoadSprite(resultsList[row].thumbnailURL, _tableCell.transform.Find("CoverImage").GetComponent <UnityEngine.UI.Image>(), 16f / 9f));
            _tableCell.reuseIdentifier = "VideosTableCell";

            return(_tableCell);
        }
示例#5
0
        public TableCell CellForRow(int row)
        {
            LevelListTableCell _tableCell = Instantiate(_songListTableCellInstance);

            _tableCell.reuseIdentifier = "MoreSongsTableCell";
            _tableCell.songName        = string.Format("{0}\n<size=80%>{1}</size>", songsList[row].songName, songsList[row].songSubName);
            _tableCell.author          = songsList[row].authorName;
            StartCoroutine(LoadScripts.LoadSprite(songsList[row].coverUrl, _tableCell));
            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);
        }
示例#6
0
        public void UpdateContent()
        {
            if (selectedVideo == null)
            {
                _title.SetText("<No Video Selected>");
                _description.SetText("Click Search to choose a video to download.");
                _uploader.SetText("");
                _duration.SetText("");

                _thumbnail.sprite = null;
                _thumbnail.color  = Color.black;

                _progressCircle.gameObject.SetActive(true);
                _progressCircle.color      = Color.white;
                _progressCircle.fillAmount = 1;

                _progressText.gameObject.SetActive(true);
                _progressText.text = "N/A";
                _hoverHint.text    = "No video selected\nDownload a video";

                _addOffset.interactable            = false;
                _subOffset.interactable            = false;
                _previewButton.interactable        = false;
                _loopButton.interactable           = false;
                _downloadDeleteButton.interactable = false;
                _downloadDeleteButton.SetButtonText("Download");
                return;
            }

            _title.SetText(selectedVideo.title);
            _description.SetText(selectedVideo.description);
            _uploader.SetText(selectedVideo.author);
            _duration.SetText($"[{selectedVideo.duration}]");
            SetOffsetText(selectedVideo.offset.ToString());
            _loopButton.SetButtonText(selectedVideo.loop ? "Loop" : "Once");
            StartCoroutine(LoadScripts.LoadSprite(selectedVideo.thumbnailURL, _thumbnail, 16f / 9f));

            if (selectedVideo.downloadState == DownloadState.NotDownloaded)
            {
                _progressText.gameObject.SetActive(false);
                _progressCircle.gameObject.SetActive(false);

                _thumbnail.color = Color.white.ColorWithAlpha(0.2f);
                _hoverHint.text  = "Video selected but not downloaded";

                _addOffset.interactable            = false;
                _subOffset.interactable            = false;
                _previewButton.interactable        = false;
                _loopButton.interactable           = false;
                _downloadDeleteButton.interactable = true;
                _downloadDeleteButton.SetButtonText("Download");
            }

            else if (selectedVideo.downloadState == DownloadState.Cancelled)
            {
                _progressText.gameObject.SetActive(false);
                _progressCircle.gameObject.SetActive(false);

                _thumbnail.color = Color.white.ColorWithAlpha(0.2f);
                _hoverHint.text  = "Download cancelled or encountered an error";

                _addOffset.interactable            = false;
                _subOffset.interactable            = false;
                _previewButton.interactable        = false;
                _loopButton.interactable           = false;
                _downloadDeleteButton.interactable = true;
                _downloadDeleteButton.SetButtonText("Download");
            }

            else if (selectedVideo.downloadState == DownloadState.Downloading)
            {
                _progressText.gameObject.SetActive(true);
                _progressCircle.gameObject.SetActive(true);
                _progressText.text         = String.Format("{0:#.0}%", selectedVideo.downloadProgress * 100);
                _progressCircle.color      = Color.white;
                _progressCircle.fillAmount = selectedVideo.downloadProgress;

                _hoverHint.text  = String.Format("Downloading: {0:#.0}% complete", selectedVideo.downloadProgress * 100);
                _thumbnail.color = Color.Lerp(Color.white.ColorWithAlpha(0.2f), Color.white, selectedVideo.downloadProgress);

                _hoverHint.text = "Download in progress";

                _addOffset.interactable            = false;
                _subOffset.interactable            = false;
                _previewButton.interactable        = false;
                _loopButton.interactable           = false;
                _downloadDeleteButton.interactable = true;
                _downloadDeleteButton.SetButtonText("Cancel");
            }

            else if (selectedVideo.downloadState == DownloadState.Downloaded)
            {
                _progressText.gameObject.SetActive(false);
                _progressCircle.gameObject.SetActive(false);

                _thumbnail.color = Color.white;
                _hoverHint.text  = "Video Ready, Search again to overwrite";

                _addOffset.interactable            = true;
                _subOffset.interactable            = true;
                _previewButton.interactable        = true;
                _loopButton.interactable           = true;
                _downloadDeleteButton.interactable = true;
                _downloadDeleteButton.SetButtonText("Delete");
            }

            else if (selectedVideo.downloadState == DownloadState.Queued)
            {
                _progressText.gameObject.SetActive(true);
                _progressText.text = "Pending";
                _progressCircle.gameObject.SetActive(true);
                _progressCircle.color      = Color.cyan;
                _progressCircle.fillAmount = 1;

                _thumbnail.color = Color.white.ColorWithAlpha(0.2f);
                _hoverHint.text  = "Download queued and will begin shortly";

                _addOffset.interactable            = false;
                _subOffset.interactable            = false;
                _previewButton.interactable        = false;
                _loopButton.interactable           = false;
                _downloadDeleteButton.interactable = true;
                _downloadDeleteButton.SetButtonText("Cancel");
            }
        }
示例#7
0
        public void UpdateContent()
        {
            if (selectedVideo == null)
            {
                _title.SetText("<No Video Selected>");
                _description.SetText("Click Search to choose a video to download.");
                _uploader.SetText("");
                _duration.SetText("");

                _thumbnail.color = Color.black;

                _progressButton.gameObject.SetActive(true);
                _progressButton.SetButtonText("N/A");
                _hoverHint.text = "No video selected\nDownload a video";

                _addOffset.interactable     = false;
                _subOffset.interactable     = false;
                _previewButton.interactable = false;
                _loopButton.interactable    = false;
                return;
            }

            _title.SetText(selectedVideo.title);
            _description.SetText(selectedVideo.description);
            _uploader.SetText(selectedVideo.author);
            _duration.SetText($"[{selectedVideo.duration}]");
            SetOffsetText(selectedVideo.offset.ToString());
            _loopButton.SetButtonText(selectedVideo.loop ? "Loop" : "Once");
            StartCoroutine(LoadScripts.LoadSprite(selectedVideo.thumbnailURL, _thumbnail, 16f / 9f));

            if (selectedVideo.downloadState == DownloadState.Downloading)
            {
                _progressButton.gameObject.SetActive(true);
                SetProgress(selectedVideo.downloadProgress);

                _hoverHint.text = "Download in progress";

                _addOffset.interactable     = false;
                _subOffset.interactable     = false;
                _previewButton.interactable = false;
                _loopButton.interactable    = false;
            }

            if (selectedVideo.downloadState == DownloadState.Downloaded)
            {
                _progressButton.gameObject.SetActive(false);

                _thumbnail.color = Color.white;

                _hoverHint.text = "Video Ready, Search again to overwrite";

                _addOffset.interactable     = true;
                _subOffset.interactable     = true;
                _previewButton.interactable = true;
                _loopButton.interactable    = true;
            }

            if (selectedVideo.downloadState == DownloadState.Queued)
            {
                _progressButton.gameObject.SetActive(true);
                _progressButton.SetButtonText("Pending");
                _progressCircle.color      = Color.cyan;
                _progressCircle.fillAmount = 1;

                _thumbnail.color = Color.white.ColorWithAlpha(0.2f);
                _hoverHint.text  = "Download queued and will begin shortly";

                _addOffset.interactable     = false;
                _subOffset.interactable     = false;
                _previewButton.interactable = false;
                _loopButton.interactable    = false;
            }
        }