Example #1
0
        private void ShowActionMappingCount(InputActionRow uiRow, ControllerType controllerType)
        {
            ControllerType controllerType2 = controllerType;

            if (controllerType2 == ControllerType.Mouse)
            {
                controllerType2 = ControllerType.Keyboard;
            }
            uiRow._addButtons[(int)controllerType2].gameObject.SetActive(true);
        }
Example #2
0
        private void HideAddActionMapButton(InputActionRow uiRow, ControllerType controllerType)
        {
            ControllerType controllerType2 = controllerType;

            if (controllerType2 == ControllerType.Mouse)
            {
                controllerType2 = ControllerType.Keyboard;
            }
            uiRow._addButtons[(int)controllerType2].gameObject.SetActive(false);
        }
Example #3
0
        private InputActionRow GetNewUIRow(InputAction action, string name)
        {
            InputActionRow inputActionRow = UnityEngine.Object.Instantiate <InputActionRow>(this._inputActionRowPrefab);

            inputActionRow.transform.parent        = this._table.transform;
            inputActionRow.transform.localPosition = Vector3.zero;
            inputActionRow.transform.localScale    = Vector3.one;
            inputActionRow._action     = action;
            inputActionRow._label.text = name;
            this._actionRowMappingCount[inputActionRow] = 0;
            return(inputActionRow);
        }
Example #4
0
 private void Confirm(InputMappingAction.ConflictResolution conflictResolution)
 {
     if (conflictResolution > InputMappingAction.ConflictResolution.Pending)
     {
         if (conflictResolution == InputMappingAction.ConflictResolution.Replace)
         {
             using (IEnumerator <ElementAssignmentConflictInfo> enumerator = ReInput.controllers.conflictChecking.ElementAssignmentConflicts(this._entry.ToElementAssignmentConflictCheck()).GetEnumerator())
             {
                 while (enumerator.MoveNext())
                 {
                     ElementAssignmentConflictInfo info = enumerator.Current;
                     if (this._knownActionMaps.Any((KeyValuePair <ActionElementMap, InputActionButton> m) => m.Key.id == info.elementMapId))
                     {
                         ActionElementMap elementMap = this._knownActionMaps.First((KeyValuePair <ActionElementMap, InputActionButton> m) => m.Key.id == info.elementMapId).Key;
                         UnityEngine.Object.Destroy(this._knownActionMaps[elementMap].gameObject);
                         this._knownActionMaps.Remove(elementMap);
                         InputActionRow key = this._actionRowMappingCount.First((KeyValuePair <InputActionRow, int> r) => r.Key._action.id == elementMap.actionId).Key;
                         Dictionary <InputActionRow, int> actionRowMappingCount;
                         InputActionRow key2;
                         (actionRowMappingCount = this._actionRowMappingCount)[key2 = key] = actionRowMappingCount[key2] - 1;
                     }
                 }
             }
             ReInput.controllers.conflictChecking.RemoveElementAssignmentConflicts(this._entry.ToElementAssignmentConflictCheck());
         }
         if (this._entry.changeType != InputMappingAction.ElementAssignmentChangeType.Add)
         {
             this._entry.controllerMapPrevious.DeleteElementMap(this._entry.actionElementMapId);
             this._entry.controllerMapPrevious = null;
             this._knownActionMaps.Remove(this._entry.uiButton._actionElementMap);
             UnityEngine.Object.Destroy(this._entry.uiButton.gameObject);
             if (this._entry.uiRow)
             {
                 Dictionary <InputActionRow, int> actionRowMappingCount;
                 InputActionRow uiRow;
                 (actionRowMappingCount = this._actionRowMappingCount)[uiRow = this._entry.uiRow] = actionRowMappingCount[uiRow] - 1;
             }
             this._entry.changeType = InputMappingAction.ElementAssignmentChangeType.Add;
         }
         this._entry.ReplaceOrCreateActionElementMap(false);
         if (this._entry.changeType == InputMappingAction.ElementAssignmentChangeType.Add)
         {
             ActionElementMap actionElementMap = this._entry.controllerMap.AllMaps.First((ActionElementMap m) => m.actionId == this._entry.actionId && !this._knownActionMaps.ContainsKey(m));
             bool             showInvert       = this._entry.actionType == InputActionType.Axis && actionElementMap.axisType == AxisType.Normal && this._entry.controllerType != ControllerType.Keyboard;
             this.AddActionAssignmentButton(this._entry.uiRow, Input.player.id, ReInput.mapping.GetAction(this._entry.actionId), actionElementMap.axisContribution, this._entry.controllerMap, false, actionElementMap, showInvert);
             this.HideAddActionMapButton(this._entry.uiRow, this._entry.controllerType);
         }
         this._nextChangeTimer = Time.realtimeSinceStartup + this._interChangeDelay;
         this.InitializeUI(false);
         this.StopPollInput();
     }
 }
Example #5
0
 private void InitAddActionMapButton(InputActionRow uiRow, int playerId, InputAction action, Pole actionAxisContribution, bool assignFullAxis)
 {
     uiRow._addButton.onClick.Add(new EventDelegate(delegate
     {
         if (this._actionRowMappingCount[uiRow] < this._maxMappingPerAction && UICamera.currentTouchID == -1 && !this.enabled)
         {
             this._replaceElementMap = false;
             this._entry             = new InputMappingAction.ElementAssignmentChange(playerId, InputMappingAction.ElementAssignmentChangeType.Add, -1, action.id, actionAxisContribution, action.type, assignFullAxis, false);
             this._entry.uiRow       = uiRow;
             this.StartPollInput();
         }
     }));
 }
Example #6
0
        private InputActionRow GetNewUIRow(InputAction action, string name)
        {
            InputActionRow inputActionRow = UnityEngine.Object.Instantiate <InputActionRow>(this._inputActionRowPrefab);

            inputActionRow.transform.parent        = this._table.transform;
            inputActionRow.transform.localPosition = Vector3.zero;
            inputActionRow.transform.localScale    = Vector3.one;
            inputActionRow._action = action;
            name = name.ToUpperInvariant();
            name = UiTranslationDatabase.TranslateKey(name, name, true);
            inputActionRow._label.text = name;
            this._actionRowMappingCount[inputActionRow] = 0;
            return(inputActionRow);
        }
Example #7
0
 private void Confirm(InputMappingAction.ConflictResolution conflictResolution)
 {
     if (conflictResolution > InputMappingAction.ConflictResolution.Pending)
     {
         if (conflictResolution == InputMappingAction.ConflictResolution.Replace)
         {
             foreach (ElementAssignmentConflictInfo info in ReInput.controllers.conflictChecking.ElementAssignmentConflicts(this._entry.ToElementAssignmentConflictCheck()))
             {
                 if (this._knownActionMaps.Any((KeyValuePair <ActionElementMap, InputActionButton> m) => m.Key.id == info.elementMapId))
                 {
                     ActionElementMap elementMap = this._knownActionMaps.First((KeyValuePair <ActionElementMap, InputActionButton> m) => m.Key.id == info.elementMapId).Key;
                     UnityEngine.Object.Destroy(this._knownActionMaps[elementMap].gameObject);
                     this._knownActionMaps.Remove(elementMap);
                     InputActionRow key = this._actionRowMappingCount.First((KeyValuePair <InputActionRow, int> r) => r.Key._action.id == elementMap.actionId).Key;
                     Dictionary <InputActionRow, int> actionRowMappingCount;
                     Dictionary <InputActionRow, int> expr_F3 = actionRowMappingCount = this._actionRowMappingCount;
                     InputActionRow key2;
                     InputActionRow expr_F7 = key2 = key;
                     int            num     = actionRowMappingCount[key2];
                     expr_F3[expr_F7] = num - 1;
                     key._actionGrid.repositionNow = true;
                     this.CheckActionMappingCount(key);
                 }
             }
             ReInput.controllers.conflictChecking.RemoveElementAssignmentConflicts(this._entry.ToElementAssignmentConflictCheck());
         }
         this._entry.ReplaceOrCreateActionElementMap(this._replaceElementMap);
         if (this._entry.changeType == InputMappingAction.ElementAssignmentChangeType.Add)
         {
             ActionElementMap actionElementMap = this._entry.controllerMap.AllMaps.First((ActionElementMap m) => m.actionId == this._entry.actionId && !this._knownActionMaps.ContainsKey(m));
             bool             showInvert       = this._entry.actionType == InputActionType.Axis && actionElementMap.axisType == AxisType.Normal && this._entry.controllerType != ControllerType.Keyboard;
             this.AddActionAssignmentButton(this._entry.uiRow, Input.player.id, ReInput.mapping.GetAction(this._entry.actionId), actionElementMap.axisContribution, this._entry.controllerMap, false, actionElementMap, showInvert);
             this._entry.uiRow._actionGrid.repositionNow = true;
             this.CheckActionMappingCount(this._entry.uiRow);
         }
         else
         {
             this._entry.uiButton._label.text = this._entry.pollingInfo.elementIdentifierName;
         }
         this._selectionScreenTimer.gameObject.SetActive(false);
         this._mappingConflictResolutionKeyLabel.transform.parent.gameObject.SetActive(false);
         this._mappingSystemConflictUI.transform.parent.gameObject.SetActive(false);
         this._nextChangeTimer = Time.realtimeSinceStartup + this._interChangeDelay;
         this.ResetUI();
         this.StopPollInput();
     }
 }
Example #8
0
        private void InitAddActionMapButton(InputActionRow uiRow, int playerId, InputAction action, Pole actionAxisContribution, bool assignFullAxis)
        {
            ControllerType controllerType = ControllerType.Keyboard;

            UIButton[] addButtons = uiRow._addButtons;
            for (int i = 0; i < addButtons.Length; i++)
            {
                UIButton       uibutton    = addButtons[i];
                ControllerType currentType = controllerType;
                uibutton.onClick.Add(new EventDelegate(delegate
                {
                    if (UICamera.currentTouchID == -1 && !this.enabled)
                    {
                        this._controllerType    = currentType;
                        this._replaceElementMap = false;
                        this._entry             = new InputMappingAction.ElementAssignmentChange(playerId, InputMappingAction.ElementAssignmentChangeType.Add, -1, action.id, actionAxisContribution, action.type, assignFullAxis, false);
                        this._entry.uiRow       = uiRow;
                        this.StartPollInput();
                    }
                }));
                controllerType++;
            }
        }
Example #9
0
 private void HideAddActionMapButton(InputActionRow uiRow)
 {
     uiRow._addButton.gameObject.SetActive(false);
 }
Example #10
0
 private void ShowUserAssignableActions()
 {
     foreach (InputCategory current in ReInput.mapping.ActionCategories)
     {
         if (ReInput.mapping.ActionsInCategory(current.id).Count <InputAction>() > 0)
         {
             this.AddNewUIActionCategory(current.name);
             foreach (InputAction action in from a in ReInput.mapping.ActionsInCategory(current.id)
                      where a.userAssignable
                      select a)
             {
                 string         name     = (!(action.descriptiveName != string.Empty)) ? action.name : action.descriptiveName;
                 InputActionRow newUIRow = this.GetNewUIRow(action, name);
                 if (action.type == InputActionType.Button)
                 {
                     this.InitAddActionMapButton(newUIRow, Input.player.id, action, Pole.Positive, true);
                     foreach (ControllerMap current2 in Input.player.controllers.maps.GetAllMaps(this._controllerType))
                     {
                         foreach (ActionElementMap current3 in current2.AllMaps.Where((ActionElementMap m) => m.actionId == action.id))
                         {
                             this.AddActionAssignmentButton(newUIRow, Input.player.id, action, Pole.Positive, current2, true, current3, false);
                         }
                     }
                     this.CheckActionMappingCount(newUIRow);
                 }
                 else if (action.type == InputActionType.Axis)
                 {
                     if (this._controllerType != ControllerType.Keyboard)
                     {
                         this.InitAddActionMapButton(newUIRow, Input.player.id, action, Pole.Positive, true);
                         foreach (ControllerMap current4 in Input.player.controllers.maps.GetAllMaps(this._controllerType))
                         {
                             foreach (ActionElementMap current5 in current4.AllMaps.Where((ActionElementMap m) => m.actionId == action.id))
                             {
                                 if (current5.elementType != ControllerElementType.Button)
                                 {
                                     if (current5.axisType != AxisType.Split)
                                     {
                                         this.AddActionAssignmentButton(newUIRow, Input.player.id, action, Pole.Positive, current4, true, current5, true);
                                     }
                                 }
                             }
                         }
                         this.CheckActionMappingCount(newUIRow);
                     }
                     else
                     {
                         this.HideAddActionMapButton(newUIRow);
                     }
                     newUIRow._actionGrid.repositionNow = true;
                     string str = (!(action.positiveDescriptiveName != string.Empty)) ? (action.descriptiveName + " +") : action.positiveDescriptiveName;
                     newUIRow = this.GetNewUIRow(action, "    " + str);
                     this.InitAddActionMapButton(newUIRow, Input.player.id, action, Pole.Positive, false);
                     foreach (ControllerMap current6 in Input.player.controllers.maps.GetAllMaps(this._controllerType))
                     {
                         foreach (ActionElementMap current7 in current6.AllMaps.Where((ActionElementMap m) => m.actionId == action.id))
                         {
                             if (current7.axisContribution == Pole.Positive)
                             {
                                 if (current7.axisType != AxisType.Normal)
                                 {
                                     this.AddActionAssignmentButton(newUIRow, Input.player.id, action, Pole.Positive, current6, false, current7, false);
                                 }
                             }
                         }
                     }
                     this.CheckActionMappingCount(newUIRow);
                     newUIRow._actionGrid.repositionNow = true;
                     string str2 = (!(action.negativeDescriptiveName != string.Empty)) ? (action.descriptiveName + " -") : action.negativeDescriptiveName;
                     newUIRow = this.GetNewUIRow(action, "    " + str2);
                     this.InitAddActionMapButton(newUIRow, Input.player.id, action, Pole.Negative, false);
                     foreach (ControllerMap current8 in Input.player.controllers.maps.GetAllMaps(this._controllerType))
                     {
                         foreach (ActionElementMap current9 in current8.AllMaps.Where((ActionElementMap m) => m.actionId == action.id))
                         {
                             if (current9.axisContribution == Pole.Negative)
                             {
                                 if (current9.axisType != AxisType.Normal)
                                 {
                                     this.AddActionAssignmentButton(newUIRow, Input.player.id, action, Pole.Negative, current8, false, current9, false);
                                 }
                             }
                         }
                     }
                     this.CheckActionMappingCount(newUIRow);
                     newUIRow._actionGrid.repositionNow = true;
                 }
             }
         }
     }
     this._table.repositionNow = true;
 }
Example #11
0
 private void InitAddActionMapButton(InputActionRow uiRow, int playerId, InputAction action, Pole actionAxisContribution, bool assignFullAxis)
 {
     uiRow._addButton.onClick.Add(new EventDelegate(delegate
     {
         if (this._actionRowMappingCount[uiRow] < this._maxMappingPerAction && UICamera.currentTouchID == -1 && !this.enabled)
         {
             this._replaceElementMap = false;
             this._entry = new InputMappingAction.ElementAssignmentChange(playerId, InputMappingAction.ElementAssignmentChangeType.Add, -1, action.id, actionAxisContribution, action.type, assignFullAxis, false);
             this._entry.uiRow = uiRow;
             this.StartPollInput();
         }
     }));
 }
Example #12
0
 private void CheckActionMappingCount(InputActionRow uiRow)
 {
     uiRow._addButton.gameObject.SetActive(this._actionRowMappingCount[uiRow] < this._maxMappingPerAction);
 }
Example #13
0
 private void AddActionAssignmentButton(InputActionRow uiRow, int playerId, InputAction action, Pole actionAxisContribution, ControllerMap controllerMap, bool assignFullAxis, ActionElementMap elementMap, bool showInvert = false)
 {
     InputActionButton uiButton;
     if (!showInvert)
     {
         uiButton = UnityEngine.Object.Instantiate<InputActionButton>(this._inputActionButtonPrefab);
     }
     else
     {
         uiButton = UnityEngine.Object.Instantiate<InputActionButton>(this._inputAxisActionButtonPrefab);
     }
     uiButton._label.text = elementMap.elementIdentifierName;
     uiButton._actionElementMap = elementMap;
     uiButton._button.onClick.Add(new EventDelegate(delegate
     {
         if (!this.enabled && this._nextChangeTimer < Time.realtimeSinceStartup)
         {
             if (UICamera.currentTouchID == -1)
             {
                 this._replaceElementMap = true;
                 this._entry = new InputMappingAction.ElementAssignmentChange(playerId, InputMappingAction.ElementAssignmentChangeType.ReassignOrRemove, elementMap.id, action.id, actionAxisContribution, action.type, assignFullAxis, elementMap.invert);
                 this._entry.controllerMap = controllerMap;
                 this._entry.uiButton = uiButton;
                 this.StartPollInput();
             }
             else if (UICamera.currentTouchID == -2)
             {
                 this._entry = new InputMappingAction.ElementAssignmentChange(playerId, InputMappingAction.ElementAssignmentChangeType.Remove, elementMap.id, action.id, actionAxisContribution, action.type, assignFullAxis, elementMap.invert);
                 controllerMap.DeleteElementMap(this._entry.actionElementMapId);
                 this._knownActionMaps.Remove(elementMap);
                 UnityEngine.Object.Destroy(uiButton.gameObject);
                 uiRow._actionGrid.repositionNow = true;
                 Dictionary<InputActionRow, int> actionRowMappingCount2;
                 Dictionary<InputActionRow, int> expr_181 = actionRowMappingCount2 = this._actionRowMappingCount;
                 InputActionRow uiRow3;
                 InputActionRow expr_189 = uiRow3 = uiRow;
                 int num2 = actionRowMappingCount2[uiRow3];
                 expr_181[expr_189] = num2 - 1;
                 this.CheckActionMappingCount(uiRow);
                 this._nextChangeTimer = Time.realtimeSinceStartup + this._interChangeDelay;
             }
         }
     }));
     if (showInvert)
     {
         uiButton._invertAxisToggle.gameObject.SetActive(true);
         uiButton._invertAxisToggle.value = uiButton._actionElementMap.invert;
         uiButton._invertAxisToggle.onChange.Add(new EventDelegate(delegate
         {
             if (!this.enabled && this._nextChangeTimer < Time.realtimeSinceStartup)
             {
                 uiButton._actionElementMap.invert = uiButton._invertAxisToggle.value;
             }
         }));
     }
     uiButton.transform.parent = uiRow._actionGrid.transform;
     uiButton.transform.localPosition = Vector3.zero;
     uiButton.transform.localScale = Vector3.one;
     this._knownActionMaps.Add(elementMap, uiButton);
     Dictionary<InputActionRow, int> actionRowMappingCount;
     Dictionary<InputActionRow, int> expr_18C = actionRowMappingCount = this._actionRowMappingCount;
     InputActionRow uiRow2;
     InputActionRow expr_194 = uiRow2 = uiRow;
     int num = actionRowMappingCount[uiRow2];
     expr_18C[expr_194] = num + 1;
 }
Example #14
0
        private InputActionButton AddActionAssignmentButton(InputActionRow uiRow, int playerId, InputAction action, Pole actionAxisContribution, ControllerMap controllerMap, bool assignFullAxis, ActionElementMap elementMap, bool showInvert = false)
        {
            ControllerType controllerType = controllerMap.controllerType;

            if (controllerType == ControllerType.Mouse)
            {
                controllerType = ControllerType.Keyboard;
            }
            if (!uiRow._addButtons[(int)controllerType].gameObject.activeSelf)
            {
                return(null);
            }
            InputActionButton uiButton;

            if (!showInvert)
            {
                uiButton = UnityEngine.Object.Instantiate <InputActionButton>(this._inputActionButtonPrefab);
            }
            else
            {
                uiButton = UnityEngine.Object.Instantiate <InputActionButton>(this._inputAxisActionButtonPrefab);
            }
            uiButton.name = string.Format("actBtn_{0}_{1}_{2}", controllerMap.controllerType, elementMap.elementType, new string[]
            {
                action.descriptiveName,
                action.positiveDescriptiveName,
                action.negativeDescriptiveName,
                action.name,
                "UNKNOWN"
            }.FirstNotNullOrEmpty(null));
            uiButton._label.text       = elementMap.elementIdentifierName.ToUpperInvariant();
            uiButton._actionElementMap = elementMap;
            uiButton._button.onClick.Add(new EventDelegate(delegate
            {
                if (!this.enabled && this._nextChangeTimer < Time.realtimeSinceStartup && !this._delayedPollInput && !this._pollInput)
                {
                    if ((Input.IsGamePad && Input.GetButtonDown("Rebind")) || (!Input.IsGamePad && UICamera.currentTouchID == -1))
                    {
                        this._controllerType              = controllerMap.controllerType;
                        this._replaceElementMap           = true;
                        this._entry                       = new InputMappingAction.ElementAssignmentChange(playerId, InputMappingAction.ElementAssignmentChangeType.ReassignOrRemove, elementMap.id, action.id, actionAxisContribution, action.type, assignFullAxis, elementMap.invert);
                        this._entry.controllerMap         = controllerMap;
                        this._entry.controllerMapPrevious = controllerMap;
                        this._entry.uiButton              = uiButton;
                        this._entry.uiRow                 = uiRow;
                        this.StartCoroutine(this.StartPollInputDelayed());
                    }
                    else if ((Input.IsGamePad && Input.GetButtonDown("AltFire")) || (!Input.IsGamePad && UICamera.currentTouchID == -2))
                    {
                        this._controllerType = controllerMap.controllerType;
                        this._entry          = new InputMappingAction.ElementAssignmentChange(playerId, InputMappingAction.ElementAssignmentChangeType.Remove, elementMap.id, action.id, actionAxisContribution, action.type, assignFullAxis, elementMap.invert);
                        controllerMap.DeleteElementMap(this._entry.actionElementMapId);
                        this._knownActionMaps.Remove(elementMap);
                        UnityEngine.Object.Destroy(uiButton.gameObject);
                        Dictionary <InputActionRow, int> actionRowMappingCount2;
                        InputActionRow uiRow3;
                        (actionRowMappingCount2 = this._actionRowMappingCount)[uiRow3 = uiRow] = actionRowMappingCount2[uiRow3] - 1;
                        this.ShowActionMappingCount(uiRow, controllerMap.controllerType);
                        this._nextChangeTimer = Time.realtimeSinceStartup + this._interChangeDelay;
                        this.InitializeUI(false);
                    }
                }
            }));
            if (showInvert)
            {
                uiButton._invertAxisToggle.gameObject.SetActive(true);
                uiButton._invertAxisToggle.value = uiButton._actionElementMap.invert;
                uiButton._invertAxisToggle.onChange.Add(new EventDelegate(delegate
                {
                    if (!this.enabled && this._nextChangeTimer < Time.realtimeSinceStartup)
                    {
                        uiButton._actionElementMap.invert = uiButton._invertAxisToggle.value;
                    }
                }));
            }
            UIButtonColor component  = uiButton.GetComponent <UIButtonColor>();
            UIButtonColor component2 = uiRow._addButtons[(int)controllerMap.controllerType].GetComponent <UIButtonColor>();

            if (component && component2)
            {
                component.tweenTarget = uiRow._addButtons[(int)controllerMap.controllerType].GetComponent <UIButtonColor>().tweenTarget;
            }
            else
            {
                Debug.LogWarning("Missing tweener for element: " + elementMap.elementIdentifierName);
            }
            uiButton.transform.parent        = uiRow._addButtons[(int)controllerType].transform.parent;
            uiButton.transform.localPosition = Vector3.zero;
            uiButton.transform.localScale    = Vector3.one;
            this.HideAddActionMapButton(uiRow, controllerMap.controllerType);
            this._knownActionMaps.Add(elementMap, uiButton);
            Dictionary <InputActionRow, int> actionRowMappingCount;
            InputActionRow uiRow2;

            (actionRowMappingCount = this._actionRowMappingCount)[uiRow2 = uiRow] = actionRowMappingCount[uiRow2] + 1;
            return(uiButton);
        }
Example #15
0
        private void ShowUserAssignableActions()
        {
            List <InputActionButton> list = new List <InputActionButton>();

            foreach (InputCategory inputCategory in ReInput.mapping.ActionCategories)
            {
                InputAction[] array = (from a in ReInput.mapping.ActionsInCategory(inputCategory.id)
                                       where a.userAssignable
                                       select a).ToArray <InputAction>();
                if (array.Length != 0)
                {
                    this.AddNewUIActionCategory(inputCategory.name);
                    InputAction[] array2 = array;
                    for (int i = 0; i < array2.Length; i++)
                    {
                        InputAction    action   = array2[i];
                        string         name     = action.descriptiveName.IfNullOrEmpty(action.name);
                        InputActionRow newUIRow = this.GetNewUIRow(action, name);
                        if (action.type == InputActionType.Button)
                        {
                            this.InitAddActionMapButton(newUIRow, Input.player.id, action, Pole.Positive, true);
                            foreach (ControllerMap controllerMap in Input.player.controllers.maps.GetAllMaps())
                            {
                                foreach (ActionElementMap elementMap in from m in controllerMap.AllMaps
                                         where m.actionId == action.id
                                         select m)
                                {
                                    InputActionButton inputActionButton = this.AddActionAssignmentButton(newUIRow, Input.player.id, action, Pole.Positive, controllerMap, true, elementMap, false);
                                    if (inputActionButton != null && controllerMap.controllerType == ControllerType.Joystick)
                                    {
                                        list.Add(inputActionButton);
                                    }
                                }
                            }
                        }
                        else if (action.type == InputActionType.Axis)
                        {
                            this.InitAddActionMapButton(newUIRow, Input.player.id, action, Pole.Positive, true);
                            foreach (ControllerMap controllerMap2 in Input.player.controllers.maps.GetAllMaps())
                            {
                                foreach (ActionElementMap actionElementMap in from m in controllerMap2.AllMaps
                                         where m.actionId == action.id
                                         select m)
                                {
                                    if (actionElementMap.elementType != ControllerElementType.Button)
                                    {
                                        if (actionElementMap.axisType != AxisType.Split)
                                        {
                                            InputActionButton inputActionButton2 = this.AddActionAssignmentButton(newUIRow, Input.player.id, action, Pole.Positive, controllerMap2, true, actionElementMap, false);
                                            if (inputActionButton2 != null && controllerMap2.controllerType == ControllerType.Joystick)
                                            {
                                                list.Add(inputActionButton2);
                                            }
                                        }
                                    }
                                }
                            }
                            if (!action.positiveDescriptiveName.IsEmpty())
                            {
                                string positiveDescriptiveName = action.positiveDescriptiveName;
                                newUIRow = this.GetNewUIRow(action, "____" + positiveDescriptiveName);
                                this.InitAddActionMapButton(newUIRow, Input.player.id, action, Pole.Positive, false);
                                foreach (ControllerMap controllerMap3 in Input.player.controllers.maps.GetAllMaps())
                                {
                                    foreach (ActionElementMap actionElementMap2 in from m in controllerMap3.AllMaps
                                             where m.actionId == action.id
                                             select m)
                                    {
                                        if (actionElementMap2.axisContribution == Pole.Positive)
                                        {
                                            if (actionElementMap2.axisType != AxisType.Normal)
                                            {
                                                InputActionButton inputActionButton3 = this.AddActionAssignmentButton(newUIRow, Input.player.id, action, Pole.Positive, controllerMap3, false, actionElementMap2, false);
                                                if (inputActionButton3 != null && controllerMap3.controllerType == ControllerType.Joystick)
                                                {
                                                    list.Add(inputActionButton3);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            if (!action.negativeDescriptiveName.IsEmpty())
                            {
                                string negativeDescriptiveName = action.negativeDescriptiveName;
                                newUIRow = this.GetNewUIRow(action, "____" + negativeDescriptiveName);
                                this.InitAddActionMapButton(newUIRow, Input.player.id, action, Pole.Negative, false);
                                foreach (ControllerMap controllerMap4 in Input.player.controllers.maps.GetAllMaps())
                                {
                                    foreach (ActionElementMap actionElementMap3 in from m in controllerMap4.AllMaps
                                             where m.actionId == action.id
                                             select m)
                                    {
                                        if (actionElementMap3.axisContribution == Pole.Negative)
                                        {
                                            if (actionElementMap3.axisType != AxisType.Normal)
                                            {
                                                InputActionButton inputActionButton4 = this.AddActionAssignmentButton(newUIRow, Input.player.id, action, Pole.Negative, controllerMap4, false, actionElementMap3, false);
                                                if (inputActionButton4 != null && controllerMap4.controllerType == ControllerType.Joystick)
                                                {
                                                    list.Add(inputActionButton4);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            InputActionButton inputActionButton5 = null;

            for (int j = 0; j < list.Count; j++)
            {
                InputActionButton inputActionButton6 = list[j];
                UIKeyNavigation   uiKeyNavigation    = inputActionButton6._UiKeyNavigation;
                if (j == 0)
                {
                    uiKeyNavigation.startsSelected = true;
                }
                if (inputActionButton5 != null)
                {
                    uiKeyNavigation.onUp = inputActionButton5.gameObject;
                    inputActionButton5._UiKeyNavigation.onDown = inputActionButton6.gameObject;
                }
                inputActionButton5 = inputActionButton6;
            }
            this._table.Reposition();
        }
Example #16
0
 private void CheckActionMappingCount(InputActionRow uiRow)
 {
     uiRow._addButton.gameObject.SetActive(this._actionRowMappingCount[uiRow] < this._maxMappingPerAction);
 }
Example #17
0
        private void AddActionAssignmentButton(InputActionRow uiRow, int playerId, InputAction action, Pole actionAxisContribution, ControllerMap controllerMap, bool assignFullAxis, ActionElementMap elementMap, bool showInvert = false)
        {
            InputActionButton uiButton;

            if (!showInvert)
            {
                uiButton = UnityEngine.Object.Instantiate <InputActionButton>(this._inputActionButtonPrefab);
            }
            else
            {
                uiButton = UnityEngine.Object.Instantiate <InputActionButton>(this._inputAxisActionButtonPrefab);
            }
            uiButton._label.text       = elementMap.elementIdentifierName;
            uiButton._actionElementMap = elementMap;
            uiButton._button.onClick.Add(new EventDelegate(delegate
            {
                if (!this.enabled && this._nextChangeTimer < Time.realtimeSinceStartup)
                {
                    if (UICamera.currentTouchID == -1)
                    {
                        this._replaceElementMap   = true;
                        this._entry               = new InputMappingAction.ElementAssignmentChange(playerId, InputMappingAction.ElementAssignmentChangeType.ReassignOrRemove, elementMap.id, action.id, actionAxisContribution, action.type, assignFullAxis, elementMap.invert);
                        this._entry.controllerMap = controllerMap;
                        this._entry.uiButton      = uiButton;
                        this.StartPollInput();
                    }
                    else if (UICamera.currentTouchID == -2)
                    {
                        this._entry = new InputMappingAction.ElementAssignmentChange(playerId, InputMappingAction.ElementAssignmentChangeType.Remove, elementMap.id, action.id, actionAxisContribution, action.type, assignFullAxis, elementMap.invert);
                        controllerMap.DeleteElementMap(this._entry.actionElementMapId);
                        this._knownActionMaps.Remove(elementMap);
                        UnityEngine.Object.Destroy(uiButton.gameObject);
                        uiRow._actionGrid.repositionNow = true;
                        Dictionary <InputActionRow, int> actionRowMappingCount2;
                        Dictionary <InputActionRow, int> expr_181 = actionRowMappingCount2 = this._actionRowMappingCount;
                        InputActionRow uiRow3;
                        InputActionRow expr_189 = uiRow3 = uiRow;
                        int num2           = actionRowMappingCount2[uiRow3];
                        expr_181[expr_189] = num2 - 1;
                        this.CheckActionMappingCount(uiRow);
                        this._nextChangeTimer = Time.realtimeSinceStartup + this._interChangeDelay;
                    }
                }
            }));
            if (showInvert)
            {
                uiButton._invertAxisToggle.gameObject.SetActive(true);
                uiButton._invertAxisToggle.value = uiButton._actionElementMap.invert;
                uiButton._invertAxisToggle.onChange.Add(new EventDelegate(delegate
                {
                    if (!this.enabled && this._nextChangeTimer < Time.realtimeSinceStartup)
                    {
                        uiButton._actionElementMap.invert = uiButton._invertAxisToggle.value;
                    }
                }));
            }
            uiButton.transform.parent        = uiRow._actionGrid.transform;
            uiButton.transform.localPosition = Vector3.zero;
            uiButton.transform.localScale    = Vector3.one;
            this._knownActionMaps.Add(elementMap, uiButton);
            Dictionary <InputActionRow, int> actionRowMappingCount;
            Dictionary <InputActionRow, int> expr_18C = actionRowMappingCount = this._actionRowMappingCount;
            InputActionRow uiRow2;
            InputActionRow expr_194 = uiRow2 = uiRow;
            int            num      = actionRowMappingCount[uiRow2];

            expr_18C[expr_194] = num + 1;
        }
Example #18
0
 private void HideAddActionMapButton(InputActionRow uiRow)
 {
     uiRow._addButton.gameObject.SetActive(false);
 }