public void Init() { // Buttons _backButton = BeatSaberUI.CreateBackButton(rectTransform as RectTransform, delegate() { backButtonPressed?.Invoke(); }); _listButton = BeatSaberUI.CreateUIButton(rectTransform, "CreditsButton", new Vector2(60, 30), new Vector2(30, 8), () => { listButtonPressed?.Invoke(); }, "Search"); _previewButton = BeatSaberUI.CreateUIButton(rectTransform, "CreditsButton", new Vector2(60, -30), new Vector2(30, 8), () => { previewButtonPressed?.Invoke(); }, "Preview"); _loopButton = BeatSaberUI.CreateUIButton(rectTransform, "CreditsButton", new Vector2(60, -20), new Vector2(30, 8), () => { loopButtonPressed?.Invoke(); }, "Loop"); _addOffset = BeatSaberUI.CreateUIButton(rectTransform, "QuitButton", new Vector2(71, -10), new Vector2(8, 8), null, "+"); foreach (StackLayoutGroup stack in _addOffset.GetComponentsInChildren <StackLayoutGroup>()) { stack.childForceExpandHeight = false; stack.childForceExpandWidth = false; stack.padding = new RectOffset(0, 0, 0, 0); } _addOffset.GetComponentInChildren <HorizontalLayoutGroup>().padding = new RectOffset(0, 0, 0, 0); _addOffset.GetComponentInChildren <TextMeshProUGUI>().margin = new Vector4(0, 0, 0, 0); (_addOffset.transform.Find("Wrapper") as RectTransform).sizeDelta = new Vector2(8, 8); _subOffset = Instantiate(_addOffset, rectTransform); (_subOffset.transform as RectTransform).anchoredPosition = new Vector2(49, -10); _subOffset.SetButtonText("-"); _subOffset.onClick.AddListener(() => { subOffsetPressed?.Invoke(); }); _addOffset.onClick.AddListener(() => { addOffsetPressed?.Invoke(); }); _offsetText = BeatSaberUI.CreateText(rectTransform, "?ms", new Vector2(60, -10)); _offsetText.rectTransform.sizeDelta = new Vector2(14, 8); _offsetText.alignment = TextAlignmentOptions.Center; var _offsetTitle = BeatSaberUI.CreateText(rectTransform, "Offset (ms)", new Vector2(60, -3)); _offsetTitle.rectTransform.sizeDelta = new Vector2(30, 8); _offsetTitle.alignment = TextAlignmentOptions.Center; // Video data _thumbnail = Instantiate(Resources.FindObjectsOfTypeAll <Image>().First(x => x.name == "CoverImage"), rectTransform); _thumbnail.rectTransform.anchorMin = new Vector2(0.5f, 0.5f); _thumbnail.rectTransform.anchorMax = new Vector2(0.5f, 0.5f); var height = 30f; var width = 16f / 9f * height; _thumbnail.rectTransform.anchoredPosition = new Vector2(0 - width / 2, 20 - height / 2); _thumbnail.rectTransform.sizeDelta = new Vector2(width, height); _thumbnail.preserveAspect = false; _thumbnail.sprite = null; _thumbnail.transform.SetAsLastSibling(); _title = BeatSaberUI.CreateText(rectTransform, "TITLE", new Vector2(0, -1)); _title.alignment = TextAlignmentOptions.Top; _title.maxVisibleLines = 1; _title.fontSize = 6; _title.rectTransform.sizeDelta = new Vector2(100, 10); _uploader = BeatSaberUI.CreateText(rectTransform, "UPLOADER", new Vector2(0, -7)); _uploader.alignment = TextAlignmentOptions.Left; _uploader.color = Color.white * 0.9f; _uploader.rectTransform.sizeDelta = new Vector2(80, 5); _duration = BeatSaberUI.CreateText(rectTransform, "[00:00]", new Vector2(0, -7)); _duration.alignment = TextAlignmentOptions.Right; _duration.color = Color.white * 0.9f; _duration.rectTransform.sizeDelta = new Vector2(80, 5); _description = BeatSaberUI.CreateText(rectTransform, "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", new Vector2(0, -14)); _description.alignment = TextAlignmentOptions.TopLeft; _description.rectTransform.sizeDelta = new Vector2(80, 10); _description.enableWordWrapping = true; _description.maxVisibleLines = 5; // Download Progress ring var _detailViewController = Resources.FindObjectsOfTypeAll <StandardLevelDetailViewController>().First(x => x.name == "StandardLevelDetailViewController"); var buttonsRect = _detailViewController.GetComponentsInChildren <RectTransform>().First(x => x.name == "Buttons"); var _playbutton = buttonsRect.GetComponentsInChildren <Button>().First(x => x.name == "PlayButton"); _progressButton = Instantiate(_playbutton, rectTransform); _progressButton.name = "DownloadProgress"; _progressButton.SetButtonText("100%"); (_progressButton.transform as RectTransform).anchorMax = new Vector2(0.5f, 0.5f); (_progressButton.transform as RectTransform).anchorMin = new Vector2(0.5f, 0.5f); (_progressButton.transform as RectTransform).anchoredPosition = new Vector2(0, 20); (_progressButton.transform as RectTransform).sizeDelta = new Vector2(16, 16); _progressButton.interactable = false; _progressRingGlow = _progressButton.GetComponentsInChildren <Image>().First(x => x.name == "Glow"); _progressRingGlow.gameObject.SetActive(false); var hlg = _progressButton.GetComponentsInChildren <HorizontalLayoutGroup>().First(x => x.name == "Content"); hlg.padding = new RectOffset(2, 2, 2, 2); _progressCircle = _progressButton.GetComponentsInChildren <Image>().First(x => x.name == "Stroke"); _progressCircle.type = Image.Type.Filled; _progressCircle.fillMethod = Image.FillMethod.Radial360; _progressCircle.fillAmount = 1f; _progressButton.transform.SetParent(_thumbnail.transform); _hoverHint = BeatSaberUI.AddHintText(_thumbnail.transform as RectTransform, "Banana banana banana"); }
protected override void DidActivate(bool firstActivation, ActivationType activationType) { if (firstActivation) { if (activationType == ActivationType.AddedToHierarchy) { _serverTableCellInstance = Resources.FindObjectsOfTypeAll <LevelListTableCell>().First(x => (x.name == "LevelListTableCell")); _selectText = BeatSaberUI.CreateText(rectTransform, "Select ServerHub", new Vector2(0f, 35.5f)); _selectText.alignment = TextAlignmentOptions.Center; _selectText.fontSize = 7f; _backButton = BeatSaberUI.CreateBackButton(rectTransform); _backButton.onClick.AddListener(delegate() { didFinishEvent?.Invoke(); }); _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, -4.5f); (_pageUpButton.transform as RectTransform).sizeDelta = new Vector2(40f, 10f); _pageUpButton.interactable = true; _pageUpButton.onClick.AddListener(delegate() { _serverHubsTableView.GetPrivateField <TableViewScroller>("_scroller").PageScrollUp(); }); _pageUpButton.interactable = true; _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, -1f); (_pageDownButton.transform as RectTransform).sizeDelta = new Vector2(40f, 10f); _pageDownButton.interactable = true; _pageDownButton.onClick.AddListener(delegate() { _serverHubsTableView.GetPrivateField <TableViewScroller>("_scroller").PageScrollDown(); }); _pageDownButton.interactable = true; RectTransform container = new GameObject("Container", typeof(RectTransform)).transform as RectTransform; container.SetParent(rectTransform, false); container.anchorMin = new Vector2(0.3f, 0.5f); container.anchorMax = new Vector2(0.7f, 0.5f); container.sizeDelta = new Vector2(0f, 60f); container.anchoredPosition = new Vector2(0f, -3f); var tableGameObject = new GameObject("CustomTableView"); tableGameObject.SetActive(false); _serverHubsTableView = tableGameObject.AddComponent <TableView>(); _serverHubsTableView.gameObject.AddComponent <RectMask2D>(); _serverHubsTableView.transform.SetParent(container, false); _serverHubsTableView.SetPrivateField("_isInitialized", false); _serverHubsTableView.SetPrivateField("_preallocatedCells", new TableView.CellsGroup[0]); RectTransform viewport = new GameObject("Viewport").AddComponent <RectTransform>(); viewport.SetParent(_serverHubsTableView.transform, false); (viewport.transform as RectTransform).sizeDelta = new Vector2(0f, 0f); (viewport.transform as RectTransform).anchorMin = new Vector2(0f, 0f); (viewport.transform as RectTransform).anchorMax = new Vector2(1f, 1f); _serverHubsTableView.GetComponent <ScrollRect>().viewport = viewport; _serverHubsTableView.Init(); (_serverHubsTableView.transform as RectTransform).anchorMin = new Vector2(0f, 0f); (_serverHubsTableView.transform as RectTransform).anchorMax = new Vector2(1f, 1f); (_serverHubsTableView.transform as RectTransform).sizeDelta = new Vector2(0f, 0f); (_serverHubsTableView.transform as RectTransform).anchoredPosition = new Vector3(0f, 0f); tableGameObject.SetActive(true); _serverHubsTableView.didSelectCellWithIdxEvent += ServerHubs_didSelectRowEvent; _serverHubsTableView.dataSource = this; _serverHubsTableView.ScrollToCellWithIdx(0, TableViewScroller.ScrollPositionType.Beginning, false); } } else { _serverHubsTableView.dataSource = this; } }
protected override void DidActivate(bool firstActivation, ActivationType type) { if (firstActivation && type == ActivationType.AddedToHierarchy) { _backButton = BeatSaberUI.CreateBackButton(rectTransform, () => { didFinishEvent?.Invoke(null); }); _presetsTableCellInstance = Resources.FindObjectsOfTypeAll <LevelListTableCell>().First(x => (x.name == "LevelListTableCell")); _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, -14f); (_pageUpButton.transform as RectTransform).sizeDelta = new Vector2(40f, 10f); _pageUpButton.interactable = true; _pageUpButton.onClick.AddListener(delegate() { _presetsTableView.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, 8f); (_pageDownButton.transform as RectTransform).sizeDelta = new Vector2(40f, 10f); _pageDownButton.interactable = true; _pageDownButton.onClick.AddListener(delegate() { _presetsTableView.PageScrollDown(); }); _pageDownButton.interactable = false; RectTransform container = new GameObject("Content", typeof(RectTransform)).transform as RectTransform; container.SetParent(rectTransform, false); container.anchorMin = new Vector2(0.3f, 0.5f); container.anchorMax = new Vector2(0.7f, 0.5f); container.sizeDelta = new Vector2(0f, 60f); container.anchoredPosition = new Vector2(0f, -3f); _presetsTableView = new GameObject("CustomTableView").AddComponent <TableView>(); _presetsTableView.gameObject.AddComponent <RectMask2D>(); _presetsTableView.transform.SetParent(container, false); _presetsTableView.SetPrivateField("_isInitialized", false); _presetsTableView.SetPrivateField("_preallocatedCells", new TableView.CellsGroup[0]); _presetsTableView.Init(); (_presetsTableView.transform as RectTransform).anchorMin = new Vector2(0f, 0f); (_presetsTableView.transform as RectTransform).anchorMax = new Vector2(1f, 1f); (_presetsTableView.transform as RectTransform).sizeDelta = new Vector2(0f, 0f); (_presetsTableView.transform as RectTransform).anchoredPosition = new Vector3(0f, 0f); ReflectionUtil.SetPrivateField(_presetsTableView, "_pageUpButton", _pageUpButton); ReflectionUtil.SetPrivateField(_presetsTableView, "_pageDownButton", _pageDownButton); _presetsTableView.didSelectCellWithIdxEvent += SongsTableView_DidSelectRow; _presetsTableView.dataSource = this; _selectPresetText = BeatSaberUI.CreateText(rectTransform, "Select preset", new Vector2(0f, 36f)); _selectPresetText.fontSize = 8f; _selectPresetText.alignment = TextAlignmentOptions.Center; _selectPresetText.rectTransform.sizeDelta = new Vector2(120f, 6f); } else { _presetsTableView.ReloadData(); } }
private void FirstActivation() { LoadAllAvatars(); _tableCellTemplate = Resources.FindObjectsOfTypeAll <LevelListTableCell>().First(x => x.name == "LevelListTableCell"); RectTransform container = new GameObject("AvatarsListContainer", typeof(RectTransform)).transform as RectTransform; container.SetParent(rectTransform, false); container.sizeDelta = new Vector2(70f, 0f); var tableViewObject = new GameObject("AvatarsListTableView"); tableViewObject.SetActive(false); _tableView = tableViewObject.AddComponent <TableView>(); _tableView.gameObject.AddComponent <RectMask2D>(); _tableView.transform.SetParent(container, false); (_tableView.transform as RectTransform).anchorMin = new Vector2(0f, 0f); (_tableView.transform as RectTransform).anchorMax = new Vector2(1f, 1f); (_tableView.transform as RectTransform).sizeDelta = new Vector2(0f, 60f); (_tableView.transform as RectTransform).anchoredPosition = new Vector3(0f, 0f); _tableView.SetPrivateField("_preallocatedCells", new TableView.CellsGroup[0]); _tableView.SetPrivateField("_isInitialized", false); _tableView.dataSource = this; _tableView.didSelectCellWithIdxEvent += _TableView_DidSelectRowEvent; tableViewObject.SetActive(true); _pageUpButton = Instantiate(Resources.FindObjectsOfTypeAll <Button>().First(x => (x.name == "PageUpButton")), container, false); (_pageUpButton.transform as RectTransform).anchoredPosition = new Vector2(0f, 30f); _pageUpButton.interactable = true; _pageUpButton.onClick.AddListener(delegate() { _tableView.PageScrollUp(); }); _pageDownButton = Instantiate(Resources.FindObjectsOfTypeAll <Button>().First(x => (x.name == "PageDownButton")), container, false); (_pageDownButton.transform as RectTransform).anchoredPosition = new Vector2(0f, -30f); _pageDownButton.interactable = true; _pageDownButton.onClick.AddListener(delegate() { _tableView.PageScrollDown(); }); _versionNumber = BeatSaberUI.CreateText(rectTransform, Plugin.Instance.Version, new Vector2(-10f, 10f)); (_versionNumber.transform as RectTransform).anchorMax = new Vector2(1f, 0f); (_versionNumber.transform as RectTransform).anchorMin = new Vector2(1f, 0f); _versionNumber.fontSize = 5; _versionNumber.color = Color.white; if (_backButton == null) { _backButton = BeatSaberUI.CreateBackButton(rectTransform as RectTransform); _backButton.onClick.AddListener(delegate() { onBackPressed(); DestroyPreview(); }); } }
protected override void DidActivate(bool firstActivation, ActivationType activationType) { if (firstActivation) { if (activationType == ActivationType.AddedToHierarchy) { _serverTableCellInstance = Resources.FindObjectsOfTypeAll <LevelListTableCell>().First(x => (x.name == "LevelListTableCell")); _selectText = BeatSaberUI.CreateText(rectTransform, "Select ServerHub", new Vector2(0f, 35.5f)); _selectText.alignment = TextAlignmentOptions.Center; _selectText.fontSize = 7f; _backButton = BeatSaberUI.CreateBackButton(rectTransform); _backButton.onClick.AddListener(delegate() { didFinishEvent?.Invoke(); }); _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, -14.5f); (_pageUpButton.transform as RectTransform).sizeDelta = new Vector2(40f, 10f); _pageUpButton.interactable = true; _pageUpButton.onClick.AddListener(delegate() { _serverHubsTableView.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, 9f); (_pageDownButton.transform as RectTransform).sizeDelta = new Vector2(40f, 10f); _pageDownButton.interactable = true; _pageDownButton.onClick.AddListener(delegate() { _serverHubsTableView.PageScrollDown(); }); _pageDownButton.interactable = false; _serverHubsTableView = new GameObject().AddComponent <TableView>(); _serverHubsTableView.transform.SetParent(rectTransform, false); _serverHubsTableView.SetPrivateField("_isInitialized", false); _serverHubsTableView.SetPrivateField("_preallocatedCells", new TableView.CellsGroup[0]); _serverHubsTableView.Init(); RectMask2D viewportMask = Instantiate(Resources.FindObjectsOfTypeAll <RectMask2D>().First(), _serverHubsTableView.transform, false); viewportMask.transform.DetachChildren(); _serverHubsTableView.GetComponentsInChildren <RectTransform>().First(x => x.name == "Content").transform.SetParent(viewportMask.rectTransform, false); (_serverHubsTableView.transform as RectTransform).anchorMin = new Vector2(0.3f, 0.5f); (_serverHubsTableView.transform as RectTransform).anchorMax = new Vector2(0.7f, 0.5f); (_serverHubsTableView.transform as RectTransform).sizeDelta = new Vector2(0f, 60f); (_serverHubsTableView.transform as RectTransform).anchoredPosition = new Vector3(0f, -3f); ReflectionUtil.SetPrivateField(_serverHubsTableView, "_pageUpButton", _pageUpButton); ReflectionUtil.SetPrivateField(_serverHubsTableView, "_pageDownButton", _pageDownButton); _serverHubsTableView.didSelectCellWithIdxEvent += ServerHubs_didSelectRowEvent; _serverHubsTableView.dataSource = this; _serverHubsTableView.ScrollToCellWithIdx(0, TableView.ScrollPositionType.Beginning, false); } } else { _serverHubsTableView.dataSource = this; } }
protected override void DidActivate(bool firstActivation, ActivationType 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); _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, -10f); (_pageUpButton.transform as RectTransform).sizeDelta = new Vector2(40f, 10f); _pageUpButton.interactable = true; _pageUpButton.onClick.AddListener(delegate() { _videosTableView.PageScrollUp(); }); _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, 10f); (_pageDownButton.transform as RectTransform).sizeDelta = new Vector2(40f, 10f); _pageDownButton.interactable = true; _pageDownButton.onClick.AddListener(delegate() { _videosTableView.PageScrollDown(); }); _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); _videoListTableCellInstance = Resources.FindObjectsOfTypeAll <LevelListTableCell>().First(x => (x.name == "LevelListTableCell")); _videosTableView = new GameObject().AddComponent <TableView>(); _videosTableView.transform.SetParent(container, false); _videosTableView.SetPrivateField("_isInitialized", false); _videosTableView.SetPrivateField("_preallocatedCells", new TableView.CellsGroup[0]); _videosTableView.Init(); RectMask2D viewportMask = Instantiate(Resources.FindObjectsOfTypeAll <RectMask2D>().First(), _videosTableView.transform, false); viewportMask.transform.DetachChildren(); _videosTableView.GetComponentsInChildren <RectTransform>().First(x => x.name == "Content").transform.SetParent(viewportMask.rectTransform, false); (_videosTableView.transform as RectTransform).anchorMin = new Vector2(0f, 0.5f); (_videosTableView.transform as RectTransform).anchorMax = new Vector2(1f, 0.5f); (_videosTableView.transform as RectTransform).sizeDelta = new Vector2(0f, 60f); (_videosTableView.transform as RectTransform).anchoredPosition = new Vector3(-10f, 0f); _videosTableView.dataSource = this; _videosTableView.didSelectRowEvent += _songsTableView_DidSelectRowEvent; } else { _videosTableView.ReloadData(); } _downloadButton.interactable = false; }
protected override void DidActivate(bool firstActivation, ActivationType type) { try { if (firstActivation) { ui = PlatformUI._instance; _songListTableCellInstance = Resources.FindObjectsOfTypeAll <LevelListTableCell>().First(x => (x.name == "LevelListTableCell")); RectTransform container = new GameObject("PlatformsListContainer", typeof(RectTransform)).transform as RectTransform; container.SetParent(rectTransform, false); container.sizeDelta = new Vector2(60f, 0f); _platformsTableView = new GameObject("PlatformsListTableView").AddComponent <TableView>(); _platformsTableView.gameObject.AddComponent <RectMask2D>(); _platformsTableView.transform.SetParent(container, false); (_platformsTableView.transform as RectTransform).anchorMin = new Vector2(0f, 0f); (_platformsTableView.transform as RectTransform).anchorMax = new Vector2(1f, 1f); (_platformsTableView.transform as RectTransform).sizeDelta = new Vector2(0f, 60f); (_platformsTableView.transform as RectTransform).anchoredPosition = new Vector3(0f, 0f); _platformsTableView.SetPrivateField("_preallocatedCells", new TableView.CellsGroup[0]); _platformsTableView.SetPrivateField("_isInitialized", false); _platformsTableView.dataSource = this; _platformsTableView.didSelectRowEvent += _PlatformTableView_DidSelectRowEvent; _pageUpButton = Instantiate(Resources.FindObjectsOfTypeAll <Button>().First(x => (x.name == "PageUpButton")), container, false); (_pageUpButton.transform as RectTransform).anchoredPosition = new Vector2(0f, 30f);//-14 _pageUpButton.interactable = true; _pageUpButton.onClick.AddListener(delegate() { _platformsTableView.PageScrollUp(); }); _pageDownButton = Instantiate(Resources.FindObjectsOfTypeAll <Button>().First(x => (x.name == "PageDownButton")), container, false); (_pageDownButton.transform as RectTransform).anchoredPosition = new Vector2(0f, -30f);//8 _pageDownButton.interactable = true; _pageDownButton.onClick.AddListener(delegate() { _platformsTableView.PageScrollDown(); }); _versionNumber = Instantiate(Resources.FindObjectsOfTypeAll <TextMeshProUGUI>().First(x => (x.name == "Text")), rectTransform, false); (_versionNumber.transform as RectTransform).anchoredPosition = new Vector2(-10f, 10f); (_versionNumber.transform as RectTransform).anchorMax = new Vector2(1f, 0f); (_versionNumber.transform as RectTransform).anchorMin = new Vector2(1f, 0f); string versionNumber = (IllusionInjector.PluginManager.Plugins.Where(x => x.Name == "Custom Platforms").First()).Version; _versionNumber.text = "v" + versionNumber; _versionNumber.fontSize = 5; _versionNumber.color = Color.white; if (_backButton == null) { _backButton = BeatSaberUI.CreateBackButton(rectTransform as RectTransform); _backButton.onClick.AddListener(delegate() { if (platformListBackWasPressed != null) { platformListBackWasPressed(); } }); } } _platformsTableView.SelectRow(PlatformManager.Instance.currentPlatformIndex); _platformsTableView.ScrollToRow(PlatformManager.Instance.currentPlatformIndex, true); } catch (Exception e) { Console.WriteLine("EXCEPTION IN DidActivate: " + e); } }
protected override void DidActivate(bool firstActivation, ActivationType activationType) { if(firstActivation) { _backButton = BeatSaberUI.CreateBackButton(rectTransform); _backButton.onClick.AddListener(delegate () { didFinishEvent?.Invoke(); }); _nameKeyboard = BeatSaberUI.CreateViewController<CustomKeyboardViewController>(); _nameKeyboard.enterButtonPressed += NameEntered; _nameKeyboard.backButtonPressed += () => { keyboardDidFinishEvent?.Invoke(_nameKeyboard); }; _passwordKeyboard = BeatSaberUI.CreateViewController<CustomKeyboardViewController>(); _passwordKeyboard.allowEmptyInput = true; _passwordKeyboard.enterButtonPressed += PasswordEntered; _passwordKeyboard.backButtonPressed += () => { keyboardDidFinishEvent?.Invoke(_passwordKeyboard); }; _presetNameKeyboard = BeatSaberUI.CreateViewController<CustomKeyboardViewController>(); _presetNameKeyboard.enterButtonPressed += PresetNameEntered; _presetNameKeyboard.backButtonPressed += () => { keyboardDidFinishEvent?.Invoke(_presetNameKeyboard); }; _usePasswordToggle = CustomSettingsHelper.AddToggleSetting<OnOffViewController>(rectTransform, "Use Password", new Vector2(0f, 11f)); _usePasswordToggle.ValueChanged += UsePasswordToggle_ValueChanged; _usePasswordToggle.Value = _usePassword; _songSelectionList = CustomSettingsHelper.AddListSetting<MultiplayerListViewController>(rectTransform, "Song Selection", new Vector2(0f, 3f)); _songSelectionList.ValueChanged += SongSelection_ValueChanged; _songSelectionList.maxValue = 1; _songSelectionList.Value = (int)_songSelectionType; _songSelectionList.textForValues = new string[] { "Manual", "Random" }; _songSelectionList.UpdateText(); _maxPlayersList = CustomSettingsHelper.AddListSetting<MultiplayerListViewController>(rectTransform, "Max Players", new Vector2(0f, -5f)); _maxPlayersList.ValueChanged += MaxPlayers_ValueChanged; _maxPlayersList.Value = _maxPlayers; _maxPlayersList.maxValue = 16; _maxPlayersList.textForValues = new string[] { "No limit" }; _maxPlayersList.UpdateText(); _resultsShowTimeList = CustomSettingsHelper.AddListSetting<MultiplayerListViewController>(rectTransform, "Results Show Time", new Vector2(0f, -13f)); _resultsShowTimeList.ValueChanged += ResultsShowTime_ValueChanged; _resultsShowTimeList.minValue = 5; _resultsShowTimeList.maxValue = 45; _resultsShowTimeList.Value = _resultsShowTime; _perPlayerDifficultyToggle = CustomSettingsHelper.AddToggleSetting<OnOffViewController>(rectTransform, "Per player difficulty", new Vector2(0f, -21f)); _perPlayerDifficultyToggle.ValueChanged += PerPlayerDifficultyToggle_ValueChanged; _perPlayerDifficultyToggle.Value = _allowPerPlayerDifficulty; _roomName = $"{GetUserInfo.GetUserName()}'s room".ToUpper(); _nameText = BeatSaberUI.CreateText(rectTransform, _roomName, new Vector2(-22.5f, 30f)); _nameText.fontSize = 5f; _editNameButton = BeatSaberUI.CreateUIButton(rectTransform, "CancelButton"); _editNameButton.SetButtonText("EDIT NAME"); (_editNameButton.transform as RectTransform).sizeDelta = new Vector2(34f, 8f); (_editNameButton.transform as RectTransform).anchoredPosition = new Vector2(34f, 32f); _editNameButton.onClick.RemoveAllListeners(); _editNameButton.onClick.AddListener(delegate () { _nameKeyboard.inputString = _roomName; presentKeyboardEvent?.Invoke(_nameKeyboard); }); _roomPassword = ""; _passwordText = BeatSaberUI.CreateText(rectTransform, "ENTER PASSWORD", new Vector2(-22.5f, 20f)); _passwordText.fontSize = 5f; _editPasswordButton = BeatSaberUI.CreateUIButton(rectTransform, "CancelButton"); _editPasswordButton.SetButtonText("EDIT PASS"); (_editPasswordButton.transform as RectTransform).sizeDelta = new Vector2(34f, 8f); (_editPasswordButton.transform as RectTransform).anchoredPosition = new Vector2(34f, 22f); _editPasswordButton.onClick.RemoveAllListeners(); _editPasswordButton.onClick.AddListener(delegate () { _passwordKeyboard.inputString = _roomPassword; presentKeyboardEvent?.Invoke(_passwordKeyboard); }); _createRoomButton = BeatSaberUI.CreateUIButton(rectTransform, "CancelButton"); _createRoomButton.SetButtonText("Create Room"); (_createRoomButton.transform as RectTransform).sizeDelta = new Vector2(30f, 10f); (_createRoomButton.transform as RectTransform).anchoredPosition = new Vector2(0f, -32.5f); _createRoomButton.onClick.RemoveAllListeners(); _createRoomButton.onClick.AddListener(delegate () { CreatedRoom?.Invoke(new RoomSettings() { Name = _roomName, UsePassword = _usePassword, Password = _roomPassword, PerPlayerDifficulty = _allowPerPlayerDifficulty, MaxPlayers = _maxPlayers, SelectionType = _songSelectionType, ResultsShowTime = _resultsShowTime}); }); _createRoomButton.interactable = PluginUI.instance.roomCreationFlowCoordinator.CheckRequirements(); _savePresetButton = BeatSaberUI.CreateUIButton(rectTransform, "CancelButton"); _savePresetButton.SetButtonText("Save Preset"); (_savePresetButton.transform as RectTransform).sizeDelta = new Vector2(30f, 10f); (_savePresetButton.transform as RectTransform).anchoredPosition = new Vector2(-32f, -32.5f); _savePresetButton.onClick.RemoveAllListeners(); _savePresetButton.onClick.AddListener(delegate () { _presetNameKeyboard.inputString = "NEW PRESET"; presentKeyboardEvent?.Invoke(_presetNameKeyboard); }); _loadPresetButton = BeatSaberUI.CreateUIButton(rectTransform, "CancelButton"); _loadPresetButton.SetButtonText("Load Preset"); (_loadPresetButton.transform as RectTransform).sizeDelta = new Vector2(30f, 10f); (_loadPresetButton.transform as RectTransform).anchoredPosition = new Vector2(32f, -32.5f); _loadPresetButton.onClick.RemoveAllListeners(); _loadPresetButton.onClick.AddListener(delegate () { LoadPresetPressed?.Invoke(); }); } else { _songSelectionList.textForValues = new string[] { "Manual", "Random" }; _songSelectionList.UpdateText(); _maxPlayersList.textForValues = new string[] { "No limit" }; _maxPlayersList.UpdateText(); _createRoomButton.interactable = PluginUI.instance.roomCreationFlowCoordinator.CheckRequirements(); } }