private void SceneManager_sceneLoaded(Scene scene, LoadSceneMode mode) { if (scene.name == "TutorialEnvironment") { if (!enabled || safetyEnabled) { return; } safetyEnabled = true; //Disable mod return; } else { safetyEnabled = false; } //Enable Mod if (scene.name == "Menu" && !safetyEnabled) /// Settings Submenus { SubMenus.Settings(); SubMenus.PlayerProperties(); if (!enabled || safetyEnabled) { return; } BeFitUI.OnLoad(); } }
private void Awake() { _instance = this; _mainFlowCoordinator = Resources.FindObjectsOfTypeAll <MainFlowCoordinator>().First(); SceneManager.sceneLoaded += SceneManager_sceneLoaded; DontDestroyOnLoad(gameObject); CreateBeFitMenuButton(); CreateSettingsUI(); }
protected override void DidActivate(bool firstActivation, ActivationType activationType) { if (firstActivation) { ui = BeFitUI._instance; _contentViewController = BeatSaberUI.CreateViewController <TCONT>(); _rightViewController = BeatSaberUI.CreateViewController <TRIGHT>(); title = OnContentCreated(_contentViewController); } if (activationType == FlowCoordinator.ActivationType.AddedToHierarchy) { ProvideInitialViewControllers(_contentViewController, null, _rightViewController); } }
protected override void DidActivate(bool firstActivation, ActivationType activationType) { if (firstActivation) { title = "BeFit Users"; ui = BeFitUI._instance; } if (_beFitListViewController == null) { _beFitListViewController = BeatSaberUI.CreateViewController <BeFitListViewController>(); _beFitListViewController.beFitListBackWasPressed += Dismiss; _beFitListViewController.beFitListNewUserPressed += Dismiss; } if (activationType == FlowCoordinator.ActivationType.AddedToHierarchy) { ProvideInitialViewControllers(_beFitListViewController, null, null); } }
protected override void DidActivate(bool firstActivation, ActivationType type) { try { LoadUsers(firstActivation); if (firstActivation) { for (int i = 0; i < _user.Count; i++) { if (_user[i].Path == Plugin.Instance._currentUser) { selected = i; } } ui = BeFitUI._instance; _songListTableCellInstance = Resources.FindObjectsOfTypeAll <LevelListTableCell>().First(x => (x.name == "LevelListTableCell")); RectTransform container = new GameObject("BeFitListContainer", typeof(RectTransform)).transform as RectTransform; container.SetParent(rectTransform, false); container.sizeDelta = new Vector2(60f, 0f); _beFitTableView = new GameObject("BeFitListTableView").AddComponent <TableView>(); _beFitTableView.gameObject.AddComponent <RectMask2D>(); _beFitTableView.transform.SetParent(container, false); (_beFitTableView.transform as RectTransform).anchorMin = new Vector2(0f, 0f); (_beFitTableView.transform as RectTransform).anchorMax = new Vector2(1f, 1f); (_beFitTableView.transform as RectTransform).sizeDelta = new Vector2(0f, 60f); (_beFitTableView.transform as RectTransform).anchoredPosition = new Vector3(0f, 0f); _beFitTableView.SetPrivateField("_preallocatedCells", new TableView.CellsGroup[0]); _beFitTableView.SetPrivateField("_isInitialized", false); _beFitTableView.dataSource = this; _beFitTableView.didSelectRowEvent += _BeFitTableView_DidSelectRowEvent; _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() { _beFitTableView.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() { _beFitTableView.PageScrollDown(); }); _newUserButton = Instantiate(Resources.FindObjectsOfTypeAll <Button>().First(x => (x.name == "PlayButton")), container, false); (_newUserButton.transform as RectTransform).anchoredPosition = new Vector2(40f, -30f); BeatSaberUIExtensions.SetButtonText(_newUserButton, "New User"); _newUserButton.interactable = true; _newUserButton.onClick.AddListener(delegate() { UserConfigs newUser = new UserConfigs(Path.Combine(Application.dataPath, "../UserData/BeFitUsers/Player" + DateTime.Now.Millisecond + ".cfg")); newUser.Save(); UnLoadUsers(); LoadUsers(firstActivation); RefreshScreen(); if (beFitListNewUserPressed != null) { beFitListNewUserPressed(); } }); _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 = Plugin.Instance.Version; _versionNumber.text = versionNumber; _versionNumber.fontSize = 5; _versionNumber.color = Color.white; if (_backButton == null) { _backButton = BeatSaberUI.CreateBackButton(rectTransform as RectTransform); _backButton.onClick.AddListener(delegate() { if (beFitListBackWasPressed != null) { beFitListBackWasPressed(); } UnLoadUsers(); }); } } _beFitTableView.SelectRow(selected); _beFitTableView.ScrollToRow(selected, true); PreviewCurrent(); } catch (Exception e) { Console.WriteLine("EXCEPTION IN DidActivate: " + e); } }