private static void UpdateActionElementRelationships(Dictionary <int[], List <ActionElementMap> > elementSourceActionLinks, Dictionary <int, ActionElementMap> storedElementMaps, InputMapCategory sourceCategory, Player player) { foreach (KeyValuePair <int[], List <ActionElementMap> > keyValuePair in elementSourceActionLinks) { if (keyValuePair.Value.SafeCount <ActionElementMap>() != 0) { int key = keyValuePair.Key[2]; ActionElementMap oldElementMap = storedElementMaps[key]; KeyboardMap firstMapInCategory = player.controllers.maps.GetFirstMapInCategory <KeyboardMap>(0, sourceCategory.id); if (firstMapInCategory == null) { Debug.LogError("newControllerMap is null!"); } else { ActionElementMap firstElementMapMatch = firstMapInCategory.GetFirstElementMapMatch((ActionElementMap searchMap) => searchMap.actionId == oldElementMap.actionId); if (firstElementMapMatch == null) { Debug.LogError("sourceMap is null!"); } else { foreach (ActionElementMap actionElementMap in keyValuePair.Value) { ControllerMap controllerMap = actionElementMap.controllerMap; ElementAssignment elementAssignment = new ElementAssignment(ControllerType.Keyboard, firstElementMapMatch.elementType, firstElementMapMatch.elementIdentifierId, firstElementMapMatch.axisRange, firstElementMapMatch.keyCode, firstElementMapMatch.modifierKeyFlags, firstElementMapMatch.actionId, firstElementMapMatch.axisContribution, firstElementMapMatch.invert, actionElementMap.id); bool flag = controllerMap.DeleteElementMap(actionElementMap.id); ActionElementMap actionElementMap2; if (!flag || !controllerMap.CreateElementMap(elementAssignment, out actionElementMap2)) { Debug.Log("Failed to remap secondary actions"); } } } } } } }
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; }
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; }
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); }