Ejemplo n.º 1
0
        internal static void CharacterSelectControllerAwake(On.RoR2.UI.CharacterSelectController.orig_Awake orig, CharacterSelectController self)
        {
            orig(self);

            var leftHandPanel = self.transform.Find("SafeArea/LeftHandPanel (Layer: Main)");

            if (!CachedPrefab)
            {
                CachePrefabFromSurvivorGrid(leftHandPanel, "SurvivorChoiceGrid, Panel");
            }

            var randomizePanel = GameObject.Instantiate(CachedPrefab, self.transform.Find("SafeArea"), false);

            HGGamepadInputEvent cscRightInputEventOne;
            HGGamepadInputEvent cscRightInputEventTwo;

            var cscInputEvents = self.GetComponents <HGGamepadInputEvent>();

            if (RandomCharacterSelectionPlugin.InLobbyConfigLoaded)
            {
                var rightInputs = cscInputEvents.Where(el => el.actionName == "UISubmenuRight");
                cscRightInputEventOne = rightInputs.ElementAt(0);
                cscRightInputEventTwo = rightInputs.ElementAt(1);
            }
            else
            {
                cscRightInputEventOne = cscInputEvents.First(el => el.actionName == "UISubmenuRight");
                cscRightInputEventOne.requiredTopLayer = leftHandPanel.GetComponent <UILayerKey>();

                cscRightInputEventTwo                        = self.gameObject.AddComponent <HGGamepadInputEvent>();
                cscRightInputEventTwo.actionName             = cscRightInputEventOne.actionName;
                cscRightInputEventTwo.actionEvent            = cscRightInputEventOne.actionEvent;
                cscRightInputEventTwo.requiredTopLayer       = leftHandPanel.Find("SurvivorInfoPanel, Active (Layer: Secondary)").GetComponent <UILayerKey>();
                cscRightInputEventTwo.enabledObjectsIfActive = Array.Empty <GameObject>();
            }

            var randomizePanelRightInputEvent = randomizePanel.GetComponents <HGGamepadInputEvent>().First(input => input.actionName == "UISubmenuRight");

            var cscLeftInputEventOne = self.gameObject.AddComponent <HGGamepadInputEvent>();

            cscLeftInputEventOne.actionName             = "UISubmenuLeft";
            cscLeftInputEventOne.actionEvent            = randomizePanel.GetComponent <EventHolder>().unityEvent;
            cscLeftInputEventOne.requiredTopLayer       = cscRightInputEventOne.requiredTopLayer;
            cscLeftInputEventOne.enabledObjectsIfActive = Array.Empty <GameObject>();

            var cscLeftInputEventTwo = self.gameObject.AddComponent <HGGamepadInputEvent>();

            cscLeftInputEventTwo.actionName             = cscLeftInputEventOne.actionName;
            cscLeftInputEventTwo.actionEvent            = cscLeftInputEventOne.actionEvent;
            cscLeftInputEventTwo.requiredTopLayer       = cscRightInputEventTwo.requiredTopLayer;
            cscLeftInputEventTwo.enabledObjectsIfActive = Array.Empty <GameObject>();

            var randomizePanelCancelInputEvent = randomizePanel.AddComponent <HGGamepadInputEvent>();

            randomizePanelCancelInputEvent.actionName             = "UICancel";
            randomizePanelCancelInputEvent.actionEvent            = randomizePanelRightInputEvent.actionEvent;
            randomizePanelCancelInputEvent.requiredTopLayer       = randomizePanelRightInputEvent.requiredTopLayer;
            randomizePanelCancelInputEvent.enabledObjectsIfActive = randomizePanelRightInputEvent.enabledObjectsIfActive;
        }
Ejemplo n.º 2
0
        private static void CharacterSelectControllerAwake(On.RoR2.UI.CharacterSelectController.orig_Awake orig, CharacterSelectController self)
        {
            try
            {
                #region LoadButton
                var quitButton = self.transform.GetChild(2).GetChild(4).GetChild(0).gameObject;
                lobbyButton = GameObject.Instantiate(quitButton, quitButton.transform.parent);

                foreach (var filter in self.GetComponents <InputSourceFilter>())
                {
                    if (filter.requiredInputSource == MPEventSystem.InputSource.MouseAndKeyboard)
                    {
                        Array.Resize(ref filter.objectsToFilter, filter.objectsToFilter.Length + 1);
                        filter.objectsToFilter[filter.objectsToFilter.Length - 1] = lobbyButton;
                        break;
                    }
                }

                lobbyButton.name = "[ProperSave] Load";

                var rectTransform = lobbyButton.GetComponent <RectTransform>();
                rectTransform.anchorMin = new Vector2(1F, 1.5F);
                rectTransform.anchorMax = new Vector2(1F, 1.5F);

                var buttonComponent = lobbyButton.GetComponent <HGButton>();
                buttonComponent.hoverToken = LanguageConsts.PS_TITLE_CONTINUE_DESC;

                var languageComponent = lobbyButton.GetComponent <LanguageTextMeshController>();
                languageComponent.token = LanguageConsts.PS_TITLE_LOAD;

                buttonComponent.onClick = new Button.ButtonClickedEvent();
                buttonComponent.onClick.AddListener(LoadOnInputEvent);
                #endregion

                #region Load GlypAndDescription
                var submenuLegend = self.transform.GetChild(2).GetChild(4).GetChild(1).gameObject;
                lobbySubmenuLegend = GameObject.Instantiate(submenuLegend, submenuLegend.transform.parent);

                foreach (var filter in self.GetComponents <InputSourceFilter>())
                {
                    if (filter.requiredInputSource == MPEventSystem.InputSource.Gamepad)
                    {
                        Array.Resize(ref filter.objectsToFilter, filter.objectsToFilter.Length + 1);
                        filter.objectsToFilter[filter.objectsToFilter.Length - 1] = lobbySubmenuLegend;
                        break;
                    }
                }

                lobbySubmenuLegend.name = "[ProperSave] SubmenuLegend";

                var uiJuiceComponent     = lobbySubmenuLegend.GetComponent <UIJuice>();
                var enableEventComponent = lobbySubmenuLegend.GetComponent <OnEnableEvent>();

                enableEventComponent.action.RemoveAllListeners();
                enableEventComponent.action.AddListener(uiJuiceComponent.TransitionPanFromTop);
                enableEventComponent.action.AddListener(uiJuiceComponent.TransitionAlphaFadeIn);

                var rectTransformComponent = lobbySubmenuLegend.GetComponent <RectTransform>();
                rectTransformComponent.anchorMin = new Vector2(1, 1);
                rectTransformComponent.anchorMax = new Vector2(1, 2);

                lobbyGlyphAndDescription = lobbySubmenuLegend.transform.GetChild(0).gameObject;

                var glyph = lobbyGlyphAndDescription.transform.GetChild(0).GetComponent <InputBindingDisplayController>();
                glyph.actionName = "UISubmenuUp";

                var description = lobbyGlyphAndDescription.transform.GetChild(1).GetComponent <LanguageTextMeshController>();
                description.token = LanguageConsts.PS_TITLE_LOAD;

                for (var i = 1; i < lobbySubmenuLegend.transform.childCount; i++)
                {
                    GameObject.Destroy(lobbySubmenuLegend.transform.GetChild(i).gameObject);
                }
                #endregion

                UpdateLobbyControls();

                var gamepadInputEvent = self.gameObject.AddComponent <HGGamepadInputEvent>();
                gamepadInputEvent.actionName             = "UISubmenuUp";
                gamepadInputEvent.enabledObjectsIfActive = Array.Empty <GameObject>();

                gamepadInputEvent.actionEvent = new UnityEngine.Events.UnityEvent();
                gamepadInputEvent.actionEvent.AddListener(LoadOnInputEvent);
            }
            catch (Exception e)
            {
                ProperSavePlugin.InstanceLogger.LogWarning("Failed while adding lobby buttons");
                ProperSavePlugin.InstanceLogger.LogError(e);
            }
            orig(self);
        }
Ejemplo n.º 3
0
        internal static void CharacterSelectControllerAwake(Action <CharacterSelectController> orig, CharacterSelectController self)
        {
            orig(self);

            var leftHandPanel  = self.transform.Find("SafeArea/LeftHandPanel (Layer: Main)");
            var rightHandPanel = self.transform.Find("SafeArea/RightHandPanel");

            if (!CachedPrefab)
            {
                CachePrefabFromSurvivorGrid(leftHandPanel, "SurvivorChoiceGrid, Panel");
            }

            var configPanel          = GameObject.Instantiate(CachedPrefab, self.transform.Find("SafeArea"), false);
            var popoutPanelContainer = rightHandPanel.Find("PopoutPanelContainer");

            var popoutPanel = GameObject.Instantiate(popoutPanelContainer.Find("PopoutPanelPrefab").gameObject, popoutPanelContainer);

            configPanel.GetComponent <ConfigPanelController>().popoutPanel = popoutPanel;

            var cscInputEvents = self.GetComponents <HGGamepadInputEvent>();

            var cscRightInputEventOne = cscInputEvents.First(el => el.actionName == "UISubmenuRight");

            cscRightInputEventOne.requiredTopLayer = leftHandPanel.GetComponent <UILayerKey>();

            var cscRightInputEventTwo = self.gameObject.AddComponent <HGGamepadInputEvent>();

            cscRightInputEventTwo.actionName             = cscRightInputEventOne.actionName;
            cscRightInputEventTwo.actionEvent            = cscRightInputEventOne.actionEvent;
            cscRightInputEventTwo.requiredTopLayer       = leftHandPanel.Find("SurvivorInfoPanel, Active (Layer: Secondary)").GetComponent <UILayerKey>();
            cscRightInputEventTwo.enabledObjectsIfActive = Array.Empty <GameObject>();

            var ruleLayout = rightHandPanel.Find("RuleLayoutActive (Layer: Tertiary)");

            var rlLeftInputEvent = ruleLayout.GetComponents <HGGamepadInputEvent>().First(input => input.actionName == "UISubmenuLeft");

            var rlRightInputEventOne = ruleLayout.gameObject.AddComponent <HGGamepadInputEvent>();

            rlRightInputEventOne.actionName             = "UISubmenuRight";
            rlRightInputEventOne.actionEvent            = configPanel.GetComponent <EventHolder>().unityEvent;
            rlRightInputEventOne.requiredTopLayer       = ruleLayout.GetComponent <UILayerKey>();
            rlRightInputEventOne.enabledObjectsIfActive = Array.Empty <GameObject>();

            var rlRightInputEventTwo = ruleLayout.gameObject.AddComponent <HGGamepadInputEvent>();

            rlRightInputEventTwo.actionName             = rlRightInputEventOne.actionName;
            rlRightInputEventTwo.actionEvent            = rlLeftInputEvent.actionEvent;
            rlRightInputEventTwo.requiredTopLayer       = rlRightInputEventOne.requiredTopLayer;
            rlRightInputEventTwo.enabledObjectsIfActive = Array.Empty <GameObject>();

            var configLeftInputEvent = configPanel.GetComponent <HGGamepadInputEvent>();

            configLeftInputEvent.actionEvent.AddListener(() => ruleLayout.gameObject.SetActive(true));

            var configCancelInputEvent = configPanel.AddComponent <HGGamepadInputEvent>();

            configCancelInputEvent.actionName             = "UICancel";
            configCancelInputEvent.actionEvent            = configLeftInputEvent.actionEvent;
            configCancelInputEvent.requiredTopLayer       = configLeftInputEvent.requiredTopLayer;
            configCancelInputEvent.enabledObjectsIfActive = configLeftInputEvent.enabledObjectsIfActive;
        }