public void RefreshControls() { if (this._controlSet == null) { return; } if (this.idToProperty == null) { return; } foreach (KeyValuePair <int, InputBehaviorWindow.PropertyType> keyValuePair in this.idToProperty) { UISliderControl control = this._controlSet.GetControl <UISliderControl>(keyValuePair.Key); if (!(control == null)) { InputBehaviorWindow.PropertyType value = keyValuePair.Value; if (value != InputBehaviorWindow.PropertyType.JoystickAxisSensitivity) { if (value == InputBehaviorWindow.PropertyType.MouseXYAxisSensitivity) { control.slider.value = this._inputBehavior.mouseXYAxisSensitivity; } } else { control.slider.value = this._inputBehavior.joystickAxisSensitivity; } } } }
public void RefreshControls() { if (_controlSet == null) { return; } if (idToProperty == null) { return; } // Redraw the controls with the current values foreach (KeyValuePair <int, PropertyType> pair in idToProperty) { UISliderControl control = _controlSet.GetControl <UISliderControl>(pair.Key); if (control == null) { continue; } switch (pair.Value) { case PropertyType.JoystickAxisSensitivity: control.slider.value = _inputBehavior.joystickAxisSensitivity; break; case PropertyType.MouseXYAxisSensitivity: control.slider.value = _inputBehavior.mouseXYAxisSensitivity; break; } } }
public void RestoreData(InputBehaviorWindow.PropertyType propertyType, int controlId) { if (propertyType != InputBehaviorWindow.PropertyType.JoystickAxisSensitivity) { if (propertyType == InputBehaviorWindow.PropertyType.MouseXYAxisSensitivity) { float mouseXYAxisSensitivity = this.copyOfOriginal.mouseXYAxisSensitivity; this._inputBehavior.mouseXYAxisSensitivity = mouseXYAxisSensitivity; UISliderControl control = this._controlSet.GetControl <UISliderControl>(controlId); if (control != null) { control.slider.value = mouseXYAxisSensitivity; } } } else { float joystickAxisSensitivity = this.copyOfOriginal.joystickAxisSensitivity; this._inputBehavior.joystickAxisSensitivity = joystickAxisSensitivity; UISliderControl control2 = this._controlSet.GetControl <UISliderControl>(controlId); if (control2 != null) { control2.slider.value = joystickAxisSensitivity; } } }
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); }
public void RestoreData(PropertyType propertyType, int controlId) { switch (propertyType) { case PropertyType.JoystickAxisSensitivity: { float value = copyOfOriginal.joystickAxisSensitivity; _inputBehavior.joystickAxisSensitivity = value; UISliderControl control = _controlSet.GetControl <UISliderControl>(controlId); if (control != null) { control.slider.value = value; // update control } break; } case PropertyType.MouseXYAxisSensitivity: { float value = copyOfOriginal.mouseXYAxisSensitivity; _inputBehavior.mouseXYAxisSensitivity = value; UISliderControl control = _controlSet.GetControl <UISliderControl>(controlId); if (control != null) { control.slider.value = value; // update control } break; } } }
public UISliderControl CreateSlider(GameObject prefab, Sprite icon, float minValue, float maxValue, System.Action <int, float> valueChangedCallback, System.Action <int> cancelCallback) { GameObject instance = (GameObject)Object.Instantiate(prefab); UISliderControl control = instance.GetComponent <UISliderControl>(); if (control == null) { Object.Destroy(instance); Debug.LogError("Prefab missing UISliderControl component!"); return(null); } instance.transform.SetParent(this.transform, false); if (control.iconImage != null) { control.iconImage.sprite = icon; } if (control.slider != null) { control.slider.minValue = minValue; control.slider.maxValue = maxValue; if (valueChangedCallback != null) { control.slider.onValueChanged.AddListener((float value) => { valueChangedCallback(control.id, value); }); } if (cancelCallback != null) { control.SetCancelCallback(() => { cancelCallback(control.id); }); } } controls.Add(control.id, control); return(control); }
public void RefreshControls() { if (Object.op_Equality((Object)this._controlSet, (Object)null) || this.idToProperty == null) { return; } foreach (KeyValuePair <int, InputBehaviorWindow.PropertyType> keyValuePair in this.idToProperty) { UISliderControl control = this._controlSet.GetControl <UISliderControl>(keyValuePair.Key); if (!Object.op_Equality((Object)control, (Object)null)) { switch (keyValuePair.Value) { case InputBehaviorWindow.PropertyType.JoystickAxisSensitivity: control.slider.set_value(this._inputBehavior.get_joystickAxisSensitivity()); continue; case InputBehaviorWindow.PropertyType.MouseXYAxisSensitivity: control.slider.set_value(this._inputBehavior.get_mouseXYAxisSensitivity()); continue; default: continue; } } } }
public void RestoreData(InputBehaviorWindow.PropertyType propertyType, int controlId) { switch (propertyType) { case InputBehaviorWindow.PropertyType.JoystickAxisSensitivity: float joystickAxisSensitivity = this.copyOfOriginal.get_joystickAxisSensitivity(); this._inputBehavior.set_joystickAxisSensitivity(joystickAxisSensitivity); UISliderControl control1 = this._controlSet.GetControl <UISliderControl>(controlId); if (!Object.op_Inequality((Object)control1, (Object)null)) { break; } control1.slider.set_value(joystickAxisSensitivity); break; case InputBehaviorWindow.PropertyType.MouseXYAxisSensitivity: float xyAxisSensitivity = this.copyOfOriginal.get_mouseXYAxisSensitivity(); this._inputBehavior.set_mouseXYAxisSensitivity(xyAxisSensitivity); UISliderControl control2 = this._controlSet.GetControl <UISliderControl>(controlId); if (!Object.op_Inequality((Object)control2, (Object)null)) { break; } control2.slider.set_value(xyAxisSensitivity); break; } }
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); }
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; }
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(); }
public UISliderControl CreateSlider(GameObject prefab, Sprite icon, float minValue, float maxValue, Action <int, float> valueChangedCallback, Action <int> cancelCallback) { GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(prefab); UISliderControl control = gameObject.GetComponent <UISliderControl>(); if (control == null) { UnityEngine.Object.Destroy(gameObject); Debug.LogError("Prefab missing UISliderControl component!"); return(null); } gameObject.transform.SetParent(base.transform, false); if (control.iconImage != null) { control.iconImage.sprite = icon; } if (control.slider != null) { control.slider.minValue = minValue; control.slider.maxValue = maxValue; if (valueChangedCallback != null) { control.slider.onValueChanged.AddListener(delegate(float value) { valueChangedCallback(control.id, value); }); } if (cancelCallback != null) { control.SetCancelCallback(delegate { cancelCallback(control.id); }); } } this.controls.Add(control.id, control); return(control); }
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); }
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; }