public static bool NeedsScoreSaberData(this SongSortMode s)
        {
            switch (s)
            {
            case SongSortMode.PP:
            case SongSortMode.Stars:
                return(true);

            default:
                return(false);
            }
        }
        public static bool NeedsBeatSaverData(this SongSortMode s)
        {
            switch (s)
            {
            case SongSortMode.UpVotes:
            case SongSortMode.Rating:
            case SongSortMode.PlayCount:
            case SongSortMode.Heat:
                return(true);

            default:
                return(false);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Generic create sort button.
        /// </summary>
        /// <param name="rect"></param>
        /// <param name="templateButtonName"></param>
        /// <param name="buttonText"></param>
        /// <param name="iconName"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="w"></param>
        /// <param name="h"></param>
        /// <param name="action"></param>
        public static SongSortButton CreateSortButton(RectTransform parent, Button buttonTemplate, Sprite iconSprite, Sprite borderSprite, string buttonText, float fontSize, float x, float y, float w, float h, SongSortMode sortMode, System.Action <SongSortMode> onClickEvent)
        {
            SongSortButton sortButton = new SongSortButton();
            Button         newButton  = UIBuilder.CreateUIButton(parent, buttonTemplate);

            newButton.interactable = true;
            (newButton.transform as RectTransform).anchoredPosition = new Vector2(x, y);
            (newButton.transform as RectTransform).sizeDelta        = new Vector2(w, h);

            UIBuilder.SetButtonText(newButton, buttonText);
            UIBuilder.SetButtonIconEnabled(newButton, false);
            UIBuilder.SetButtonIcon(newButton, iconSprite);
            UIBuilder.SetButtonTextSize(newButton, fontSize);

            Image stroke = newButton.GetComponentsInChildren <Image>().First(btn => btn.name == "Stroke");

            stroke.sprite = borderSprite;
            //stroke.rectTransform.localScale = new Vector2(0.9f, 0.9f);

            newButton.GetComponentsInChildren <HorizontalLayoutGroup>().First(btn => btn.name == "Content").padding = new RectOffset(2, 2, 2, 2);

            newButton.onClick.RemoveAllListeners();
            newButton.onClick.AddListener(delegate()
            {
                onClickEvent(sortMode);
            });

            sortButton.Button   = newButton;
            sortButton.SortMode = sortMode;

            return(sortButton);
        }