public static void OpenMenu()
    {
        EventSystem es = EventSystem.current;

        GameObject temp = es.firstSelectedGameObject;

        es.SetSelectedGameObject(null);

        if (ControlManager.GetControllerState() == ControlManager.ControllerState.JoystickPS4)
        {
            es.SetSelectedGameObject(temp);

            temp.GetComponent <Button>().OnSelect(null);
        }

        RewiredStandaloneInputModule rsim = es.GetComponent <RewiredStandaloneInputModule>();

        if (rsim)
        {
            if (ControlManager.GetControllerState() == ControlManager.ControllerState.KeyboardAndMouse)
            {
                rsim.allowMouseInput = true;
            }
            else
            {
                rsim.allowMouseInput = false;
            }
        }
    }
Beispiel #2
0
        // Token: 0x06001503 RID: 5379 RVA: 0x000599F4 File Offset: 0x00057BF4
        private static void Initialize()
        {
            GameObject     original = Resources.Load <GameObject>("Prefabs/UI/MPEventSystem");
            IList <Player> players  = ReInput.players.Players;

            for (int i = 0; i < players.Count; i++)
            {
                GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(original, RoR2Application.instance.transform);
                gameObject.name = string.Format(CultureInfo.InvariantCulture, "MPEventSystem Player{0}", i);
                MPEventSystem component = gameObject.GetComponent <MPEventSystem>();
                RewiredStandaloneInputModule component2 = gameObject.GetComponent <RewiredStandaloneInputModule>();
                Player player = players[i];
                component2.RewiredPlayerIds = new int[]
                {
                    player.id
                };
                gameObject.GetComponent <MPInput>().player = player;
                if (i == 1)
                {
                    MPEventSystemManager.kbmEventSystem = component;
                    component.allowCursorPush           = false;
                }
                component.player = players[i];
                MPEventSystemManager.eventSystems[players[i].id] = component;
            }
            MPEventSystemManager.combinedEventSystem = MPEventSystemManager.eventSystems[0];
            MPEventSystemManager.combinedEventSystem.isCombinedEventSystem = true;
            MPEventSystemManager.RefreshEventSystems();
        }
Beispiel #3
0
        public void SetJoystick(int playerId, Rewired.Joystick joystick)
        {
            if (!base.initialized)
            {
                return;
            }
            this.playerId = playerId;
            this.joystick = joystick;
            if (joystick == null)
            {
                Debug.LogError("Rewired Control Mapper: Joystick cannot be null!");
                return;
            }
            float num = 0f;

            for (int i = 0; i < joystick.axisCount; i++)
            {
                int                   index      = i;
                GameObject            gameObject = UITools.InstantiateGUIObject <UnityEngine.UI.Button>(this.axisButtonPrefab, this.axisScrollAreaContent, "Axis" + i);
                UnityEngine.UI.Button button     = gameObject.GetComponent <UnityEngine.UI.Button>();
                button.onClick.AddListener(delegate
                {
                    this.OnAxisSelected(index, button);
                });
                Text componentInSelfOrChildren = UnityTools.GetComponentInSelfOrChildren <Text>(gameObject);
                if (componentInSelfOrChildren != null)
                {
                    componentInSelfOrChildren.text = joystick.AxisElementIdentifiers[i].name;
                }
                if (num == 0f)
                {
                    num = UnityTools.GetComponentInSelfOrChildren <LayoutElement>(gameObject).minHeight;
                }
                this.axisButtons.Add(button);
            }
            float spacing = this.axisScrollAreaContent.GetComponent <VerticalLayoutGroup>().spacing;

            this.axisScrollAreaContent.sizeDelta = new Vector2(this.axisScrollAreaContent.sizeDelta.x, Mathf.Max((float)joystick.axisCount * (num + spacing) - spacing, this.axisScrollAreaContent.sizeDelta.y));
            this.origCalibrationData             = joystick.calibrationMap.ToXmlString();
            this.displayAreaWidth             = this.rightContentContainer.sizeDelta.x;
            this.rewiredStandaloneInputModule = base.gameObject.transform.root.GetComponentInChildren <RewiredStandaloneInputModule>();
            if (this.rewiredStandaloneInputModule != null)
            {
                this.menuHorizActionId = ReInput.mapping.GetActionId(this.rewiredStandaloneInputModule.horizontalAxis);
                this.menuVertActionId  = ReInput.mapping.GetActionId(this.rewiredStandaloneInputModule.verticalAxis);
            }
            if (joystick.axisCount > 0)
            {
                this.SelectAxis(0);
            }
            base.defaultUIElement = this.doneButton.gameObject;
            this.RefreshControls();
            this.Redraw();
        }
    private void switchToMenuControlMaps()
    {
        // change controller maps
        RewiredStandaloneInputModule rewiredEventSystem = FindObjectOfType <RewiredStandaloneInputModule>();

        rewiredEventSystem.horizontalAxis = "Menu Horizontal";
        rewiredEventSystem.verticalAxis   = "Menu Vertical";
        rewiredEventSystem.submitButton   = "Submit";

        // player1 switch maps
        player1.controllers.maps.SetMapsEnabled(true, "Default", "Menu Joystick");
        player1.controllers.maps.SetMapsEnabled(false, "Default", "Default");
        player1.controllers.maps.SetMapsEnabled(true, ControllerType.Keyboard, "Keyboard1", "Menu Keyboard1");
        player1.controllers.maps.SetMapsEnabled(false, ControllerType.Keyboard, "Keyboard1", "Default");

        // player2 switch maps
        player2.controllers.maps.SetMapsEnabled(true, "Default", "Menu Joystick");
        player2.controllers.maps.SetMapsEnabled(false, "Default", "Default");
        player2.controllers.maps.SetMapsEnabled(true, "Keyboard2", "Menu Keyboard2");
        player2.controllers.maps.SetMapsEnabled(false, "Keyboard2", "Default");
    }
Beispiel #5
0
    static Game()
    {
        GameObject game = SafeFind("_app");

        m_setManager         = (PersistentSetManager)SafeComponent(game, "PersistentSetManager");
        m_options            = (OptionManager)SafeComponent(game, "OptionManager");
        m_languages          = (LanguageManager)SafeComponent(game, "LanguageManager");
        m_audio              = (AudioManager)SafeComponent(game, "AudioManager");
        m_projPool           = (ProjectilePooler)SafeComponent(SafeFind("ProjectilePooler"), "ProjectilePooler");
        m_npcGenerator       = (NPCGenerator)SafeComponent(game, "NPCGenerator");
        m_enemyGenerator     = (EnemyGenerator)SafeComponent(game, "EnemyGenerator");
        m_rewiredEventSystem = (RewiredStandaloneInputModule)SafeComponent(SafeFind("Rewired Event System"), "RewiredStandaloneInputModule");
        m_controlMapper      = (ControlMapper)SafeComponent(SafeFind("ControlMapper"), "ControlMapper");
        m_controlMapperMenu  = (Menu)SafeComponent(SafeFind("Canvas"), "Menu");

        ProjectileBehaviour.LoadAll();
        ShotPattern.LoadAll();
        BaseItem.LoadAll();
        Ability.LoadAll();
        Skill.LoadAll();
        State.LoadAll();

        m_controlMapperMenu.gameObject.SetActive(false);
    }
Beispiel #6
0
        public void SetJoystick(int playerId, Joystick joystick)
        {
            if (!initialized)
            {
                return;
            }

            this.playerId = playerId;
            this.joystick = joystick;

            if (joystick == null)
            {
                Debug.LogError("Rewired Control Mapper: Joystick cannot be null!");
                return;
            }

            // Create axis list
            float buttonHeight = 0.0f;

            for (int i = 0; i < joystick.axisCount; i++)
            {
                int        index    = i;
                GameObject instance = UITools.InstantiateGUIObject <Button>(axisButtonPrefab, axisScrollAreaContent, "Axis" + i);
                Button     button   = instance.GetComponent <Button>();
                button.onClick.AddListener(() => { OnAxisSelected(index, button); });
                Text text = UnityTools.GetComponentInSelfOrChildren <Text>(instance);
                if (text != null)
                {
                    text.text = joystick.AxisElementIdentifiers[i].name;
                }
                if (buttonHeight == 0.0f)
                {
                    buttonHeight = UnityTools.GetComponentInSelfOrChildren <LayoutElement>(instance).minHeight;
                }
                axisButtons.Add(button);
            }

            // set axis list height
            float vSpacing = axisScrollAreaContent.GetComponent <VerticalLayoutGroup>().spacing;

            axisScrollAreaContent.sizeDelta = new Vector2(axisScrollAreaContent.sizeDelta.x, Mathf.Max((joystick.axisCount * (buttonHeight + vSpacing) - vSpacing), axisScrollAreaContent.sizeDelta.y));

            // Store the original calibration data so we can revert
            origCalibrationData = joystick.calibrationMap.ToXmlString();

            // Record info
            displayAreaWidth = rightContentContainer.sizeDelta.x;

            // Try to get the UI control axis deadzone from the RewiredStandaloneInputModule if it exists in the hierarchy
            // This is used to prevent users from rendering menu navigation axes unusable by changing the axis sensitivity
            rewiredStandaloneInputModule = gameObject.transform.root.GetComponentInChildren <RewiredStandaloneInputModule>();
            if (rewiredStandaloneInputModule != null)
            {
                menuHorizActionId = ReInput.mapping.GetActionId(rewiredStandaloneInputModule.horizontalAxis);
                menuVertActionId  = ReInput.mapping.GetActionId(rewiredStandaloneInputModule.verticalAxis);
            }

            // Select first axis
            if (joystick.axisCount > 0)
            {
                SelectAxis(0);
            }

            // Set default UI element
            defaultUIElement = doneButton.gameObject;

            // Draw window
            RefreshControls();
            Redraw();
        }
Beispiel #7
0
 public void SetJoystick(int playerId, Joystick joystick)
 {
     if (!this.initialized)
     {
         return;
     }
     this.playerId = playerId;
     this.joystick = joystick;
     if (joystick == null)
     {
         Debug.LogError((object)"Rewired Control Mapper: Joystick cannot be null!");
     }
     else
     {
         float num = 0.0f;
         for (int index = 0; index < ((ControllerWithAxes)joystick).get_axisCount(); ++index)
         {
             // ISSUE: object of a compiler-generated type is created
             // ISSUE: variable of a compiler-generated type
             CalibrationWindow.\u003CSetJoystick\u003Ec__AnonStorey0 joystickCAnonStorey0 = new CalibrationWindow.\u003CSetJoystick\u003Ec__AnonStorey0();
             // ISSUE: reference to a compiler-generated field
             joystickCAnonStorey0.\u0024this = this;
             // ISSUE: reference to a compiler-generated field
             joystickCAnonStorey0.index = index;
             GameObject gameObject = UITools.InstantiateGUIObject <Button>(this.axisButtonPrefab, (Transform)this.axisScrollAreaContent, "Axis" + (object)index);
             // ISSUE: reference to a compiler-generated field
             joystickCAnonStorey0.button = (Button)gameObject.GetComponent <Button>();
             // ISSUE: reference to a compiler-generated field
             // ISSUE: method pointer
             ((UnityEvent)joystickCAnonStorey0.button.get_onClick()).AddListener(new UnityAction((object)joystickCAnonStorey0, __methodptr(\u003C\u003Em__0)));
             Text inSelfOrChildren = (Text)UnityTools.GetComponentInSelfOrChildren <Text>(gameObject);
             if (Object.op_Inequality((Object)inSelfOrChildren, (Object)null))
             {
                 inSelfOrChildren.set_text(((ControllerWithAxes)joystick).get_AxisElementIdentifiers()[index].get_name());
             }
             if ((double)num == 0.0)
             {
                 num = ((LayoutElement)UnityTools.GetComponentInSelfOrChildren <LayoutElement>(gameObject)).get_minHeight();
             }
             // ISSUE: reference to a compiler-generated field
             this.axisButtons.Add(joystickCAnonStorey0.button);
         }
         float spacing = ((HorizontalOrVerticalLayoutGroup)((Component)this.axisScrollAreaContent).GetComponent <VerticalLayoutGroup>()).get_spacing();
         this.axisScrollAreaContent.set_sizeDelta(new Vector2((float)this.axisScrollAreaContent.get_sizeDelta().x, Mathf.Max((float)((ControllerWithAxes)joystick).get_axisCount() * (num + spacing) - spacing, (float)this.axisScrollAreaContent.get_sizeDelta().y)));
         this.origCalibrationData          = ((ControllerWithAxes)joystick).get_calibrationMap().ToXmlString();
         this.displayAreaWidth             = (float)this.rightContentContainer.get_sizeDelta().x;
         this.rewiredStandaloneInputModule = (RewiredStandaloneInputModule)((Component)((Component)this).get_gameObject().get_transform().get_root()).GetComponentInChildren <RewiredStandaloneInputModule>();
         if (Object.op_Inequality((Object)this.rewiredStandaloneInputModule, (Object)null))
         {
             this.menuHorizActionId = ReInput.get_mapping().GetActionId(this.rewiredStandaloneInputModule.horizontalAxis);
             this.menuVertActionId  = ReInput.get_mapping().GetActionId(this.rewiredStandaloneInputModule.verticalAxis);
         }
         if (((ControllerWithAxes)joystick).get_axisCount() > 0)
         {
             this.SelectAxis(0);
         }
         this.defaultUIElement = ((Component)this.doneButton).get_gameObject();
         this.RefreshControls();
         this.Redraw();
     }
 }