public virtual void AddMenuButton(Button button, string text = null) { if (button == null) { return; } if (button is UISelectButtonArrow) { return; } Text componentInChildren = button.GetComponentInChildren <Text>(); if (componentInChildren == null) { DebugUtils.Assert(componentInChildren, "Button without Text component!", true, DebugUtils.AssertType.Info); return; } if (!this.m_OptionsObjects.Values.Any((MenuBase.MenuOptionData d) => d.m_Button == button)) { Dictionary <GameObject, MenuBase.MenuOptionData> optionsObjects = this.m_OptionsObjects; GameObject gameObject = button.gameObject; MenuBase.MenuOptionData menuOptionData = new MenuBase.MenuOptionData(); menuOptionData.m_Button = button; menuOptionData.m_Object = button.gameObject; menuOptionData.m_Texts = new Text[0]; MenuBase.MenuOptionData menuOptionData2 = menuOptionData; UIButtonEx uibuttonEx = button as UIButtonEx; menuOptionData2.m_AnimatedRectTransform = ((uibuttonEx == null || uibuttonEx.m_MoveWhenFocused) ? componentInChildren.GetComponent <RectTransform>() : null); menuOptionData.m_ExtentRectTransforms = new RectTransform[] { button.GetComponent <RectTransform>() }; menuOptionData.m_InteractRectTransforms = new RectTransform[] { button.GetComponent <RectTransform>() }; optionsObjects.Add(gameObject, menuOptionData); } if (!text.Empty()) { componentInChildren.text = GreenHellGame.Instance.GetLocalization().Get(text, true); } }
private void UpdateButtons() { this.m_SelectedChallenge = null; for (int i = 0; i < this.m_Buttons.Count; i++) { Button button = this.m_Buttons[i]; if (!button.gameObject.activeSelf) { break; } UnityEngine.Object gameObject = button.gameObject; MenuBase.MenuOptionData activeMenuOption = this.m_ActiveMenuOption; if (gameObject == ((activeMenuOption != null) ? activeMenuOption.m_Object : null)) { this.m_SelectedChallenge = ChallengesManager.Get().m_Challenges[i]; this.SetActiveButton(button); } } }
private void UpdateButtons(bool force) { this.m_ButtonsActive = (this.m_State == MainMenuState.MainMenu && this.m_ButtonActivationTime > 0f && Time.time - this.m_ButtonActivationTime > this.m_ButtonsFadeInDuration); if (this.m_ButtonsActive && !this.m_WasButtonsActive) { if (GreenHellGame.IsPCControllerActive()) { CursorManager.Get().ShowCursor(true, false); } this.m_WasButtonsActive = true; } if (force || Time.time - this.m_ButtonActivationTime <= this.m_ButtonsFadeInDuration || this.m_ButtonActivationTime < 0f) { Color color = this.m_StartSurvival.GetComponentInChildren <Text>().color; Color color2 = this.m_StartSurvival.GetComponentInChildren <Text>().color; float num = Mathf.Clamp01((Time.time - this.m_ButtonActivationTime) / this.m_ButtonsFadeInDuration) * MenuScreen.s_ButtonsAlpha; float num2 = Mathf.Clamp01((Time.time - this.m_ButtonActivationTime) / this.m_ButtonsFadeInDuration) * MenuScreen.s_InactiveButtonsAlpha; color.a = (this.m_ButtonsEnabled ? num : 0f); color2.a = (this.m_ButtonsEnabled ? num2 : 0f); this.m_Continue.GetComponentInChildren <Text>().color = (this.m_Continue.interactable ? color : color2); this.m_Tutorial.GetComponentInChildren <Text>().color = (this.m_Tutorial.interactable ? color : color2); this.m_StartStory.GetComponentInChildren <Text>().color = (this.m_StartStory.interactable ? color : color2); this.m_StartChallenge.GetComponentInChildren <Text>().color = (this.m_StartChallenge.interactable ? color : color2); this.m_StartSurvival.GetComponentInChildren <Text>().color = (this.m_StartSurvival.interactable ? color : color2); this.m_LoadGame.GetComponentInChildren <Text>().color = (this.m_LoadGame.interactable ? color : color2); this.m_Options.GetComponentInChildren <Text>().color = (this.m_Options.interactable ? color : color2); this.m_Credits.GetComponentInChildren <Text>().color = (this.m_Credits.interactable ? color : color2); this.m_Quit.GetComponentInChildren <Text>().color = (this.m_Quit.interactable ? color : color2); this.m_VLine.color = color; this.m_VLineWContinue.color = color; this.m_GameVersion.color = color; color = this.m_PadSelectButton.color; color.a = (this.m_ButtonsEnabled ? num : 0f); this.m_PadSelectButton.color = color; this.m_PadSelectButton.GetComponentInChildren <Text>().color = color; } GameObject continueSlot = this.m_ContinueSlot; MenuBase.MenuOptionData activeMenuOption = this.m_ActiveMenuOption; continueSlot.SetActive(((activeMenuOption != null) ? activeMenuOption.m_Button : null) == this.m_Continue); }
public void UpdateMenuOptionAnimation(MenuBase.MenuOptionData data) { if (!data.IsEnabled()) { return; } if (data.m_Button == null) { data.SetColorAlpha((this.m_ActiveMenuOption == data) ? MenuScreen.s_ButtonsHighlightedAlpha : MenuScreen.s_ButtonsAlpha); } if (data.m_AnimatedRectTransform != null) { Vector3 localPosition = data.m_AnimatedRectTransform.localPosition; float num = Mathf.Ceil(((this.m_ActiveMenuOption == data) ? this.SELECTED_OPTION_OFFSET.x : 0f) + data.GetInitialPosition().x - localPosition.x) * Mathf.Min(1f, Time.unscaledDeltaTime * 10f); localPosition.x += num; data.m_AnimatedRectTransform.localPosition = localPosition; if (this.m_ActiveMenuOption == data) { data.m_Button.Select(); data.m_Button.OnSelect(null); } } }
public void UpdateActiveMenuOption(MenuBase.MenuOptionData data) { if (data.m_Object == null) { return; } bool flag = true; if (data.m_Button && !this.IsMenuButtonEnabled(data.m_Button)) { flag = false; } else if (data.m_Slider && !this.IsMenuSliderEnabled(data.m_Slider)) { flag = false; } else if (data.m_SelectButton && !this.IsMenuSelectButtonEnabled(data.m_SelectButton)) { flag = false; } else if (!data.m_Object.activeSelf) { flag = false; } if (data.m_Button) { data.m_Button.interactable = flag; } else if (data.m_Slider) { data.m_Slider.interactable = flag; } else if (data.m_SelectButton) { data.m_SelectButton.enabled = flag; } if (!flag) { data.SetColorAlpha(MenuScreen.s_InactiveButtonsAlpha); return; } MenuBase.MenuOptionData activeMenuOption = this.m_ActiveMenuOption; bool?flag2; if (activeMenuOption == null) { flag2 = null; } else { UISliderEx slider = activeMenuOption.m_Slider; flag2 = ((slider != null) ? new bool?(slider.m_IsDragged) : null); } if (flag2 ?? false) { return; } if (data.m_Slider && data.m_Slider.m_IsDragged) { this.m_ActiveMenuOption = data; this.m_ActiveMenuOptionCanInteract = false; return; } Vector2 screenPoint = Input.mousePosition; RectTransform[] extentRectTransforms = data.m_ExtentRectTransforms; for (int i = 0; i < extentRectTransforms.Length; i++) { if (RectTransformUtility.RectangleContainsScreenPoint(extentRectTransforms[i], screenPoint)) { this.m_ActiveMenuOption = data; this.m_ActiveMenuOptionCanInteract = false; RectTransform[] interactRectTransforms = data.m_InteractRectTransforms; for (int j = 0; j < interactRectTransforms.Length; j++) { if (RectTransformUtility.RectangleContainsScreenPoint(interactRectTransforms[j], screenPoint)) { this.m_ActiveMenuOptionCanInteract = true; return; } } return; } } }
private void UpdateButtons() { MenuBase.MenuOptionData activeMenuOption = this.m_ActiveMenuOption; this.SetActiveButton((activeMenuOption != null) ? activeMenuOption.m_Button : null); }
public virtual void OnInputAction(InputActionData action_data) { if (action_data.m_Action == InputsManager.InputAction.Button_B) { if (!GreenHellGame.GetYesNoDialog().gameObject.activeSelf) { this.OnBack(); return; } } else if (action_data.m_Action == InputsManager.InputAction.Button_X) { if (!GreenHellGame.GetYesNoDialog().gameObject.activeSelf) { this.OnAccept(); return; } } else if (action_data.m_Action == InputsManager.InputAction.Button_A) { if (this.m_ActiveMenuOption != null && this.m_ActiveMenuOption.m_Button && !GreenHellGame.IsYesNoDialogActive()) { string persistentMethodName = this.m_ActiveMenuOption.m_Button.onClick.GetPersistentMethodName(0); base.SendMessage(persistentMethodName); return; } } else if (action_data.m_Action == InputsManager.InputAction.LSRight || action_data.m_Action == InputsManager.InputAction.DPadRight) { if (this.m_ActiveMenuOption != null && this.m_ActiveMenuOption.m_SelectButton) { this.m_ActiveMenuOption.m_SelectButton.PressRightArrow(); return; } } else if (action_data.m_Action == InputsManager.InputAction.LSLeft || action_data.m_Action == InputsManager.InputAction.DPadLeft) { if (this.m_ActiveMenuOption != null && this.m_ActiveMenuOption.m_SelectButton) { this.m_ActiveMenuOption.m_SelectButton.PressLeftArrow(); return; } } else { if (action_data.m_Action == InputsManager.InputAction.LSBackward || action_data.m_Action == InputsManager.InputAction.DPadDown) { for (int i = 0; i < this.m_OptionsObjects.Values.Count; i++) { MenuBase.MenuOptionData menuOptionData = this.m_OptionsObjects.Values.ElementAt(i); if (this.m_ActiveMenuOption == menuOptionData) { for (int j = i + 1; j < this.m_OptionsObjects.Values.Count; j++) { menuOptionData = this.m_OptionsObjects.Values.ElementAt(j); if (this.IsMenuButtonEnabled(menuOptionData.m_Button)) { UIButtonEx component = menuOptionData.m_Button.GetComponent <UIButtonEx>(); if (!component || component.m_MoveWhenFocused) { this.m_ActiveMenuOption = menuOptionData; return; } } if (this.IsMenuSliderEnabled(menuOptionData.m_Slider)) { this.m_ActiveMenuOption = menuOptionData; return; } if (this.IsMenuSelectButtonEnabled(menuOptionData.m_SelectButton)) { this.m_ActiveMenuOption = menuOptionData; return; } } return; } } return; } if (action_data.m_Action == InputsManager.InputAction.LSForward || action_data.m_Action == InputsManager.InputAction.DPadUp) { for (int k = 0; k < this.m_OptionsObjects.Values.Count; k++) { MenuBase.MenuOptionData menuOptionData2 = this.m_OptionsObjects.Values.ElementAt(k); if (this.m_ActiveMenuOption == menuOptionData2) { for (int l = k - 1; l >= 0; l--) { menuOptionData2 = this.m_OptionsObjects.Values.ElementAt(l); if (this.IsMenuButtonEnabled(menuOptionData2.m_Button)) { UIButtonEx component2 = menuOptionData2.m_Button.GetComponent <UIButtonEx>(); if (!component2 || component2.m_MoveWhenFocused) { this.m_ActiveMenuOption = menuOptionData2; return; } } if (this.IsMenuSliderEnabled(menuOptionData2.m_Slider)) { this.m_ActiveMenuOption = menuOptionData2; return; } if (this.IsMenuSelectButtonEnabled(menuOptionData2.m_SelectButton)) { this.m_ActiveMenuOption = menuOptionData2; return; } } return; } } } } }