Esempio n. 1
0
        public static void PrepareColorSetting(ColorSetting p_Setting, BSMLAction p_Action, Color p_Value, bool p_RemoveLabel)
        {
            p_Setting.gameObject.SetActive(false);

            p_Value.a = 1.0f;
            p_Setting.CurrentColor = p_Value;

            if (p_Action != null)
            {
                p_Setting.onChange = p_Action;
            }

            p_Setting.updateOnChange = true;

            if (p_RemoveLabel)
            {
                GameObject.Destroy(p_Setting.gameObject.GetComponentsInChildren <TextMeshProUGUI>().ElementAt(0).transform.gameObject);

                RectTransform l_RectTransform = p_Setting.gameObject.transform.GetChild(1) as RectTransform;
                l_RectTransform.anchorMin = Vector2.zero;
                l_RectTransform.anchorMax = Vector2.one;
                l_RectTransform.sizeDelta = Vector2.one;

                p_Setting.gameObject.GetComponent <LayoutElement>().preferredWidth = -1f;
            }

            p_Setting.gameObject.SetActive(true);
        }
Esempio n. 2
0
        /// <summary>
        /// Setup a increment setting
        /// </summary>
        /// <param name="p_Setting">Setting to setup</param>
        /// <param name="p_Action">Action on change</param>
        /// <param name="p_Formatter">Value formatter</param>
        /// <param name="p_Value">New value</param>
        /// <param name="p_RemoveLabel">Should remove label</param>
        public static void Setup(BSMLIncrementSetting p_Setting, BSMLAction p_Action, BSMLAction p_Formatter, float p_Value, bool p_RemoveLabel)
        {
            p_Setting.gameObject.SetActive(false);

            if (p_Formatter != null)
            {
                p_Setting.formatter = p_Formatter;
            }

            p_Setting.Value = p_Value;

            if (p_Action != null)
            {
                p_Setting.onChange = p_Action;
            }

            if (p_RemoveLabel)
            {
                UnityEngine.GameObject.Destroy(p_Setting.gameObject.GetComponentsInChildren <TextMeshProUGUI>().ElementAt(0).transform.gameObject);

                UnityEngine.RectTransform l_RectTransform = p_Setting.gameObject.transform.GetChild(1) as UnityEngine.RectTransform;
                l_RectTransform.anchorMin = UnityEngine.Vector2.zero;
                l_RectTransform.anchorMax = UnityEngine.Vector2.one;
                l_RectTransform.sizeDelta = UnityEngine.Vector2.one;

                p_Setting.gameObject.GetComponent <UnityEngine.UI.LayoutElement>().preferredWidth = -1f;
            }

            p_Setting.gameObject.SetActive(true);
        }
Esempio n. 3
0
        ////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////

        /// <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 void Init(ListSetting listSetting, MultiplayerModeSelectionViewController multiplayerView)
        {
            _multiplayerView = multiplayerView;
            var changed = new BSMLAction(this, typeof(ServerSelectionController).GetMethod("OnServerChanged"));

            listSetting.onChange = changed;
            UpdateUI(multiplayerView, Plugin.ServerDetailProvider.Selection);
            GameEventDispatcher.Instance.MultiplayerViewEntered += OnMultiplayerViewEntered;
        }
Esempio n. 5
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)
        {
            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);
            }
        }
Esempio n. 6
0
        ////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// On view creation
        /// </summary>
        protected override sealed void OnViewCreation()
        {
            var l_Event     = new BSMLAction(this, this.GetType().GetMethod(nameof(OnSettingChanged), System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic));
            var l_AnchorMin = new Vector2(0.77f, -0.05f);
            var l_AnchorMax = new Vector2(0.91f, 1.05f);

            /// Left
            SDK.UI.ToggleSetting.Setup(m_MenuRain, l_Event, Config.ChatEmoteRain.MenuRain, true);
            SDK.UI.ToggleSetting.Setup(m_SongRain, l_Event, Config.ChatEmoteRain.SongRain, true);
            SDK.UI.SliderSetting.Setup(m_MenuRainSizeSlider, l_Event, null, Config.ChatEmoteRain.MenuRainSize, true, true, l_AnchorMin, l_AnchorMax);
            SDK.UI.SliderSetting.Setup(m_SongRainSizeSlider, l_Event, null, Config.ChatEmoteRain.SongRainSize, true, true, l_AnchorMin, l_AnchorMax);

            /// Right
            SDK.UI.SliderSetting.Setup(m_EmoteDelay, l_Event, null, Config.ChatEmoteRain.EmoteDelay, true, true, l_AnchorMin, l_AnchorMax);
            SDK.UI.SliderSetting.Setup(m_Fallspeed, l_Event, null, Config.ChatEmoteRain.EmoteFallSpeed, true, true, l_AnchorMin, l_AnchorMax);
            SDK.UI.ToggleSetting.Setup(m_ModeratorPowerToggle, l_Event, Config.ChatEmoteRain.ModeratorPower, true);
        }
Esempio n. 7
0
#pragma warning restore CS0649

        ////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////

        /// <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 first activation, bind event
            if (p_FirstActivation)
            {
                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_MenuRain, l_Event, Config.ChatEmoteRain.MenuRain, false);
                Utils.GameUI.PrepareToggleSetting(m_SongRain, l_Event, Config.ChatEmoteRain.SongRain, false);
                Utils.GameUI.PrepareSliderSetting(m_MenuRainSizeSlider, l_Event, null, Config.ChatEmoteRain.MenuRainSize, false);
                Utils.GameUI.PrepareSliderSetting(m_SongRainSizeSlider, l_Event, null, Config.ChatEmoteRain.SongRainSize, false);
                Utils.GameUI.PrepareSliderSetting(m_EmoteDelay, l_Event, null, Config.ChatEmoteRain.EmoteDelay, false);
                Utils.GameUI.PrepareSliderSetting(m_Fallspeed, l_Event, null, Config.ChatEmoteRain.EmoteFallSpeed, false);
            }
        }
        /// <summary>
        /// Setup a toggle setting
        /// </summary>
        /// <param name="p_Setting">Setting to setûp</param>
        /// <param name="p_Action">Action on change</param>
        /// <param name="p_Formatter">Value formatter</param>
        /// <param name="p_Value">New value</param>
        /// <param name="p_RemoveLabel">Should remove label</param>
        /// <param name="p_AddControls">Add Inc/dec buttons</param>
        /// <param name="p_NewRectMin">New rect min</param>
        /// <param name="p_NewRectMax">New rect max</param>
        public static void Setup(BSMLSliderSetting p_Setting,
                                 BSMLAction p_Action,
                                 BSMLAction p_Formatter,
                                 float p_Value,
                                 bool p_RemoveLabel,
                                 bool p_AddControls = false,
                                 UnityEngine.Vector2 p_NewRectMin = default,
                                 UnityEngine.Vector2 p_NewRectMax = default)
        {
            p_Setting.gameObject.SetActive(false);

            if (p_Formatter != null)
            {
                p_Setting.formatter = p_Formatter;
            }

            p_Setting.slider.value = p_Value;

            if (p_Action != null)
            {
                p_Setting.onChange = p_Action;
            }

            p_Setting.updateOnChange = true;

            if (p_RemoveLabel)
            {
                UnityEngine.GameObject.Destroy(p_Setting.gameObject.GetComponentsInChildren <TextMeshProUGUI>().ElementAt(0).transform.gameObject);

                UnityEngine.RectTransform l_RectTransform = p_Setting.gameObject.transform.GetChild(1) as UnityEngine.RectTransform;
                l_RectTransform.anchorMin = UnityEngine.Vector2.zero;
                l_RectTransform.anchorMax = UnityEngine.Vector2.one;
                l_RectTransform.sizeDelta = UnityEngine.Vector2.one;

                p_Setting.gameObject.GetComponent <UnityEngine.UI.LayoutElement>().preferredWidth = -1f;

                if (p_AddControls)
                {
                    l_RectTransform           = p_Setting.gameObject.transform.Find("BSMLSlider") as UnityEngine.RectTransform;
                    l_RectTransform.anchorMin = p_NewRectMin;
                    l_RectTransform.anchorMax = p_NewRectMax;

                    FormattedFloatListSettingsValueController l_BaseSettings = UnityEngine.MonoBehaviour.Instantiate(UnityEngine.Resources.FindObjectsOfTypeAll <FormattedFloatListSettingsValueController>().First(x => (x.name == "VRRenderingScale")), p_Setting.gameObject.transform, false);
                    var l_DecButton = l_BaseSettings.transform.GetChild(1).GetComponentsInChildren <UnityEngine.UI.Button>().First();
                    var l_IncButton = l_BaseSettings.transform.GetChild(1).GetComponentsInChildren <UnityEngine.UI.Button>().Last();

                    l_DecButton.transform.SetParent(p_Setting.gameObject.transform, false);
                    l_DecButton.name = "BSP_DecButton";
                    l_IncButton.transform.SetParent(p_Setting.gameObject.transform, false);
                    l_IncButton.name = "BSP_IncButton";

                    l_IncButton.transform.SetAsFirstSibling();
                    l_DecButton.transform.SetAsFirstSibling();

                    foreach (UnityEngine.Transform l_Child in l_BaseSettings.transform)
                    {
                        UnityEngine.GameObject.Destroy(l_Child.gameObject);
                    }

                    UnityEngine.GameObject.Destroy(l_BaseSettings);

                    p_Setting.slider.valueDidChangeEvent += (_, p_NewValue) =>
                    {
                        l_DecButton.interactable = p_NewValue > p_Setting.slider.minValue;
                        l_IncButton.interactable = p_NewValue < p_Setting.slider.maxValue;
                        p_Setting.ApplyValue();
                        p_Setting.ReceiveValue();
                    };

                    l_DecButton.interactable = p_Setting.slider.value > p_Setting.slider.minValue;
                    l_IncButton.interactable = p_Setting.slider.value < p_Setting.slider.maxValue;

                    l_DecButton.onClick.RemoveAllListeners();
                    l_DecButton.onClick.AddListener(() =>
                    {
                        p_Setting.slider.value  -= p_Setting.increments;
                        l_DecButton.interactable = p_Setting.slider.value > p_Setting.slider.minValue;
                        l_IncButton.interactable = p_Setting.slider.value < p_Setting.slider.maxValue;
                        p_Setting.ApplyValue();
                        p_Setting.ReceiveValue();
                    });
                    l_IncButton.onClick.RemoveAllListeners();
                    l_IncButton.onClick.AddListener(() =>
                    {
                        p_Setting.slider.value  += p_Setting.increments;
                        l_DecButton.interactable = p_Setting.slider.value > p_Setting.slider.minValue;
                        l_IncButton.interactable = p_Setting.slider.value < p_Setting.slider.maxValue;
                        p_Setting.ApplyValue();
                        p_Setting.ReceiveValue();
                    });
                }
            }

            p_Setting.gameObject.SetActive(true);
        }