示例#1
0
        private UISliderControl CreateSlider(UIControlSet set, int inputBehaviorId, string defaultTitle, string overrideTitle, Sprite icon, float minValue, float maxValue, System.Action <int, int, float> valueChangedCallback, System.Action <int, int> cancelCallback)
        {
            // Create slider control
            UISliderControl control = set.CreateSlider(
                uiSliderControlPrefab,
                icon,
                minValue,
                maxValue,
                (int cId, float value) => { valueChangedCallback(inputBehaviorId, cId, value); },
                (int cId) => { cancelCallback(inputBehaviorId, cId); }
                );

            // Title
            string title = string.IsNullOrEmpty(overrideTitle) ? defaultTitle : overrideTitle;

            if (!string.IsNullOrEmpty(title))
            {
                control.showTitle  = true;
                control.title.text = title;
            }
            else
            {
                control.showTitle = false;
            }

            // Icon
            control.showIcon = icon != null;

            return(control);
        }
示例#2
0
 public InputBehaviorInfo(InputBehavior inputBehavior, UIControlSet controlSet, Dictionary <int, InputBehaviorWindow.PropertyType> idToProperty)
 {
     this._inputBehavior = inputBehavior;
     this._controlSet    = controlSet;
     this.idToProperty   = idToProperty;
     this.copyOfOriginal = new InputBehavior(inputBehavior);
 }
示例#3
0
        private UISliderControl CreateSlider(
            UIControlSet set,
            int inputBehaviorId,
            string defaultTitle,
            string overrideTitle,
            Sprite icon,
            float minValue,
            float maxValue,
            Action <int, int, float> valueChangedCallback,
            Action <int, int> cancelCallback)
        {
            UISliderControl slider = set.CreateSlider(this.uiSliderControlPrefab, icon, minValue, maxValue, (Action <int, float>)((cId, value) => valueChangedCallback(inputBehaviorId, cId, value)), (Action <int>)(cId => cancelCallback(inputBehaviorId, cId)));
            string          str    = !string.IsNullOrEmpty(overrideTitle) ? overrideTitle : defaultTitle;

            if (!string.IsNullOrEmpty(str))
            {
                slider.showTitle = true;
                slider.title.set_text(str);
            }
            else
            {
                slider.showTitle = false;
            }
            slider.showIcon = Object.op_Inequality((Object)icon, (Object)null);
            return(slider);
        }
示例#4
0
 public void SetData(int playerId, ControlMapper.InputBehaviorSettings[] data)
 {
     if (!base.initialized)
     {
         return;
     }
     this.playerId = playerId;
     for (int i = 0; i < data.Length; i++)
     {
         ControlMapper.InputBehaviorSettings inputBehaviorSettings = data[i];
         if (inputBehaviorSettings != null && inputBehaviorSettings.isValid)
         {
             InputBehavior inputBehavior = this.GetInputBehavior(inputBehaviorSettings.inputBehaviorId);
             if (inputBehavior != null)
             {
                 UIControlSet uIControlSet = this.CreateControlSet();
                 Dictionary <int, InputBehaviorWindow.PropertyType> dictionary = new Dictionary <int, InputBehaviorWindow.PropertyType>();
                 string customEntry = ControlMapper.GetLanguage().GetCustomEntry(inputBehaviorSettings.labelLanguageKey);
                 if (!string.IsNullOrEmpty(customEntry))
                 {
                     uIControlSet.SetTitle(customEntry);
                 }
                 else
                 {
                     uIControlSet.SetTitle(inputBehavior.name);
                 }
                 if (inputBehaviorSettings.showJoystickAxisSensitivity)
                 {
                     UISliderControl uISliderControl = this.CreateSlider(uIControlSet, inputBehavior.id, null, ControlMapper.GetLanguage().GetCustomEntry(inputBehaviorSettings.joystickAxisSensitivityLabelLanguageKey), inputBehaviorSettings.joystickAxisSensitivityIcon, inputBehaviorSettings.joystickAxisSensitivityMin, inputBehaviorSettings.joystickAxisSensitivityMax, new Action <int, int, float>(this.JoystickAxisSensitivityValueChanged), new Action <int, int>(this.JoystickAxisSensitivityCanceled));
                     uISliderControl.slider.value = Mathf.Clamp(inputBehavior.joystickAxisSensitivity, inputBehaviorSettings.joystickAxisSensitivityMin, inputBehaviorSettings.joystickAxisSensitivityMax);
                     dictionary.Add(uISliderControl.id, InputBehaviorWindow.PropertyType.JoystickAxisSensitivity);
                 }
                 if (inputBehaviorSettings.showMouseXYAxisSensitivity)
                 {
                     UISliderControl uISliderControl2 = this.CreateSlider(uIControlSet, inputBehavior.id, null, ControlMapper.GetLanguage().GetCustomEntry(inputBehaviorSettings.mouseXYAxisSensitivityLabelLanguageKey), inputBehaviorSettings.mouseXYAxisSensitivityIcon, inputBehaviorSettings.mouseXYAxisSensitivityMin, inputBehaviorSettings.mouseXYAxisSensitivityMax, new Action <int, int, float>(this.MouseXYAxisSensitivityValueChanged), new Action <int, int>(this.MouseXYAxisSensitivityCanceled));
                     uISliderControl2.slider.value = Mathf.Clamp(inputBehavior.mouseXYAxisSensitivity, inputBehaviorSettings.mouseXYAxisSensitivityMin, inputBehaviorSettings.mouseXYAxisSensitivityMax);
                     dictionary.Add(uISliderControl2.id, InputBehaviorWindow.PropertyType.MouseXYAxisSensitivity);
                 }
                 this.inputBehaviorInfo.Add(new InputBehaviorWindow.InputBehaviorInfo(inputBehavior, uIControlSet, dictionary));
             }
         }
     }
     base.defaultUIElement = this.doneButton.gameObject;
 }
示例#5
0
 public void SetData(int playerId, Rewired.UI.ControlMapper.ControlMapper.InputBehaviorSettings[] data)
 {
     if (!this.initialized)
     {
         return;
     }
     this.playerId = playerId;
     for (int index = 0; index < data.Length; ++index)
     {
         Rewired.UI.ControlMapper.ControlMapper.InputBehaviorSettings behaviorSettings = data[index];
         if (behaviorSettings != null && behaviorSettings.isValid)
         {
             InputBehavior inputBehavior = this.GetInputBehavior(behaviorSettings.inputBehaviorId);
             if (inputBehavior != null)
             {
                 UIControlSet controlSet = this.CreateControlSet();
                 Dictionary <int, InputBehaviorWindow.PropertyType> idToProperty = new Dictionary <int, InputBehaviorWindow.PropertyType>();
                 string customEntry = Rewired.UI.ControlMapper.ControlMapper.GetLanguage().GetCustomEntry(behaviorSettings.labelLanguageKey);
                 if (!string.IsNullOrEmpty(customEntry))
                 {
                     controlSet.SetTitle(customEntry);
                 }
                 else
                 {
                     controlSet.SetTitle(inputBehavior.get_name());
                 }
                 if (behaviorSettings.showJoystickAxisSensitivity)
                 {
                     UISliderControl slider = this.CreateSlider(controlSet, inputBehavior.get_id(), (string)null, Rewired.UI.ControlMapper.ControlMapper.GetLanguage().GetCustomEntry(behaviorSettings.joystickAxisSensitivityLabelLanguageKey), behaviorSettings.joystickAxisSensitivityIcon, behaviorSettings.joystickAxisSensitivityMin, behaviorSettings.joystickAxisSensitivityMax, new Action <int, int, float>(this.JoystickAxisSensitivityValueChanged), new Action <int, int>(this.JoystickAxisSensitivityCanceled));
                     slider.slider.set_value(Mathf.Clamp(inputBehavior.get_joystickAxisSensitivity(), behaviorSettings.joystickAxisSensitivityMin, behaviorSettings.joystickAxisSensitivityMax));
                     idToProperty.Add(slider.id, InputBehaviorWindow.PropertyType.JoystickAxisSensitivity);
                 }
                 if (behaviorSettings.showMouseXYAxisSensitivity)
                 {
                     UISliderControl slider = this.CreateSlider(controlSet, inputBehavior.get_id(), (string)null, Rewired.UI.ControlMapper.ControlMapper.GetLanguage().GetCustomEntry(behaviorSettings.mouseXYAxisSensitivityLabelLanguageKey), behaviorSettings.mouseXYAxisSensitivityIcon, behaviorSettings.mouseXYAxisSensitivityMin, behaviorSettings.mouseXYAxisSensitivityMax, new Action <int, int, float>(this.MouseXYAxisSensitivityValueChanged), new Action <int, int>(this.MouseXYAxisSensitivityCanceled));
                     slider.slider.set_value(Mathf.Clamp(inputBehavior.get_mouseXYAxisSensitivity(), behaviorSettings.mouseXYAxisSensitivityMin, behaviorSettings.mouseXYAxisSensitivityMax));
                     idToProperty.Add(slider.id, InputBehaviorWindow.PropertyType.MouseXYAxisSensitivity);
                 }
                 this.inputBehaviorInfo.Add(new InputBehaviorWindow.InputBehaviorInfo(inputBehavior, controlSet, idToProperty));
             }
         }
     }
     this.defaultUIElement = ((Component)this.doneButton).get_gameObject();
 }
示例#6
0
        private UISliderControl CreateSlider(UIControlSet set, int inputBehaviorId, string defaultTitle, string overrideTitle, Sprite icon, float minValue, float maxValue, Action <int, int, float> valueChangedCallback, Action <int, int> cancelCallback)
        {
            UISliderControl uisliderControl = set.CreateSlider(this.uiSliderControlPrefab, icon, minValue, maxValue, delegate(int cId, float value)
            {
                valueChangedCallback(inputBehaviorId, cId, value);
            }, delegate(int cId)
            {
                cancelCallback(inputBehaviorId, cId);
            });
            string text = (!string.IsNullOrEmpty(overrideTitle)) ? overrideTitle : defaultTitle;

            if (!string.IsNullOrEmpty(text))
            {
                uisliderControl.showTitle  = true;
                uisliderControl.title.text = text;
            }
            else
            {
                uisliderControl.showTitle = false;
            }
            uisliderControl.showIcon = (icon != null);
            return(uisliderControl);
        }
示例#7
0
        public void SetData(int playerId, ControlMapper.InputBehaviorSettings[] data)
        {
            if (!initialized)
            {
                return;
            }

            this.playerId = playerId;

            // Create control sets
            for (int i = 0; i < data.Length; i++)
            {
                var item = data[i];
                if (item == null || !item.isValid)
                {
                    continue;
                }

                InputBehavior inputBehavior = GetInputBehavior(item.inputBehaviorId);
                if (inputBehavior == null)
                {
                    continue;
                }

                UIControlSet set = CreateControlSet();
                Dictionary <int, PropertyType> idToProperty = new Dictionary <int, PropertyType>();;

                // Set the title
                string customTitle = ControlMapper.GetLanguage().GetCustomEntry(item.labelLanguageKey);
                if (!string.IsNullOrEmpty(customTitle))
                {
                    set.SetTitle(customTitle);
                }
                else
                {
                    set.SetTitle(inputBehavior.name);
                }

                // Create sliders

                if (item.showJoystickAxisSensitivity)
                {
                    UISliderControl slider = CreateSlider(
                        set,
                        inputBehavior.id,
                        null,
                        ControlMapper.GetLanguage().GetCustomEntry(item.joystickAxisSensitivityLabelLanguageKey),
                        item.joystickAxisSensitivityIcon,
                        item.joystickAxisSensitivityMin,
                        item.joystickAxisSensitivityMax,
                        JoystickAxisSensitivityValueChanged,
                        JoystickAxisSensitivityCanceled
                        );
                    // Set initial value
                    slider.slider.value = Mathf.Clamp(inputBehavior.joystickAxisSensitivity, item.joystickAxisSensitivityMin, item.joystickAxisSensitivityMax);
                    // Store property type
                    idToProperty.Add(slider.id, PropertyType.JoystickAxisSensitivity);
                }

                if (item.showMouseXYAxisSensitivity)
                {
                    UISliderControl slider = CreateSlider(
                        set,
                        inputBehavior.id,
                        null,
                        ControlMapper.GetLanguage().GetCustomEntry(item.mouseXYAxisSensitivityLabelLanguageKey),
                        item.mouseXYAxisSensitivityIcon,
                        item.mouseXYAxisSensitivityMin,
                        item.mouseXYAxisSensitivityMax,
                        MouseXYAxisSensitivityValueChanged,
                        MouseXYAxisSensitivityCanceled
                        );
                    // Set initial value
                    slider.slider.value = Mathf.Clamp(inputBehavior.mouseXYAxisSensitivity, item.mouseXYAxisSensitivityMin, item.mouseXYAxisSensitivityMax);
                    // Store property type
                    idToProperty.Add(slider.id, PropertyType.MouseXYAxisSensitivity);
                }

                // mouseOtherAxisSensitivity not implemented

                // Add to the list
                inputBehaviorInfo.Add(new InputBehaviorInfo(inputBehavior, set, idToProperty));
            }

            // Set default UI element
            defaultUIElement = doneButton.gameObject;
        }