Example #1
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);
        }
Example #2
0
        public TableCell CellForIdx(int row)
        {
            LevelListTableCell _tableCell = Instantiate(_songListTableCellInstance);

            _tableCell.reuseIdentifier = "PlaylistTableCell";
            _tableCell.GetPrivateField <TextMeshProUGUI>("_songNameText").text      = playlistList[row].playlistTitle;
            _tableCell.GetPrivateField <TextMeshProUGUI>("_authorText").text        = playlistList[row].playlistAuthor;
            _tableCell.GetPrivateField <UnityEngine.UI.Image>("_coverImage").sprite = playlistList[row].icon;

            _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);
            }

            if (highlightDownloadedPlaylists)
            {
                if (PlaylistsCollection.loadedPlaylists.Any(x => x.PlaylistEqual(playlistList[row])))
                {
                    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);
        }
        public TableCell CellForIdx(TableView tableView, int idx)
        {
            LevelListTableCell tableCell = avatarList.tableView.DequeueReusableCellForIdentifier(kTableCellReuseIdentifier) as LevelListTableCell;

            if (!tableCell)
            {
                tableCell = Instantiate(_tableCellTemplate);

                foreach (var image in tableCell.GetPrivateField <LevelListTableCell, UnityEngine.UI.Image[]>("_beatmapCharacteristicImages"))
                {
                    DestroyImmediate(image);
                }

                tableCell.SetPrivateField("_beatmapCharacteristicImages", new UnityEngine.UI.Image[0]);
                tableCell.GetPrivateField <LevelListTableCell, RawImage>("_favoritesBadgeImage").enabled = false;

                tableCell.reuseIdentifier = kTableCellReuseIdentifier;
            }

            AvatarListItem avatar = _avatars[idx];

            tableCell.GetPrivateField <LevelListTableCell, TextMeshProUGUI>("_songNameText").text = avatar.name;
            tableCell.GetPrivateField <LevelListTableCell, TextMeshProUGUI>("_authorText").text   = avatar.author;
            tableCell.GetPrivateField <LevelListTableCell, RawImage>("_coverRawImage").texture    = avatar.icon ?? _blankAvatarIcon;

            return(tableCell);
        }
        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);
        }
Example #5
0
        public override TableCell CellForIdx(int row)
        {
            LevelListTableCell cell         = Instantiate(cellInstance);
            var beatmapCharacteristicImages = cell.GetPrivateField <UnityEngine.UI.Image[]>("_beatmapCharacteristicImages");

            foreach (UnityEngine.UI.Image i in beatmapCharacteristicImages)
            {
                i.enabled = false;
            }
            cell.SetPrivateField("_beatmapCharacteristicAlphas", new float[0]);
            cell.SetPrivateField("_beatmapCharacteristicImages", new UnityEngine.UI.Image[0]);
            TextMeshProUGUI songName = cell.GetPrivateField <TextMeshProUGUI>("_songNameText");
            TextMeshProUGUI author   = cell.GetPrivateField <TextMeshProUGUI>("_authorText");

            author.overflowMode = TextOverflowModes.Overflow;
            RawImage image = cell.GetPrivateField <RawImage>("_coverRawImage");

            if (row == 0)
            {
                songName.text = "Main Settings";
                author.text   = "Configure basic Counters+ settings.";
                image.texture = Images.Images.LoadTexture("MainSettings");
            }
            else if (row == NumberOfCells() - 2)
            {
                songName.text = "Credits";
                author.text   = "View credits for Counters+.";
                image.texture = Images.Images.LoadTexture("Credits");
            }
            else if (row == NumberOfCells() - 1)
            {
                songName.text = "Contributors";
                author.text   = "See who helped with Counters+!";
                image.texture = Images.Images.LoadTexture("Contributors");
            }
            else
            {
                SettingsInfo info = counterInfos[row - 1];
                songName.text = info.Name;
                author.text   = info.Description;
                try
                {
                    if (info.IsCustom)
                    {
                        image.texture = Images.Images.LoadTexture("Custom");
                    }
                    else
                    {
                        image.texture = Images.Images.LoadTexture(info.Name);
                    }
                }
                catch { image.texture = Images.Images.LoadTexture("Bug"); }
            }
            cell.reuseIdentifier = "CountersPlusSettingCell";
            return(cell);
        }
Example #6
0
        public override TableCell CellForIdx(int idx)
        {
            CustomNote         note       = Plugin.customNotes[idx];
            LevelListTableCell _tableCell = GetTableCell(false);

            _tableCell.GetPrivateField <TextMeshProUGUI>("_songNameText").text             = note.noteDescriptor.NoteName;
            _tableCell.GetPrivateField <TextMeshProUGUI>("_authorText").text               = note.noteDescriptor.AuthorName;
            _tableCell.GetPrivateField <UnityEngine.UI.RawImage>("_coverRawImage").texture = note.noteDescriptor.Icon ?? UnityEngine.Texture2D.blackTexture;
            _tableCell.reuseIdentifier = "CustomNoteListCell";
            return(_tableCell);
        }
        public override TableCell CellForIdx(TableView t, int idx)
        {
            CustomPlatform     platform   = PlatformManager.Instance.GetPlatform(idx);
            LevelListTableCell _tableCell = GetTableCell(false);

            _tableCell.GetPrivateField <TextMeshProUGUI>("_songNameText").text             = platform.platName;
            _tableCell.GetPrivateField <TextMeshProUGUI>("_authorText").text               = platform.platAuthor;
            _tableCell.GetPrivateField <UnityEngine.UI.RawImage>("_coverRawImage").texture = platform.icon != null? platform.icon.texture : UnityEngine.Texture2D.blackTexture;
            _tableCell.reuseIdentifier = "PlatformListCell";
            return(_tableCell);
        }
Example #8
0
        public override TableCell CellForIdx(int idx)
        {
            CustomPlatform platform = PlatformManager.Instance.GetPlatform(idx);

            LevelListTableCell _tableCell = GetTableCell(idx, false);

            _tableCell.GetPrivateField <TextMeshProUGUI>("_songNameText").text      = platform.platName;
            _tableCell.GetPrivateField <TextMeshProUGUI>("_authorText").text        = platform.platAuthor;
            _tableCell.GetPrivateField <UnityEngine.UI.Image>("_coverImage").sprite = platform.icon;
            _tableCell.reuseIdentifier = "PlatformListCell";
            return(_tableCell);
        }
        TableCell TableView.IDataSource.CellForIdx(int row)
        {
            LevelListTableCell tableCell = _tableView.DequeueReusableCellForIdentifier("AvatarListCell") as LevelListTableCell;

            if (tableCell == null)
            {
                tableCell = Instantiate(_tableCellTemplate);

                // remove level type icons
                tableCell.transform.Find("LevelTypeIcon0").gameObject.SetActive(false);
                tableCell.transform.Find("LevelTypeIcon1").gameObject.SetActive(false);
                tableCell.transform.Find("LevelTypeIcon2").gameObject.SetActive(false);

                tableCell.reuseIdentifier = "AvatarListCell";
            }

            var cellInfo = new AvatarCellInfo();

            if (__AvatarLoadResults[row] != AvatarLoadResult.Completed)
            {
                cellInfo.name            = System.IO.Path.GetFileName(AvatarList[row].FullPath) + " failed to load";
                cellInfo.authorName      = "Make sure it's not a duplicate avatar.";
                cellInfo.rawImageTexture = null;
            }
            else
            {
                try
                {
                    cellInfo.name            = __AvatarNames[row];
                    cellInfo.authorName      = __AvatarAuthors[row];
                    cellInfo.rawImageTexture = __AvatarCovers[row] ? __AvatarCovers[row].texture : Texture2D.blackTexture;
                }
                catch (Exception e)
                {
                    cellInfo.name            = "If you see this yell at Assistant";
                    cellInfo.authorName      = "because she f****d up";
                    cellInfo.rawImageTexture = Texture2D.blackTexture;
                    Console.WriteLine(e);
                }
            }

            tableCell.SetPrivateField("_beatmapCharacteristicAlphas", new float[0]);
            tableCell.SetPrivateField("_beatmapCharacteristicImages", new UnityEngine.UI.Image[0]);

            tableCell.GetPrivateField <TextMeshProUGUI>("_songNameText").text             = cellInfo.name;
            tableCell.GetPrivateField <TextMeshProUGUI>("_authorText").text               = cellInfo?.authorName;
            tableCell.GetPrivateField <UnityEngine.UI.RawImage>("_coverRawImage").texture = cellInfo.rawImageTexture;


            return(tableCell);
        }
Example #10
0
        public TableCell CellForIdx(TableView tableView, int idx)
        {
            LevelListTableCell tableCell = _tableView.DequeueReusableCellForIdentifier(kTableCellReuseIdentifier) as LevelListTableCell;

            if (!tableCell)
            {
                tableCell = Instantiate(_tableCellTemplate);

                tableCell.name = "AvatarsTableViewCell";

                tableCell.GetPrivateField <Image>("_backgroundImage").enabled     = false;
                tableCell.GetPrivateField <Image>("_favoritesBadgeImage").enabled = false;

                tableCell.transform.Find("BpmIcon").gameObject.SetActive(false);

                tableCell.GetPrivateField <TextMeshProUGUI>("_songDurationText").enabled = false;
                tableCell.GetPrivateField <TextMeshProUGUI>("_songBpmText").enabled      = false;

                tableCell.reuseIdentifier = kTableCellReuseIdentifier;
            }

            AvatarListItem avatar = _avatars[idx];

            tableCell.GetPrivateField <TextMeshProUGUI>("_songNameText").text   = avatar.name;
            tableCell.GetPrivateField <TextMeshProUGUI>("_songAuthorText").text = avatar.author;

            Texture2D icon = avatar.icon ? avatar.icon : _blankAvatarIcon;

            tableCell.GetPrivateField <Image>("_coverImage").sprite = Sprite.Create(icon, new Rect(0, 0, icon.width, icon.height), Vector2.zero);

            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);
        }
        public TableCell CellForIdx(int row)
        {
            LevelListTableCell _tableCell = _sabersTableView.DequeueReusableCellForIdentifier("LevelListTableCell") as LevelListTableCell;

            if (!_tableCell)
            {
                _tableCell = Instantiate(_songListTableCellInstance);
                _tableCell.reuseIdentifier = "LevelListTableCell";
            }

            _tableCell.SetPrivateField("_beatmapCharacteristicAlphas", new float[0]);
            _tableCell.SetPrivateField("_beatmapCharacteristicImages", new UnityEngine.UI.Image[0]);

            var saber = _sabers.ElementAtOrDefault(row);

            _tableCell.GetPrivateField <TextMeshProUGUI>("_songNameText").text      = saber?.Name;
            _tableCell.GetPrivateField <TextMeshProUGUI>("_authorText").text        = saber?.Author;
            _tableCell.GetPrivateField <UnityEngine.UI.Image>("_coverImage").sprite = Sprite.Create(Texture2D.blackTexture, new Rect(), Vector2.zero);

            return(_tableCell);
        }
        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
            {
                tableCell.GetPrivateField <TextMeshProUGUI>("_songNameText").text = string.Format("{0} <size=80%>{1}</size>", requestedSongs[idx].songName, requestedSongs[idx].songSubName);
                tableCell.GetPrivateField <TextMeshProUGUI>("_authorText").text   = "Loading info...";

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

                tableCell.GetPrivateField <RawImage>("_favoritesBadgeImage").enabled = false;

                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;
                        coverImage.color   = Color.white;
                    }));
                });
            }

            tableCell.reuseIdentifier = _songsTableView.reuseIdentifier;
            return(tableCell);
        }
Example #14
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);
        }
        public TableCell CellForIdx(TableView tableView, int idx)
        {
            // adapted from CustomUI's CustomListViewController
            LevelListTableCell tableCell = (LevelListTableCell)_tableView.DequeueReusableCellForIdentifier(ReuseIdentifier);

            if (tableCell == null)
            {
                tableCell = Instantiate(_tableCellInstance);

                // force text to take up full width (minus cover image)
                var cellText = tableCell.GetPrivateField <TextMeshProUGUI>("_songNameText");
                cellText.rectTransform.sizeDelta        += new Vector2(14f, 0f);
                cellText.rectTransform.anchoredPosition += new Vector2(7f, 0f);
                cellText = tableCell.GetPrivateField <TextMeshProUGUI>("_authorText");
                cellText.rectTransform.sizeDelta        += new Vector2(12f, 0f);
                cellText.rectTransform.anchoredPosition += new Vector2(6f, 0f);

                foreach (UEImage i in tableCell.GetPrivateField <UEImage[]>("_beatmapCharacteristicImages"))
                {
                    i.enabled = false;
                }
                tableCell.SetPrivateField("_beatmapCharacteristicImages", new UEImage[0]);
                tableCell.transform.Find("FavoritesIcon").gameObject.SetActive(false);
                tableCell.reuseIdentifier = ReuseIdentifier;
            }

            IPreviewBeatmapLevel level = _beatmapLevels[idx];

            string contributorsText = "";

            if (!string.IsNullOrEmpty(level.levelAuthorName))
            {
                contributorsText = $"[{level.levelAuthorName}]";
                contributorsText = (string.IsNullOrEmpty(level.songAuthorName) ? "" : " ") + contributorsText;
            }

            tableCell.GetPrivateField <TextMeshProUGUI>("_songNameText").text = $"{level.songName} <size=80%>{level.songSubName}</size>";
            tableCell.GetPrivateField <TextMeshProUGUI>("_authorText").text   = $"{level.songAuthorName}<size=80%>{contributorsText}</size>";
            tableCell.SetPrivateField("_bought", true);

            // black placeholder image
            RawImage coverImage = tableCell.GetPrivateField <RawImage>("_coverRawImage");

            coverImage.texture = Texture2D.blackTexture;
            coverImage.color   = Color.black;

            SetBaseGameCoverImageAsync(tableCell, level);

            return(tableCell);
        }
Example #16
0
        public LevelListTableCell GetTableCell(int row, bool beatmapCharacteristicImages = false)
        {
            LevelListTableCell _tableCell = (LevelListTableCell)_customListTableView.DequeueReusableCellForIdentifier(reuseIdentifier);

            if (!_tableCell)
            {
                _tableCell = Instantiate(_songListTableCellInstance);
            }

            if (!beatmapCharacteristicImages)
            {
                foreach (UnityEngine.UI.Image i in _tableCell.GetPrivateField <UnityEngine.UI.Image[]>("_beatmapCharacteristicImages"))
                {
                    i.enabled = false;
                }
            }
            _tableCell.SetPrivateField("_beatmapCharacteristicAlphas", new float[0]);
            _tableCell.SetPrivateField("_beatmapCharacteristicImages", new UnityEngine.UI.Image[0]);
            _tableCell.reuseIdentifier = reuseIdentifier;
            return(_tableCell);
        }
Example #17
0
 public static void SetText(this LevelListTableCell cell, string text)
 {
     cell.GetPrivateField <TextMeshProUGUI>("_songNameText").text = text;
 }
Example #18
0
        public override TableCell CellForIdx(TableView tablewView, int idx)
        {
            // adapted from CustomUI's CustomListViewController
            LevelListTableCell tableCell = (LevelListTableCell)_customListTableView.DequeueReusableCellForIdentifier(reuseIdentifier);
            TextMeshProUGUI    cellText;
            UEImage            statusImg;

            if (!tableCell)
            {
                tableCell = Instantiate(_songListTableCellInstance);

                // remove unused elements
                Destroy(tableCell.GetPrivateField <RawImage>("_coverRawImage").gameObject);
                Destroy(tableCell.GetPrivateField <TextMeshProUGUI>("_authorText").gameObject);

                cellText           = tableCell.GetPrivateField <TextMeshProUGUI>("_songNameText");
                cellText.fontSize  = 5f;
                cellText.alignment = TextAlignmentOptions.Left;
                cellText.rectTransform.anchorMin        = new Vector2(0.15f, 0f);
                cellText.rectTransform.anchorMax        = Vector2.one;
                cellText.rectTransform.pivot            = new Vector2(0.5f, 0.5f);
                cellText.rectTransform.sizeDelta        = Vector2.zero;
                cellText.rectTransform.anchoredPosition = Vector2.zero;

                UEImage bgImg = tableCell.GetComponentsInChildren <UEImage>().First(x => x.name == "BG");
                bgImg.rectTransform.anchorMin        = Vector2.zero;
                bgImg.rectTransform.anchorMax        = Vector2.one;
                bgImg.rectTransform.pivot            = new Vector2(0.5f, 0.5f);
                bgImg.rectTransform.anchoredPosition = Vector2.zero;
                bgImg.rectTransform.sizeDelta        = Vector2.zero;
                UEImage highlightImg = tableCell.GetComponentsInChildren <UEImage>().First(x => x.name == "Highlight");
                highlightImg.rectTransform.anchorMin        = Vector2.zero;
                highlightImg.rectTransform.anchorMax        = Vector2.one;
                highlightImg.rectTransform.pivot            = new Vector2(0.5f, 0.5f);
                highlightImg.rectTransform.anchoredPosition = Vector2.zero;
                highlightImg.rectTransform.sizeDelta        = Vector2.zero;

                statusImg = new GameObject("StatusImage").AddComponent <UEImage>();
                statusImg.transform.SetParent(tableCell.transform, false);
                statusImg.rectTransform.anchorMin        = Vector2.zero;
                statusImg.rectTransform.anchorMax        = new Vector2(0.03f, 1f);
                statusImg.rectTransform.pivot            = new Vector2(0.5f, 0.5f);
                statusImg.rectTransform.sizeDelta        = new Vector2(0.5f, 0.5f);
                statusImg.rectTransform.anchoredPosition = Vector2.zero;
                statusImg.sprite   = Sprite.Create(Texture2D.whiteTexture, new Rect(0f, 0f, 1f, 1f), Vector2.zero);
                statusImg.color    = DefaultFilterColor;
                statusImg.material = Utilities.NoGlowMaterial;

                foreach (UEImage i in tableCell.GetPrivateField <UEImage[]>("_beatmapCharacteristicImages"))
                {
                    i.enabled = false;
                }
                tableCell.SetPrivateField("_beatmapCharacteristicAlphas", new float[0]);
                tableCell.SetPrivateField("_beatmapCharacteristicImages", new UEImage[0]);
                tableCell.reuseIdentifier = reuseIdentifier;
            }

            IFilter filter = FilterList[idx];

            cellText  = tableCell.GetPrivateField <TextMeshProUGUI>("_songNameText");
            statusImg = tableCell.GetComponentsInChildren <UEImage>().First(x => x.name == "StatusImage");

            if (filter.IsAvailable)
            {
                cellText.text = filter.FilterName;
            }
            else
            {
                cellText.text = $"<color=#FF8888><i>{filter.FilterName}</i></color>";
            }

            if (filter.Status == FilterStatus.NotAppliedAndDefault)
            {
                statusImg.color = DefaultFilterColor;
            }
            else if (filter.Status == FilterStatus.NotAppliedAndChanged)
            {
                statusImg.color = PendingFilterColor;
            }
            else if (filter.Status == FilterStatus.AppliedAndChanged)
            {
                statusImg.color = AppliedPendingFilterColor;
            }
            else
            {
                statusImg.color = AppliedFilterColor;
            }

            return(tableCell);
        }
Example #19
0
 public static void SetSubText(this LevelListTableCell cell, string subtext)
 {
     cell.GetPrivateField <TextMeshProUGUI>("_authorText").text = subtext;
 }
Example #20
0
 public static void SetIcon(this LevelListTableCell cell, Sprite icon)
 {
     cell.GetPrivateField <UnityEngine.UI.Image>("_coverImage").sprite = icon;
 }
Example #21
0
        private async void SetDataFromLevelAsync(SongRequest request, LevelListTableCell _tableCell, int row)
        {
            bool highlight = (request.requestInfo.Length > 0) && (request.requestInfo[0] == '!');

            string msg = highlight ? "MSG" : "";

            var hasMessage  = (request.requestInfo.Length > 0) && (request.requestInfo[0] == '!');
            var isChallenge = request.requestInfo.IndexOf("!challenge", StringComparison.OrdinalIgnoreCase) >= 0;

            var beatmapCharacteristicImages = _tableCell.GetPrivateField <UnityEngine.UI.Image[]>("_beatmapCharacteristicImages"); // NEW VERSION

            foreach (var i in beatmapCharacteristicImages)
            {
                i.enabled = false;
            }
            _tableCell.SetPrivateField("_beatmapCharacteristicAlphas", new float[3] {
                0f, 1f, 1f
            });
            // set message icon if request has a message // NEW VERSION
            if (hasMessage)
            {
                beatmapCharacteristicImages.Last().sprite  = Base64Sprites.InfoIcon;
                beatmapCharacteristicImages.Last().enabled = true;
            }

            // set challenge icon if song is a challenge
            if (isChallenge)
            {
                var el = beatmapCharacteristicImages.ElementAt(1);

                el.sprite  = Base64Sprites.VersusChallengeIcon;
                el.enabled = true;
            }

            string pp      = "";
            int    ppvalue = request.song["pp"].AsInt;

            if (ppvalue > 0)
            {
                pp = $" {ppvalue} PP";
            }

            var dt = new RequestBot.DynamicText().AddSong(request.song).AddUser(ref request.requestor); // Get basic fields

            dt.Add("Status", request.status.ToString());
            dt.Add("Info", (request.requestInfo != "") ? " / " + request.requestInfo : "");
            dt.Add("RequestTime", request.requestTime.ToLocalTime().ToString("hh:mm"));

            var songName = _tableCell.GetPrivateField <TextMeshProUGUI>("_songNameText");

            //songName.text = $"{request.song["songName"].Value} <size=50%>{RequestBot.GetRating(ref request.song)} <color=#3fff3f>{pp}</color></size> <color=#ff00ff>{msg}</color>";
            songName.text = $"{request.song["songName"].Value} <size=50%>{RequestBot.GetRating(ref request.song)} <color=#3fff3f>{pp}</color></size>"; // NEW VERSION

            var author = _tableCell.GetPrivateField <TextMeshProUGUI>("_authorText");

            author.text = dt.Parse(RequestBot.QueueListRow2);

            var image    = _tableCell.GetPrivateField <RawImage>("_coverRawImage");
            var imageSet = false;

            if (SongCore.Loader.AreSongsLoaded)
            {
                CustomPreviewBeatmapLevel level = CustomLevelForRow(row);
                if (level != null)
                {
                    Plugin.Log("custom level found");
                    // set image from song's cover image
                    var tex = await level.GetCoverImageTexture2DAsync(System.Threading.CancellationToken.None);

                    image.texture = tex;
                    imageSet      = true;
                }
            }

            if (!imageSet)
            {
                string url = request.song["coverURL"].Value;
                var    s   = GetSongCoverArt(url, (sprite) => { _cachedSprites[url] = sprite; _customListTableView.ReloadData(); });
                image.texture = s.texture;
            }

            BeatSaberUI.AddHintText(_tableCell.transform as RectTransform, dt.Parse(RequestBot.SongHintText));
        }