private void onInputButtonSetLoaded(string path, InputButtonGroupDefinition groupDefinition) { bool flag = false; if (RightContainer != null && doesGroupDefinitionMatchDataModel(groupDefinition)) { if (shouldUseButtonOverrides(groupDefinition)) { for (int i = 0; i < groupDefinition.InputButtonDefinitions.Length; i++) { bool flag2 = false; InputButtonDefinition currentButtonDefinition = GetCurrentButtonDefinition(i); if (currentButtonDefinition != groupDefinition.InputButtonDefinitions[i]) { setUpButton(groupDefinition.InputButtonDefinitions[i], i); flag2 = true; } if (groupDefinition.ButtonStateOverrides != null && groupDefinition.ButtonStateOverrides.Length > i && groupDefinition.ButtonStateOverrides[i] != TrayInputButton.ButtonState.None) { if (flag2) { pendingButtonStateOverrides[i] = groupDefinition.ButtonStateOverrides[i]; } else { trayInputButtonGroup.Buttons[i].SetState(groupDefinition.ButtonStateOverrides[i]); } flag2 = true; } if (!flag2 && currentButtonDefinition != null) { setButtonToDefault(i); } restartButtonComponents(trayInputButtonGroup.Buttons[i]); } } else { flag = true; if (replaceButtonsCoroutine != null && !replaceButtonsCoroutine.Disposed) { replaceButtonsCoroutine.Stop(); } replaceButtonsCoroutine = CoroutineRunner.Start(replaceButtons(groupDefinition), this, ""); } } if (!flag) { Service.Get <EventDispatcher>().DispatchEvent(default(ControlsScreenEvents.ControlLayoutLoadComplete)); } }
private void setUpButton(InputButtonDefinition definition, int index) { overrideDefinitions[index] = definition; if (definition != null) { pendingInputButtonDefinitions[index] = definition; trayInputButtonGroup.Buttons[index].OnReady += onTrayInputButtonReady; trayInputButtonGroup.Buttons[index].ResetButton(); } else { trayInputButtonGroup.Buttons[index].ResetButton(playIntro: false); trayInputButtonGroup.Buttons[index].gameObject.SetActive(value: false); } }
private void onInputButtonLoaded(string path, InputButtonDefinition definition) { if (pathToButtonIndexMap.TryGetValue(path, out var value)) { if (value >= trayInputButtonGroup.Buttons.Length) { throw new IndexOutOfRangeException("The button index supplied is out of bounds for the current template"); } setUpButton(definition, value); pathToButtonIndexMap.Remove(path); } else { Log.LogErrorFormatted(this, "There was no index specified for button {0}", path); } }
private bool shouldUseButtonOverrides(InputButtonGroupDefinition groupDefinition) { if (currentGroupDefinition != null && currentGroupDefinition.TemplateContentKey.Key == groupDefinition.TemplateContentKey.Key) { for (int i = 0; i < groupDefinition.InputButtonDefinitions.Length; i++) { InputButtonDefinition inputButtonDefinition = groupDefinition.InputButtonDefinitions[i]; if (overrideDefinitions.ContainsKey(i)) { if (overrideDefinitions[i] == inputButtonDefinition) { return(true); } } else if (currentGroupDefinition.InputButtonDefinitions.Length > i && currentGroupDefinition.InputButtonDefinitions[i] == inputButtonDefinition) { return(true); } } } return(false); }