コード例 #1
0
ファイル: MyControl.cs プロジェクト: whztt07/Miner-Wars-2081
 public void SetNoControl()
 {
     m_joystickAxis   = MyJoystickAxesEnum.None;
     m_joystickButton = MyJoystickButtonsEnum.None;
     m_mouseButton    = MyMouseButtonsEnum.None;
     m_keyboardKey    = Keys.None;
     m_keyboardKey2   = Keys.None;
 }
コード例 #2
0
ファイル: MyControl.cs プロジェクト: whztt07/Miner-Wars-2081
 public MyControl(MyEditorControlEnums control, MyTextsWrapperEnum text, MyGuiControlTypeEnum controlType, MyMouseButtonsEnum?defaultControlMouse,
                  Keys?defaultControlKey, MyJoystickButtonsEnum?defaultControlJoy, MyJoystickAxesEnum?defaultControlJoyAxis)
     : this(control, text, controlType)
 {
     m_mouseButton    = defaultControlMouse.HasValue ? defaultControlMouse.Value : MyMouseButtonsEnum.None;
     m_keyboardKey    = defaultControlKey.HasValue ? defaultControlKey.Value : Keys.None;
     m_joystickButton = defaultControlJoy.HasValue ? defaultControlJoy.Value : MyJoystickButtonsEnum.None;
     m_joystickAxis   = defaultControlJoyAxis.HasValue ? defaultControlJoyAxis.Value : MyJoystickAxesEnum.None;
 }
コード例 #3
0
            private void OverwriteAssignment(MyControl controlAlreadySet, MyMouseButtonsEnum button)
            {
                Debug.Assert(controlAlreadySet != null);
                Debug.Assert(m_deviceType == MyGuiInputDeviceEnum.Mouse);
                Debug.Assert(controlAlreadySet.GetMouseControl() == button);

                controlAlreadySet.SetControl(MyMouseButtonsEnum.None);
                m_controlBeingSet.SetControl(button);
            }
コード例 #4
0
ファイル: MyControl.cs プロジェクト: whztt07/Miner-Wars-2081
 public MyControl(MyEditorControlEnums control, MyTextsWrapperEnum text, MyGuiControlTypeEnum controlType)
 {
     m_editorControl   = control;
     m_gameControlType = MyGuiGameControlType.EDITOR;
     m_text            = text;
     m_controlType     = controlType;
     m_joystickButton  = MyJoystickButtonsEnum.None;
     m_joystickAxis    = MyJoystickAxesEnum.None;
     m_mouseButton     = MyMouseButtonsEnum.None;
     m_keyboardKey     = Keys.None;
 }
コード例 #5
0
 public static bool GetMouseButtonUp(MyMouseButtonsEnum monoMouseButton)
 {
     if (Input.myMouseStates.TryGetValue(monoMouseButton, out MyInputStateEnum myInputState))
     {
         return(myInputState == MyInputStateEnum.GetMouseButtonUp);
     }
     else
     {
         return(false);
     }
 }
コード例 #6
0
ファイル: InputHandler.cs プロジェクト: THDigi/PaintGun
        /// <summary>
        /// Reads the bound button or key from the given control to bypass control blocking.
        /// </summary>
        public static bool IsControlPressedIgnoreBlock(MyStringId controlId, bool newPress = false)
        {
            IMyControl control = MyAPIGateway.Input.GetGameControl(controlId);

            // WARNING: IsKeyPress(MyKeys.None) returns true for some people!

            if (newPress)
            {
                MyMouseButtonsEnum button = control.GetMouseControl();
                if (button != MyMouseButtonsEnum.None && MyAPIGateway.Input.IsNewMousePressed(button))
                {
                    return(true);
                }

                MyKeys kb1 = control.GetKeyboardControl();
                if (kb1 != MyKeys.None && MyAPIGateway.Input.IsNewKeyPressed(kb1))
                {
                    return(true);
                }

                MyKeys kb2 = control.GetSecondKeyboardControl();
                if (kb2 != MyKeys.None && MyAPIGateway.Input.IsNewKeyPressed(kb2))
                {
                    return(true);
                }
            }
            else
            {
                MyMouseButtonsEnum button = control.GetMouseControl();
                if (button != MyMouseButtonsEnum.None && MyAPIGateway.Input.IsMousePressed(button))
                {
                    return(true);
                }

                MyKeys kb1 = control.GetKeyboardControl();
                if (kb1 != MyKeys.None && MyAPIGateway.Input.IsKeyPress(kb1))
                {
                    return(true);
                }

                MyKeys kb2 = control.GetSecondKeyboardControl();
                if (kb2 != MyKeys.None && MyAPIGateway.Input.IsKeyPress(kb2))
                {
                    return(true);
                }
            }

            return(false);
        }
コード例 #7
0
        string IMyControlNameLookup.GetName(MyMouseButtonsEnum button)
        {
            switch (button)
            {
            case MyMouseButtonsEnum.Left: return(MyTexts.GetString(MyCommonTexts.LeftMouseButton));

            case MyMouseButtonsEnum.Middle: return(MyTexts.GetString(MyCommonTexts.MiddleMouseButton));

            case MyMouseButtonsEnum.Right: return(MyTexts.GetString(MyCommonTexts.RightMouseButton));

            case MyMouseButtonsEnum.XButton1: return(MyTexts.GetString(MyCommonTexts.MouseXButton1));

            case MyMouseButtonsEnum.XButton2: return(MyTexts.GetString(MyCommonTexts.MouseXButton2));
            }
            return(MyTexts.GetString(MySpaceTexts.Blank));
        }
コード例 #8
0
ファイル: MyControl.cs プロジェクト: warex0/SpaceEngineers
 public MyControl(MyStringId controlId,
                  MyStringId name,
                  MyGuiControlTypeEnum controlType,
                  MyMouseButtonsEnum?defaultControlMouse,
                  MyKeys?defaultControlKey,
                  MyStringId?helpText       = null,
                  MyKeys?defaultControlKey2 = null,
                  MyStringId?description    = null)
 {
     m_controlId        = controlId;
     m_name             = name;
     m_controlType      = controlType;
     m_mouseButton      = defaultControlMouse ?? MyMouseButtonsEnum.None;
     m_keyboardKey      = defaultControlKey ?? MyKeys.None;
     m_KeyboardKey2     = defaultControlKey2 ?? MyKeys.None;
     m_data.Description = description;
 }
コード例 #9
0
ファイル: MyControl.cs プロジェクト: fluxit/SpaceEngineers
 public MyControl(MyStringId controlId,
     MyStringId name,
     MyGuiControlTypeEnum controlType,
     MyMouseButtonsEnum? defaultControlMouse,
     MyKeys? defaultControlKey,
     MyStringId? helpText = null,
     MyKeys? defaultControlKey2 = null,
     MyStringId? description = null)
 {
     m_controlId = controlId;
     m_name = name;
     m_controlType = controlType;
     m_mouseButton = defaultControlMouse ?? MyMouseButtonsEnum.None;
     m_keyboardKey = defaultControlKey ?? MyKeys.None;
     m_KeyboardKey2 = defaultControlKey2 ?? MyKeys.None;
     m_data.Description = description;
 }
コード例 #10
0
        // Handle mouse button release
        private static void MouseDown(List <MyMouseButtonsEnum> monoPressedMouseButtons)
        {
            var myMouseStatesNew = new Dictionary <MyMouseButtonsEnum, MyInputStateEnum>(Input.myMouseStates);  // Copy states

            foreach (KeyValuePair <MyMouseButtonsEnum, MyInputStateEnum> amaInputStatePairInLoop in Input.myMouseStates)
            {
                MyMouseButtonsEnum monoMouseButtonInLoop = amaInputStatePairInLoop.Key;

                if (false == monoPressedMouseButtons.Contains(monoMouseButtonInLoop))
                {
                    if (amaInputStatePairInLoop.Value == MyInputStateEnum.GetMouseButton || amaInputStatePairInLoop.Value == MyInputStateEnum.GetMouseButtonDown)
                    {
                        myMouseStatesNew[monoMouseButtonInLoop] = MyInputStateEnum.GetMouseButtonUp;
                    }
                    else
                    {
                        myMouseStatesNew.Remove(monoMouseButtonInLoop);
                    }
                }
            }

            Input.myMouseStates.Clear();
            Input.myMouseStates = myMouseStatesNew;
        }
コード例 #11
0
 //  Return true if mouse button is used by some user control
 public MyControl GetControl(MyMouseButtonsEnum button)
 {
     foreach (var item in m_gameControlsList.Values)
     {
         if (item.GetMouseControl() == button) return item;
     }
     return null;
 }
コード例 #12
0
 bool ModAPI.IMyInput.IsMousePressed(MyMouseButtonsEnum button)
 {
     return(((IMyInput)this).IsMousePressed(button));
 }
コード例 #13
0
 //  Return true if mouse button is used by some user control
 ModAPI.IMyControl ModAPI.IMyInput.GetControl(MyMouseButtonsEnum button)
 {
     return(((IMyInput)this).GetControl(button));
 }
コード例 #14
0
 public bool IsNewMouseReleased(MyMouseButtonsEnum button)
 {
     switch (button)
     {
         case MyMouseButtonsEnum.Left: return IsNewLeftMouseReleased();
         case MyMouseButtonsEnum.Middle: return IsNewMiddleMouseReleased();
         case MyMouseButtonsEnum.Right: return IsNewRightMouseReleased();
         case MyMouseButtonsEnum.XButton1: return IsNewXButton1MouseReleased();
         case MyMouseButtonsEnum.XButton2: return IsNewXButton2MouseReleased();
         default:
             return false;
     }
 }
コード例 #15
0
 //  Return true if mouse button is valid for user controls
 bool ModAPI.IMyInput.IsMouseButtonValid(MyMouseButtonsEnum button)
 {
     return(IsMouseButtonValid(button));
 }
コード例 #16
0
 bool ModAPI.IMyInput.IsMouseReleased(MyMouseButtonsEnum button)
 {
     return(IsMouseReleased(button));
 }
コード例 #17
0
            private void OverwriteAssignment(MyControl controlAlreadySet, MyMouseButtonsEnum button)
            {
                Debug.Assert(controlAlreadySet != null);
                Debug.Assert(m_deviceType == MyGuiInputDeviceEnum.Mouse);
                Debug.Assert(controlAlreadySet.GetMouseControl() == button);

                controlAlreadySet.SetControl(MyMouseButtonsEnum.None);
                m_controlBeingSet.SetControl(button);
            }
コード例 #18
0
ファイル: MyControl.cs プロジェクト: fluxit/SpaceEngineers
 public void SetControl(MyMouseButtonsEnum mouseButton)
 {
     m_mouseButton = mouseButton;
 }
コード例 #19
0
ファイル: MyControl.cs プロジェクト: fluxit/SpaceEngineers
 public static void AppendName(ref StringBuilder output, MyMouseButtonsEnum mouseButton)
 {
     EnsureExists(ref output);
     output.Append(MyInput.Static.GetName(mouseButton));
 }
コード例 #20
0
ファイル: MyControl.cs プロジェクト: whztt07/Miner-Wars-2081
 public MyControl(MyEditorControlEnums control, MyTextsWrapperEnum text, MyGuiControlTypeEnum controlType, MyMouseButtonsEnum defaultControl)
     : this(control, text, controlType, defaultControl, null, null, null)
 {
 }
コード例 #21
0
ファイル: MyControl.cs プロジェクト: Bunni/Miner-Wars-2081
 public void SetNoControl()
 {
     m_joystickAxis = MyJoystickAxesEnum.None;
     m_joystickButton = MyJoystickButtonsEnum.None;
     m_mouseButton = MyMouseButtonsEnum.None;
     m_keyboardKey = Keys.None;
     m_keyboardKey2 = Keys.None;
 }
コード例 #22
0
ファイル: MyControl.cs プロジェクト: Bunni/Miner-Wars-2081
 public MyControl(MyEditorControlEnums control, MyTextsWrapperEnum text, MyGuiControlTypeEnum controlType)
 {
     m_editorControl = control;
     m_gameControlType = MyGuiGameControlType.EDITOR;
     m_text = text;
     m_controlType = controlType;
     m_joystickButton = MyJoystickButtonsEnum.None;
     m_joystickAxis = MyJoystickAxesEnum.None;
     m_mouseButton = MyMouseButtonsEnum.None;
     m_keyboardKey = Keys.None;
 }
コード例 #23
0
ファイル: MyControl.cs プロジェクト: Bunni/Miner-Wars-2081
 public MyControl(MyEditorControlEnums control, MyTextsWrapperEnum text, MyGuiControlTypeEnum controlType, MyMouseButtonsEnum? defaultControlMouse,
     Keys? defaultControlKey, MyJoystickButtonsEnum? defaultControlJoy, MyJoystickAxesEnum? defaultControlJoyAxis)
     : this(control, text, controlType)
 {
     m_mouseButton = defaultControlMouse.HasValue ? defaultControlMouse.Value : MyMouseButtonsEnum.None;
     m_keyboardKey = defaultControlKey.HasValue ? defaultControlKey.Value : Keys.None;
     m_joystickButton = defaultControlJoy.HasValue ? defaultControlJoy.Value : MyJoystickButtonsEnum.None;
     m_joystickAxis = defaultControlJoyAxis.HasValue ? defaultControlJoyAxis.Value : MyJoystickAxesEnum.None;
 }
コード例 #24
0
ファイル: MyControl.cs プロジェクト: Bunni/Miner-Wars-2081
 public MyControl(MyEditorControlEnums control, MyTextsWrapperEnum text, MyGuiControlTypeEnum controlType, MyMouseButtonsEnum defaultControl)
     : this(control, text, controlType, defaultControl, null, null, null)
 {
 }
コード例 #25
0
 bool ModAPI.IMyInput.IsMouseReleased(MyMouseButtonsEnum button) { return IsMouseReleased(button); }
コード例 #26
0
ファイル: MyControl.cs プロジェクト: fluxit/SpaceEngineers
 public void SetNoControl()
 {
     m_mouseButton = MyMouseButtonsEnum.None;
     m_keyboardKey = MyKeys.None;
     m_KeyboardKey2 = MyKeys.None;
 }
コード例 #27
0
 bool ModAPI.IMyInput.IsMousePressed(MyMouseButtonsEnum button) { return ((IMyInput)this).IsMousePressed(button); }
コード例 #28
0
ファイル: MyControl.cs プロジェクト: warex0/SpaceEngineers
 public void SetNoControl()
 {
     m_mouseButton  = MyMouseButtonsEnum.None;
     m_keyboardKey  = MyKeys.None;
     m_KeyboardKey2 = MyKeys.None;
 }
コード例 #29
0
 bool ModAPI.IMyInput.IsNewMousePressed(MyMouseButtonsEnum button)
 {
     return(IsNewMousePressed(button));
 }
コード例 #30
0
ファイル: MyControl.cs プロジェクト: warex0/SpaceEngineers
 public static void AppendName(ref StringBuilder output, MyMouseButtonsEnum mouseButton)
 {
     EnsureExists(ref output);
     output.Append(MyInput.Static.GetName(mouseButton));
 }
コード例 #31
0
 public bool WasMouseReleased(MyMouseButtonsEnum button)
 {
     switch (button)
     {
         case MyMouseButtonsEnum.Left: return WasLeftMouseReleased();
         case MyMouseButtonsEnum.Middle: return WasMiddleMouseReleased();
         case MyMouseButtonsEnum.Right: return WasRightMouseReleased();
         case MyMouseButtonsEnum.XButton1: return WasXButton1MouseReleased();
         case MyMouseButtonsEnum.XButton2: return WasXButton2MouseReleased();
         default:
             return false;
     }
 }
コード例 #32
0
        public bool IsNewMouseReleased(MyMouseButtonsEnum button)
        {
#if UNSHARPER
            Debug.Assert(false, "Mouse Support Not Implemented!");
#endif
            return false;
        }
コード例 #33
0
 protected static void AddDefaultGameControl(
     Dictionary<MyStringId, MyControl> self,
     MyGuiControlTypeEnum controlTypeEnum,
     MyStringId controlId,
     MyMouseButtonsEnum? mouse = null,
     MyKeys? key = null,
     MyKeys? key2 = null)
 {
     var helper = MyGuiGameControlsHelpers.GetGameControlHelper(controlId);
     self[controlId] = new MyControl(controlId, helper.NameEnum, controlTypeEnum, mouse, key, defaultControlKey2: key2, description: helper.DescriptionEnum);
 }
コード例 #34
0
ファイル: MyNullInput.cs プロジェクト: fluxit/SpaceEngineers
 MyControl IMyInput.GetControl(MyMouseButtonsEnum button) { return null; }
コード例 #35
0
 string ModAPI.IMyInput.GetName(MyMouseButtonsEnum mouseButton)
 {
     return(((IMyInput)this).GetName(mouseButton));
 }
コード例 #36
0
ファイル: MyNullInput.cs プロジェクト: fluxit/SpaceEngineers
 bool IMyInput.IsMouseReleased(MyMouseButtonsEnum button) { return false; }
コード例 #37
0
 //  Return true if mouse button is valid for user controls
 public bool IsMouseButtonValid(MyMouseButtonsEnum button)
 {
     foreach (var item in m_validMouseButtons)
     {
         if (item == button) return true;
     }
     return false;
 }
コード例 #38
0
 string IMyControlNameLookup.GetName(MyMouseButtonsEnum button)
 {
     switch (button)
     {
         case MyMouseButtonsEnum.Left: return MyTexts.GetString(MyCommonTexts.LeftMouseButton);
         case MyMouseButtonsEnum.Middle: return MyTexts.GetString(MyCommonTexts.MiddleMouseButton);
         case MyMouseButtonsEnum.Right: return MyTexts.GetString(MyCommonTexts.RightMouseButton);
         case MyMouseButtonsEnum.XButton1: return MyTexts.GetString(MyCommonTexts.MouseXButton1);
         case MyMouseButtonsEnum.XButton2: return MyTexts.GetString(MyCommonTexts.MouseXButton2);
     }
     return MyTexts.GetString(MySpaceTexts.Blank);
 }
コード例 #39
0
 public string GetName(MyMouseButtonsEnum mouseButton)
 {
     return m_nameLookup.GetName(mouseButton);
 }
コード例 #40
0
 //  Return true if mouse button is used by some user control
 ModAPI.IMyControl ModAPI.IMyInput.GetControl(MyMouseButtonsEnum button) { return GetControl(button); }
コード例 #41
0
ファイル: MyNullInput.cs プロジェクト: fluxit/SpaceEngineers
 bool IMyInput.IsMouseButtonValid(MyMouseButtonsEnum button) { return false; }
コード例 #42
0
ファイル: MyControl.cs プロジェクト: warex0/SpaceEngineers
 public void SetControl(MyMouseButtonsEnum mouseButton)
 {
     m_mouseButton = mouseButton;
 }
コード例 #43
0
ファイル: MyNullInput.cs プロジェクト: fluxit/SpaceEngineers
 string IMyInput.GetName(MyMouseButtonsEnum mouseButton) { return ""; }
コード例 #44
0
 bool IMyInput.IsMouseReleased(MyMouseButtonsEnum button)
 {
     return(false);
 }
コード例 #45
0
ファイル: MyNullInput.cs プロジェクト: fluxit/SpaceEngineers
 bool IMyInput.IsNewMousePressed(MyMouseButtonsEnum button) { return false; }
コード例 #46
0
 bool IMyInput.IsNewMousePressed(MyMouseButtonsEnum button)
 {
     return(false);
 }
コード例 #47
0
 //  Return true if mouse button is valid for user controls
 bool ModAPI.IMyInput.IsMouseButtonValid(MyMouseButtonsEnum button) { return IsMouseButtonValid(button); }
コード例 #48
0
 bool IMyInput.IsMouseButtonValid(MyMouseButtonsEnum button)
 {
     return(false);
 }
コード例 #49
0
 string ModAPI.IMyInput.GetName(MyMouseButtonsEnum mouseButton) { return GetName(mouseButton); }
コード例 #50
0
 MyControl IMyInput.GetControl(MyMouseButtonsEnum button)
 {
     return(null);
 }
コード例 #51
0
 bool ModAPI.IMyInput.IsNewMousePressed(MyMouseButtonsEnum button) { return IsNewMousePressed(button); }
コード例 #52
0
 string IMyInput.GetName(MyMouseButtonsEnum mouseButton)
 {
     return("");
 }
コード例 #53
0
        private void HandleNewMousePress(ref MyGuiControlBase captureInput)
        {
            bool cursorInItems = m_rowsArea.Contains(MyGuiManager.MouseCursorPosition - GetPositionAbsoluteTopLeft());

            MyMouseButtonsEnum mouseButton = MyMouseButtonsEnum.None;

            if (MyInput.Static.IsNewPrimaryButtonPressed())
            {
                mouseButton = MyMouseButtonsEnum.Left;
            }
            else if (MyInput.Static.IsNewSecondaryButtonPressed())
            {
                mouseButton = MyMouseButtonsEnum.Right;
            }
            else if (MyInput.Static.IsNewMiddleMousePressed())
            {
                mouseButton = MyMouseButtonsEnum.Middle;
            }
            else if (MyInput.Static.IsNewXButton1MousePressed())
            {
                mouseButton = MyMouseButtonsEnum.XButton1;
            }
            else if (MyInput.Static.IsNewXButton2MousePressed())
            {
                mouseButton = MyMouseButtonsEnum.XButton2;
            }

            if (MyInput.Static.IsAnyNewMouseOrJoystickPressed() && cursorInItems)
            {
                SelectedRowIndex = ComputeRowIndexFromPosition(MyGuiManager.MouseCursorPosition);
                captureInput     = this;
                if (ItemSelected != null)
                {
                    ItemSelected(this, new EventArgs()
                    {
                        RowIndex = SelectedRowIndex.Value, MouseButton = mouseButton
                    });
                    MyGuiSoundManager.PlaySound(GuiSounds.MouseClick);
                }
            }

            if (MyInput.Static.IsNewPrimaryButtonPressed())
            {
                if (m_mouseOverHeader)
                {
                    Debug.Assert(m_mouseOverColumnIndex.HasValue);
                    SortByColumn(m_mouseOverColumnIndex.Value);
                    if (ColumnClicked != null)
                    {
                        ColumnClicked(this, m_mouseOverColumnIndex.Value);
                    }
                }
                else if (cursorInItems)
                {
                    if (!m_doubleClickStarted.HasValue)
                    {
                        m_doubleClickStarted       = MyGuiManager.TotalTimeInMilliseconds;
                        m_doubleClickFirstPosition = MyGuiManager.MouseCursorPosition;
                    }
                    else if ((MyGuiManager.TotalTimeInMilliseconds - m_doubleClickStarted.Value) <= MyGuiConstants.DOUBLE_CLICK_DELAY &&
                             (m_doubleClickFirstPosition - MyGuiManager.MouseCursorPosition).Length() <= 0.005f)
                    {
                        if (ItemDoubleClicked != null && SelectedRowIndex.HasValue)
                        {
                            ItemDoubleClicked(this, new EventArgs()
                            {
                                RowIndex = SelectedRowIndex.Value, MouseButton = mouseButton
                            });
                        }

                        m_doubleClickStarted = null;
                        captureInput         = this;
                    }
                }
            }
        }
コード例 #54
0
ファイル: MyGuiInput.cs プロジェクト: Bunni/Miner-Wars-2081
 //  Return true if mouse button is used by some user control
 public MyControl GetControl(MyMouseButtonsEnum button, MyGuiGameControlType gameControlType)
 {
     MyControl[] controlsList = GetControlsListByGameControlType(gameControlType);
     foreach (var item in controlsList)
     {
         if (item.GetMouseControl() == button) return item;
     }
     return null;
 }