public override CustomListTableData.CustomCellInfo CellInfoForIdx(int idx)
        {
            var model          = flowCoordinator.Value.AllConfigModels[idx];
            var customCellInfo = new CountersPlusListTableCell(idx, model.DisplayName);

            if (model is CustomConfigModel customConfig)
            {
                customCellInfo.text = customConfig.AttachedCustomCounter.Name;
                if (customConfig.AttachedCustomCounter.BSML != null && !string.IsNullOrEmpty(customConfig.AttachedCustomCounter.BSML.Icon))
                {
                    try
                    {
                        customCellInfo.icon = ImagesUtility.LoadSpriteFromExternalAssemblyResources(
                            customConfig.AttachedCustomCounter.CounterType.Assembly, customConfig.AttachedCustomCounter.BSML.Icon);
                    }
                    catch
                    {
                        customCellInfo.icon    = LoadSprite("Counters.Custom");
                        customCellInfo.subtext = "\n<i>(Failed to load custom icon.)</i>";
                    }
                }
                else
                {
                    customCellInfo.icon = LoadSprite("Counters.Custom");
                }
            }
            else
            {
                customCellInfo.icon = LoadSprite($"Counters.{model.DisplayName}");
            }

            return(customCellInfo);
        }
Exemplo n.º 2
0
        protected void GetCell(TableView view, out CountersPlusListTableCell cell, out TextMeshProUGUI packText, out ImageView image)
        {
            cell = view.DequeueReusableCellForIdentifier(settingsList.Value.ReuseIdentifier) as CountersPlusListTableCell;
            if (cell == null) //Dequeue the cell, and make an instance if it doesn't exist.
            {
                if (countersPlusTableCellInstance == null)
                {
                    var original = Object.Instantiate(settingsList.Value.levelPackTableCellInstance);
                    countersPlusTableCellInstance = original.CopyComponent <CountersPlusListTableCell>(original.gameObject);
                    Object.Destroy(original.GetComponent <AnnotatedBeatmapLevelCollectionTableCell>());
                    cell      = countersPlusTableCellInstance;
                    cell.name = $"{nameof(CountersPlusListTableCell)}";
                }
                else
                {
                    cell = Object.Instantiate(countersPlusTableCellInstance);
                }
                cell.reuseIdentifier = settingsList.Value.ReuseIdentifier;
            }
            cell.showNewRibbon = false; //Dequeued cells will keep NEW ribbon value. Always change it to false.

            var annotatedCell = cell as AnnotatedBeatmapLevelCollectionTableCell;

            packText          = PackInfoTextAccessor(ref annotatedCell);
            packText.richText = true; //Enable rich text for info text. Optional, but I use it for Counters+.
            image             = CoverImageAccessor(ref annotatedCell) as ImageView;
            image.rectTransform.localPosition = Vector3.up * 0.25f;
            image.rectTransform.localScale    = Vector3.one * 0.8f;
            image.preserveAspect = true; // oh boy beat games why must you make me do this
            ImageViewSkewAccessor(ref image) = 0;
            ImageViewSkewAccessor(ref SelectionImageAccessor(ref annotatedCell)) = 0;
            image.mainTexture.wrapMode = TextureWrapMode.Clamp; //Fixes bordering on images (especially transparent ones)
        }
 private void OptionSelected(TableView view, CountersPlusListTableCell cell)
 {
     selectedGroup.OnCellSelect(view, cell.CellIdx);
 }