コード例 #1
0
        protected override void DidActivate(bool firstActivation, ActivationType type)
        {
            if (firstActivation && type == ActivationType.AddedToHierarchy)
            {
                SongDownloader.Instance.songDownloaded -= SongDownloaded;
                SongDownloader.Instance.songDownloaded += SongDownloaded;
                _songListTableCellInstance              = Resources.FindObjectsOfTypeAll <LevelListTableCell>().First(x => (x.name == "LevelListTableCell"));

                _titleText           = BeatSaberUI.CreateText(rectTransform, "DOWNLOAD QUEUE", new Vector2(0f, 35f));
                _titleText.alignment = TextAlignmentOptions.Top;
                _titleText.fontSize  = 6f;

                _pageUpButton = Instantiate(Resources.FindObjectsOfTypeAll <Button>().Last(x => (x.name == "PageUpButton")), rectTransform, false);
                (_pageUpButton.transform as RectTransform).anchorMin        = new Vector2(0.5f, 1f);
                (_pageUpButton.transform as RectTransform).anchorMax        = new Vector2(0.5f, 1f);
                (_pageUpButton.transform as RectTransform).anchoredPosition = new Vector2(0f, -14f);
                (_pageUpButton.transform as RectTransform).sizeDelta        = new Vector2(40f, 10f);
                _pageUpButton.interactable = true;
                _pageUpButton.onClick.AddListener(delegate()
                {
                    _queuedSongsTableView.PageScrollUp();
                });

                _pageDownButton = Instantiate(Resources.FindObjectsOfTypeAll <Button>().Last(x => (x.name == "PageDownButton")), rectTransform, false);
                (_pageDownButton.transform as RectTransform).anchorMin        = new Vector2(0.5f, 0f);
                (_pageDownButton.transform as RectTransform).anchorMax        = new Vector2(0.5f, 0f);
                (_pageDownButton.transform as RectTransform).anchoredPosition = new Vector2(0f, 8f);
                (_pageDownButton.transform as RectTransform).sizeDelta        = new Vector2(40f, 10f);
                _pageDownButton.interactable = true;
                _pageDownButton.onClick.AddListener(delegate()
                {
                    _queuedSongsTableView.PageScrollDown();
                });

                _queuedSongsTableView = new GameObject().AddComponent <TableView>();
                _queuedSongsTableView.transform.SetParent(rectTransform, false);

                _queuedSongsTableView.SetPrivateField("_isInitialized", false);
                _queuedSongsTableView.SetPrivateField("_preallocatedCells", new TableView.CellsGroup[0]);
                _queuedSongsTableView.Init();

                RectMask2D viewportMask = Instantiate(Resources.FindObjectsOfTypeAll <RectMask2D>().First(), _queuedSongsTableView.transform, false);
                viewportMask.transform.DetachChildren();
                _queuedSongsTableView.GetComponentsInChildren <RectTransform>().First(x => x.name == "Content").transform.SetParent(viewportMask.rectTransform, false);

                (_queuedSongsTableView.transform as RectTransform).anchorMin        = new Vector2(0.3f, 0.5f);
                (_queuedSongsTableView.transform as RectTransform).anchorMax        = new Vector2(0.7f, 0.5f);
                (_queuedSongsTableView.transform as RectTransform).sizeDelta        = new Vector2(0f, 60f);
                (_queuedSongsTableView.transform as RectTransform).anchoredPosition = new Vector3(0f, -3f);

                ReflectionUtil.SetPrivateField(_queuedSongsTableView, "_pageUpButton", _pageUpButton);
                ReflectionUtil.SetPrivateField(_queuedSongsTableView, "_pageDownButton", _pageDownButton);

                _queuedSongsTableView.selectionType = TableViewSelectionType.None;
                _queuedSongsTableView.dataSource    = this;

                _abortButton = BeatSaberUI.CreateUIButton(rectTransform, "CreditsButton", new Vector2(36f, -30f), new Vector2(20f, 10f), AbortDownloads, "Abort All");
                _abortButton.ToggleWordWrapping(false);
            }
        }
コード例 #2
0
        private static IEnumerator AddModListButton()
        {
            yield return(_bottomPanelExists);

            Logger.log.Debug("Adding button to main menu");

            lock (Instance)
            {
                if (menuFlow == null)
                {
                    menuFlow = new GameObject("BSIPA Mod List Flow Controller").AddComponent <ModListFlowCoordinator>();
                }
                if (panel == null)
                {
                    panel = GameObject.Find(ControllerPanel).transform as RectTransform;
                }

                if (button == null)
                {
                    button = BeatSaberUI.CreateUIButton(panel, CopyButton, () =>
                    {
                        menuFlow.Present();
                    }, "Mod List");
                    panel.Find(CopyButton).SetAsLastSibling();

                    hintText = BeatSaberUI.AddHintText(button.transform as RectTransform, "View and control updates for installed mods");
                }

                yield break;
            }
        }
コード例 #3
0
        public override void __Activate(ActivationType activationType)
        {
            base.__Activate(activationType);
            //
            if (!initialized && activationType == ActivationType.AddedToHierarchy)
            {
                (_pageUpButton.transform as RectTransform).anchoredPosition = new Vector2(0, 25);
                SongDownloader.Instance.songDownloaded -= SongDownloaded;
                SongDownloader.Instance.songDownloaded += SongDownloaded;
                _songListTableCellInstance              = Resources.FindObjectsOfTypeAll <LevelListTableCell>().First(x => (x.name == "LevelListTableCell"));

                RectTransform viewControllersContainer = FindObjectsOfType <RectTransform>().First(x => x.name == "ViewControllers");

                var headerPanelRectTransform = Instantiate(viewControllersContainer.GetComponentsInChildren <RectTransform>(true).First(x => x.name == "HeaderPanel" && x.parent.name == "PlayerSettingsViewController"), rectTransform);
                headerPanelRectTransform.gameObject.SetActive(true);

                _titleText      = headerPanelRectTransform.GetComponentInChildren <TextMeshProUGUI>();
                _titleText.text = "DOWNLOAD QUEUE";

                _customListTableView.selectionType = TableViewSelectionType.None;

                _abortButton = BeatSaberUI.CreateUIButton(rectTransform, "CreditsButton", new Vector2(36f, -30f), new Vector2(20f, 10f), AbortDownloads, "Abort All");
                _abortButton.ToggleWordWrapping(false);
                initialized = true;
            }
            else
            {
                _titleText.text = "DOWNLOAD QUEUE";
            }
        }
コード例 #4
0
        private void CreateOnlineButton()
        {
            _newVersionText           = BeatSaberUI.CreateText(_mainMenuRectTransform, "A new version of the mod\nis available!", new Vector2(18.25f, 30f));
            _newVersionText.fontSize  = 6f;
            _newVersionText.alignment = TextAlignmentOptions.Center;
            _newVersionText.gameObject.SetActive(false);

            _multiplayerButton = BeatSaberUI.CreateUIButton(_mainMenuRectTransform, "SoloFreePlayButton");
            _multiplayerButton.transform.SetParent(Resources.FindObjectsOfTypeAll <Button>().First(x => x.name == "SoloFreePlayButton").transform.parent);
            _multiplayerButton.transform.SetSiblingIndex(2);

            _multiplayerButton.SetButtonText("Online");
            _multiplayerButton.SetButtonIcon(Sprites.onlineIcon);

            _multiplayerButton.onClick.AddListener(delegate()
            {
                try
                {
                    MainFlowCoordinator mainFlow = Resources.FindObjectsOfTypeAll <MainFlowCoordinator>().First();

                    mainFlow.InvokeMethod("PresentFlowCoordinator", modeSelectionFlowCoordinator, null, false, false);
                }
                catch (Exception e)
                {
                    Misc.Logger.Exception($"Unable to present flow coordinator! Exception: {e}");
                }
            });
        }
コード例 #5
0
        protected override void DidActivate(bool firstActivation, ActivationType activationType)
        {
            if (firstActivation)
            {
                foreach (string path in _dllPaths)
                {
                    if (!File.Exists(path))
                    {
                        _filesMising         = true;
                        _missingFilesString += "\n" + path;
                    }
                }

                if (_filesMising)
                {
                    _missingFilesText           = BeatSaberUI.CreateText(rectTransform, _missingFilesString, new Vector2(0f, 0f));
                    _missingFilesText.alignment = TextAlignmentOptions.Center;
                    _missingFilesText.color     = Color.red;
                    _missingFilesText.fontSize  = 6f;
                }
                else
                {
                    _roomsButton = BeatSaberUI.CreateUIButton(rectTransform, "SoloFreePlayButton", new Vector2(-40f, 10f), () => { didSelectRooms?.Invoke(); }, "ROOMS");
                    Destroy(_roomsButton.GetComponentInChildren <HoverHint>());
                    _roomsButton.SetButtonIcon(Sprites.roomsIcon);

                    _radioButton = BeatSaberUI.CreateUIButton(rectTransform, "SoloFreePlayButton", new Vector2(10f, 10f), () => { didSelectRadio?.Invoke(); }, "RADIO");
                    Destroy(_radioButton.GetComponentInChildren <HoverHint>());
                    _radioButton.SetButtonIcon(Sprites.radioIcon);
                }
            }
        }
コード例 #6
0
        public void SetQuickButtons(IPreviewBeatmapLevel level)
        {
            if (_titleButton == null)
            {
                _titleButton = BeatSaberUI.CreateUIButton(rectTransform, "QuitButton", new Vector2(-35, 35), new Vector2(30f, 6f));
            }
            _titleButton.SetButtonText(level.songName);
            _titleButton.SetButtonTextSize(3);
            _titleButton.onClick.RemoveAllListeners();
            _titleButton.onClick.AddListener(delegate() { _inputString += level.songName + " "; UpdateInputText(); });

            if (_subtitleButton == null)
            {
                _subtitleButton = BeatSaberUI.CreateUIButton(rectTransform, "QuitButton", new Vector2(0, 35), new Vector2(30f, 6f));
            }
            _subtitleButton.SetButtonText(level.songSubName);
            _subtitleButton.SetButtonTextSize(3);
            _subtitleButton.onClick.RemoveAllListeners();
            _subtitleButton.onClick.AddListener(delegate() { _inputString += level.songSubName + " "; UpdateInputText(); });

            if (_artistButton == null)
            {
                _artistButton = BeatSaberUI.CreateUIButton(rectTransform, "QuitButton", new Vector2(35, 35), new Vector2(30f, 6f));
            }
            _artistButton.SetButtonText(level.songAuthorName);
            _artistButton.SetButtonTextSize(3);
            _artistButton.onClick.RemoveAllListeners();
            _artistButton.onClick.AddListener(delegate() { _inputString += level.songAuthorName + " "; UpdateInputText(); });
        }
コード例 #7
0
        protected override void DidActivate(bool firstActivation, ActivationType activationType)
        {
            if (firstActivation && activationType == ActivationType.AddedToHierarchy)
            {
                _tokensText = BeatSaberUI.CreateText(rectTransform, "Tokens: XX", Vector2.zero);
                _tokensText.rectTransform.anchorMin = new Vector2(0.3f, 0.5f);
                _tokensText.rectTransform.anchorMax = new Vector2(0.3f, 0.5f);
                _tokensText.fontSize = 8f;

                _rankUpButton = BeatSaberUI.CreateUIButton(rectTransform, "QuitButton", () =>
                {
                    var currentTeam = _teams.First(x => x.TeamId == _player.Team);
                    var nextTeam    = _teams.First(x => x.TeamId == currentTeam.NextPromotion);

                    var s = RSA.SignRankRequest(Plugin.UserId, nextTeam.TeamId, false);
#if BETA
                    var n = "SubmitRankRequest";
#else
                    var n = "b";
#endif
                    typeof(Client).InvokeMethod(n, Plugin.UserId, nextTeam.TeamId, "[NOT YET IMPLEMENTED]", false, s, null);
                }, "Rank Up");
                (_rankUpButton.transform as RectTransform).anchorMin        = new Vector2(0.7f, 0.5f);
                (_rankUpButton.transform as RectTransform).anchorMax        = new Vector2(0.7f, 0.5f);
                (_rankUpButton.transform as RectTransform).anchoredPosition = Vector2.zero;
                (_rankUpButton.transform as RectTransform).sizeDelta        = new Vector2(50, 10);
                _rankUpButton.interactable = false;

                UpdateUI();
            }
        }
コード例 #8
0
        private void CreateOnlineButton()
        {
            _newVersionText             = BeatSaberUI.CreateText(_mainMenuRectTransform, "A new version of the mod\nis available!", new Vector2(55.5f, 33f));
            _newVersionText.fontSize    = 5f;
            _newVersionText.lineSpacing = -52;
            _newVersionText.gameObject.SetActive(false);

            Button[] mainButtons = Resources.FindObjectsOfTypeAll <RectTransform>().First(x => x.name == "MainButtons" && x.parent.name == "MainMenuViewController").GetComponentsInChildren <Button>();

            foreach (var item in mainButtons)
            {
                (item.transform as RectTransform).sizeDelta = new Vector2(35f, 30f);
            }

            _multiplayerButton = BeatSaberUI.CreateUIButton(_mainMenuRectTransform, "CampaignButton");
            _multiplayerButton.transform.SetParent(mainButtons.First(x => x.name == "CampaignButton").transform.parent);
            _multiplayerButton.transform.SetSiblingIndex(3);

            _multiplayerButton.SetButtonText("Online");
            _multiplayerButton.SetButtonIcon(Sprites.onlineIcon);

            _multiplayerButton.onClick.AddListener(delegate()
            {
                try
                {
                    MainFlowCoordinator mainFlow = Resources.FindObjectsOfTypeAll <MainFlowCoordinator>().First();

                    mainFlow.InvokeMethod("PresentFlowCoordinator", modeSelectionFlowCoordinator, null, false, false);
                }
                catch (Exception e)
                {
                    Misc.Logger.Exception($"Unable to present flow coordinator! Exception: {e}");
                }
            });
        }
コード例 #9
0
        protected override void DidActivate(bool firstActivation, ActivationType activationType)
        {
            if (firstActivation && activationType == ActivationType.AddedToHierarchy)
            {
                _downloadListTableCellInstance = Resources.FindObjectsOfTypeAll <LeaderboardTableCell>().First();

                _destroyRoomButton = BeatSaberUI.CreateUIButton(rectTransform, "CreditsButton", new Vector2(44f, 33f), new Vector2(26f, 10f), () => { DestroyRoomPressed?.Invoke(); }, "Destroy\nroom");
                _destroyRoomButton.ToggleWordWrapping(false);

                _pageUpButton = Instantiate(Resources.FindObjectsOfTypeAll <Button>().First(x => (x.name == "PageUpButton")), rectTransform, false);
                (_pageUpButton.transform as RectTransform).anchorMin        = new Vector2(0.5f, 1f);
                (_pageUpButton.transform as RectTransform).anchorMax        = new Vector2(0.5f, 1f);
                (_pageUpButton.transform as RectTransform).anchoredPosition = new Vector2(0f, -12f);
                (_pageUpButton.transform as RectTransform).sizeDelta        = new Vector2(40f, 6f);
                _pageUpButton.interactable = true;
                _pageUpButton.onClick.AddListener(delegate()
                {
                    _downloadProgressTableView.PageScrollUp();
                });
                _pageUpButton.interactable = false;

                _pageDownButton = Instantiate(Resources.FindObjectsOfTypeAll <Button>().First(x => (x.name == "PageDownButton")), rectTransform, false);
                (_pageDownButton.transform as RectTransform).anchorMin        = new Vector2(0.5f, 0f);
                (_pageDownButton.transform as RectTransform).anchorMax        = new Vector2(0.5f, 0f);
                (_pageDownButton.transform as RectTransform).anchoredPosition = new Vector2(0f, 6f);
                (_pageDownButton.transform as RectTransform).sizeDelta        = new Vector2(40f, 6f);
                _pageDownButton.interactable = true;
                _pageDownButton.onClick.AddListener(delegate()
                {
                    _downloadProgressTableView.PageScrollDown();
                });
                _pageDownButton.interactable = false;

                RectTransform container = new GameObject("Content", typeof(RectTransform)).transform as RectTransform;
                container.SetParent(rectTransform, false);
                container.anchorMin        = new Vector2(0.15f, 0.5f);
                container.anchorMax        = new Vector2(0.85f, 0.5f);
                container.sizeDelta        = new Vector2(0f, 56f);
                container.anchoredPosition = new Vector2(0f, -3f);

                _downloadProgressTableView = new GameObject("CustomTableView").AddComponent <TableView>();
                _downloadProgressTableView.gameObject.AddComponent <RectMask2D>();
                _downloadProgressTableView.transform.SetParent(container, false);

                _downloadProgressTableView.SetPrivateField("_isInitialized", false);
                _downloadProgressTableView.SetPrivateField("_preallocatedCells", new TableView.CellsGroup[0]);
                _downloadProgressTableView.Init();

                (_downloadProgressTableView.transform as RectTransform).anchorMin        = new Vector2(0f, 0f);
                (_downloadProgressTableView.transform as RectTransform).anchorMax        = new Vector2(1f, 1f);
                (_downloadProgressTableView.transform as RectTransform).sizeDelta        = new Vector2(0f, 0f);
                (_downloadProgressTableView.transform as RectTransform).anchoredPosition = new Vector3(0f, 0f);

                ReflectionUtil.SetPrivateField(_downloadProgressTableView, "_pageUpButton", _pageUpButton);
                ReflectionUtil.SetPrivateField(_downloadProgressTableView, "_pageDownButton", _pageDownButton);

                _downloadProgressTableView.dataSource = this;
            }
        }
コード例 #10
0
        private void SetupLinks(PluginManifest.LinksObject links = null, Uri moreInfoLink = null)
        {
            bool addedLink = false;

            if (links != null || moreInfoLink != null)
            {
                Logger.log.Debug($"Adding links");

                rowTransform                  = Instantiate(rowTransformOriginal, rectTransform);
                rowTransform.anchorMin        = new Vector2(0f, 0f);
                rowTransform.anchorMax        = new Vector2(1f, .15f);
                rowTransform.anchoredPosition = new Vector2(-3.5f, 4f);
                rowTransform.sizeDelta        = Vector2.zero;
                Destroy(rowTransform.GetComponent <StartMiddleEndButtonsGroup>());

                foreach (Transform child in rowTransform)
                {
                    child.name = string.Empty;
                    Destroy(child.gameObject);
                }

                if (links?.ProjectHome != null)
                {
                    linkHomeButton = BeatSaberUI.CreateUIButton(rowTransform, "CreditsButton", buttonText: "Home", anchoredPosition: Vector2.zero, sizeDelta: new Vector2(20, 10),
                                                                onClick: () => Process.Start(links.ProjectHome.ToString()));
                    addedLink = true;
                }
                if (links?.ProjectSource != null)
                {
                    linkSourceButton = BeatSaberUI.CreateUIButton(rowTransform, "CreditsButton", buttonText: "Source", anchoredPosition: Vector2.zero, sizeDelta: new Vector2(20, 10),
                                                                  onClick: () => Process.Start(links.ProjectSource.ToString()));
                    addedLink = true;
                }
                if (links?.Donate != null)
                {
                    linkDonateButton = BeatSaberUI.CreateUIButton(rowTransform, "CreditsButton", buttonText: "Donate", anchoredPosition: Vector2.zero, sizeDelta: new Vector2(20, 10),
                                                                  onClick: () => Process.Start(links.Donate.ToString()));
                    addedLink = true;
                }
                if (moreInfoLink != null)
                {
                    linkDonateButton = BeatSaberUI.CreateUIButton(rowTransform, "CreditsButton", buttonText: "More Info", anchoredPosition: Vector2.zero, sizeDelta: new Vector2(20, 10),
                                                                  onClick: () => Process.Start(moreInfoLink.ToString()));
                    addedLink = true;
                }

                foreach (var cmp in rowTransform.GetComponentsInChildren <StartMiddleEndButtonBackgroundController>())
                {
                    cmp.SetMiddleSprite();
                }
            }
            if (UpdateInfo != null && !addedLink)
            {
                StartCoroutine(GetMoreInfoLink());
            }
        }
コード例 #11
0
        public void Init()
        {
            LeaderboardTableCell cell = GetComponent <LeaderboardTableCell>();

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

            Destroy(cell);

            reuseIdentifier = "PlayerCell";

            if (_buttonStrokeSprite == null)
            {
                _buttonStrokeSprite = Resources.FindObjectsOfTypeAll <Sprite>().First(x => x.name == "RoundRectSmallStroke");
            }

            _playerNameText.rectTransform.anchoredPosition = new Vector2(12f, 0f);

            _playerSpeakerIcon = new GameObject("Player Speaker Icon", typeof(Canvas), typeof(CanvasRenderer)).AddComponent <Image>();
            _playerSpeakerIcon.GetComponent <Canvas>().renderMode = RenderMode.WorldSpace;
            _playerSpeakerIcon.rectTransform.SetParent(transform);
            _playerSpeakerIcon.rectTransform.localScale       = new Vector3(0.05f, 0.05f, 0.05f);
            _playerSpeakerIcon.rectTransform.pivot            = new Vector2(0.5f, 0.5f);
            _playerSpeakerIcon.rectTransform.anchoredPosition = new Vector2(-38f, 0f);
            _playerSpeakerIcon.sprite   = Sprites.speakerIcon;
            _playerSpeakerIcon.material = Sprites.NoGlowMat;

            _transferHostButton = BeatSaberUI.CreateUIButton(transform as RectTransform, "CancelButton", new Vector2(14f, 0f), new Vector2(14f, 6f), () => {
                if (buttonsInterface != null)
                {
                    buttonsInterface.TransferHostButtonWasPressed(playerInfo);
                }
            }, "PASS\nHOST");

            _transferHostButton.ToggleWordWrapping(false);
            _transferHostButton.SetButtonTextSize(3.25f);
            _transferHostButton.GetComponentsInChildren <UnityEngine.UI.Image>().First(x => x.name == "Stroke").sprite = _buttonStrokeSprite;
            _transferHostButtonEnabled = true;

            _muteButton = BeatSaberUI.CreateUIButton(transform as RectTransform, "CancelButton", new Vector2(30f, 0f), new Vector2(14f, 6f), () => {
                if (buttonsInterface != null)
                {
                    buttonsInterface.MuteButtonWasPressed(playerInfo);
                }
            }, "MUTE");
            _isMuted = false;

            _muteButton.ToggleWordWrapping(false);
            _muteButton.GetComponentsInChildren <UnityEngine.UI.Image>().First(x => x.name == "Stroke").sprite = _buttonStrokeSprite;
            _muteButtonEnabled = true;

            _scoreText.overflowMode       = TextOverflowModes.Overflow;
            _scoreText.enableWordWrapping = false;
        }
コード例 #12
0
        protected override void DidActivate(bool firstActivation, ActivationType activationType)
        {
            if (!firstActivation)
            {
                return;
            }
            instance = this;
            TextMeshProUGUI name, version, creator;
            Button          github, issues, donate;

            name                  = BeatSaberUI.CreateText(rectTransform, "Counters+", Vector2.zero);
            name.fontSize         = 11;
            name.alignment        = TextAlignmentOptions.Center;
            name.characterSpacing = 2;
            setPositioning(name.rectTransform, 0, 0.7f, 1, 0.166f, 0.5f);

            version = BeatSaberUI.CreateText(rectTransform,
                                             $"Version <color={(Plugin.UpToDate ? "#00FF00" : "#FF0000")}>{Plugin.PluginVersion}</color>", Vector2.zero);
            version.fontSize  = 3;
            version.alignment = TextAlignmentOptions.Center;
            setPositioning(version.rectTransform, 0, 0.5f, 1, 0.166f, 0.5f);

            if (!Plugin.UpToDate)
            {
                TextMeshProUGUI warning = BeatSaberUI.CreateText(rectTransform,
                                                                 $"<color=#FF0000>Version {Plugin.WebVersion} available for download!</color>", Vector2.zero);
                warning.fontSize  = 3;
                warning.alignment = TextAlignmentOptions.Center;
                setPositioning(warning.rectTransform, 0, 0.47f, 1, 0.166f, 0.5f);
            }

            creator           = BeatSaberUI.CreateText(rectTransform, "Developed by: <color=#00c0ff>Caeden117</color>", Vector2.zero);
            creator.fontSize  = 5;
            creator.alignment = TextAlignmentOptions.Center;
            setPositioning(creator.rectTransform, 0, 0.35f, 1, 0.166f, 0.5f);

            try //attempt to load BSML's button cuz it messes with layout
            {
                github = BeatSaberUI.CreateUIButton(rectTransform, "SettingsButton(Clone)", Vector2.left, null, "GitHub");
            }
            catch { github = BeatSaberUI.CreateUIButton(rectTransform, "SettingsButton", Vector2.left, null, "GitHub"); }
            github.onClick.AddListener(() => { GoTo("https://github.com/Caeden117/CountersPlus", github); });
            setPositioning(github.transform as RectTransform, 0f, 0f, 0.39f, 0.125f, 0.5f);
            BeatSaberUI.AddHintText(github.transform as RectTransform, "Opens in a new browser tab on your desktop. Feel free to explore the source code! Maybe try out experimental versions?");

            issues = BeatSaberUI.CreateUIButton(rectTransform, "QuitButton", Vector2.right, null, "Report an Issue");
            issues.onClick.AddListener(() => { GoTo("https://github.com/Caeden117/CountersPlus/issues", issues); });
            setPositioning(issues.transform as RectTransform, 0.5f, 0f, 0.5f, 0.125f, 0.5f);
            BeatSaberUI.AddHintText(issues.transform as RectTransform, "Opens in a new browser tab on your desktop. Be sure to read the Issue template thoroughly!");

            donate = BeatSaberUI.CreateUIButton(rectTransform, "CreditsButton", Vector2.zero, null, "<3");
            donate.onClick.AddListener(() => { GoTo("https://ko-fi.com/Caeden117", donate); });
            BeatSaberUI.AddHintText(donate.transform as RectTransform, "Buy me a coffee if you feel like I'm deserving of one.");
            setPositioning(donate.transform as RectTransform, 0.36f, 0f, 0.17f, 0.125f, 0.5f);
        }
コード例 #13
0
        public void Init(Sprite icon, string name, string version, string author, string description, PluginLoader.PluginMetadata updateInfo, PluginManifest.LinksObject links = null, bool showEnDis = false, ModListFlowCoordinator mlfc = null)
        {
            showEnableDisable      = showEnDis;
            Plugin.OnConfigChaned -= OptHideButton;

            Icon        = icon;
            Name        = name;
            Version     = version;
            Author      = author;
            Description = description;
            UpdateInfo  = updateInfo;

            enabled = !PluginManager.IsDisabled(updateInfo);

            flowController = mlfc;

            if (rowTransformOriginal == null)
            {
                rowTransformOriginal = MenuButtonUI.Instance.GetPrivateField <RectTransform>("menuButtonsOriginal");
            }

            // i also have no clue why this is necessary
            rectTransform.anchorMin = new Vector2(0f, 0f);
            rectTransform.anchorMax = new Vector2(0.5f, 1f);

            var go = new GameObject("Info View", typeof(RectTransform));

            go.SetActive(false);
            go.AddComponent <RectMask2D>();
            view = go.AddComponent <ModInfoView>();
            var rt = view.transform as RectTransform;

            rt.SetParent(transform);
            rt.anchorMin        = new Vector2(0f, 0f);
            rt.anchorMax        = new Vector2(1f, 1f);
            rt.anchoredPosition = new Vector2(0f, 0);
            view.Init(this);
            go.SetActive(true);

            if (showEnDis)
            {
                restartMessage          = BeatSaberUI.CreateText(rectTransform, "A restart is required to apply", new Vector2(11f, 33.5f));
                restartMessage.fontSize = 4f;
                restartMessage.gameObject.SetActive(false);

                enableDisableButton = BeatSaberUI.CreateUIButton(rectTransform, "CreditsButton", new Vector2(33, 32), new Vector2(25, 10), ToggleEnable);
                enableDisableButton.GetComponentInChildren <StartMiddleEndButtonBackgroundController>().SetMiddleSprite();
                UpdateButtonText();

                Plugin.OnConfigChaned += OptHideButton;
                OptHideButton(Plugin.config.Value);
            }

            SetupLinks(links);
        }
コード例 #14
0
        protected override void DidActivate(bool firstActivation, ActivationType activationType)
        {
            if (firstActivation)
            {
                _roomsButton = BeatSaberUI.CreateUIButton(rectTransform, "SoloFreePlayButton", new Vector2(-5f, 10f), () => { didSelectRooms?.Invoke(); }, "ROOMS");
                _roomsButton.SetButtonIcon(Sprites.roomsIcon);

                _radioButton = BeatSaberUI.CreateUIButton(rectTransform, "SoloFreePlayButton", new Vector2(45f, 10f), () => { didSelectRadio?.Invoke(); }, "RADIO");
                _radioButton.SetButtonIcon(Sprites.radioIcon);
            }
        }
コード例 #15
0
        private void SetupLinks(PluginManifest.LinksObject links = null, Uri moreInfoLink = null)
        {
            bool addedLink = false;

            if (links != null || moreInfoLink != null)
            {
                Logger.log.Debug($"Adding links");

                rowTransform                  = Instantiate(rowTransformOriginal, rectTransform);
                rowTransform.anchorMin        = new Vector2(0f, 0f);
                rowTransform.anchorMax        = new Vector2(1f, .15f);
                rowTransform.anchoredPosition = new Vector2(-3.5f, -2f);

                foreach (Transform child in rowTransform)
                {
                    child.name = string.Empty;
                    Destroy(child.gameObject);
                }

                if (links?.ProjectHome != null)
                {
                    linkHomeButton = BeatSaberUI.CreateUIButton(rowTransform, "QuitButton", buttonText: "Home",
                                                                onClick: () => Process.Start(links.ProjectHome.ToString()));
                    linkHomeButton.GetComponentInChildren <HorizontalLayoutGroup>().padding = new RectOffset(6, 6, 0, 0);
                    addedLink = true;
                }
                if (links?.ProjectSource != null)
                {
                    linkSourceButton = BeatSaberUI.CreateUIButton(rowTransform, "QuitButton", buttonText: "Source",
                                                                  onClick: () => Process.Start(links.ProjectSource.ToString()));
                    linkSourceButton.GetComponentInChildren <HorizontalLayoutGroup>().padding = new RectOffset(6, 6, 0, 0);
                    addedLink = true;
                }
                if (links?.Donate != null)
                {
                    linkDonateButton = BeatSaberUI.CreateUIButton(rowTransform, "QuitButton", buttonText: "Donate",
                                                                  onClick: () => Process.Start(links.Donate.ToString()));
                    linkDonateButton.GetComponentInChildren <HorizontalLayoutGroup>().padding = new RectOffset(6, 6, 0, 0);
                    addedLink = true;
                }
                if (moreInfoLink != null)
                {
                    linkDonateButton = BeatSaberUI.CreateUIButton(rowTransform, "QuitButton", buttonText: "More Info",
                                                                  onClick: () => Process.Start(moreInfoLink.ToString()));
                    linkDonateButton.GetComponentInChildren <HorizontalLayoutGroup>().padding = new RectOffset(6, 6, 0, 0);
                    addedLink = true;
                }
            }
            if (UpdateInfo != null && !addedLink)
            {
                StartCoroutine(GetMoreInfoLink());
            }
        }
コード例 #16
0
        public MockPartyViewController()
        {
            _partyFlowCoordinator = Resources.FindObjectsOfTypeAll <PartyFreePlayFlowCoordinator>().FirstOrDefault();
            LevelListViewController level = ReflectionUtil.GetPrivateField <LevelListViewController>(_partyFlowCoordinator, "_levelListViewController");

            detail = ReflectionUtil.GetPrivateField <StandardLevelDetailViewController>(_partyFlowCoordinator, "_levelDetailViewController");
            BeatmapDifficultyViewController beatmap = ReflectionUtil.GetPrivateField <BeatmapDifficultyViewController>(_partyFlowCoordinator, "_beatmapDifficultyViewController");

            _gameplaySetupViewController = ReflectionUtil.GetPrivateField <GameplaySetupViewController>(_partyFlowCoordinator, "_gameplaySetupViewController");

            level.didActivateEvent += (first, type) => {
                if (Data.Steam.SteamAPI.GetConnectionState() != SteamAPI.ConnectionState.CONNECTED || !_partyFlowCoordinator || !_partyFlowCoordinator.isActivated)
                {
                    return;
                }
                _partyFlowCoordinator.InvokePrivateMethod("SetRightScreenViewController", new object[] { MultiplayerLobby.Instance.rightViewController, true });
            };
            level.didSelectLevelEvent += didSelectLevel;

            beatmap.didSelectDifficultyEvent += didSelectBeatmap;
            mPlay = BeatSaberUI.CreateUIButton(detail.rectTransform, "CreditsButton", new Vector2(0f, -24f), new Vector2(40, 9f));

            mPlay.SetButtonText("Play with Lobby");
            mPlay.SetButtonTextSize(5f);
            mPlay.gameObject.SetActive(false);
            mPlay.ToggleWordWrapping(false);

            mPlay.onClick.AddListener(didSelectPlay);

            _mainMenuController = Resources.FindObjectsOfTypeAll <MainMenuViewController>().FirstOrDefault();
            Button    partyButton = ReflectionUtil.GetPrivateField <Button>(_mainMenuController, "_partyButton");
            HoverHint hint        = Resources.FindObjectsOfTypeAll <HoverHint>().Where(x => x.text == "Play with your friends locally!").First();

            _mainMenuController.didActivateEvent += (first, type) =>
            {
                if (Data.Steam.SteamAPI.GetConnectionState() != SteamAPI.ConnectionState.CONNECTED)
                {
                    partyButton.SetButtonText("Party");
                    if (hint)
                    {
                        hint.text = "Play with your friends locally!";
                    }
                }
                else
                {
                    partyButton.SetButtonText("Online Lobby");
                    if (hint)
                    {
                        hint.text = "Play with your friends in your steam lobby!";
                    }
                }
            };
        }
コード例 #17
0
 public static void AddButton(string buttonText, UnityAction onClick, Sprite icon = null)
 {
     lock (Instance)
     {
         if (buttonsInCurrentRow >= ButtonsPerRow)
         {
             currentRow          = AddRow();
             buttonsInCurrentRow = 0;
         }
         Button newButton = BeatSaberUI.CreateUIButton(currentRow as RectTransform, "QuitButton", onClick, buttonText, icon);
         buttonsInCurrentRow++;
     }
 }
コード例 #18
0
        public void CreateButtons()
        {
            AddFollowerButton = BeatSaberUI.CreateUIButton(rectTransform, "OkButton", new Vector2(43, 30));
            AddFollowerButton.ToggleWordWrapping(false);
            AddFollowerButton.SetButtonText("Add");
            AddFollowerButton.onClick.AddListener(delegate { AddFriendButtonPressed.Invoke(); });

            RemoveFollowerButton = BeatSaberUI.CreateUIButton(rectTransform, "OkButton", new Vector2(43, 20));
            RemoveFollowerButton.ToggleWordWrapping(false);
            RemoveFollowerButton.SetButtonText("Delete");
            RemoveFollowerButton.interactable = false;
            RemoveFollowerButton.onClick.AddListener(delegate { RemoveFollower(_lastSelectedRow); });
        }
コード例 #19
0
        private static IEnumerator AddMenuButtonListButton()
        {
            yield return(_bottomPanelExists);

            lock (Instance)
            {
                var bottomPanel = GameObject.Find("MainMenuViewController/BottomPanel").transform as RectTransform;
                var buttonRow   = bottomPanel.Find("Buttons") as RectTransform;

                Button newButton = BeatSaberUI.CreateUIButton(buttonRow as RectTransform, "QuitButton", () => Instance.PresentList(), "Mods", null);
                buttonRow.Find("QuitButton").SetAsLastSibling();
            }
        }
コード例 #20
0
        private void AddButtonToMainMenu(MenuButton button)
        {
            if (buttonsInCurrentRow >= ButtonsPerRow)
            {
                AddRow();
            }

            Button newButton = BeatSaberUI.CreateUIButton(currentRow, "QuitButton", button.onClick, button.text, button.icon);

            newButton.GetComponentInChildren <HorizontalLayoutGroup>().padding = new RectOffset(6, 6, 0, 0);
            newButton.name = button.text;
            buttonsInCurrentRow++;
        }
        protected override void DidActivate(bool firstActivation, ActivationType activationType)
        {
            if (firstActivation)
            {
                BeatSaberUI.CreateBackButton(this.rectTransform, () => BackButtonPressed?.Invoke());
                _loadingSpinner = BeatSaberUI.CreateLoadingSpinner(this.rectTransform);

                var headerRectTransform = Instantiate(Resources.FindObjectsOfTypeAll <RectTransform>()
                                                      .First(x => x.name == "HeaderPanel" && x.parent.name == "PlayerSettingsViewController"), this.rectTransform);
                _header = headerRectTransform.gameObject;

                _resultsText                    = BeatSaberUI.CreateText(this.rectTransform, _placeholderResultsText, Vector2.zero, Vector2.zero);
                _resultsText.alignment          = TextAlignmentOptions.Center;
                _resultsText.enableWordWrapping = true;
                _forceButton                    = BeatSaberUI.CreateUIButton(this.rectTransform, "CancelButton", new Vector2(59f, -32f), new Vector2(36f, 10f), () => ForceShowButtonPressed?.Invoke(), "Force Show Results");

                _lastSearchButton = BeatSaberUI.CreateUIButton(this.rectTransform, "CancelButton", new Vector2(59f, -32f), new Vector2(36f, 10f), () => LastSearchButtonPressed?.Invoke(), "<color=#FFFFCC>Redo Last Search</color>");
                (_lastSearchButton as HMUI.NoTransitionsButton).selectionStateDidChangeEvent += delegate(HMUI.NoTransitionsButton.SelectionState selectionState)
                {
                    var text = _lastSearchButton.GetComponentInChildren <TextMeshProUGUI>();
                    if (selectionState == HMUI.NoTransitionsButton.SelectionState.Highlighted)
                    {
                        text.text = "<color=#444400>Redo Last Search</color>";
                    }
                    else
                    {
                        text.text = "<color=#FFFFCC>Redo Last Search</color>";
                    }
                };
                _lastSearchText           = BeatSaberUI.CreateText(this.rectTransform, "", new Vector2(23f, -31.5f), new Vector2(30f, 8f));
                _lastSearchText.fontSize  = 3.5f;
                _lastSearchText.color     = new Color(1f, 1f, 1f, 0.3f);
                _lastSearchText.alignment = TextAlignmentOptions.TopRight;

                _songPreviewPlayer = Instantiate(Resources.FindObjectsOfTypeAll <SongPreviewPlayer>().First());
            }
            else
            {
                _resultsText.text     = _placeholderResultsText;
                _resultsText.fontSize = 6f;
            }

            AdjustElements();

            _loadingSpinner.SetActive(false);
            _resultsText.gameObject.SetActive(!PluginConfig.CompactSearchMode);
            _forceButton.gameObject.SetActive(false);
            _lastSearchButton.gameObject.SetActive(false);
            _lastSearchText.gameObject.SetActive(false);
            SetHeaderActive(!PluginConfig.CompactSearchMode);
        }
コード例 #22
0
        public override TableCell CellForIdx(int row)
        {
            TableCell _tableCell = Instantiate(_modListTableCellInstance);

            for (int i = 0; i < buttonsPerRow; i++)
            {
                int index = row * buttonsPerRow + i;
                if (buttons.Count > index)
                {
                    var menuButton = buttons.ElementAt(index);

                    RectTransform container = new GameObject("container", typeof(RectTransform)).GetComponent <RectTransform>();
                    container.SetParent(_tableCell.transform);
                    container.sizeDelta = buttonSize;

                    Button newButton = BeatSaberUI.CreateUIButton(container, "QuitButton", new Vector2(0, 0), buttonSize, menuButton.onClick, menuButton.text, menuButton.icon);
                    newButton.GetComponentInChildren <HorizontalLayoutGroup>().padding = new RectOffset(6, 8, 0, 0);
                    newButton.GetComponentInChildren <TextMeshProUGUI>().lineSpacing   = -65;
                    newButton.name = menuButton.text;
                    if (menuButton.hintText != String.Empty)
                    {
                        BeatSaberUI.AddHintText(newButton.transform as RectTransform, menuButton.hintText);
                    }
                    menuButton.buttons.Add(newButton);
                    newButton.interactable = menuButton.interactable;

                    //  sub button
                    var pinButton = BeatSaberUI.CreateUIButton(container, "QuitButton", new Vector2(-6, 0), new Vector2(8, 8), null, "", null);

                    if (_highlightedClip == null)
                    {
                        _highlightedClip = pinButton.GetComponent <ButtonStaticAnimations>().GetPrivateField <AnimationClip>("_highlightedClip");
                    }
                    if (_normalClip == null)
                    {
                        _normalClip = pinButton.GetComponent <ButtonStaticAnimations>().GetPrivateField <AnimationClip>("_normalClip");
                    }

                    PinButtonPushEffect(pinButton, menuButton);
                    (pinButton.transform as RectTransform).anchorMin                   = new Vector2(1, 0.5f);
                    (pinButton.transform as RectTransform).anchorMax                   = new Vector2(1, 0.5f);
                    (pinButton.transform as RectTransform).anchoredPosition            = new Vector2(-4, 0);
                    pinButton.GetComponentInChildren <HorizontalLayoutGroup>().padding = new RectOffset(0, 0, 0, 0);
                    pinButton.onClick.AddListener(() => { pinButtonPushed?.Invoke(menuButton); PinButtonPushEffect(pinButton, menuButton); });
                }
            }

            return(_tableCell);
        }
コード例 #23
0
        private void FirstActivation()
        {
            // add some buttons
            RectTransform verticalLayout = UIFunctions.CreateVerticalLayoutObj(new RectOffset(6, 6, 6, 6), 1, TextAnchor.UpperCenter);

            UIFunctions.SetRect(verticalLayout, transform, new Vector2(0, 1), new Vector2(0, 1), new Vector2(85, -40), new Vector2(150, 80));

            UIFunctions.CreateModelSwapPanel(verticalLayout, PartEditor.BladeList, "BLADE MODEL");
            UIFunctions.CreateModelSwapPanel(verticalLayout, PartEditor.GuardList, "GUARD MODEL");
            UIFunctions.CreateModelSwapPanel(verticalLayout, PartEditor.HandleList, "HANDLE MODEL");
            UIFunctions.CreateModelSwapPanel(verticalLayout, PartEditor.PommelList, "POMMEL MODEL");;

            UIFunctions.CreateModelSwapPanel(verticalLayout, PartEditor.AccAList, "ACCESSORY A MODEL");
            UIFunctions.CreateModelSwapPanel(verticalLayout, PartEditor.AccBList, "ACCESSORY B MODEL");

            BeatSaberUI.CreateUIButton(transform.GetComponent <RectTransform>(), "PlayButton", new Vector2(69, 33), new Vector2(16, 16), delegate() { SaberForgeUI.HelpMenu.Present(); }, "?");
        }
コード例 #24
0
        private void FirstActivation()
        {
            string helpText = "<size=150%><b>Instructions</b> \n" +
                              "\n" +
                              "<size=120%>1 - Adjust your sabers using the options provided in Saber Forge.\n" +
                              "\n" +
                              "2 - Open the Custom Sabers mod menu and choose the 'Saber Forge' sabers. \n" +
                              "\n" +
                              "3 - Hit bloq"
            ;

            RectTransform verticalLayout = UIFunctions.CreateVerticalLayoutObj(new RectOffset(6, 6, 6, 6), 1, TextAnchor.UpperCenter);

            UIFunctions.SetRect(verticalLayout, transform, new Vector2(0, 1), new Vector2(0, 1), new Vector2(85, -40), new Vector2(150, 80));

            TextMeshProUGUI matLabelText = BeatSaberUI.CreateText(verticalLayout, helpText, new Vector2(0, 0), new Vector2(100, 80));

            //format
            matLabelText.alignment = TextAlignmentOptions.Top;

            //donate button
            Button donate = BeatSaberUI.CreateUIButton(transform as RectTransform, "PlayButton", new Vector2(-50, -33), new Vector2(50, 16), null, "DONATE <3");

            donate.onClick.AddListener(() => { GoTo("https://ko-fi.com/frostdragonliz", donate); });
            BeatSaberUI.AddHintText(donate.transform as RectTransform, "Kofi $$ will go towards future mod and part development, ta!");


            //reload assets button TO DO
            //  Button reload = BeatSaberUI.CreateUIButton(transform as RectTransform, "PlayButton", new Vector2(0, -33), new Vector2(50, 16), null, "USER TEXTURES");
            //  reload.onClick.AddListener(() => { Plugin.ReloadAssets(); });
            //  BeatSaberUI.AddHintText(reload.transform as RectTransform, "Force a reload of SaberForge Assets");

            //tutes button
            Button tutorials = BeatSaberUI.CreateUIButton(transform as RectTransform, "PlayButton", new Vector2(8, -33), new Vector2(50, 16), null, "TUTORIALS");

            tutorials.onClick.AddListener(() => { GoTo("https://www.youtube.com/playlist?list=PLyJh_4G6B76PPdL-rAmb44-475D0_0UBs", tutorials); });
            BeatSaberUI.AddHintText(tutorials.transform as RectTransform, "YouTube Tutorials");


            //github button
            Button github = BeatSaberUI.CreateUIButton(transform as RectTransform, "PlayButton", new Vector2(60, -33), new Vector2(50, 16), null, "SOURCE");

            github.onClick.AddListener(() => { GoTo("https://github.com/lizfrost/SaberForge", github); });
            BeatSaberUI.AddHintText(github.transform as RectTransform, "Source and mod info");
        }
コード例 #25
0
        protected override void DidActivate(bool firstActivation, ActivationType activationType)
        {
            if (firstActivation)
            {
                _prevChannelButton = BeatSaberUI.CreateUIButton(rectTransform, "QuitButton", new Vector2(-55f, 34f), () => { prevPressedEvent?.Invoke(); }, "<<");
                _nextChannelButton = BeatSaberUI.CreateUIButton(rectTransform, "QuitButton", new Vector2(65f, 34f), () => { nextPressedEvent?.Invoke(); }, ">>");

                _loadingIndicator = BeatSaberUI.CreateLoadingSpinner(rectTransform);
                (_loadingIndicator.transform as RectTransform).anchoredPosition = new Vector2(4.5f, 4.5f);

                _container = new GameObject("Container", typeof(RectTransform));
                _container.transform.SetParent(rectTransform, false);

                _joinButton = BeatSaberUI.CreateUIButton(rectTransform, "QuitButton", new Vector2(4.5f, -30f), () => { joinPressedEvent?.Invoke(currentChannel); }, "Join");
                _joinButton.ToggleWordWrapping(false);
                _joinButton.transform.SetParent(_container.transform, true);

                _channelCover = new GameObject("CustomUIImage").AddComponent <Image>();

                _channelCover.material = Sprites.NoGlowMat;
                _channelCover.rectTransform.SetParent(rectTransform, false);
                _channelCover.rectTransform.anchorMin        = new Vector2(0.5f, 0.5f);
                _channelCover.rectTransform.anchorMax        = new Vector2(0.5f, 0.5f);
                _channelCover.rectTransform.anchoredPosition = new Vector2(4.5f, 4.5f);
                _channelCover.rectTransform.sizeDelta        = new Vector2(32f, 32f);
                _channelCover.sprite = UIUtilities.BlankSprite;
                _channelCover.rectTransform.SetParent(_container.transform, true);

                _channelNameText              = BeatSaberUI.CreateText(rectTransform, "CHANNEL NAME", new Vector2(4.5f, 35.50f));
                _channelNameText.alignment    = TextAlignmentOptions.Top;
                _channelNameText.overflowMode = TextOverflowModes.Overflow;
                _channelNameText.lineSpacing  = -46f;
                _channelNameText.fontSize     = 10;
                _channelNameText.transform.SetParent(_container.transform, true);

                _playerCountText           = BeatSaberUI.CreateText(rectTransform, "Players: 0", new Vector2(4.5f, -15f));
                _playerCountText.alignment = TextAlignmentOptions.Center;
                _playerCountText.transform.SetParent(_container.transform, true);

                _nowPlayingText           = BeatSaberUI.CreateText(rectTransform, "Now playing: UNKNOWN", new Vector2(4.5f, -21f));
                _nowPlayingText.alignment = TextAlignmentOptions.Center;
                _nowPlayingText.transform.SetParent(_container.transform, true);
            }
            _container.SetActive(false);
        }
コード例 #26
0
ファイル: Util.cs プロジェクト: cvrebeatsaber/CVREReplayMod
        public static void CreateButton(string text, UnityAction onClick, string hintText)
        {
            Logger.log.Debug("Creating button with message: " + text);
            ResultsViewController controller = UnityEngine.Object.FindObjectOfType <ResultsViewController>();
            RectTransform         panel      = controller.GetComponent <RectTransform>();

            if (panel == null)
            {
                return;
            }
            Logger.log.Debug("Non-null panel!");

            Button button = BeatSaberUI.CreateUIButton(panel, CopyButton, onClick, text);

            panel.Find(CopyButton).SetAsLastSibling();

            BeatSaberUI.AddHintText(button.transform as RectTransform, hintText);
        }
コード例 #27
0
        protected override void DidActivate(bool firstActivation, ActivationType type)
        {
            base.DidActivate(firstActivation, type);

            if (firstActivation && type == ActivationType.AddedToHierarchy)
            {
                _backButton = BeatSaberUI.CreateBackButton(rectTransform as RectTransform, delegate() { backButtonPressed?.Invoke(); });

                RectTransform container = new GameObject("VideoListContainer", typeof(RectTransform)).transform as RectTransform;
                container.SetParent(rectTransform, false);
                container.sizeDelta = new Vector2(105f, 0f);

                _searchButton = BeatSaberUI.CreateUIButton(rectTransform, "CreditsButton", new Vector2(60, -20), new Vector2(30, 8), () =>
                {
                    searchButtonPressed?.Invoke();
                }, "Refine");

                _downloadButton = BeatSaberUI.CreateUIButton(rectTransform, "CreditsButton", new Vector2(60, -30), new Vector2(30, 8), () =>
                {
                    downloadButtonPressed?.Invoke(resultsList[_lastSelectedRow]);
                }, "Download");
//                _downloadButton.GetComponentInChildren<HorizontalLayoutGroup>().padding = new RectOffset(0, 0, 0, 0);

                _loadingIndicator = BeatSaberUI.CreateLoadingSpinner(rectTransform);
                (_loadingIndicator.transform as RectTransform).anchorMin        = new Vector2(0.5f, 0.5f);
                (_loadingIndicator.transform as RectTransform).anchorMax        = new Vector2(0.5f, 0.5f);
                (_loadingIndicator.transform as RectTransform).anchoredPosition = new Vector2(0f, 0f);
                _loadingIndicator.SetActive(true);

                _customListTableView.didSelectCellWithIdxEvent -= DidSelectRowEvent;
                _customListTableView.didSelectCellWithIdxEvent += _songsTableView_DidSelectRowEvent;

                (_customListTableView.transform.parent as RectTransform).sizeDelta = new Vector2(105, 0);
                (_customListTableView.transform as RectTransform).anchorMin        = new Vector2(0f, 0.5f);
                (_customListTableView.transform as RectTransform).anchorMax        = new Vector2(1f, 0.5f);
                (_customListTableView.transform as RectTransform).sizeDelta        = new Vector2(0f, 60f);
                (_customListTableView.transform as RectTransform).anchoredPosition = new Vector3(-10f, 0f);
            }
            else
            {
                _customListTableView.ReloadData();
            }
            _downloadButton.interactable = false;
        }
コード例 #28
0
        private void AddButtonToMainMenu(MenuButton button)
        {
            if (buttonsInCurrentRow >= ButtonsPerRow)
            {
                AddRow();
            }

            Button newButton = BeatSaberUI.CreateUIButton(currentRow, "QuitButton", button.onClick, button.text, button.icon);

            newButton.GetComponentInChildren <HorizontalLayoutGroup>().padding = new RectOffset(6, 6, 0, 0);
            newButton.name = button.text;
            if (button.hintText != String.Empty)
            {
                BeatSaberUI.AddHintText(newButton.transform as RectTransform, button.hintText);
            }
            button.buttons.Add(newButton);
            newButton.interactable = button.interactable;
            buttonsInCurrentRow++;
        }
コード例 #29
0
        private void AddArrowButton(RectTransform parent, UnityAction pressed = null, Vector2?position = null, bool downArrow = false)
        {
            if (position == null)
            {
                position = Vector2.zero;
            }
            var originalUpArrow = Resources.FindObjectsOfTypeAll <Button>().Last(x => x.name == "PageUpButton");

            var button = BeatSaberUI.CreateUIButton(parent, "BeatmapEditorButton", (Vector2)position, new Vector2(12.5f, 7.75f), pressed);

            Destroy(button.GetComponentsInChildren <RectTransform>(true).FirstOrDefault(x => x.name == "Text").gameObject);
            Destroy(button.GetComponentsInChildren <Image>().First(x => x.name == "Stroke"));
            var img = button.GetComponentsInChildren <Image>(true).FirstOrDefault(x => x.name == "Icon");

            img.sprite = originalUpArrow.GetComponentsInChildren <Image>().FirstOrDefault(x => x.name == "Arrow").sprite;
            if (!downArrow)
            {
                img.rectTransform.Rotate(0, 0, 180);
            }
        }
コード例 #30
0
        private void CreateButtons()
        {
            if (EditNameButton == null)
            {
                EditNameButton = BeatSaberUI.CreateUIButton(rectTransform, "OkButton", new Vector2(-55, 25));
                EditNameButton.ToggleWordWrapping(false);
                EditNameButton.SetButtonText("Edit Name");
                EditNameButton.SetButtonTextSize(4);
                EditNameButton.onClick.AddListener(delegate { NameButtonPressed.Invoke(_nameText.text); });
            }

            if (EditProfileButton == null)
            {
                EditProfileButton = BeatSaberUI.CreateUIButton(rectTransform, "OkButton", new Vector2(-55, 15));
                EditProfileButton.ToggleWordWrapping(false);
                EditProfileButton.SetButtonText("Change Image");
                EditProfileButton.SetButtonTextSize(3);
                EditProfileButton.onClick.AddListener(delegate { ImageButtonPressed.Invoke(); });
            }
        }