//////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// /// <summary> /// On view creation /// </summary> protected override sealed void OnViewCreation() { /// Create event var l_Event = new BSMLAction(this, this.GetType().GetMethod(nameof(OnSettingChanged), System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)); var l_AnchorMin = new Vector2(1.00f, -0.05f); var l_AnchorMax = new Vector2(0.90f, 1.05f); /// Create type selector m_TypeSegmentControl = SDK.UI.TextSegmentedControl.Create(m_TypeSegmentPanel.transform as RectTransform, false, new string[] { "SubRain", "ComboMode" }); m_TypeSegmentControl.didSelectCellEvent += OnTypeChanged; /// SubRain panel SDK.UI.Backgroundable.SetOpacity(m_SubRainPanel_InfoBackground, 0.5f); SDK.UI.ToggleSetting.Setup(m_SubRainPanel_EnableToggle, l_Event, Config.ChatEmoteRain.SubRain, true); SDK.UI.SliderSetting.Setup(m_SubRainPanel_EmoteCountSlider, l_Event, null, Config.ChatEmoteRain.SubRainEmoteCount, true, true, l_AnchorMin, l_AnchorMax); /// Combo panel SDK.UI.Backgroundable.SetOpacity(m_ComboModePanel_InfoBackground, 0.5f); SDK.UI.ToggleSetting.Setup(m_ComboModePanel_EnableToggle, l_Event, Config.ChatEmoteRain.ComboMode, true); SDK.UI.ListSetting.Setup(m_ComboModePanel_ComboTypeList, l_Event, true); SDK.UI.SliderSetting.Setup(m_ComboModePanel_ComboTimerSlider, l_Event, null, Config.ChatEmoteRain.ComboTimer, true, true, l_AnchorMin, l_AnchorMax); SDK.UI.SliderSetting.Setup(m_ComboModePanel_ComboCountSlider, l_Event, null, Config.ChatEmoteRain.ComboCount, true, true, l_AnchorMin, l_AnchorMax); /// Force change to tab SubRain OnTypeChanged(null, 0); }
public T AddTextSegmentsSetting <T>(string name, string hintText, string[] texts) where T : SegmentedControlViewController { var volumeSettings = GetVolumeSettings(); GameObject newSettingsObject = MonoBehaviour.Instantiate(volumeSettings.gameObject, transform); newSettingsObject.name = name; ListSettingsController volume = newSettingsObject.GetComponent <ListSettingsController>(); T newTextSegmentsSettingsController = (T)ReflectionUtil.CopyComponent(volume, typeof(ListSettingsController), typeof(T), newSettingsObject); MonoBehaviour.DestroyImmediate(volume); GameObject.Destroy(newSettingsObject.transform.Find("Value").Find("DecButton").gameObject); GameObject.Destroy(newSettingsObject.transform.Find("Value").Find("ValueText").gameObject); GameObject.Destroy(newSettingsObject.transform.Find("Value").Find("IncButton").gameObject); TextSegmentedControl segmentedControl = BeatSaberUI.CreateTextSegmentedControl(newSettingsObject.transform.Find("Value") as RectTransform, new Vector2(0f, 0f), new Vector2(40f, 7f)); newTextSegmentsSettingsController.segmentedControl = segmentedControl; segmentedControl.SetTexts(texts); var tmpText = newSettingsObject.GetComponentInChildren <TMP_Text>(); tmpText.text = name; if (hintText != String.Empty) { BeatSaberUI.AddHintText(tmpText.rectTransform, hintText); } viewController?.AddSubmenuOption(newSettingsObject); AddHooks(newTextSegmentsSettingsController); return(newTextSegmentsSettingsController); }
public static void Postfix(TextSegmentedControl ____selectionSegmentedControl) { var texts = ____selectionSegmentedControl.GetField <IReadOnlyList <string>, TextSegmentedControl>("_texts"); var list = new List <string>(texts); list.Add("Sabers"); SaberPanelIdx = list.Count - 1; ____selectionSegmentedControl.SetTexts(list); }
public void SetSelectedDifficulty(TextSegmentedControl _, int index) { _selectedDifficultyBeatmap = _selectedLevel.beatmapLevelData.GetDifficultyBeatmapSet(_playerDataModel.playerData.lastSelectedBeatmapCharacteristic).difficultyBeatmaps[index]; _playerDataModel.playerData.SetLastSelectedBeatmapDifficulty(_selectedDifficultyBeatmap.difficulty); UpdateContent(); DifficultyBeatmapChanged?.Invoke(_selectedDifficultyBeatmap); }
//////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// /// <summary> /// On activation /// </summary> /// <param name="p_FirstActivation">Is the first activation ?</param> /// <param name="p_AddedToHierarchy">Activation type</param> /// <param name="p_ScreenSystemEnabling">Is screen system enabled</param> protected override void DidActivate(bool p_FirstActivation, bool p_AddedToHierarchy, bool p_ScreenSystemEnabling) { if (p_FirstActivation) { int l_TypeIndex = Config.ChatEmoteRain.ComboModeType % m_ComboModeTypes.Count; if (l_TypeIndex >= 0) { m_ComboModeTypeValue = m_ComboModeTypes[l_TypeIndex] as string; } else { Config.ChatEmoteRain.ComboModeType = 0; m_ComboModeTypeValue = m_ComboModeTypes[0] as string; } } /// Forward event base.DidActivate(p_FirstActivation, p_AddedToHierarchy, p_ScreenSystemEnabling); /// If first activation, bind event if (p_FirstActivation) { /// Create type selector m_TypeSegmentControl = BeatSaberPlus.Utils.GameUI.CreateTextSegmentedControl(m_TypeSegmentPanel.transform as RectTransform, false); m_TypeSegmentControl.SetTexts(new string[] { "SubRain", "ComboMode" }); m_TypeSegmentControl.ReloadData(); m_TypeSegmentControl.didSelectCellEvent += OnTypeChanged; /// Update background color Color l_Color = this.m_InfoBackground.GetComponent <ImageView>().color; l_Color.a = 0.5f; m_InfoBackground.GetComponent <ImageView>().color = l_Color; m_InfoBackground2.GetComponent <ImageView>().color = l_Color; /// Create event var l_Event = new BSMLAction(this, this.GetType().GetMethod(nameof(OnSettingChanged), System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)); /// Set values Utils.GameUI.PrepareToggleSetting(m_SubRain, l_Event, Config.ChatEmoteRain.SubRain, false); Utils.GameUI.PrepareSliderSetting(m_SubRainEmoteCount, l_Event, null, Config.ChatEmoteRain.SubRainEmoteCount, false); Utils.GameUI.PrepareToggleSetting(m_ComboMode, l_Event, Config.ChatEmoteRain.ComboMode, false); Utils.GameUI.PrepareSliderSetting(m_ComboTimer, l_Event, null, Config.ChatEmoteRain.ComboTimer, false); Utils.GameUI.PrepareSliderSetting(m_ComboCount, l_Event, null, Config.ChatEmoteRain.ComboCount, false); /// Bind events m_ComboModeType.onChange = l_Event; /// Force change to tab SubRain OnTypeChanged(null, 0); } }
//////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// /// <summary> /// On view creation /// </summary> protected override sealed void OnViewCreation() { /// Scale down up & down button m_SongUpButton.transform.localScale = Vector3.one * 0.6f; m_SongDownButton.transform.localScale = Vector3.one * 0.6f; /// Create type selector m_TypeSegmentControl = SDK.UI.TextSegmentedControl.Create(m_TypeSegmentPanel.transform as RectTransform, false); m_TypeSegmentControl.SetTexts(new string[] { "Requests", "History", "Blacklist" }); m_TypeSegmentControl.ReloadData(); m_TypeSegmentControl.didSelectCellEvent += OnQueueTypeChanged; /// Prepare song list var l_BSMLTableView = m_SongListView.GetComponentInChildren <BSMLTableView>(); l_BSMLTableView.SetDataSource(null, false); GameObject.DestroyImmediate(m_SongListView.GetComponentInChildren <CustomListTableData>()); m_SongList = l_BSMLTableView.gameObject.AddComponent <SDK.UI.DataSource.SongList>(); m_SongList.PlayPreviewAudio = Config.ChatRequest.PlayPreviewMusic; m_SongList.PreviewAudioVolume = 1.0f; m_SongList.TableViewInstance = l_BSMLTableView; m_SongList.Init(); l_BSMLTableView.SetDataSource(m_SongList, false); /// Bind events m_SongUpButton.onClick.AddListener(OnSongPageUpPressed); m_SongList.OnCoverFetched += OnSongCoverFetched; m_SongList.TableViewInstance.didSelectCellWithIdxEvent += OnSongSelected; m_SongDownButton.onClick.AddListener(OnSongPageDownPressed); /// Show song info panel m_SongInfo_Detail = new SDK.UI.LevelDetail(m_SongInfoPanel.transform); UnselectSong(); m_SongInfo_Detail.SetFavoriteToggleEnabled(true); m_SongInfo_Detail.SetFavoriteToggleImage("BeatSaberPlus.Modules.ChatRequest.Resources.Blacklist.png", "BeatSaberPlus.Modules.ChatRequest.Resources.Unblacklist.png"); m_SongInfo_Detail.SetFavoriteToggleHoverHint("Add/Remove to blacklist"); m_SongInfo_Detail.SetFavoriteToggleCallback(OnBlacklistButtonPressed); m_SongInfo_Detail.SetPracticeButtonEnabled(true); m_SongInfo_Detail.SetPracticeButtonText("Skip"); m_SongInfo_Detail.SetPracticeButtonAction(SkipSong); m_SongInfo_Detail.SetPlayButtonText("Play"); m_SongInfo_Detail.SetPlayButtonEnabled(true); m_SongInfo_Detail.SetPlayButtonAction(PlaySong); /// Force change to tab Request OnQueueTypeChanged(null, 0); }
public override GameObject CreateObject(Transform parent) { TextSegmentedControl prefab = Resources.FindObjectsOfTypeAll <TextSegmentedControl>().FirstOrDefault(x => x.transform.parent.name == "PlayerStatisticsViewController" && x.GetField <DiContainer, TextSegmentedControl>("_container") != null); TextSegmentedControl textSegmentedControl = MonoBehaviour.Instantiate(prefab, parent, false); textSegmentedControl.name = "BSMLTabSelector"; textSegmentedControl.SetField("_container", prefab.GetField <DiContainer, TextSegmentedControl>("_container")); (textSegmentedControl.transform as RectTransform).anchoredPosition = new Vector2(0, 0); foreach (Transform transform in textSegmentedControl.transform) { GameObject.Destroy(transform.gameObject); } textSegmentedControl.gameObject.AddComponent <TabSelector>().textSegmentedControl = textSegmentedControl; return(textSegmentedControl.gameObject); }
public override GameObject CreateObject(Transform parent) { TextSegmentedControl prefab = Resources.FindObjectsOfTypeAll <TextSegmentedControl>().First(x => x.name == "BeatmapDifficultySegmentedControl" && x.GetField <DiContainer, TextSegmentedControl>("_container") != null); TextSegmentedControl textSegmentedControl = MonoBehaviour.Instantiate(prefab, parent, false); textSegmentedControl.name = "BSMLTextSegmentedControl"; textSegmentedControl.SetField("_container", prefab.GetField <DiContainer, TextSegmentedControl>("_container")); (textSegmentedControl.transform as RectTransform).anchoredPosition = new Vector2(0, 0); foreach (Transform transform in textSegmentedControl.transform) { GameObject.Destroy(transform.gameObject); } MonoBehaviour.Destroy(textSegmentedControl.GetComponent <BeatmapDifficultySegmentedControlController>()); return(textSegmentedControl.gameObject); }
public static bool Prefix(int panelIdx, int ____activePanelIdx, TextSegmentedControl ____selectionSegmentedControl) { if (panelIdx == GameplaySetupViewPatch.SaberPanelIdx) { var cell = ____selectionSegmentedControl.GetField <List <SegmentedControlCell>, SegmentedControl>("_cells")[ GameplaySetupViewPatch.SaberPanelIdx]; ____selectionSegmentedControl.SelectCellWithNumber(____activePanelIdx); Editor.Editor.Instance?.Open(); cell.ClearHighlight(SelectableCell.TransitionType.Instant); return(false); } return(true); }
public override GameObject CreateObject(Transform parent) { if (segmentControlTemplate == null) { segmentControlTemplate = Resources.FindObjectsOfTypeAll <TextSegmentedControl>().FirstOrDefault(x => x.transform.parent.name == "PlayerStatisticsViewController" && x.GetField <DiContainer, TextSegmentedControl>("_container") != null); } TextSegmentedControl textSegmentedControl = Object.Instantiate(segmentControlTemplate, parent, false); textSegmentedControl.name = "SUIButtonCollection"; textSegmentedControl.SetField("_container", segmentControlTemplate.GetField <DiContainer, TextSegmentedControl>("_container")); (textSegmentedControl.transform as RectTransform).anchoredPosition = new Vector2(0, 0); foreach (Transform transform in textSegmentedControl.transform) { Object.Destroy(transform.gameObject); } textSegmentedControl.gameObject.AddComponent <ButtonCollection>().textSegmentedControl = textSegmentedControl; return(textSegmentedControl.gameObject); }
void SetupDifficultyDisplay(TextSegmentedControl controller, Song song) { List <string> Diffs = new List <string>(); if (selectedCharacteristic != null) { if (selectedCharacteristic.difficulties.easy != null) { Diffs.Add("Easy"); } if (selectedCharacteristic.difficulties.normal != null) { Diffs.Add("Normal"); } if (selectedCharacteristic.difficulties.hard != null) { Diffs.Add("Hard"); } if (selectedCharacteristic.difficulties.expert != null) { Diffs.Add("Expert"); } if (selectedCharacteristic.difficulties.expertPlus != null) { Diffs.Add("Expert+"); } } controller.SetTexts(Diffs.ToArray()); if (Diffs.Count > 0) { controller.SelectCellWithNumber(0); } if (currentDifficulties != null) { SelectedDifficulty(currentDifficulties[0]); } else { // Plugin.log.Info("current diffs null"); } }
//////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// /// <summary> /// On view creation /// </summary> protected override sealed void OnViewCreation() { var l_Event = new BeatSaberMarkupLanguage.Parser.BSMLAction(this, this.GetType().GetMethod(nameof(SettingsRight.OnSettingChanged), System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)); /// Create type selector m_TypeSegmentControl = SDK.UI.TextSegmentedControl.Create(m_TypeSegmentPanel.transform as RectTransform, false); m_TypeSegmentControl.SetTexts(new string[] { "Menu", "Dev / Testing" }); m_TypeSegmentControl.ReloadData(); m_TypeSegmentControl.didSelectCellEvent += OnTypeChanged; //////////////////////////////////////////////////////////////////////////// /// Menu //////////////////////////////////////////////////////////////////////////// /// Main menu SDK.UI.ToggleSetting.Setup(m_DisableBeatMapEditorButtonInMainMenu, l_Event, Config.GameTweaker.DisableBeatMapEditorButtonOnMainMenu, true); SDK.UI.ToggleSetting.Setup(m_ShowPlayerStatisticsInMainMenu, l_Event, Config.GameTweaker.ShowPlayerStatisticsOnMainMenu, true); SDK.UI.ToggleSetting.Setup(m_RemoveNewContentPromotional, l_Event, Config.GameTweaker.RemoveNewContentPromotional, true); /// Level selection SDK.UI.ToggleSetting.Setup(m_ReorderPlayerSettings, l_Event, Config.GameTweaker.ReorderPlayerSettings, true); SDK.UI.ToggleSetting.Setup(m_AddOverrideLightIntensityOption, l_Event, Config.GameTweaker.AddOverrideLightIntensityOption, true); SDK.UI.ToggleSetting.Setup(m_RemoveBaseGameFilterButton, l_Event, Config.GameTweaker.RemoveBaseGameFilterButton, true); SDK.UI.ToggleSetting.Setup(m_DeleteSongButton, l_Event, Config.GameTweaker.DeleteSongButton, true); //////////////////////////////////////////////////////////////////////////// /// Dev / Testing //////////////////////////////////////////////////////////////////////////// /// Prepare sliders SDK.UI.ToggleSetting.Setup(m_FPFCEscape, l_Event, Config.GameTweaker.FPFCEscape, false); //////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// /// Force change to tab GamePlay OnTypeChanged(null, 0); }
public override void HandleType(ComponentTypeWithData componentType, BSMLParserParams parserParams) { TextSegmentedControl textControl = componentType.component as TextSegmentedControl; if (componentType.data.TryGetValue("data", out string value)) { if (!parserParams.values.TryGetValue(value, out BSMLValue contents)) { throw new Exception("value '" + value + "' not found"); } textControl.SetTexts((contents.GetValue() as IEnumerable).Cast <object>().Select(x => x.ToString()).ToArray()); } if (componentType.data.TryGetValue("selectCell", out string selectCell)) { textControl.didSelectCellEvent += (SegmentedControl control, int index) => { if (!parserParams.actions.TryGetValue(selectCell, out BSMLAction action)) { throw new Exception("select-cell action '" + componentType.data["selectCell"] + "' not found"); } action.Invoke(control, index); }; } }
/// <summary> /// Create text segmented control /// </summary> /// <param name="p_Parent">Parent game object transform</param> /// <param name="p_HideCellBackground">Should hide cell background</param> /// <returns>GameObject</returns> public static TextSegmentedControl CreateTextSegmentedControl(RectTransform p_Parent, bool p_HideCellBackground) { TextSegmentedControl l_Prefab = Resources.FindObjectsOfTypeAll <TextSegmentedControl>().First(x => x.name == "BeatmapDifficultySegmentedControl" && x.GetField <DiContainer, TextSegmentedControl>("_container") != null); TextSegmentedControl l_Control = MonoBehaviour.Instantiate(l_Prefab, p_Parent, false); l_Control.name = "BSMLTextSegmentedControl"; l_Control.SetField("_container", l_Prefab.GetField <DiContainer, TextSegmentedControl>("_container")); l_Control.SetField("_hideCellBackground", p_HideCellBackground); RectTransform l_RectTransform = l_Control.transform as RectTransform; l_RectTransform.anchorMin = Vector2.one * 0.5f; l_RectTransform.anchorMax = Vector2.one * 0.5f; l_RectTransform.anchoredPosition = Vector2.zero; l_RectTransform.pivot = Vector2.one * 0.5f; foreach (Transform l_Transform in l_Control.transform) { GameObject.Destroy(l_Transform.gameObject); } MonoBehaviour.Destroy(l_Control.GetComponent <BeatmapDifficultySegmentedControlController>()); return(l_Control); }
protected override void DidActivate(bool firstActivation, ActivationType activationType) { if (firstActivation && activationType == ActivationType.AddedToHierarchy) { _downloadListTableCellInstance = Resources.FindObjectsOfTypeAll <LeaderboardTableCell>().First(); _tabControl = CustomExtensions.CreateTextSegmentedControl(rectTransform, new Vector2(0f, -9f)); _tabControl.SetTexts(new string[] { "Players", "Modifiers" }); _tabControl.didSelectCellEvent += _tabControl_didSelectCellEvent; #region Modifiers tab _modifiersTab = new GameObject("ModifiersTab", typeof(RectTransform)).GetComponent <RectTransform>(); _modifiersTab.SetParent(rectTransform, false); _modifiersTab.anchorMin = new Vector2(0f, 0f); _modifiersTab.anchorMax = new Vector2(1f, 1f); _modifiersTab.anchoredPosition = new Vector2(0f, 0f); _modifiersTab.sizeDelta = new Vector2(0f, 0f); _modifiersPanel = Instantiate(Resources.FindObjectsOfTypeAll <GameplayModifiersPanelController>().First(), rectTransform, false); _modifiersPanel.gameObject.SetActive(true); _modifiersPanel.transform.SetParent(_modifiersTab, false); (_modifiersPanel.transform as RectTransform).anchorMin = new Vector2(0.5f, 0f); (_modifiersPanel.transform as RectTransform).anchorMax = new Vector2(0.5f, 1f); (_modifiersPanel.transform as RectTransform).anchoredPosition = new Vector2(0f, -23f); (_modifiersPanel.transform as RectTransform).sizeDelta = new Vector2(120f, -23f); _modifiersPanel.Init(GameplayModifiers.defaultModifiers); _modifiersPanel.Awake(); var modifierToggles = _modifiersPanel.GetPrivateField <GameplayModifierToggle[]>("_gameplayModifierToggles"); foreach (var item in modifierToggles) { item.toggle.onValueChanged.AddListener((enabled) => { gameplayModifiersChanged?.Invoke(); }); } _modifiersPanelBlocker = new GameObject("ModifiersPanelBlocker", typeof(RectTransform)).GetComponent <RectTransform>(); //"If it works it's not stupid" _modifiersPanelBlocker.SetParent(_modifiersTab, false); _modifiersPanelBlocker.gameObject.AddComponent <UnityEngine.UI.Image>().color = new Color(0f, 0f, 0f, 0f); _modifiersPanelBlocker.anchorMin = new Vector2(0f, 0f); _modifiersPanelBlocker.anchorMax = new Vector2(1f, 0f); _modifiersPanelBlocker.pivot = new Vector2(0.5f, 0f); _modifiersPanelBlocker.sizeDelta = new Vector2(-10f, 62f); _modifiersPanelBlocker.anchoredPosition = new Vector2(0f, 0f); #endregion #region Players tab _playersTab = new GameObject("PlayersTab", typeof(RectTransform)).GetComponent <RectTransform>(); _playersTab.SetParent(rectTransform, false); _playersTab.anchorMin = new Vector2(0f, 0f); _playersTab.anchorMax = new Vector2(1f, 1f); _playersTab.anchoredPosition = new Vector2(0f, 0f); _playersTab.sizeDelta = new Vector2(0f, 0f); _pageUpButton = Instantiate(Resources.FindObjectsOfTypeAll <Button>().First(x => (x.name == "PageUpButton")), _playersTab, 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, -18f); (_pageUpButton.transform as RectTransform).sizeDelta = new Vector2(40f, 6f); _pageUpButton.interactable = true; _pageUpButton.onClick.AddListener(delegate() { _playersTableView.PageScrollUp(); }); _pageUpButton.interactable = false; _pageDownButton = Instantiate(Resources.FindObjectsOfTypeAll <Button>().First(x => (x.name == "PageDownButton")), _playersTab, 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() { _playersTableView.PageScrollDown(); }); _pageDownButton.interactable = false; RectTransform container = new GameObject("Content", typeof(RectTransform)).transform as RectTransform; container.SetParent(_playersTab, false); container.anchorMin = new Vector2(0.15f, 0.5f); container.anchorMax = new Vector2(0.85f, 0.5f); container.sizeDelta = new Vector2(0f, 49f); container.anchoredPosition = new Vector2(0f, -3f); _playersTableView = new GameObject("CustomTableView").AddComponent <TableView>(); _playersTableView.gameObject.AddComponent <RectMask2D>(); _playersTableView.transform.SetParent(container, false); _playersTableView.SetPrivateField("_isInitialized", false); _playersTableView.SetPrivateField("_preallocatedCells", new TableView.CellsGroup[0]); _playersTableView.Init(); (_playersTableView.transform as RectTransform).anchorMin = new Vector2(0f, 0f); (_playersTableView.transform as RectTransform).anchorMax = new Vector2(1f, 1f); (_playersTableView.transform as RectTransform).sizeDelta = new Vector2(0f, 0f); (_playersTableView.transform as RectTransform).anchoredPosition = new Vector3(0f, 0f); ReflectionUtil.SetPrivateField(_playersTableView, "_pageUpButton", _pageUpButton); ReflectionUtil.SetPrivateField(_playersTableView, "_pageDownButton", _pageDownButton); _playersTableView.dataSource = this; #endregion _pingText = this.CreateText("PING: 0", new Vector2(75f, 22.5f)); _pingText.alignment = TextAlignmentOptions.Left; _tabControl_didSelectCellEvent(null, 0); } if (activationType == ActivationType.AddedToHierarchy) { SetGameplayModifiers(GameplayModifiers.defaultModifiers); } }
//////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// /// <summary> /// On activation /// </summary> /// <param name="p_FirstActivation">Is the first activation ?</param> /// <param name="p_AddedToHierarchy">Activation type</param> /// <param name="p_ScreenSystemEnabling">Is screen system enabled</param> protected override void DidActivate(bool p_FirstActivation, bool p_AddedToHierarchy, bool p_ScreenSystemEnabling) { /// Forward event base.DidActivate(p_FirstActivation, p_AddedToHierarchy, p_ScreenSystemEnabling); if (p_FirstActivation) { /// Scale down up & down button m_SongUpButton.transform.localScale = Vector3.one * 0.6f; m_SongDownButton.transform.localScale = Vector3.one * 0.6f; /// Create type selector m_TypeSegmentControl = Utils.GameUI.CreateTextSegmentedControl(m_TypeSegmentPanel.transform as RectTransform, false); m_TypeSegmentControl.SetTexts(new string[] { "Requests", "History", "Blacklist" }); m_TypeSegmentControl.ReloadData(); m_TypeSegmentControl.didSelectCellEvent += OnQueueTypeChanged; /// Prepare song list var l_BSMLTableView = m_SongListView.GetComponentInChildren <BSMLTableView>(); l_BSMLTableView.SetDataSource(null, false); GameObject.DestroyImmediate(m_SongListView.GetComponentInChildren <CustomListTableData>()); m_SongList = l_BSMLTableView.gameObject.AddComponent <SongListDataSource>(); m_SongList.TableViewInstance = l_BSMLTableView; l_BSMLTableView.SetDataSource(m_SongList, false); /// Bind events m_SongUpButton.onClick.AddListener(OnSongPageUpPressed); m_SongList.TableViewInstance.didSelectCellWithIdxEvent += OnSongSelected; m_SongDownButton.onClick.AddListener(OnSongPageDownPressed); /// Find song preview object m_SongPreviewPlayer = Resources.FindObjectsOfTypeAll <SongPreviewPlayer>().First(); /// Show song info panel m_SongInfo_Detail = new BeatSaberPlus.UI.Widget.SongDetail(m_SongInfoPanel.transform); UnselectSong(); m_SongInfo_Detail.SetFavoriteToggleEnabled(true); m_SongInfo_Detail.SetFavoriteToggleImage("BeatSaberPlus.Plugins.ChatRequest.Resources.Blacklist.png", "BeatSaberPlus.Plugins.ChatRequest.Resources.Unblacklist.png"); m_SongInfo_Detail.SetFavoriteToggleHoverHint("Add/Remove to blacklist"); m_SongInfo_Detail.SetFavoriteToggleCallback(OnBlacklistButtonPressed); m_SongInfo_Detail.SetPracticeButtonEnabled(true); m_SongInfo_Detail.SetPracticeButtonText("Skip"); m_SongInfo_Detail.SetPracticeButtonAction(SkipSong); m_SongInfo_Detail.SetPlayButtonText("Play"); m_SongInfo_Detail.SetPlayButtonEnabled(true); m_SongInfo_Detail.SetPlayButtonAction(PlaySong); /// Init loading modal m_LoadingModalSpinner = GameObject.Instantiate(Resources.FindObjectsOfTypeAll <LoadingControl>().First(), m_LoadingModal.transform); m_LoadingModalSpinner.transform.SetAsLastSibling(); Destroy(m_LoadingModalSpinner.GetComponent <Touchable>()); /// Force change to tab Request OnQueueTypeChanged(null, 0); } /// Go back to request tab if (!p_FirstActivation && m_TypeSegmentControl.selectedCellNumber != 0) { m_TypeSegmentControl.SelectCellWithNumber(0); OnQueueTypeChanged(null, 0); } else { RebuildSongList(true); } }
protected override void DidActivate(bool firstActivation, ActivationType activationType) { if (firstActivation) { _settingsSegments = CustomExtensions.CreateTextSegmentedControl(rectTransform, new Vector2(0f, -9f)); _settingsSegments.SetTexts(new string[] { "General", "Voice" }); _settingsSegments.didSelectCellEvent += SettingsCellSelected; #region General Settings int generalSettingsIndex = 0; var avatarsInGame = CustomSettingsHelper.AddToggleSetting <OnOffViewController>(rectTransform, "Show Avatars In Game", new Vector2(0f, 22.5f + -8f * generalSettingsIndex++)); avatarsInGame.ValueChanged += (value) => { Config.Instance.ShowAvatarsInGame = value; }; avatarsInGame.Value = Config.Instance.ShowAvatarsInGame; _generalSettings.Add(avatarsInGame.gameObject); var blocksInGame = CustomSettingsHelper.AddToggleSetting <OnOffViewController>(rectTransform, "Show Other Players Blocks", new Vector2(0f, 22.5f + -8f * generalSettingsIndex++)); blocksInGame.ValueChanged += (value) => { Config.Instance.ShowOtherPlayersBlocks = value; }; blocksInGame.Value = Config.Instance.ShowOtherPlayersBlocks; _generalSettings.Add(blocksInGame.gameObject); var avatarsInRoom = CustomSettingsHelper.AddToggleSetting <OnOffViewController>(rectTransform, "Show Avatars In Room", new Vector2(0f, 22.5f + -8f * generalSettingsIndex++)); avatarsInRoom.ValueChanged += (value) => { Config.Instance.ShowAvatarsInRoom = value; }; avatarsInRoom.Value = Config.Instance.ShowAvatarsInRoom; _generalSettings.Add(avatarsInRoom.gameObject); var downloadAvatars = CustomSettingsHelper.AddToggleSetting <OnOffViewController>(rectTransform, "Download Other Players Avatars", new Vector2(0f, 22.5f + -8f * generalSettingsIndex++)); downloadAvatars.ValueChanged += (value) => { Config.Instance.DownloadAvatars = value; }; downloadAvatars.Value = Config.Instance.DownloadAvatars; _generalSettings.Add(downloadAvatars.gameObject); var separateAvatar = CustomSettingsHelper.AddToggleSetting <OnOffViewController>(rectTransform, "Separate Avatar For Multiplayer", new Vector2(0f, 22.5f + -8f * generalSettingsIndex++)); separateAvatar.ValueChanged += (value) => { InGameOnlineController.Instance.SetSeparatePublicAvatarState(value); }; separateAvatar.Value = Config.Instance.SeparateAvatarForMultiplayer; _generalSettings.Add(separateAvatar.gameObject); _publicAvatarOption = CustomSettingsHelper.AddListSetting <MultiplayerListViewController>(rectTransform, "Public Avatar", new Vector2(0f, 22.5f + -8f * generalSettingsIndex++)); _publicAvatarOption.OnEnable(); _publicAvatarOption.ValueChanged += (e) => { InGameOnlineController.Instance.SetSeparatePublicAvatarHash(ModelSaberAPI.cachedAvatars.FirstOrDefault(x => x.Value == CustomAvatar.Plugin.Instance.AvatarLoader.Avatars[e]).Key); }; _publicAvatarOption.maxValue = CustomAvatar.Plugin.Instance.AvatarLoader.Avatars.Count - 1; _publicAvatarOption.textForValues = CustomAvatar.Plugin.Instance.AvatarLoader.Avatars.Select(x => (string.IsNullOrEmpty(x.Name) ? "" : x.Name)).ToArray(); if (ModelSaberAPI.cachedAvatars.TryGetValue(Config.Instance.PublicAvatarHash, out CustomAvatar.CustomAvatar avatar)) { _publicAvatarOption.Value = CustomAvatar.Plugin.Instance.AvatarLoader.Avatars.ToList().IndexOf(avatar); } else { if (ModelSaberAPI.isCalculatingHashes) { ModelSaberAPI.hashesCalculated -= UpdateSelectedAvatar; ModelSaberAPI.hashesCalculated += UpdateSelectedAvatar; } _publicAvatarOption.Value = 0; } _publicAvatarOption.UpdateText(); _generalSettings.Add(_publicAvatarOption.gameObject); var spectatorMode = CustomSettingsHelper.AddToggleSetting <OnOffViewController>(rectTransform, "Spectator Mode", new Vector2(0f, 22.5f + -8f * generalSettingsIndex++)); spectatorMode.Value = Config.Instance.SpectatorMode; spectatorMode.ValueChanged += (value) => { Config.Instance.SpectatorMode = value; }; _generalSettings.Add(spectatorMode.gameObject); #endregion #region Voice Settings int voiceSettingsIndex = 0; var voiceEnabled = CustomSettingsHelper.AddToggleSetting <OnOffViewController>(rectTransform, "Enable Voice Chat", new Vector2(0f, 22.5f + -8f * voiceSettingsIndex++)); voiceEnabled.ValueChanged += (value) => { InGameOnlineController.Instance.ToggleVoiceChat(value); }; voiceEnabled.Value = Config.Instance.EnableVoiceChat; _voiceSettings.Add(voiceEnabled.gameObject); var voiceVolume = CustomSettingsHelper.AddListSetting <MultiplayerListViewController>(rectTransform, "Voice Chat Volume", new Vector2(0f, 22.5f + -8f * voiceSettingsIndex++)); voiceVolume.Value = (int)(Config.Instance.VoiceChatVolume * 20f); voiceVolume.ValueChanged += delegate(int value) { Config.Instance.VoiceChatVolume = value / 20f; InGameOnlineController.Instance.VoiceChatVolumeChanged(value / 20f); }; voiceVolume.maxValue = 20; _voiceSettings.Add(voiceVolume.gameObject); var micEnabled = CustomSettingsHelper.AddToggleSetting <OnOffViewController>(rectTransform, "Enable Microphone", new Vector2(0f, 22.5f + -8f * voiceSettingsIndex++)); micEnabled.Value = Config.Instance.MicEnabled; micEnabled.ValueChanged += delegate(bool value) { Config.Instance.MicEnabled = value; }; _voiceSettings.Add(micEnabled.gameObject); var spatialAudio = CustomSettingsHelper.AddToggleSetting <OnOffViewController>(rectTransform, "Spatial Audio", new Vector2(0f, 22.5f + -8f * voiceSettingsIndex++)); spatialAudio.Value = Config.Instance.SpatialAudio; spatialAudio.ValueChanged += delegate(bool value) { Config.Instance.SpatialAudio = value; InGameOnlineController.Instance.VoiceChatSpatialAudioChanged(value); }; _voiceSettings.Add(spatialAudio.gameObject); var pushToTalk = CustomSettingsHelper.AddToggleSetting <OnOffViewController>(rectTransform, "Push to Talk", new Vector2(0f, 22.5f + -8f * voiceSettingsIndex++)); pushToTalk.Value = Config.Instance.PushToTalk; pushToTalk.ValueChanged += delegate(bool value) { Config.Instance.PushToTalk = value; }; _voiceSettings.Add(pushToTalk.gameObject); var pushToTalkButton = CustomSettingsHelper.AddListSetting <MultiplayerListViewController>(rectTransform, "Push to Talk Button", new Vector2(0f, 22.5f + -8f * voiceSettingsIndex++)); pushToTalkButton.OnEnable(); pushToTalkButton.ValueChanged += (e) => { Config.Instance.PushToTalkButton = e; }; pushToTalkButton.maxValue = 7; pushToTalkButton.textForValues = new string[] { "L Grip", "R Grip", "L Trigger", "R Trigger", "L+R Grip", "L+R Trigger", "Any Grip", "Any Trigger" }; pushToTalkButton.Value = Config.Instance.PushToTalkButton; pushToTalkButton.UpdateText(); _voiceSettings.Add(pushToTalkButton.gameObject); #endregion SettingsCellSelected(null, 0); } }
//////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// /// <summary> /// On activation /// </summary> /// <param name="p_FirstActivation">Is the first activation ?</param> /// <param name="p_AddedToHierarchy">Activation type</param> /// <param name="p_ScreenSystemEnabling">Is screen system enabled</param> protected override void DidActivate(bool p_FirstActivation, bool p_AddedToHierarchy, bool p_ScreenSystemEnabling) { /// Forward event base.DidActivate(p_FirstActivation, p_AddedToHierarchy, p_ScreenSystemEnabling); if (p_FirstActivation) { var l_Event = new BeatSaberMarkupLanguage.Parser.BSMLAction(this, this.GetType().GetMethod(nameof(Settings.OnSettingChanged), System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)); /// Create type selector m_TypeSegmentControl = BeatSaberPlus.Utils.GameUI.CreateTextSegmentedControl(m_TypeSegmentPanel.transform as RectTransform, false); m_TypeSegmentControl.SetTexts(new string[] { "Gameplay", "Menu", "Dev / Testing" }); m_TypeSegmentControl.ReloadData(); m_TypeSegmentControl.didSelectCellEvent += OnTypeChanged; //////////////////////////////////////////////////////////////////////////// /// GamePlay //////////////////////////////////////////////////////////////////////////// /// Prepare sliders left Utils.GameUI.PrepareToggleSetting(m_RemoveDebris, l_Event, Config.GameTweaker.RemoveDebris, true); Utils.GameUI.PrepareToggleSetting(m_RemoveAllCutParticles, l_Event, Config.GameTweaker.RemoveAllCutParticles, true); Utils.GameUI.PrepareToggleSetting(m_RemoveAllObstacleParticles, l_Event, Config.GameTweaker.RemoveObstacleParticles, true); Utils.GameUI.PrepareToggleSetting(m_RemoveFloorBurnMarkParticles, l_Event, Config.GameTweaker.RemoveSaberBurnMarkSparkles, true); Utils.GameUI.PrepareToggleSetting(m_RemoveFloorBurnMarkEffects, l_Event, Config.GameTweaker.RemoveSaberBurnMarks, true); Utils.GameUI.PrepareToggleSetting(m_RemoveSaberClashEffects, l_Event, Config.GameTweaker.RemoveSaberClashEffects, true); /// Prepare sliders right Utils.GameUI.PrepareToggleSetting(m_RemoveMusicBandLogo, l_Event, Config.GameTweaker.RemoveMusicBandLogo, true); Utils.GameUI.PrepareToggleSetting(m_RemoveFullComboLossAnimation, l_Event, Config.GameTweaker.RemoveFullComboLossAnimation, true); Utils.GameUI.PrepareToggleSetting(m_NoFake360HUD, l_Event, Config.GameTweaker.NoFake360HUD, true); Utils.GameUI.PrepareToggleSetting(m_RemoveTrail, l_Event, Config.GameTweaker.RemoveSaberSmoothingTrail, true); Utils.GameUI.PrepareIncrementSetting(m_Intensity, l_Event, null, Config.GameTweaker.SaberSmoothingTrailIntensity, true); //m_MenuConfirmation.Value = Config.GameTweaker.SongBackButtonConfirm; //m_RestartConfirmation.Value = Config.GameTweaker.SongRestartButtonConfirm; //m_MenuConfirmation.onChange = l_Event; //m_RestartConfirmation.onChange = l_Event; /// Update UI m_Intensity.gameObject.SetActive(false); m_Intensity.interactable = !Config.GameTweaker.RemoveSaberSmoothingTrail; m_Intensity.gameObject.SetActive(true); //////////////////////////////////////////////////////////////////////////// /// Menu //////////////////////////////////////////////////////////////////////////// /// Prepare sliders Utils.GameUI.PrepareToggleSetting(m_DisableBeatMapEditorButtonInMainMenu, l_Event, Config.GameTweaker.DisableBeatMapEditorButtonOnMainMenu, false); Utils.GameUI.PrepareToggleSetting(m_ShowPlayerStatisticsInMainMenu, l_Event, Config.GameTweaker.ShowPlayerStatisticsOnMainMenu, false); Utils.GameUI.PrepareToggleSetting(m_RemoveNewContentPromotional, l_Event, Config.GameTweaker.RemoveNewContentPromotional, false); Utils.GameUI.PrepareToggleSetting(m_ReorderPlayerSettings, l_Event, Config.GameTweaker.ReorderPlayerSettings, false); Utils.GameUI.PrepareToggleSetting(m_AddOverrideLightIntensityOption, l_Event, Config.GameTweaker.AddOverrideLightIntensityOption, false); Utils.GameUI.PrepareToggleSetting(m_RemoveBaseGameFilterButton, l_Event, Config.GameTweaker.RemoveBaseGameFilterButton, false); Utils.GameUI.PrepareToggleSetting(m_DeleteSongButton, l_Event, Config.GameTweaker.DeleteSongButton, false); //////////////////////////////////////////////////////////////////////////// /// Dev / Testing //////////////////////////////////////////////////////////////////////////// /// Prepare sliders Utils.GameUI.PrepareToggleSetting(m_FPFCEscape, l_Event, Config.GameTweaker.FPFCEscape, false); //////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// /// Force change to tab SubRain OnTypeChanged(null, 0); } }
protected override void DidActivate(bool firstActivation, ActivationType activationType) { if (firstActivation && activationType == ActivationType.AddedToHierarchy) { _downloadListTableCellInstance = Resources.FindObjectsOfTypeAll <LeaderboardTableCell>().First(); _tabControl = BeatSaberUI.CreateTextSegmentedControl(rectTransform, new Vector2(0f, 31f), new Vector2(100f, 7f), _tabControl_didSelectCellEvent); _tabControl.SetTexts(new string[] { "Players", "Modifiers" }); #region Modifiers tab _modifiersTab = new GameObject("ModifiersTab", typeof(RectTransform)).GetComponent <RectTransform>(); _modifiersTab.SetParent(rectTransform, false); _modifiersTab.anchorMin = new Vector2(0f, 0f); _modifiersTab.anchorMax = new Vector2(1f, 1f); _modifiersTab.anchoredPosition = new Vector2(0f, 0f); _modifiersTab.sizeDelta = new Vector2(0f, 0f); _modifiersPanel = Instantiate(Resources.FindObjectsOfTypeAll <GameplayModifiersPanelController>().First(), rectTransform, false); _modifiersPanel.SetData(GameplayModifiers.defaultModifiers); _modifiersPanel.gameObject.SetActive(true); _modifiersPanel.transform.SetParent(_modifiersTab, false); (_modifiersPanel.transform as RectTransform).anchorMin = new Vector2(0.5f, 0f); (_modifiersPanel.transform as RectTransform).anchorMax = new Vector2(0.5f, 1f); (_modifiersPanel.transform as RectTransform).anchoredPosition = new Vector2(0f, -23f); (_modifiersPanel.transform as RectTransform).sizeDelta = new Vector2(120f, -23f); HoverHintController hoverHintController = Resources.FindObjectsOfTypeAll <HoverHintController>().First(); foreach (var hint in _modifiersPanel.GetComponentsInChildren <HoverHint>()) { hint.SetPrivateField("_hoverHintController", hoverHintController); } _modifiersPanel.Awake(); var modifierToggles = _modifiersPanel.GetPrivateField <GameplayModifierToggle[]>("_gameplayModifierToggles"); foreach (var item in modifierToggles) { item.toggle.onValueChanged.AddListener((enabled) => { Plugin.log.Info("Toggle changed"); gameplayModifiersChanged?.Invoke(); }); } _modifiersPanelBlocker = new GameObject("ModifiersPanelBlocker", typeof(RectTransform)).GetComponent <RectTransform>(); //"If it works it's not stupid" _modifiersPanelBlocker.SetParent(_modifiersTab, false); _modifiersPanelBlocker.gameObject.AddComponent <UnityEngine.UI.Image>().color = new Color(0f, 0f, 0f, 0f); _modifiersPanelBlocker.anchorMin = new Vector2(0f, 0f); _modifiersPanelBlocker.anchorMax = new Vector2(1f, 0f); _modifiersPanelBlocker.pivot = new Vector2(0.5f, 0f); _modifiersPanelBlocker.sizeDelta = new Vector2(-10f, 62f); _modifiersPanelBlocker.anchoredPosition = new Vector2(0f, 0f); #endregion #region Players tab _playersTab = new GameObject("PlayersTab", typeof(RectTransform)).GetComponent <RectTransform>(); _playersTab.SetParent(rectTransform, false); _playersTab.anchorMin = new Vector2(0f, 0f); _playersTab.anchorMax = new Vector2(1f, 1f); _playersTab.anchoredPosition = new Vector2(0f, 0f); _playersTab.sizeDelta = new Vector2(0f, 0f); _pageUpButton = Instantiate(Resources.FindObjectsOfTypeAll <Button>().Last(x => (x.name == "PageUpButton")), _playersTab, 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, -18.5f); (_pageUpButton.transform as RectTransform).sizeDelta = new Vector2(40f, 6f); _pageUpButton.interactable = true; _pageUpButton.onClick.AddListener(delegate() { _playersTableViewScroller.PageScrollUp(); }); _pageUpButton.interactable = false; _pageDownButton = Instantiate(Resources.FindObjectsOfTypeAll <Button>().First(x => (x.name == "PageDownButton")), _playersTab, 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, 7f); (_pageDownButton.transform as RectTransform).sizeDelta = new Vector2(40f, 6f); _pageDownButton.interactable = true; _pageDownButton.onClick.AddListener(delegate() { _playersTableViewScroller.PageScrollDown(); }); _pageDownButton.interactable = false; RectTransform container = new GameObject("Content", typeof(RectTransform)).transform as RectTransform; container.SetParent(_playersTab, false); container.anchorMin = new Vector2(0.15f, 0.5f); container.anchorMax = new Vector2(0.85f, 0.5f); container.sizeDelta = new Vector2(0f, 49f); container.anchoredPosition = new Vector2(0f, -3f); var tableGameObject = new GameObject("CustomTableView"); tableGameObject.SetActive(false); _playersTableView = tableGameObject.AddComponent <TableView>(); _playersTableView.gameObject.AddComponent <RectMask2D>(); _playersTableView.transform.SetParent(container, false); _playersTableView.SetPrivateField("_isInitialized", false); _playersTableView.SetPrivateField("_preallocatedCells", new TableView.CellsGroup[0]); _playersTableView.SetPrivateField("_tableType", TableView.TableType.Vertical); var viewport = new GameObject("Viewport").AddComponent <RectTransform>(); viewport.SetParent(tableGameObject.GetComponent <RectTransform>(), 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); tableGameObject.GetComponent <ScrollRect>().viewport = viewport; _playersTableView.Init(); (_playersTableView.transform as RectTransform).anchorMin = new Vector2(0f, 0f); (_playersTableView.transform as RectTransform).anchorMax = new Vector2(1f, 1f); (_playersTableView.transform as RectTransform).sizeDelta = new Vector2(0f, 0f); (_playersTableView.transform as RectTransform).anchoredPosition = new Vector3(0f, 0f); ReflectionUtil.SetPrivateField(_playersTableView, "_pageUpButton", _pageUpButton); ReflectionUtil.SetPrivateField(_playersTableView, "_pageDownButton", _pageDownButton); tableGameObject.SetActive(true); _playersTableViewScroller = _playersTableView.GetPrivateField <TableViewScroller>("_scroller"); //_playersTableViewScroller.SetPrivateField("position", zero); _playersTableView.dataSource = this; #endregion _pingText = this.CreateText("PING: 0", new Vector2(75f, 22.5f)); _pingText.alignment = TextAlignmentOptions.Left; _tabControl_didSelectCellEvent(0); } else { for (int i = 0; i < _tableCells.Count; i++) { Destroy(_tableCells[i].gameObject); } _tableCells.Clear(); _playersTableView.ReloadData(); } if (activationType == ActivationType.AddedToHierarchy) { StartCoroutine(ScrollWithDelay()); SetGameplayModifiers(GameplayModifiers.defaultModifiers); } }
//////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// /// <summary> /// On activation /// </summary> /// <param name="p_FirstActivation">Is the first activation ?</param> /// <param name="p_AddedToHierarchy">Activation type</param> /// <param name="p_ScreenSystemEnabling">Is screen system enabled</param> protected override void DidActivate(bool p_FirstActivation, bool p_AddedToHierarchy, bool p_ScreenSystemEnabling) { /// Forward event base.DidActivate(p_FirstActivation, p_AddedToHierarchy, p_ScreenSystemEnabling); if (p_FirstActivation) { m_SongsProvider = Plugins.ChatRequest.ChatRequest.Instance.SongHistory; /// Scale down up & down button m_SongUpButton.transform.localScale = Vector3.one * 0.6f; m_SongDownButton.transform.localScale = Vector3.one * 0.6f; /// Create type selector m_TypeSegmentControl = Utils.GameUI.CreateTextSegmentedControl(m_TypeSegmentPanel.transform as RectTransform, false); m_TypeSegmentControl.SetTexts(new string[] { "Playlist Generator", "Playlist" }); m_TypeSegmentControl.ReloadData(); m_TypeSegmentControl.didSelectCellEvent += OnTabChanged; /// Bind events m_SongUpButton.onClick.AddListener(OnSongPageUpPressed); m_SongList.tableView.didSelectCellWithIdxEvent += OnSongSelected; m_SongDownButton.onClick.AddListener(OnSongPageDownPressed); /// Find song preview object m_SongPreviewPlayer = Resources.FindObjectsOfTypeAll <SongPreviewPlayer>().First(); /// Show song info panel m_SongInfo_Detail = new BeatSaberPlus.UI.Widget.SongDetail(m_SongInfoPanel.transform); UnselectSong(); m_SongInfo_Detail.SetPlayButtonText("Play"); m_SongInfo_Detail.SetPlayButtonEnabled(true); m_SongInfo_Detail.SetPlayButtonAction(PlaySong); m_SongInfo_Detail.OnActiveDifficultyChanged += (x) => { /// Hide if no data if (x == null) { BeatSaberPlus.UI.ViewFlowCoordinator.Instance.SetRightScreen(null); } /// Show score board var l_ScoreBoard = Resources.FindObjectsOfTypeAll <PlatformLeaderboardViewController>().FirstOrDefault(); if (l_ScoreBoard != null) { if (!l_ScoreBoard.isInViewControllerHierarchy) { BeatSaberPlus.UI.ViewFlowCoordinator.Instance.SetRightScreen(l_ScoreBoard); } l_ScoreBoard.SetData(x); } }; /// Init loading modal m_LoadingModalSpinner = GameObject.Instantiate(Resources.FindObjectsOfTypeAll <LoadingControl>().First(), m_LoadingModal.transform); m_LoadingModalSpinner.transform.SetAsLastSibling(); Destroy(m_LoadingModalSpinner.GetComponent <Touchable>()); /// Force change to tab Request OnTabChanged(null, 0); } }
public void SetContent(MoreSongsFlowCoordinator sender, Song newSongInfo) { selectedCharacteristic = null; currentDifficulties = null; _currentSong = newSongInfo; songNameText.text = _currentSong.songName; if (_characteristicSegmentedDisplay == null) { _characteristicSegmentedDisplay = BeatSaberUI.CreateIconSegmentedControl(rectTransform, new Vector2(-40, .2f), new Vector2(70, 9f), delegate(int value) { SelectedCharacteristic(_currentSong.metadata.characteristics[value]); }); SetupCharacteristicDisplay(_characteristicSegmentedDisplay, _currentSong); } else { SetupCharacteristicDisplay(_characteristicSegmentedDisplay, _currentSong); } if (_difficultySegmentedDisplay == null) { _difficultySegmentedDisplay = BeatSaberUI.CreateTextSegmentedControl(rectTransform, new Vector2(-40, -9f), new Vector2(85, 8f), delegate(int value) { SelectedDifficulty(currentDifficulties[value]); }); _difficultySegmentedDisplay.transform.localScale = new Vector3(.8f, _difficultySegmentedDisplay.transform.localScale.y, _difficultySegmentedDisplay.transform.localScale.z); SetupDifficultyDisplay(_difficultySegmentedDisplay, _currentSong); } else { SetupDifficultyDisplay(_difficultySegmentedDisplay, _currentSong); } downloadsText.text = _currentSong.downloads.ToString(); _levelParams.bpm = (float)(_currentSong.plays); _levelParams.notesCount = (int)_currentSong.bpm; _levelParams.obstaclesCount = _currentSong.upVotes; _levelParams.bombsCount = _currentSong.downVotes; Polyglot.LocalizedTextMeshProUGUI localizer1 = difficulty1Title.GetComponentInChildren <Polyglot.LocalizedTextMeshProUGUI>(); if (localizer1 != null) { GameObject.Destroy(localizer1); } Polyglot.LocalizedTextMeshProUGUI localizer2 = difficulty2Title.GetComponentInChildren <Polyglot.LocalizedTextMeshProUGUI>(); if (localizer2 != null) { GameObject.Destroy(localizer2); } Polyglot.LocalizedTextMeshProUGUI localizer3 = difficulty3Title.GetComponentInChildren <Polyglot.LocalizedTextMeshProUGUI>(); if (localizer3 != null) { GameObject.Destroy(localizer3); } difficulty1Title.text = ""; difficulty2Title.text = ""; difficulty3Title.text = ""; difficulty1Text.text = ""; difficulty2Text.text = ""; difficulty3Text.text = ""; // difficulty1Text.text = (_currentSong.metadata.difficulties.expert || _currentSong.metadata.difficulties.expertPlus) ? "Yes" : "No"; // difficulty2Text.text = (_currentSong.metadata.difficulties.hard) ? "Yes" : "No"; // difficulty3Text.text = (_currentSong.metadata.difficulties.easy || _currentSong.metadata.difficulties.normal) ? "Yes" : "No"; StartCoroutine(LoadScripts.LoadSpriteCoroutine(_currentSong.coverURL, (cover) => { coverImage.texture = cover.texture; })); SetFavoriteState(PluginConfig.favoriteSongs.Any(x => x.Contains(_currentSong.hash))); SetDownloadState((SongDownloader.Instance.IsSongDownloaded(_currentSong) ? DownloadState.Downloaded : (sender.IsDownloadingSong(_currentSong) ? DownloadState.Downloading : DownloadState.NotDownloaded))); SetLoadingState(false); SelectedCharacteristic(_currentSong.metadata.characteristics[0]); }
protected override void DidActivate(bool firstActivation, ActivationType activationType) { if (firstActivation && activationType == ActivationType.AddedToHierarchy) { _beatmapCharacteristics = Resources.FindObjectsOfTypeAll <BeatmapCharacteristicSO>(); _standardCharacteristic = _beatmapCharacteristics.First(x => x.serializedName == "Standard"); bool isHost = Client.Instance.isHost; _selectedSongCell = Instantiate(Resources.FindObjectsOfTypeAll <LevelListTableCell>().First(x => (x.name == "LevelListTableCell")), rectTransform, false); (_selectedSongCell.transform as RectTransform).anchorMin = new Vector2(0.5f, 0.5f); (_selectedSongCell.transform as RectTransform).anchorMax = new Vector2(0.5f, 0.5f); (_selectedSongCell.transform as RectTransform).anchoredPosition = new Vector2(-25f, 7.5f); _selectedSongCell.SetPrivateField("_beatmapCharacteristicAlphas", new float[0]); _selectedSongCell.SetPrivateField("_beatmapCharacteristicImages", new UnityEngine.UI.Image[0]); _selectedSongCell.SetPrivateField("_bought", true); foreach (var icon in _selectedSongCell.GetComponentsInChildren <UnityEngine.UI.Image>().Where(x => x.name.StartsWith("LevelTypeIcon"))) { Destroy(icon.gameObject); } _playersReadyText = BeatSaberUI.CreateText(rectTransform, "0/0 players ready", new Vector2(0f, 5f)); _playersReadyText.rectTransform.anchorMin = new Vector2(0.5f, 0f); _playersReadyText.rectTransform.anchorMax = new Vector2(0.5f, 0f); _playersReadyText.alignment = TextAlignmentOptions.Center; _playersReadyText.fontSize = 5.5f; _cancelButton = BeatSaberUI.CreateUIButton(rectTransform, "CancelButton"); (_cancelButton.transform as RectTransform).anchoredPosition = new Vector2(-30f, -25f); (_cancelButton.transform as RectTransform).sizeDelta = new Vector2(28f, 12f); _cancelButton.SetButtonText("CANCEL"); _cancelButton.ToggleWordWrapping(false); _cancelButton.SetButtonTextSize(5.5f); _cancelButton.onClick.AddListener(delegate() { discardPressed?.Invoke(); }); _cancelButton.gameObject.SetActive(isHost); _playButton = BeatSaberUI.CreateUIButton(rectTransform, "CancelButton"); (_playButton.transform as RectTransform).anchoredPosition = new Vector2(30f, -25f); (_playButton.transform as RectTransform).sizeDelta = new Vector2(28f, 12f); _playButton.SetButtonText("PLAY"); _playButton.ToggleWordWrapping(false); _playButton.SetButtonTextSize(5.5f); _playButton.onClick.AddListener(delegate() { playPressed?.Invoke(_selectedSong, selectedCharacteristic, selectedDifficulty); }); var playGlow = Instantiate(Resources.FindObjectsOfTypeAll <Button>().First(x => x.name == "PlayButton").GetComponentsInChildren <RectTransform>().First(x => x.name == "GlowContainer"), _playButton.transform); //Let's add some glow! playGlow.transform.SetAsFirstSibling(); playGlow.GetComponentInChildren <UnityEngine.UI.Image>().color = new Color(0f, 0.7058824f, 1f, 0.7843137f); _playButton.gameObject.SetActive(isHost); _characteristicControl = BeatSaberUI.CreateTextSegmentedControl(rectTransform, new Vector2(0f, 34f), new Vector2(110f, 7f), _characteristicControl_didSelectCellEvent); _characteristicControl.SetTexts(new string[] { "Standard", "No Arrows", "One Saber" }); _characteristicControlBlocker = new GameObject("CharacteristicControlBlocker", typeof(RectTransform)).GetComponent <RectTransform>(); //"If it works it's not stupid" _characteristicControlBlocker.SetParent(rectTransform, false); _characteristicControlBlocker.gameObject.AddComponent <UnityEngine.UI.Image>().color = new Color(0f, 0f, 0f, 0f); _characteristicControlBlocker.anchorMin = new Vector2(0f, 1f); _characteristicControlBlocker.anchorMax = new Vector2(1f, 1f); _characteristicControlBlocker.sizeDelta = new Vector2(-30f, 7f); _characteristicControlBlocker.anchoredPosition = new Vector2(0f, -6f); _difficultyControl = BeatSaberUI.CreateTextSegmentedControl(rectTransform, new Vector2(0f, 24f), new Vector2(110f, 7f), _difficultyControl_didSelectCellEvent); _difficultyControl.SetTexts(new string[] { "Easy", "Normal", "Hard", "Expert", "Expert+" }); _difficultyControlBlocker = new GameObject("DifficultyControlBlocker", typeof(RectTransform)).GetComponent <RectTransform>(); //"If it works it's not stupid" _difficultyControlBlocker.SetParent(rectTransform, false); _difficultyControlBlocker.gameObject.AddComponent <UnityEngine.UI.Image>().color = new Color(0f, 0f, 0f, 0f); _difficultyControlBlocker.anchorMin = new Vector2(0f, 1f); _difficultyControlBlocker.anchorMax = new Vector2(1f, 1f); _difficultyControlBlocker.sizeDelta = new Vector2(-30f, 7f); _difficultyControlBlocker.anchoredPosition = new Vector2(0f, -16f); _progressBarRect = new GameObject("ProgressBar", typeof(RectTransform)).GetComponent <RectTransform>(); _progressBarRect.SetParent(rectTransform, false); _progressBarRect.anchorMin = new Vector2(0.5f, 0.5f); _progressBarRect.anchorMax = new Vector2(0.5f, 0.5f); _progressBarRect.anchoredPosition = new Vector2(0f, -7.5f); _progressBarRect.sizeDelta = new Vector2(46f, 5f); _progressBackground = new GameObject("Background", typeof(RectTransform), typeof(UnityEngine.UI.Image)).GetComponent <UnityEngine.UI.Image>(); _progressBackground.rectTransform.SetParent(_progressBarRect, false); _progressBackground.rectTransform.anchorMin = new Vector2(0f, 0f); _progressBackground.rectTransform.anchorMax = new Vector2(1f, 1f); _progressBackground.rectTransform.anchoredPosition = new Vector2(0f, 0f); _progressBackground.rectTransform.sizeDelta = new Vector2(0f, 0f); _progressBackground.sprite = Sprites.whitePixel; _progressBackground.material = Sprites.NoGlowMat; _progressBackground.color = new Color(1f, 1f, 1f, 0.075f); _progressBarImage = new GameObject("ProgressImage", typeof(RectTransform), typeof(UnityEngine.UI.Image)).GetComponent <UnityEngine.UI.Image>(); _progressBarImage.rectTransform.SetParent(_progressBarRect, false); _progressBarImage.rectTransform.anchorMin = new Vector2(0f, 0f); _progressBarImage.rectTransform.anchorMax = new Vector2(1f, 1f); _progressBarImage.rectTransform.anchoredPosition = new Vector2(0f, 0f); _progressBarImage.rectTransform.sizeDelta = new Vector2(0f, 0f); _progressBarImage.sprite = Sprites.whitePixel; _progressBarImage.material = Sprites.NoGlowMat; _progressBarImage.type = UnityEngine.UI.Image.Type.Filled; _progressBarImage.fillMethod = UnityEngine.UI.Image.FillMethod.Horizontal; _progressBarImage.fillAmount = 0.5f; _progressText = BeatSaberUI.CreateText(rectTransform, "0.0%", new Vector2(55f, -10f)); _progressText.rectTransform.SetParent(_progressBarRect, true); } _playButton.interactable = false; _progressBarRect.gameObject.SetActive(false); }
public void DifficultySelected(TextSegmentedControl sender, int index) { selectedDifficulty = selectedLevel.beatmapLevelData.GetDifficultyBeatmapSet(selectedBeatmapCharacteristic).difficultyBeatmaps[index].difficulty; _playerDataModel.playerData.SetLastSelectedBeatmapDifficulty(selectedDifficulty); }