Exemplo n.º 1
0
        public T AddIconSegmentsSetting <T>(string name, string hintText, IconSegmentedControl.DataItem[] icons) where T : SegmentedControlViewController
        {
            var        volumeSettings    = GetVolumeSettings();
            GameObject newSettingsObject = MonoBehaviour.Instantiate(volumeSettings.gameObject, transform);

            newSettingsObject.name = name;

            ListSettingsController volume       = newSettingsObject.GetComponent <ListSettingsController>();
            T newTextSegmentsSettingsController = (T)ReflectionUtil.CopyComponent(volume, typeof(ListSettingsController), typeof(T), newSettingsObject);

            MonoBehaviour.DestroyImmediate(volume);

            GameObject.Destroy(newSettingsObject.transform.Find("Value").Find("DecButton").gameObject);
            GameObject.Destroy(newSettingsObject.transform.Find("Value").Find("ValueText").gameObject);
            GameObject.Destroy(newSettingsObject.transform.Find("Value").Find("IncButton").gameObject);

            IconSegmentedControl segmentedControl = BeatSaberUI.CreateIconSegmentedControl(newSettingsObject.transform.Find("Value") as RectTransform, new Vector2(0f, 0f), new Vector2(40f, 7f));

            newTextSegmentsSettingsController.segmentedControl = segmentedControl;
            segmentedControl.SetData(icons);

            var tmpText = newSettingsObject.GetComponentInChildren <TMP_Text>();

            tmpText.text = name;
            if (hintText != String.Empty)
            {
                BeatSaberUI.AddHintText(tmpText.rectTransform, hintText);
            }

            viewController?.AddSubmenuOption(newSettingsObject);
            AddHooks(newTextSegmentsSettingsController);
            return(newTextSegmentsSettingsController);
        }
Exemplo n.º 2
0
        public void SetControlData(IDifficultyBeatmapSet[] difficultyBeatmapSets, BeatmapCharacteristicSO selectedBeatmapCharacteristic)
        {
            _beatmapCharacteristics.Clear();
            var beatmapSetList = new List <IDifficultyBeatmapSet>(difficultyBeatmapSets);

            beatmapSetList.Sort((IDifficultyBeatmapSet a, IDifficultyBeatmapSet b) => a.beatmapCharacteristic.sortingOrder.CompareTo(b.beatmapCharacteristic.sortingOrder));
            _beatmapCharacteristics.AddRange(beatmapSetList.Select(x => x.beatmapCharacteristic));

            var itemArray     = beatmapSetList.Select(beatmapSet => new IconSegmentedControl.DataItem(beatmapSet.beatmapCharacteristic.icon, Localization.Get(beatmapSet.beatmapCharacteristic.descriptionLocalizationKey))).ToArray();
            var selectedIndex = Math.Max(0, beatmapSetList.FindIndex(x => x.beatmapCharacteristic == selectedBeatmapCharacteristic));

            characteristicControl.SetData(itemArray);
            characteristicControl.SelectCellWithNumber(selectedIndex);
            SetSelectedCharacteristic(null, selectedIndex);
        }
        static void Postfix(ref Sprite ____friendsLeaderboardIcon, ref Sprite ____globalLeaderboardIcon, ref Sprite ____aroundPlayerLeaderboardIcon, ref IconSegmentedControl ____scopeSegmentedControl, ref PlatformLeaderboardViewController __instance)
        {//LeaderboardUIManager.Instance.PCIcon;
            ____scopeSegmentedControl.didSelectCellEvent += __instance.HandleScopeSegmentedControlDidSelectCell;

            ____scopeSegmentedControl.SetData(new IconSegmentedControl.DataItem[] {
                new IconSegmentedControl.DataItem(____globalLeaderboardIcon, "Global"),
                new IconSegmentedControl.DataItem(____aroundPlayerLeaderboardIcon, "Around You"),
                new IconSegmentedControl.DataItem(BeatBoardsUIManager.Instance.PCIcon, "Platform: PC")
            });

            var replayButton = __instance.CreateUIButton("OkButton", new Vector2(0f, -37f), new Vector2(9.0f, 5.0f));

            replayButton.ToggleWordWrapping(false);
            replayButton.SetButtonText("Replays");
            replayButton.SetButtonTextSize(3);
            //replayButton.onClick.AddListener(LeaderboardUIManager.Instance.ReplayMenu);

            BeatBoardsUIManager.Instance.replaysButton = replayButton;
        }
Exemplo n.º 4
0
        void SetupCharacteristicDisplay(IconSegmentedControl controller, Song song)
        {
            List <IconSegmentedControl.DataItem> characteristics = new List <IconSegmentedControl.DataItem>();

            foreach (var c in song.metadata.characteristics)
            {
                BeatmapCharacteristicSO characteristic = SongCore.Loader.beatmapCharacteristicCollection.GetBeatmapCharacteristicBySerialiedName(c.name);
                if (characteristic.characteristicName == "Missing Characteristic")
                {
                    characteristics.Add(new IconSegmentedControl.DataItem(characteristic.icon, $"Missing Characteristic: {c.name}"));
                }
                else
                {
                    characteristics.Add(new IconSegmentedControl.DataItem(characteristic.icon, characteristic.hintText));
                }
            }

            controller.SetData(characteristics.ToArray());
        }
Exemplo n.º 5
0
        public void SetControlData(IDifficultyBeatmapSet[] difficultyBeatmapSets, BeatmapCharacteristicSO selectedBeatmapCharacteristic)
        {
            _beatmapCharacteristics.Clear();
            List <IDifficultyBeatmapSet> list = new List <IDifficultyBeatmapSet>(difficultyBeatmapSets);

            list.Sort((IDifficultyBeatmapSet a, IDifficultyBeatmapSet b) => a.beatmapCharacteristic.sortingOrder.CompareTo(b.beatmapCharacteristic.sortingOrder));
            difficultyBeatmapSets = list.ToArray();
            IconSegmentedControl.DataItem[] array = new IconSegmentedControl.DataItem[difficultyBeatmapSets.Length];
            int num = 0;

            for (int i = 0; i < difficultyBeatmapSets.Length; i++)
            {
                BeatmapCharacteristicSO beatmapCharacteristic = difficultyBeatmapSets[i].beatmapCharacteristic;
                array[i] = new IconSegmentedControl.DataItem(beatmapCharacteristic.icon, Localization.Get(beatmapCharacteristic.descriptionLocalizationKey));
                _beatmapCharacteristics.Add(beatmapCharacteristic);
                if (beatmapCharacteristic == selectedBeatmapCharacteristic)
                {
                    num = i;
                }
            }
            characteristicControl.SetData(array);
            characteristicControl.SelectCellWithNumber(num);
            SetSelectedCharateristic(null, num);
        }
        public override void HandleType(ComponentTypeWithData componentType, BSMLParserParams parserParams)
        {
            IconSegmentedControl iconControl = componentType.component as IconSegmentedControl;

            if (componentType.data.TryGetValue("data", out string value))
            {
                if (!parserParams.values.TryGetValue(value, out BSMLValue contents))
                {
                    throw new Exception("value '" + value + "' not found");
                }
                iconControl.SetData((contents.GetValue() as List <IconSegmentedControl.DataItem>).ToArray());
            }

            if (componentType.data.TryGetValue("selectCell", out string selectCell))
            {
                iconControl.didSelectCellEvent += (SegmentedControl control, int index) => {
                    if (!parserParams.actions.TryGetValue(selectCell, out BSMLAction action))
                    {
                        throw new Exception("select-cell action '" + componentType.data["selectCell"] + "' not found");
                    }
                    action.Invoke(control, index);
                };
            }
        }